[Zope] SQL Method, dtml-with and namespace weirdness
Mayers, Philip J
p.mayers@ic.ac.uk
Wed, 10 Jan 2001 14:23:44 -0000
Ok, using Postgresql 7.0.2-2, PoPo 2.0.1, ZPoPyDA 1.1-pre2, Zope 2.2.5,
here's a reproducible scenario:
Create the following tables in your database:
create table bugtest1 (
name text,
domain text,
);
create table bugtest2 (
name text,
domain text,
refer text,
foreign key(refer) references bugtest1(name)
);
insert into bugtest1 values ('a','aa');
insert into bugtest1 values ('b','bb');
insert into bugtest1 values ('c','cc');
insert into bugtest2 values ('w','ww','a');
insert into bugtest2 values ('x','xx','a');
insert into bugtest2 values ('y','yy','a');
insert into bugtest2 values ('z','zz','a');
insert into bugtest2 values ('g','gg','b');
insert into bugtest2 values ('h','hh','b');
insert into bugtest2 values ('i','hh','b');
Create the following folder structure:
/root
dbconn (ZPoPyDA connection to whatever database you just put the tables
in)
index_html
get_host (Z SQL method)
get_alias (Z SQL method)
/alias
show
/host
show
/root/get_host
select * from bugtest1
/root/get_alias
select * from bugtest2
<dtml-sqlgroup where>
<dtml-sqltest name column=refer type=string>
</dtml-sqlgroup>
/root/alias/show
<TR><TD></TD><TD>&dtml-name;</TD><TD>&dtml-domain;</TD></TR>
/root/host/host
<TR><TD>&dtml-name;</TD><TD>&dtml-domain;</TD></TR>
/root/index_html:
1: <dtml-var standard_html_header>
2: <TABLE>
3: <dtml-in get_host>
4: <dtml-with host><dtml-var show></dtml-with>
5: <dtml-in "get_alias(name=name)">
6: <dtml-let name2=name
7: domain2=domain>
8: <dtml-with alias>
9: <TR><TD>POINT
A</TD><TD>&dtml-name;</TD><TD>&dtml-domain;</TD></TR>
10: <TR><TD>POINT
B</TD><TD>&dtml-name2;</TD><TD>&dtml-domain2;</TD></TR>
11: <dtml-var show>
12: </dtml-with>
13: <TR><TD>POINT C</TD><TD>&dtml-name;</TD><TD>&dtml-domain;</TD></TR>
14: <TR><TD>POINT
D</TD><TD>&dtml-name2;</TD><TD>&dtml-domain2;</TD></TR>
15: </dtml-let>
16: </dtml-in>
17: </dtml-in>
18: </TABLE>
19: <dtml-var standard_html_footer>
The output of all that is (a bit hard to read):
a aa
POINT A a aa
POINT B w ww
a aa
POINT C w ww
POINT D w ww
POINT A a aa
POINT B x xx
a aa
POINT C x xx
POINT D x xx
POINT A a aa
POINT B y yy
a aa
POINT C y yy
POINT D y yy
POINT A a aa
POINT B z zz
a aa
POINT C z zz
POINT D z zz
<snipped for clarity>
So: at point A, the "name" and "domain" variables have been overwritten with
the "name" and "domain" variables as they were on line 6/7, *BUT* name2 and
domain2 haven't been overwritten (point B). BUT, outside the dtml-with tab
(point C) "name" and "domain" are at their correct values.
So - given that the dtml-with tag "must" work, I'm clearly not understanding
*how* it works.
Regards,
Phil
+----------------------------------+
| Phil Mayers, Network Support |
| Centre for Computing Services |
| Imperial College |
+----------------------------------+