Thanks Chris, the thing is I have several other views configured almost identically that are not causing conflicts with these decorators. it's just the login and logout views. the only thing unique about those is that I have login/logout defined to take a different context and they have a slightly different implementation to set some more data when someone logs in.
But commenting those out doesn't make these errors go away either. I will look at this more over the holidays and see if I can find anything else out. On Dec 21, 12:41 pm, Chris McDonough <[email protected]> wrote: > Hi Tom, > > I ran into a baffling issue exactly like this yesterday. What I found > out was that I was defining a view as an instance at module scope like > this: > > class SomeViewClass(object): > .... > > wizard = SomeViewClass(...) > wizard_view = view_config(...)(wizard) > > When I started up the process, and scanned the package, I would get a > conflict error that pointed at "wizard_view". What was happening was > that I was unwittlingly creating *two* views at module scope by > assigning the result of "view_config" to "wizard_view". When I did this > instead, it all worked: > > class SomeViewClass(object): > .... > > wizard = SomeViewClass(...) > view_config(...)(wizard) > > Probably what is happening here is that your code is generating *two* > separately named implementations of the same view and a scan is > registering both, like mine was. > > It's unclear how this is happening from the code. You don't mention > below if it works when you use @view_config and @log_event together. > Does that work? If so, then it would point at @t_view. > > > > > > > > On Tue, 2010-12-21 at 07:45 -0800, Thomas G. Willis wrote: > > I'm porting a bfg app over to pyramid and getting some strange things > > happening that I don't understand... > > > first of all, in order to cut down on the cruft I wrote a wrapper > > around view_config(formerly bfg_view) and it looks like this... > > > def t_view(route_name="model", renderer="json", **kw): > > """ > > some sugar to for the common things. > > most views have a common route and renderer > > > **DRY** > > """ > > kw["route_name"] = route_name > > kw["renderer"] = renderer > > return view_config(**kw) > > > and I also have a decorator for logging "events" > > def log_event(func): > > @functools.wraps(func) > > def _inner(context, request): > > try: > > result = func(context, request) > > except Exception, ex: > > raise > > else: > > try: > > if hasattr(context, "key"): > > context_obj = context.key() > > else: > > context_obj = None > > > if hasattr(request, "user"): > > created_by = request.user > > else: > > created_by = None > > > data = dict(view=request.view_name) > > evt = Event(context_path=context.path, > > context_obj=context_obj, > > created_by=created_by, > > data=json.dumps(data)) > > evt.put() > > except Exception, ex: > > log.error(ex) > > > return result > > return _inner > > > I get this error at startup > > > ConfigurationConflictError: Conflicting configuration actions > > For: ('view', <class 'hydrant.model.user.UserModel'>, 'login', None, > > <InterfaceClass pyramid.interfaces.IView>, None, None, None, 'model', > > None, False, None, None, None) > > ('/Users/twillis/projects/hydrant-pyarmid/src/hydrant/hydrant/ > > views/user.py', 21, '<module>', '@log_event') > > ('/Users/twillis/projects/hydrant-pyarmid/src/hydrant/hydrant/ > > views/user.py', 21, '<module>', '@log_event') > > For: ('view', <class 'hydrant.model.user.UserModel'>, 'logout', > > None, <InterfaceClass pyramid.interfaces.IView>, None, None, None, > > 'model', None, False, None, None, None) > > ('/Users/twillis/projects/hydrant-pyarmid/src/hydrant/hydrant/ > > views/user.py', 49, '<module>', '@log_event') > > ('/Users/twillis/projects/hydrant-pyarmid/src/hydrant/hydrant/ > > views/user.py', 49, '<module>', '@log_event') > > > and here's the functions it's whining about, I can't show the > > implementation though sorry... > > > #view_config(context=UserModel, name="login", route_name="model", > > renderer="json") > > @t_view(context=UserModel, name="login") > > @log_event > > def view_login(context, request): > > ... > > > #view_config(context=UserModel, name="logout", route_name="model", > > renderer="json") > > @t_view(context=UserModel, name="logout") > > @log_event > > def view_logout(context, request): > > ... > > > I was thinking that maybe it's the log_event decorator but removing > > that.... > > > ConfigurationConflictError: Conflicting configuration actions > > For: ('view', <class 'hydrant.model.user.UserModel'>, 'login', None, > > <InterfaceClass pyramid.interfaces.IView>, None, None, None, 'model', > > None, False, None, None, None) > > ('/Users/twillis/projects/hydrant-pyarmid/src/hydrant/hydrant/ > > views/user.py', 20, '<module>', '@t_view(context=UserModel, > > name="login")') > > ('/Users/twillis/projects/hydrant-pyarmid/src/hydrant/hydrant/ > > views/user.py', 20, '<module>', '@t_view(context=UserModel, > > name="login")') > > For: ('view', <class 'hydrant.model.user.UserModel'>, 'logout', > > None, <InterfaceClass pyramid.interfaces.IView>, None, None, None, > > 'model', None, False, None, None, None) > > ('/Users/twillis/projects/hydrant-pyarmid/src/hydrant/hydrant/ > > views/user.py', 48, '<module>', '@t_view(context=UserModel, > > name="logout")') > > ('/Users/twillis/projects/hydrant-pyarmid/src/hydrant/hydrant/ > > views/user.py', 48, '<module>', '@t_view(context=UserModel, > > name="logout")') > > > so I switch to the view_config decorators... > > > view_config(context=UserModel, name="login", route_name="model", > > renderer="json") > > #...@t_view(context=UserModel, name="login") > > #...@log_event > > def view_login(context, request): > > ... > > > view_config(context=UserModel, name="logout", route_name="model", > > renderer="json") > > #...@t_view(context=UserModel, name="logout") > > #...@log_event > > def view_logout(context, request): > > ... > > > and I get a 404, all my other views seem to work and they are > > configured with t_view, and log_event > > > I'm calling config.scan at startup after adding the route. I don't > > know if I've run into a bug or I'm doing it wrong, any guidance is > > appreciated. -- 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.
