You can clone with
Hey, pull request #134 raises an AttributeError when passing callables to
colander.deferred, i.e.: colander.deferred now expects its arg to be a
function, whereas before it could be an instance with a __call__ method.
Is this intended? Or is it intended that the decorator continue to work
with arbitrary callables?
For example, I have code (which worked fine in colander 1.0a5) like:
product_widget = colander.deferred(ModelWidget(Product))
Where ModelWidget is along the lines of:
def __call__(self, node, kw):
# returns a widget with values populated from the database
Updating to 1.0b1 now raises an exception at import time:
14:55:12 web.1 | File "XXX", line XXX, in <module>
14:55:12 web.1 | product_widget = colander.deferred(ModelWidget(Product))
14:55:12 web.1 | File "XXX/lib/python2.7/site-packages/colander/__init__.py", line 2128, in __init__
14:55:12 web.1 | functools.update_wrapper(self, wrapped)
14:55:12 web.1 | File "/usr/local/Cellar/python/2.7.2/lib/python2.7/functools.py", line 33, in update_wrapper
14:55:12 web.1 | setattr(wrapper, attr, getattr(wrapped, attr))
14:55:12 web.1 | AttributeError: 'ModelWidget' object has no attribute '__name__'
Looking at the functools docs it seems pretty clear that wrapped needs to
be a function with a __name__ attribute.
Un-break wrapping of callable instances as 'colander.deferred'.
Thanks for the report.
Thanks for fixing and testing :)
Out of interest, how do I build a distribution that includes the locale directory? I wanted to deploy code that relies on this fix, so I built a sdist against the repo head:
python setup.py sdist
However, when I deploy this in tandem with pyramid_deform, I get an error because pyramid_deform has a configuration line that expects the colander dist to have a locale directory:
Clearly I can workaround this and it's not an issue with the colander lib. However, I just wondered how to build a distribution that contains the locale directory, as per the main package releases?
Install setuptools_git, and use a checkout of Colander. This will cause all files checked into git to be included in the tgz when you run "setup.py sdist".