Repository.xxx_download

This commit is contained in:
Vincent Jacques
2012-02-25 13:26:37 +00:00
parent 1bdb937597
commit 8a7ab941cd
4 changed files with 37 additions and 4 deletions
+18
View File
@@ -186,6 +186,19 @@ Issue = GithubObject(
),
)
Download = GithubObject(
"Download",
BaseUrl( lambda obj: obj._repo._baseUrl + "/downloads/" + str( obj.id ) ),
InternalSimpleAttributes(
"url", "html_url", "id", "name", "description", "size",
"download_count", "content_type", "policy", "signature", "bucket",
"accesskeyid", "path", "acl", "expirationdate", "prefix", "mime_type",
"redirect", "s3_url", "created_at",
"_repo", ### Ugly hack
),
Deletable(),
)
__modifyAttributesForObjectsReferingRepo = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) )
Repository = GithubObject(
"Repository",
@@ -242,6 +255,11 @@ Repository = GithubObject(
ElementCreatable( "issue", [ "title" ], [ "body", "assignee", "milestone", "labels", ], __modifyAttributesForObjectsReferingRepo )
),
ExternalSimpleAttribute( "languages" ),
ExternalListOfObjects( "downloads", Download,
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( "download", lambda repo, id : { "_repo": repo, "number": number } ),
ElementCreatable( "download", [ "name", "size" ], [ "description", "content_type" ], __modifyAttributesForObjectsReferingRepo ),
)
)
Repository._addAttributePolicy( InternalObjectAttribute( "parent", Repository ) )
Repository._addAttributePolicy( InternalObjectAttribute( "source", Repository ) )