[Zope] Creating a DTM Document in a variable folder.

Paul Winkler pw_lists at slinkp.com
Thu Dec 1 09:49:20 EST 2005


On Thu, Dec 01, 2005 at 07:40:38AM +0000, Chris Withers wrote:
> Jonathan Cyr wrote:
> >You might want to use index_html rather than index.html in this 
> >example.  The dot means other things in Python, and index.html is a 
> >carryover from filesystem webservers.  My impression is that the 
> >acquisition mechanism doesn't like ids with a dot, in some circumstances.
> 
> Acquisition works fine irrespective of the object id.
> And dotted or dashed names work fine in ZPT path:
> 
> tal:content="here/my-folder/index.html/title"
> 
> If you use python, most objectmanagers support dictionary-like notation:
> 
> tal:content="python:here['my-folder']['index.html'].title"
> 
> ...and if you object doesn't support dictionary-like notation, you can 
> use getattr:
> 
> getattr(getattr(here,'my-folder'),'index.html').title
> 
> And getattr performs Acquisition just fine...

... but __getitem__ doesn't :-)
So here['my-folder']['index.html'] is semantically different
from  getattr(getattr(here, 'my-folder'), 'index.html').
The former works strictly by local containment and does
not use acquisition. The latter may use acquisition.
I know Chris knows this, but maybe other people following
along don't.

p.s. "here" should be deprecated, use "context" instead.
 
-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope mailing list