[Zope-dev] Implementing a URL path resolver

2001-01-18 Thread morten

Hi guys,

I've been tinkling with a function that does what REQUEST.resolve_url does,
except without it relying on having a REQUEST instance available.

That is, just resolving the path itself, something like this:

path ÿstring.split(relative_url, '/')
path ÿfilter(None, path)
new_path ÿ'%s' % path[0]
path ÿpath[1:]

for element in path:

new_path ÿnew_path + "['%s']" % element

return eval("self%s" % new_path)

Now, neither []- or .-like evaluation of the path works..

Any ideas?

Cheers,

Morten


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Implementing a URL path resolver

2001-01-18 Thread Steve Alexander

[EMAIL PROTECTED] wrote:

 Hi guys,
 
 I've been tinkling with a function that does what REQUEST.resolve_url does,
 except without it relying on having a REQUEST instance available.

Have you seen the methods restrictedTraverse and unrestrictedTraverse in 
lib/python/OFS/Traversable.py ?

These would seem to do what you need. The methods restrictedTraverse is 
available from DTML.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Implementing a URL path resolver

2001-01-18 Thread Morten W. Petersen

[[EMAIL PROTECTED]]

(Bug in the encoding of the message, MHA)

| path = string.split(relative_url, '/')
| path = filter(None, path)
| new_path = '%s' % path[0]
| path = path[1:]
| 
| for element in path:
| 
|   new_path = new_path + "['%s']" % element
| 
| return eval("self%s" % new_path)

-Morten

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Implementing a URL path resolver

2001-01-18 Thread Morten W. Petersen

[Steve Alexander]

| Have you seen the methods restrictedTraverse and unrestrictedTraverse in 
| lib/python/OFS/Traversable.py ?

Exactly what I needed.  Thank you.

-Morten

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )