[Zope] inserting half a dtml tag into a zclass

Tim Hicks Tim Hicks" <tim@sitefusion.co.uk
Thu, 28 Dec 2000 01:55:59 -0000


This is a multi-part message in MIME format.

------=_NextPart_000_0009_01C07071.533E96C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

OK, I'm sorry for the wierd title, but I can't really describe what I =
want to say very easily in one line.

Basically, my problem is this;

- I have a zclass called DEHS with catalog_aware and dtml_document as =
base classes.
- DEHS instances have a selectable property of public/private.
- I want to be able to make it so that if the property is set to =
'private', then only people on a particular network may access it. So, =
here is what I have done (and it works),

<dtml-call "REQUEST.set('available', 0)">
<dtml-if "propertyLabel(availability) =3D=3D 'private'">
<dtml-call "REQUEST.set('available', 1)">
</dtml-if>

<dtml-call "REQUEST.set('dom', _.string.split(REQUEST.REMOTE_ADDR, =
'.'))">
<dtml-if "dom[0] =3D=3D '192'">
<dtml-if "dom[1] =3D=3D '168'">
<dtml-call "REQUEST.set('available', 0)">
</dtml-if>
</dtml-if>

<dtml-if "available =3D=3D 1">
<dtml-in PARENTS>
<dtml-let PARENT=3D"_.getitem('sequence-item')">
<dtml-if "PARENT.hasProperty('dehs_site_root_folder')"><dtml-call =
"REQUEST.set('restricted', PARENT.absolute_url())"></dtml-if>
</dtml-let>
</dtml-in>
<dtml-call "RESPONSE.redirect(restricted+'/restricted.html')">
<dtml-else>

<dtml-var standard_html_header>



<dtml-var standard_html_footer>
</dtml-if>

So, what's the problem I hear you ask.  Well, I don't really want all =
this code to be visible (or breakable) in every DEHS instance. What I =
would really like to do is have this,

<dtml-var privacy>

<dtml-var standard_html_header>

<dtml-var standard_html_footer>

</dtml-if>

where, <dtml-var privacy> is just all of the code that I have above =
s_h_h. However, zope will not let me do this because I end up with a =
<dtml-if> that is missing its closing tag, and one that does not have an =
opening tag. I realise that I there are products already designed with =
the sort of functionality I am after built in, but I will not have much =
influence on the products that will be available on the server that this =
site will end up on... which is why I'm doing it in this way.

Any input is much appreciated.

cheers

tim

------=_NextPart_000_0009_01C07071.533E96C0
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.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>OK, I'm sorry for the wierd title, but =
I can't=20
really describe what I want to say very easily in one line.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Basically, my problem is =
this;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>- I have a zclass called DEHS with =
catalog_aware=20
and dtml_document as base classes.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>- DEHS instances have a selectable =
property of=20
public/private.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>- I want to be able to make it so that =
if the=20
property is set to 'private', then only people on a particular network =
may=20
access it. So, here is what I have done (and it works),</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-call "REQUEST.set('available', =

0)"&gt;<BR>&lt;dtml-if "propertyLabel(availability) =3D=3D=20
'private'"&gt;<BR>&lt;dtml-call "REQUEST.set('available',=20
1)"&gt;<BR>&lt;/dtml-if&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-call "REQUEST.set('dom',=20
_.string.split(REQUEST.REMOTE_ADDR, '.'))"&gt;<BR>&lt;dtml-if "dom[0] =
=3D=3D=20
'192'"&gt;<BR>&lt;dtml-if "dom[1] =3D=3D '168'"&gt;<BR>&lt;dtml-call=20
"REQUEST.set('available',=20
0)"&gt;<BR>&lt;/dtml-if&gt;<BR>&lt;/dtml-if&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-if "available =3D=3D =
1"&gt;<BR>&lt;dtml-in=20
PARENTS&gt;<BR>&lt;dtml-let=20
PARENT=3D"_.getitem('sequence-item')"&gt;<BR>&lt;dtml-if=20
"PARENT.hasProperty('dehs_site_root_folder')"&gt;&lt;dtml-call=20
"REQUEST.set('restricted',=20
PARENT.absolute_url())"&gt;&lt;/dtml-if&gt;<BR>&lt;/dtml-let&gt;<BR>&lt;/=
dtml-in&gt;<BR>&lt;dtml-call=20
"RESPONSE.redirect(restricted+'/restricted.html')"&gt;<BR>&lt;dtml-else&g=
t;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-var =
standard_html_header&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-var=20
standard_html_footer&gt;<BR>&lt;/dtml-if&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So, what's the problem I hear you =
ask.&nbsp; Well,=20
I don't really want all this code to be visible (or breakable) in every =
DEHS=20
instance. What I would really like to do is have this,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-var privacy&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-var =
standard_html_header&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;dtml-var =
standard_html_footer&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;/dtml-if&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>where, &lt;dtml-var privacy&gt; is just =
all of the=20
code that I have above s_h_h.&nbsp;However, zope will not let me do this =
because=20
I end up with a &lt;dtml-if&gt; that&nbsp;is missing&nbsp;its closing =
tag, and=20
one that does not have an opening tag. I realise that I there are =
products=20
already designed with the sort of functionality I am after built in, but =
I will=20
not have much influence on the products that will be available on the =
server=20
that this site will end up on... which is why I'm doing it in this=20
way.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any input is much =
appreciated.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>cheers</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>tim</FONT></DIV></BODY></HTML>

------=_NextPart_000_0009_01C07071.533E96C0--