Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newly introduced AttributeError when using colander.deferred with callables. #141

Closed
thruflo opened this issue Sep 16, 2013 · 5 comments
Closed

Comments

@thruflo
Copy link

thruflo commented Sep 16, 2013

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:

class ModelWidget(object):
    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.

@tseaver
Copy link
Member

tseaver commented Sep 16, 2013

Thanks for the report.

@thruflo
Copy link
Author

thruflo commented Sep 16, 2013

Thanks for fixing and testing :)

@thruflo
Copy link
Author

thruflo commented Oct 25, 2013

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:

config.add_translation_dirs('colander:locale', 'deform:locale')

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?

@mcdonc
Copy link
Member

mcdonc commented Oct 25, 2013

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".

@thruflo
Copy link
Author

thruflo commented Oct 28, 2013

Ah yes, cheers.

On Fri, Oct 25, 2013 at 4:50 PM, Chris McDonough
[email protected]:

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".


Reply to this email directly or view it on GitHubhttps://github.com//issues/141#issuecomment-27103429
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants