Remember that some values are not fetchable

This commit is contained in:
Vincent Jacques
2012-02-12 14:37:33 +01:00
parent a942b0c85c
commit 80ec0bde33
2 changed files with 17 additions and 3 deletions
+15 -3
View File
@@ -3,18 +3,26 @@ class BadGithubObjectException( Exception ):
class SimpleScalarAttributes:
class AttributeDefinition:
def __init__( self, attributeNames ):
self.__attributeNames = attributeNames
def getValueFromRawValue( self, obj, rawValue ):
return rawValue
def fetchRawValues( self, obj ):
return obj._github.rawRequest( "GET", "/test" )
attributes = obj._github.rawRequest( "GET", "/test" )
for attributeName in self.__attributeNames:
if attributeName not in attributes:
attributes[ attributeName ] = None
return attributes
def __init__( self, *attributeNames ):
self.__attributeNames = attributeNames
def getAttributeDefinitions( self ):
commonDefinition = SimpleScalarAttributes.AttributeDefinition( self.__attributeNames )
return [
( attributeName, SimpleScalarAttributes.AttributeDefinition() )
( attributeName, commonDefinition )
for attributeName in self.__attributeNames
]
@@ -44,7 +52,11 @@ def GithubObject( className, *attributePolicies ):
def __updateAttributes( self, attributes ):
for attributeName, attributeValue in attributes.iteritems():
attributeDefinition = attributeDefinitions[ attributeName ]
self.__attributes[ attributeName ] = attributeDefinition.getValueFromRawValue( self, attributeValue )
if attributeValue is None:
if attributeName not in self.__attributes:
self.__attributes[ attributeName ] = None
else:
self.__attributes[ attributeName ] = attributeDefinition.getValueFromRawValue( self, attributeValue )
def __fetchAttribute( self, attributeName ):
attributeDefinition = attributeDefinitions[ attributeName ]