traversal and path with one element
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 |
From: rockerzz <rocke...@gmail.com>
Date: Mon, 23 Apr 2012 06:08:00 -0700 (PDT)
Subject: traversal and path with one element
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 must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
From: Alexey Gelyadov <rocke...@gmail.com>
Date: Mon, 23 Apr 2012 06:40:16 -0700 (PDT)
Local: Mon, Apr 23 2012 9:40 am
Subject: Re: traversal and path with one element
I would like to work with interfaces, by doing something like for url example.com/catalog and m.example.com/catalog: <view context=".resources.ISite" view=".views.views.my_view" renderer="catlog/catalog.html"/> <view context=".resources.IMobile" view=".views.views.my_view" renderer="mobile/catalog/catalog.html"/>
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
From: Feng Wang <wangfen...@gmail.com>
Date: Mon, 23 Apr 2012 19:06:11 -0700 (PDT)
Local: Mon, Apr 23 2012 10:06 pm
Subject: Re: traversal and path with one element
I think maybe you will raise a KeyError when the getitem method of you root resource dont't have a self.children[name].
在 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 must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
From: Feng Wang <wangfen...@gmail.com>
Date: Mon, 23 Apr 2012 19:07:40 -0700 (PDT)
Local: Mon, Apr 23 2012 10:07 pm
Subject: Re: traversal and path with one element
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 must Sign in before you can post messages.
You do not have the permission required to post.
|
|
|