Re: [Zope] Restricted Traverse

2006-11-11 Thread Nancy Donnelly
- Original Message From: Andrew Milton <[EMAIL PROTECTED]>> Try removing the 'anchor' (#quotes), since you dont have an object called> 'index_frame.pt#quotes', do you ?Well, ya know, I do, but I took that out and it worked!Thanks,Nancy___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Restricted Traverse

2006-11-11 Thread Paul Winkler
On Sun, Nov 12, 2006 at 12:57:21AM +1100, Andrew Milton wrote:
> +---[ Nancy Donnelly ]--
> | Could someone tell me what's wrong with this code?
> | 
> |  | tal:define="global url python:here.absolute_url(relative=None) + '/
> | index_frame.pt#quotes'"
> | />
> |  | tal:define="root python:container.restrictedTraverse(url)"
> | tal:replace="structure python:here.printSiteMap(root, 12)"
> | />
> | 
> | --or--
> | 
> |  | tal:define="root python:container.restrictedTraverse(here.absolute_url
> | (relative=None) + '/index_frame.pt#quotes')"
> | tal:replace="structure python:here.printSiteMap(root, 12)"
> | />
> | 
> | 
> | I'm trying to automate that restrictedTraverse.
> 
> absolute url returns a string prefixed with "http(s)://", unless the relative
> parameter evaluates to true None doesn't do that.
> 
> Try using relative = True

Aside from that, and the problem with '#quotes' as Andrew pointed out,
absolute_url() is just not safe to use with restrictedTraverse(), since
the url takes virtual hosting into account and thus may add or remove
parts of the path.  This technique tends to work fine during local
development and then as soon as you deploy to a server with virtual
hosting configured, boom, everything breaks. No fun.
So, Don't Do That.
See http://www.plope.com/Books/2_7Edition/AppendixB.stx#2-394

When creating paths for use with restrictedTraverse(),
you should always use getPhysicalPath() instead.

In this particular case, I suspect you don't even need to do that.
Try:

 tal:define="root python:here.restrictedTraverse('index_frame.pt')"

which can be spelled a bit more simply as:

 tal:define="root nocall:here/index_frame.pt"


-- 

Paul Winkler
http://www.slinkp.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Restricted Traverse

2006-11-11 Thread Andrew Milton
+---[ Nancy Donnelly ]--
| - Original Message 
| From: Andrew Milton <[EMAIL PROTECTED]>
| 
| > absolute url returns a string prefixed with "http(s)://", unless the 
relative
| > parameter evaluates to true None doesn't do that.
| >
| > Try using relative = True
| 
| You mean like this?
| 
| 
| 
| 
| It didn't like that either :(

Try removing the 'anchor' (#quotes), since you dont have an object called
'index_frame.pt#quotes', do you ?

Do you have any more information? 
Like error messages? The value that url evaluates to?

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


Re: [Zope] Restricted Traverse

2006-11-11 Thread Nancy Donnelly
- Original Message From: Andrew Milton <[EMAIL PROTECTED]>> absolute url returns a string prefixed with "http(s)://", unless the relative> parameter evaluates to true None doesn't do that.>> Try using relative = TrueYou mean like this?    tal:define="global url python:here.absolute_url(relative=True) + '/index_frame.pt#quotes'"/>    tal:define="root python:container.restrictedTraverse(url)"    tal:replace="structure python:here.printSiteMap(root, 12)"/>It didn't like that
 either :(Another idea?TIA,Nancy-- Andrew Milton[EMAIL PROTECTED]___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Restricted Traverse

2006-11-11 Thread Andrew Milton
+---[ Nancy Donnelly ]--
| Could someone tell me what's wrong with this code?
| 
| 
| 
| 
| --or--
| 
| 
| 
| 
| I'm trying to automate that restrictedTraverse.

absolute url returns a string prefixed with "http(s)://", unless the relative
parameter evaluates to true None doesn't do that.

Try using relative = True


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