Swap argument order for specs.register

This will allow us to put the id in the inner Meta class.
This commit is contained in:
Matthew Tretter 2012-10-24 21:50:53 -04:00
parent 606f59a102
commit 8d3fcafcd9
2 changed files with 4 additions and 12 deletions

View file

@ -67,7 +67,7 @@ More often, however, you'll want to register your spec with ImageKit:
.. code-block:: python
from imagekit import specs
specs.register('myapp:fancy_thumbnail', Thumbnail)
specs.register(Thumbnail, 'myapp:fancy_thumbnail')
Once a spec is registered with a unique name, you can start to take advantage of
ImageKit's powerful utilities to automatically generate images for you...

View file

@ -36,7 +36,7 @@ class SpecRegistry(object):
signal.connect(self.source_receiver)
before_access.connect(self.before_access_receiver)
def register(self, id, spec):
def register(self, spec, id):
if id in self._specs:
raise AlreadyRegistered('The spec with id %s is already registered' % id)
self._specs[id] = spec
@ -228,7 +228,7 @@ class SpecHost(object):
"""
self.spec_id = id
registry.register(id, self._original_spec)
registry.register(self._original_spec, id)
def get_spec(self, **kwargs):
"""
@ -244,15 +244,7 @@ class SpecHost(object):
registry = SpecRegistry()
def register(id, spec=None):
if not spec:
def decorator(cls):
registry.register(id, cls)
return cls
return decorator
registry.register(id, spec)
register = registry.register
def unregister(id, spec):