In your case, catalog will be the context ,and the view_name will be none.

在 2012年4月23日星期一UTC+8下午9时08分00秒,Alexey Gelyadov写道:
>
> Could you explain why not return view_name if I work with url 
> something like http://0.0.0.0:6543/catalog/. 
>
> If I remove from my root resources object __getitem__ function - its 
> work fine. 
>
>  class Resource(object): 
>     def __init__(self, name=None, parent=None): 
>         self.__name__ = name 
>         self.__parent__ = parent 
>         self.children = {} 
>
>     def add_child(self, name, klass=None, **kw): 
>         if klass is None: 
>             child = Resource(name, self) 
>         else: 
>             child = klass(name, self, **kw) 
>         self.children[name] = child 
>     ''' 
>     def __getitem__(self, name): 
>         return self.children[name] 
>     ''' 
> class Catalog(Resource): 
>     pass 
>
>
> root = Resource('root') 
> root.add_child('catalog', Catalog) 
>
> As I understand it, this is the logic of work. How do I properly solve 
> this problem? 
>
> Code from traversal.py ResourceTreeTraverser class: 
>
>                 try: 
>                     getitem = ob.__getitem__ 
>                 except AttributeError: 
>                     return {'context':ob, 
>                             'view_name':segment, 
>                             'subpath':vpath_tuple[i+1:], 
>                             'traversed':vpath_tuple[:vroot_idx+i+1], 
>                             'virtual_root':vroot, 
>                             'virtual_root_path':vroot_tuple, 
>                             'root':root} 
>
>                 try: 
>                     next = getitem(segment) 
>                 except KeyError: 
>                     return {'context':ob, 
>                             'view_name':segment, 
>                             'subpath':vpath_tuple[i+1:], 
>                             'traversed':vpath_tuple[:vroot_idx+i+1], 
>                             'virtual_root':vroot, 
>                             'virtual_root_path':vroot_tuple, 
>                             'root':root} 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/pylons-discuss/-/eRPr2dunMrcJ.
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.

Reply via email to