Created
May 2, 2010 23:02
-
-
Save codysoyland/387536 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tastypie/api.py b/tastypie/api.py | |
index 0344a81..b4f2adc 100644 | |
--- a/tastypie/api.py | |
+++ b/tastypie/api.py | |
@@ -50,6 +50,19 @@ class Api(object): | |
# Register it globally so we can build URIs. | |
_add_resource(self, resource, canonical) | |
+ def register_representation(self, representation, name, canonical=True): | |
+ """ | |
+ Registers a ``Representation`` subclass with the API. | |
+ | |
+ This serves as a Resource factory method and a proxy to Api.register | |
+ to reduce boilerplate in cases where you need no customization in your | |
+ ``Resource`` subclass. | |
+ """ | |
+ class BasicResource(Resource): | |
+ representation = representation | |
+ resource_name = name | |
+ self.register(BasicResource, canonical) | |
+ | |
def unregister(self, resource_name): | |
""" | |
If present, unregisters a resource from the API. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment