[Zope] Re: Photo Product fix/question/suggestion

Andrew Lahser andrew@apl-software.com
Mon, 10 Jan 2000 22:48:19 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_00C5_01BF5BBC.CA253AC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

> > This should work:
> > <dtml-var "blah(REQUEST, class=3D'fooimage', alt=3D'[Can't use dtml =
tags
inside
> > dtml tags]', pdcookie=3D'1')">
>
> Zope spits out the following:
>
> Expression (Python) Syntax error:
> invalid syntax
>
> , for tag <dtml-var "blah(REQUEST, class=3D'fooimage', alt=3D'[Can't =
use dtml
tags
> inside dtml tags]', pdcookie=3D'1')">, on line 6 of index_html
>
> It gives the same error if I use the other version.
I hope that you did not take my example literaly. I included an extra
apostrophe (')
in the example that would give a syntax error. Here is a simplier =
example.

<dtml-var "blah(REQUEST, alt=3D'your text', pdcookie=3D'1')">

Add all the additional tags that you would want. Remember that blah =
needs to
be photo object, not an attribute with the name of the photo

> > Let me know right away if this doesn't work for you.
>
> The *major* problem I am suffering is that I don't know what "blah" is =
in
my
> method, so the above doesn't work.
>
> The ZClass FooImage has a property "image".
> Inside the image property for a given instance, I stick the ID of the
proper
> photo object.
> My DTML is in the index_html method of FooImage.
>
> I don't know how to tell DTML to grab the object referred to by =
"image"
(as
> opposed to the string CONTENTS of the "image" property, which is what =
it
does
> right now, I assume).  If I just plug in the Property name as in
> "image(REQUEST", then it gives a "call of non-function" error.
>
If I understand your problem correctly, you should be able to do this.
<dtml-with blah> # blah is an attribute of the index_html document
  <dtml-var "tag(REQUEST, pdcookie=3D'1', alt=3D'your text')">
</dtml-with>

Also, you could loop through all the Photos in a container as follows.

<dtml-in "objectValues('Photo')">
  <dtml-var "tag(REQUEST, pdcookie=3D'1', alt=3D'your text')">
</dtml-in>

> > > Alternately, figuring out how to use this "pdcookie" feature from =
a
normal
> > > <img> tag would work too.

The pdcookie feature is nothing more than a switch to spit out some =
html.
Feel
free to copy that anywhere you need. The trick is to set the cookie in =
the
user's browser.




------=_NextPart_000_00C5_01BF5BBC.CA253AC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>&gt; &gt; This should work:<BR>&gt; =
&gt;=20
&lt;dtml-var "blah(REQUEST, class=3D'fooimage', alt=3D'[Can't use dtml=20
tags<BR>inside<BR>&gt; &gt; dtml tags]', =
pdcookie=3D'1')"&gt;<BR>&gt;<BR>&gt; Zope=20
spits out the following:<BR>&gt;<BR>&gt; Expression (Python) Syntax=20
error:<BR>&gt; invalid syntax<BR>&gt;<BR>&gt; , for tag &lt;dtml-var=20
"blah(REQUEST, class=3D'fooimage', alt=3D'[Can't use =
dtml<BR>tags<BR>&gt; inside=20
dtml tags]', pdcookie=3D'1')"&gt;, on line 6 of =
index_html<BR>&gt;<BR>&gt; It=20
gives the same error if I use the other version.<BR>I hope that you did =
not take=20
my example literaly. I included an extra<BR>apostrophe (')<BR>in the =
example=20
that would give a syntax error. Here is a simplier =
example.<BR><BR>&lt;dtml-var=20
"blah(REQUEST, alt=3D'your text', pdcookie=3D'1')"&gt;<BR><BR>Add all =
the additional=20
tags that you would want. Remember that blah needs to<BR>be photo =
object, not an=20
attribute with the name of the photo<BR><BR>&gt; &gt; Let me know right =
away if=20
this doesn't work for you.<BR>&gt;<BR>&gt; The *major* problem I am =
suffering is=20
that I don't know what "blah" is in<BR>my<BR>&gt; method, so the above =
doesn't=20
work.<BR>&gt;<BR>&gt; The ZClass FooImage has a property =
"image".<BR>&gt; Inside=20
the image property for a given instance, I stick the ID of =
the<BR>proper<BR>&gt;=20
photo object.<BR>&gt; My DTML is in the index_html method of=20
FooImage.<BR>&gt;<BR>&gt; I don't know how to tell DTML to grab the =
object=20
referred to by "image"<BR>(as<BR>&gt; opposed to the string CONTENTS of =
the=20
"image" property, which is what it<BR>does<BR>&gt; right now, I =
assume).&nbsp;=20
If I just plug in the Property name as in<BR>&gt; "image(REQUEST", then =
it gives=20
a "call of non-function" error.<BR>&gt;<BR>If I understand your problem=20
correctly, you should be able to do this.<BR>&lt;dtml-with blah&gt; # =
blah is an=20
attribute of the index_html document<BR>&nbsp; &lt;dtml-var =
"tag(REQUEST,=20
pdcookie=3D'1', alt=3D'your =
text')"&gt;<BR>&lt;/dtml-with&gt;<BR><BR>Also, you could=20
loop through all the Photos in a container as =
follows.<BR><BR>&lt;dtml-in=20
"objectValues('Photo')"&gt;<BR>&nbsp; &lt;dtml-var "tag(REQUEST, =
pdcookie=3D'1',=20
alt=3D'your text')"&gt;<BR>&lt;/dtml-in&gt;<BR><BR>&gt; &gt; &gt; =
Alternately,=20
figuring out how to use this "pdcookie" feature from a<BR>normal<BR>&gt; =
&gt;=20
&gt; &lt;img&gt; tag would work too.<BR><BR>The pdcookie feature is =
nothing more=20
than a switch to spit out some html.<BR>Feel<BR>free to copy that =
anywhere you=20
need. The trick is to set the cookie in the<BR>user's=20
browser.<BR><BR><BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_00C5_01BF5BBC.CA253AC0--