[Zope] Architectural decisions

Peter Bengtsson mail at peterbe.com
Mon May 24 18:44:02 EDT 2004


I don't know of a "definitive listing" but try to have as a rule of 
thumb to never use getattr or hasattr in TAL.
If you find yourself doing so you know you've gone to far without 
refactoring into python scripts.
The most advanced luxury I afford myself in TAL is python:test() or 
python:path()

You can also make it a habit to set aside Python scripts in a certain 
fashion just to support your TAL. You could for example name all the 
python scripts something like "evaluateEnvironment_4tal" and then be 
able to do something like this in TAL.
<div tal:condition="here/evaluateEnvironment_4tal">foo bar</div>

Peter

Ben Last (Zope) wrote:

>>From: Peter Bengtsson [mailto:mail at peterbe.com]
>><h2 tal:content="python:path('here/%s/environment'%request['partner'])">
>>    
>>
>Beautifully elegant, Peter, thanks :)
>Now I shall write 100 times; "I must remember to invoke Python more
>often..."  And thanks to Matt also for the python script reference.
>
>Something I'm finding *slightly* annoying is the mix of Python semantics in
>Zope.  In some places, one uses:
>object['attributeName']
>...and in others:
>getattr(object, 'attributeName')
>...depending, of course, on the type of object with which one is provided.
>In one Python script I had, one container appeared to work the first way and
>another the second.  ZPT seems to work it out every time.  Is there a
>definitive listing of what things are treatable as dicts and which as
>objects?
>
>ben
>
>
>
>  
>

-- 
Peter Bengtsson, http://www.peterbe.com




More information about the Zope mailing list