Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
traversal and path with one element
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
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:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
rockerzz  
View profile  
 More options Apr 23 2012, 9:08 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alexey Gelyadov  
View profile  
 More options Apr 23 2012, 9:40 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Feng Wang  
View profile  
 More options Apr 23 2012, 10:06 pm
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写道:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Feng Wang  
View profile  
 More options Apr 23 2012, 10:07 pm
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写道:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »