From b9a0ba9ade2f790af541beb08af6233a42438ddd Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sun, 26 Feb 2012 10:29:59 +0000 Subject: [PATCH] On the way to remove modifyAttributes from ElementCreatable and ListGetable --- github/GithubObjects.py | 10 ++++++---- github/ObjectCapacities/List.py | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 1950963e..838d588f 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -133,6 +133,8 @@ Label = GithubObject( 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 ) ), @@ -144,7 +146,7 @@ Milestone = GithubObject( 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( @@ -173,16 +175,16 @@ Issue = GithubObject( 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 ), ), ) diff --git a/github/ObjectCapacities/List.py b/github/ObjectCapacities/List.py index e875b0a3..fda63cea 100644 --- a/github/ObjectCapacities/List.py +++ b/github/ObjectCapacities/List.py @@ -43,7 +43,8 @@ class ElementCreatable( ListCapacity ): 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 ):