mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Swap argument order for specs.register
This will allow us to put the id in the inner Meta class.
This commit is contained in:
parent
606f59a102
commit
8d3fcafcd9
2 changed files with 4 additions and 12 deletions
|
|
@ -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...
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue