Apply attributeModifiers to ElementGetable too

This commit is contained in:
Vincent Jacques
2012-02-26 10:46:46 +00:00
parent 8ed008de51
commit f8b9580b40
2 changed files with 23 additions and 22 deletions
+14 -14
View File
@@ -183,7 +183,7 @@ Issue = GithubObject(
),
ExternalListOfObjects( "comments", "comment", IssueComment,
ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ),
ElementGetable( [ "id" ], [], "_repo" ),
ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingReferedRepo ),
ElementCreatable( [ "body" ], [], __modifyAttributesForObjectsReferingReferedRepo ),
),
)
@@ -251,7 +251,7 @@ Branch = GithubObject(
InternalObjectAttribute( "commit", Commit )
)
__modifyAttributesForObjectsReferingRepo = { "_repo": lambda obj: obj }
__modifyAttributesForObjectsReferingRepo = { "_repo": lambda repo: repo }
Repository = GithubObject(
"Repository",
BaseUrl( lambda obj: "/repos/" + obj.owner.login + "/" + obj.name ),
@@ -272,53 +272,53 @@ Repository = GithubObject(
Editable( [ "name" ], [ "description", "homepage", "public", "has_issues", "has_wiki", "has_downloads" ] ),
ExternalListOfObjects( "git/refs", "git_ref", GitRef,
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( [ "ref" ], [], "_repo" ),
ElementGetable( [ "ref" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "ref", "sha" ], [], __modifyAttributesForObjectsReferingRepo )
),
ExternalListOfObjects( "git/commits", "git_commit", GitCommit,
ElementGetable( [ "sha" ], [], "_repo" ),
ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "message", "tree", "parents" ], [ "author", "commiter" ], __modifyAttributesForObjectsReferingRepo )
),
ExternalListOfObjects( "git/trees", "git_tree", GitTree,
ElementGetable( [ "sha" ], [], "_repo" ),
ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "tree" ], [], __modifyAttributesForObjectsReferingRepo )
),
ExternalListOfObjects( "git/blobs", "git_blob", GitBlob,
ElementGetable( [ "sha" ], [], "_repo" ),
ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "content", "encoding" ], [], __modifyAttributesForObjectsReferingRepo )
),
ExternalListOfObjects( "git/tags", "git_tag", GitTag,
ElementGetable( [ "sha" ], [], "_repo" ),
ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "tag", "message", "object", "type" ], [ "tagger" ], __modifyAttributesForObjectsReferingRepo )
),
ExternalListOfObjects( "labels", "label", Label,
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( [ "name" ], [], "_repo" ),
ElementGetable( [ "name" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "name", "color" ], [], __modifyAttributesForObjectsReferingRepo ),
),
ExternalListOfObjects( "milestones", "milestone", Milestone,
ListGetable( [], [ "state", "sort", "direction" ], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( [ "number" ], [], "_repo" ),
ElementGetable( [ "number" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "title" ], [ "state", "description", "due_on" ], __modifyAttributesForObjectsReferingRepo )
),
ExternalListOfObjects( "issues", "issue", Issue,
ListGetable( [], [ "milestone", "state", "assignee", "mentioned", "labels", "sort", "direction", "since" ], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( [ "number" ], [], "_repo" ),
ElementGetable( [ "number" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "title" ], [ "body", "assignee", "milestone", "labels", ], __modifyAttributesForObjectsReferingRepo )
),
ExternalSimpleAttribute( "languages" ),
ExternalListOfObjects( "downloads", "download", Download,
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( [ "id" ], [], "_repo" ),
ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ),
ElementCreatable( [ "name", "size" ], [ "description", "content_type" ], __modifyAttributesForObjectsReferingRepo ),
),
ExternalListOfObjects( "comments", "comment", CommitComment,
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( [ "id" ], [], "_repo" ),
ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ),
),
ExternalListOfObjects( "commits", "commit", Commit,
ListGetable( [], [ "sha", "path" ], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( [ "sha" ], [], "_repo" ),
ElementGetable( [ "sha" ], [], __modifyAttributesForObjectsReferingRepo ),
),
ExternalListOfObjects( "tags", "tag", Tag,
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
@@ -332,7 +332,7 @@ Repository._addAttributePolicy( InternalObjectAttribute( "source", Repository )
Repository._addAttributePolicy( ExternalListOfObjects( "forks", "fork", Repository, ListGetable( [], [] ) ) )
__repoElementCreatable = ElementCreatable( [ "name" ], [ "description", "homepage", "private", "has_issues", "has_wiki", "has_downloads", "team_id", ] )
__repoElementGetable = ElementGetable( [ "name" ], [], "owner" )
__repoElementGetable = ElementGetable( [ "name" ], [], { "owner" : lambda user: user } )
__repoListGetable = ListGetable( [], [] )
AuthenticatedUser._addAttributePolicy( ExternalListOfObjects( "repos", "repo", Repository, __repoListGetable, __repoElementGetable, __repoElementCreatable ) )
NamedUser._addAttributePolicy( ExternalListOfObjects( "repos", "repo", Repository, __repoListGetable, __repoElementGetable ) )