Hi folks, I'm getting a really weird error wondering if anyone might have experienced anything like it.
I made a view url building helper, url_for. It uses the route name, and builds the correct url for the resource, where this route is a hybrid route with traversal. My helper works fine, when I log from it, I get what I want. It's returning the correct url. My logging output looks good: 15:42:38,354 INFO [xornot.dram.views] route_name: admin 15:42:38,354 INFO [xornot.dram.views] resource_path: pet 15:42:38,354 INFO [xornot.dram.views] traverse: [u'pet', '1', 'edit'] 15:42:38,354 INFO [xornot.dram.views] returning url: http://localhost:8081/admin/pet/1/edit But when I call this view helper from a zpt template like so: href=""{view.url_for('list')}" I see the correct url coming out of the logger, and in my actual response in the browser I see http://localhost:8081/admin/admin/pet/list ( the route name appearing twice ). The only thing that might be funny here is that the route does use a wrapper view, but I can't for the life of me figure out why the string being returned from the helper function correctly is getting mutated when it is shown through the zpt template. Any one have any ideas what might be going? Helper code below: thanks iain 87 # XXX: fixing this, June 13 88 def url_for(self, action, context=None): 89 "return a url for actions new/edit/delete, depending on context" 90 log.info("\n\nurl_for() action: %s context: %s" % (action, context) ) 91 # base ActionView.url_for is for ResourceProxy objects 92 context = context or self.context 93 route_name = self.request['bfg.routes.route'].name 94 log.info("route_name: %s" % route_name) 95 resource_class = getattr(self.context, 'resource_class', 96 getattr( self.context, '__class__' ) ) 97 resource_path = self.get_resource_path(resource_class) 98 log.info("resource_path: %s" % resource_path) 99 traverse = [resource_path, action] 100 # for new or list actions, we want to use parent path 101 if action not in ('new', 'list', 'delete'): 102 traverse.insert( -1, '%s' % context.id ) 103 log.info("traverse: %s" % traverse) 104 url = route_url(route_name, self.request, traverse=traverse ) 105 log.info("returning url: %s" % url) 106 return url
_______________________________________________ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev