[Zope] Zope 2.1.0 &dtml-expr="5+5"; doesn't work anymore?

Jim Fulton jim@digicool.com
Tue, 14 Dec 1999 16:10:40 +0000


Joe Grace wrote:
> 
(snip)
> 
> I just upgraded from Zope 2.0.0 (stable version I believe) to Zope 2.1.0
> and my site broke where I use
> 
>     &dtml-expr="";

This was never correct usage. If it ever worked, it was a bug.
When using the entity-regerance syntax in 2.0, you aren't allowed to
specify any attributes. The form is:

  &dtml-foo;

which is equivalent to:

  <dtml name="foo">

> 
> syntax.  I looked in the release notes for any changes to DTML syntax
> but noticed none which seem to cause my problem.  (However, this same
> thing happened to me upgrading to 2.0.0 and the docs escaped my notice
> then so...)  Basically, I'm using
> 
>     <... &dtml-expr="Python calculations go here"; ...>
> 
> e.g.,
> 
>    <TR BGCOLOR="#&dtml-expr="_.hex( 0xF8 -
> depth)[2:]";&dtml-expr="_.hex(
> 0xF8 - depth)[2:]";FF">
> 
> in several places.  I noticed that the entity syntax has been upgraded
> with qualifiers.  I've also tried a whole bunch of syntactic variations
> to get my &dtml-expr=""s to work, all to no avail.  Finally, I've
> practiced newbie Zope Zen and tried to decipher DT_Var.py (or
> thereabouts) to see if I could figure out the fate of &dtml-expr.
> Anyway...
> 
> Has &dtml-expr="" been deprecated, i.e., removed from Zope, or have I
> just failed to find the new secret incantation which gets me an
> expression using the entity syntax?

It was never supported. I'm quite surprized that it worked.
 
> Needless to say, any help appreciated.  I don't mind changing my code,
> but I do need to know the new Zope 2.1.0 Zen of &dtml-expr="";).

The new and old Zope zen is that you can't use '&dtml-expr="";'.

Use <dtml expr="">.  If you need to use an entity reference, then
you need to use a with or let tag:

 <dtml-with "_(
     bgcolor=_.hex( 0xF8 - depth)[2:]
    )">
  <TR BGCOLOR="#&dtml-bgcolor1;&dtml-bgcolor1;FF">
 </dtml-with>

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.