[Zope] Doubt about the ZPT example in Using Zope Page Templates
Max M
maxm@mxm.dk
Fri, 27 Jun 2003 12:38:26 +0200
Geir B=E6kholt wrote:
> using "python:item.title or default" or even cleaner, a
> tales-statement: "item/title | default" just might help..
Hmmm, yeah
I wonder why title_or_id() was removed from CMF products?
instead we have to use:
tal:define=3D"title_or_id python:test(
item.Title(), item.Title(), item.getId())
And that sucks! as it is so often used.
Guess I will have to put a "util_title(item)" script in my skin folder
## Script (Python) "util_title"
##bind container=3Dcontainer
##bind context=3Dcontext
##bind namespace=3D
##bind script=3Dscript
##bind subpath=3Dtraverse_subpath
##parameters=3Ditem, default=3DNone
##title=3DReturns title, default of id
##
# Returns title, default value, or title for item, in that order.
try:
return item.Title()
except:
if default:
return default
return item.getId()
regards Max M