This turned out to be a stupid mistake on my part. The ContactHandler was being subclassed and the inherited methods which were decorated were being registered multiple times.
Thanks for the quick response. On Thu, Dec 6, 2012 at 2:35 PM, Michael Merickel <[email protected]> wrote: > Without being able to see the implementation of action_config this is just a > guess/check exercise. My first guess is that you're calling scan() multiple > times with overlapping options that are possibly scanning that module > multiple times. > > You said you tried using view_defaults and removing action_config, which of > course does nothing if you didn't replace the action_config calls with the > appropriate view_config calls. > > Also if action_config is using view_config directly, instead of implementing > its own venusian callback, there will be issues here unless you are using > 1.4 and overriding the depth argument to view_config. > > > On Thu, Dec 6, 2012 at 11:54 AM, ian marcinkowski > <[email protected]> wrote: >> >> I am having a problem using the view_config decorator. >> >> We have extended the view_config decorator to automatically include >> the match_param >> attribute. This new decorator is called action_config. I have >> already eliminated >> this as the source of my troubles, as the stock view_config decorator >> raises >> the same errors. >> >> I have 2 routes, 'contact' and 'contact id' that are being used by 4 >> view callables on a ContactHandler class. Only 1 of the view callables is >> using >> the 'contact id' route while the other 3 use the 'contact' route. >> >> (Note: Our project is using namespace packages, so application.lib is >> located at application.lib/application/lib on disk, for example) >> >> Routes >> application/module/__init__.py: >> ... >> config.add_route('contact', >> '/contact/{action}', >> factory='application.lib.contexts:ContactFactory') >> >> config.add_route('contact id', >> '/contact/{action}/{contact_id}', >> factory='application.lib.contexts:ContactFactory') >> >> config.scan('application.lib.handlers') >> ... >> >> >> Callables >> application.lib/application/lib/handlers/contact.py: >> >> class ContactHandler(Handler): >> >> @action_config(route_name='contact id') >> def edit(self): >> """ Add or edit a contact """ >> ... >> >> @action_config(route_name='contact') >> def index(self): >> """ Return list of contacts. """ >> ... >> >> >> @action_config(route_name='contact') >> def search(self): >> """ Return a list of contacts matching search parameters """ >> ... >> >> @action_config(route_name='contact') >> def find(self): >> """ Find a contacts """ >> ... >> >> I can't figure out how or why these route is conflicting. My application >> is >> only scanning application.lib/application/lib/handlers/contact.py in one >> place >> and each view/callable method is only decorated once, each for a specific >> route >> as defined in my __init__.py. >> >> If I decorate the ContactHandler class with >> @view_defaults(route_name='contact') >> and remove all of the @action_config decorators from my class methods, no >> errors >> are raised. However, this is not ideal as I one route requires an ID >> parameter >> and one does not. >> >> When using pdb.set_trace() inside of the our extended action_config >> __call__ method >> inside of the callback passed to view_config.venusian.attach(), >> I find that the callback is being called 3 times for each of these routes. >> I don't know if that is related to the problem. >> >> Stragely, I am using this same action_config decorator in another module >> inside of my application with no problems. >> >> The error: >> Traceback (most recent call last): >> File "~/.virtualenvs/application/bin/paster", line 8, in <module> >> load_entry_point('PasteScript==1.7.5', 'console_scripts', 'paster')() >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteScript-1.7.5-py2.7.egg/paste/script/command.py", >> line 104, in run >> invoke(command, command_name, options, args[1:]) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteScript-1.7.5-py2.7.egg/paste/script/command.py", >> line 143, in invoke >> exit_code = runner.run(args) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteScript-1.7.5-py2.7.egg/paste/script/command.py", >> line 238, in run >> result = self.command() >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteScript-1.7.5-py2.7.egg/paste/script/serve.py", >> line 284, in command >> relative_to=base, global_conf=vars) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteScript-1.7.5-py2.7.egg/paste/script/serve.py", >> line 321, in loadapp >> **kw) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", >> line 247, in loadapp >> return loadobj(APP, uri, name=name, **kw) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", >> line 272, in loadobj >> return context.create() >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", >> line 710, in create >> return self.object_type.invoke(self) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", >> line 144, in invoke >> **context.local_conf) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/util.py", >> line 56, in fix_call >> val = callable(*args, **kw) >> File >> "~/code/src/application/BRANCH/application.lib/application/lib/middleware/vhost.py", >> line 199, in vhost_addict_factory >> settings['app'] = loader.get_app(key, global_conf=global_conf) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", >> line 350, in get_app >> name=name, global_conf=global_conf).create() >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", >> line 710, in create >> return self.object_type.invoke(self) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/loadwsgi.py", >> line 146, in invoke >> return fix_call(context.object, context.global_conf, >> **context.local_conf) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/PasteDeploy-1.5.0-py2.7.egg/paste/deploy/util.py", >> line 56, in fix_call >> val = callable(*args, **kw) >> File >> "~/code/src/application/BRANCH/application/application/module/__init__.py", >> line 137, in main >> return config.make_wsgi_app() >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/config/__init__.py", >> line 921, in make_wsgi_app >> self.commit() >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/config/__init__.py", >> line 594, in commit >> self.action_state.execute_actions(introspector=self.introspector) >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/config/__init__.py", >> line 1030, in execute_actions >> for action in resolveConflicts(self.actions): >> File >> "~/.virtualenvs/application/lib/python2.7/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/config/__init__.py", >> line 1136, in resolveConflicts >> raise ConfigurationConflictError(conflicts) >> >> >> pyramid.exceptions.ConfigurationConflictError: Conflicting configuration >> actions >> For: ('view', None, '', None, <InterfaceClass >> pyramid.interfaces.IView>, None, None, None, 'contact', 'add', False, >> None, None, None, 'action=add') >> Line 184 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> Line 184 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> Line 184 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> For: ('view', None, '', None, <InterfaceClass >> pyramid.interfaces.IView>, None, None, None, 'contact', 'find', False, >> None, None, None, 'action=find') >> Line 137 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> Line 137 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> Line 137 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> For: ('view', None, '', None, <InterfaceClass >> pyramid.interfaces.IView>, None, None, None, 'contact', 'index', >> False, None, None, None, 'action=index') >> Line 94 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> Line 94 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> Line 94 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> For: ('view', None, '', None, <InterfaceClass >> pyramid.interfaces.IView>, None, None, None, 'contact', 'search', >> False, None, None, None, 'action=search') >> Line 133 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> Line 133 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> Line 133 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact') >> For: ('view', None, '', None, <InterfaceClass >> pyramid.interfaces.IView>, None, None, None, 'contact id', 'edit', >> False, None, None, None, 'action=edit') >> Line 37 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact id') >> Line 37 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact id') >> Line 37 of file >> >> ~/code/src/application/BRANCH/application.lib/application/lib/handlers/contact.py: >> @action_config(route_name='contact id') >> >> >> >> >> -- >> Ian Marcinkowski >> [email protected] >> >> -- >> You received this message because you are subscribed to the Google Groups >> "pylons-discuss" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/pylons-discuss?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. -- Ian Marcinkowski [email protected] -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
