Skip to content

Commit

Permalink
On the way to remove modifyAttributes from ElementCreatable and ListG…
Browse files Browse the repository at this point in the history
…etable
  • Loading branch information
jacquev6 committed Feb 26, 2012
1 parent f5e9a55 commit b9a0ba9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions github/GithubObjects.py
Expand Up @@ -133,6 +133,8 @@
Deletable(),
)

__modifyAttributesForObjectsReferingReferedRepo = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj._repo }.iteritems() ) )

Milestone = GithubObject(
"Milestone",
BaseUrl( lambda obj: obj._repo._baseUrl + "/milestones/" + str( obj.number ) ),
Expand All @@ -144,7 +146,7 @@
InternalObjectAttribute( "creator", NamedUser ),
Editable( [ "title" ], [ "state", "description", "due_on" ] ),
Deletable(),
ExternalListOfObjects( "labels", "label", Label, ListGetable( [], [], lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj._repo }.iteritems() ) ) ) ),
ExternalListOfObjects( "labels", "label", Label, ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ) ),
)

IssueComment = GithubObject(
Expand Down Expand Up @@ -173,16 +175,16 @@
InternalObjectAttribute( "milestone", Milestone ),
Editable( [], [ "title", "body", "assignee", "state", "milestone", "labels" ] ),
ExternalListOfObjects( "labels", "label", Label,
ListGetable( [], [], lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj._repo }.iteritems() ) ) ),
ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ),
SeveralElementsAddable(),
ListSetable(),
ListDeletable(),
ElementRemovable(),
),
ExternalListOfObjects( "comments", "comment", IssueComment,
ListGetable( [], [], lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj._repo }.iteritems() ) ) ),
ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ),
ElementGetable( [ "id" ], [], "_repo" ),
ElementCreatable( [ "body" ], [], lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj._repo }.iteritems() ) ) ),
ElementCreatable( [ "body" ], [], __modifyAttributesForObjectsReferingReferedRepo ),
),
)

Expand Down
3 changes: 2 additions & 1 deletion github/ObjectCapacities/List.py
Expand Up @@ -43,7 +43,8 @@ def apply( self, cls ):

def __execute( self, obj, *args, **kwds ):
data = self.__argumentsChecker.check( args, kwds )
return self.typePolicy.createLazy( obj, self.__modifyAttributes( obj, obj._github._dataRequest( "POST", obj._baseUrl + "/" + self.attributeName, None, data ) ) )
attributes = obj._github._dataRequest( "POST", obj._baseUrl + "/" + self.attributeName, None, data )
return self.typePolicy.createLazy( obj, self.__modifyAttributes( obj, attributes ) )

class ElementGetable( ListCapacity ):
def __init__( self, mandatoryParameters, optionalParameters, objReferenceName = None ):
Expand Down

0 comments on commit b9a0ba9

Please sign in to comment.