[Zope] dtml-lesson learned...
Maik Jablonski
maik.jablonski@uni-bielefeld.de
Tue, 20 Aug 2002 15:57:54 +0200
and still another lesson... python this time. it's my learning day
today. ;-)
**explicit is better than implicit!**
IMPLICIT [no checks at all => that's the dark side of coding]:
return context.title[context.title.find('#')+1:]
BETTER:
title=context.getProperty('title')
if title<>'':
pos = title.find('#')
if pos<>-1:
return title[pos+1:]
return title
that's enough for today.
cheers, maik
Maik Jablonski wrote:
> hi,
>
> I've just learned my DTML-lesson... Don't use DTML for any
> program-logic!!! Not even the small bits...
>
> Debuged 3 hours...
>
> if've used this snippet for months and it worked well...
>
> <dtml-return "_['title'][_['title'].find('#')+1:]">
>
> today it stopped working with an "access denied"-error... don't ask
> why... I've no idea, but maybe I've touched a guarded-namespace...
> typical DTML-mystery.
>
> this python one works well:
>
> return context.title[context.title.find('#')+1:]
>
> ergo: don't use DTML for logic, use Python!
>
> maybe: don't use DTML for presentation, use ZPT [I'm not totally
> convinced of that by now, but especially for Chris W.: maybe I will
> following your ZPT-church in the near future too...;-)]
>
> cheers, maik
--
Maik Jablonski __o
www.zfl.uni-bielefeld.de _ \<_ Deutsche Zope User Group
Bielefeld, Germany (_)/(_) www.dzug.org