Re: [Zope] REPOST: dtml-with doesn't work

2001-01-14 Thread Shai Berger


Philip has already made it clear that this was not his problem, but
still,

Dieter Maurer wrote:

 Just a remark:
 
   SQL methods do *NOT* look at the DTML namespace *AT ALL*,
   just at REQUEST (or the expliciitly passed keyword arguments).
 
   Thus, "dtml-with", "dtml-let" and friends are all ineffective
   with respect to ZSQL methods.
 

My experience is somewhat different: ZSQL methods in general *DO*
look at the namespace just like normal DTML methods, with two 
exceptions:

1) The major one, is that Dieter's remark does describe (almost) 
correctly the behavior of dtml-sqlvar and dtml-sqltest. These two 
tags only look at a very limited local namespace, initialized with the
REQUEST and passed arguments; but even this namespace may be modified,
*INSIDE* the ZSQL method, with dtml-in and dtml-let. However, 
other tags behave quite normally -- which means that a lot of the
problems can be bypassed by thoughtful use of dtml-var, especially
using the sql_quote modifier (BTW, it is by virtue of this that you
can call other methods -- even other ZSQL methods -- from within a
ZSQL method).

2) Changing REQUEST does *not* update the local namespace, that is,
within a ZSQL method,

dtml-call "REQUEST.set('some_var', 17)"
dtml-var some_var

doesn't work; but

dtml-var "REQUEST['some_var']"

Does.

Hope this helps,

Shai.

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] REPOST: dtml-with doesn't work

2001-01-14 Thread Dieter Maurer

I checked the sources

Shai Berger writes:
  My experience is somewhat different: ZSQL methods in general *DO*
  look at the namespace just like normal DTML methods, with two 
  exceptions:
ZSQL methods do *NOT* look at the DTML(!) namespace.

They do look at REQUEST or (exclusive) explicitly provided keyword arguments
*AND* they can acquire names from the ZSQL methods and its
acquisition context.

  ...
  dtml-sqlvar and dtml-sqltest
  only look at a very limited local namespace, initialized with the
  REQUEST and passed arguments; but even this namespace may be modified,
  *INSIDE* the ZSQL method, with dtml-in and dtml-let.
I see, I should have been more specific.

ZSQL methods do not look at the DTML namespace of the *CALLING*
document template.

They use a document template (to generate the query)
which is evaluated in a (newly creatd) namespace.
Of cause, it looks at this DTML namespace in the usual
way. And all DTML tags are available to extend this namespace.

  However, 
  other tags behave quite normally -- which means that a lot of the
  problems can be bypassed by thoughtful use of dtml-var, especially
  using the sql_quote modifier (BTW, it is by virtue of this that you
  can call other methods -- even other ZSQL methods -- from within a
  ZSQL method).
There is no difference with respect to name lookup
between "dtml-var" and "dtml-sqlvar" or the other "dtml-sql*" tags.
They *ALL* work with the same namespace.

  2) Changing REQUEST does *not* update the local namespace, that is,
  within a ZSQL method,
That is right.
The reason is that "REQUEST" is not part of the newly
generated namespace in which the ZSQL template is evaluated.
"REQUEST" is acquired.

  dtml-call "REQUEST.set('some_var', 17)"
  dtml-var some_var
  
  doesn't work; but
  
  dtml-var "REQUEST['some_var']"
  
  Does.



Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




[Zope] REPOST: dtml-with doesn't work

2001-01-10 Thread Mayers, Philip J

Hopefully that will get someone's attention. I have an SQL method that
returns

(name,domain,otherstuff)

I have a DTML method (/root/host/show) that looks like this:

dtml-comment

'name' and 'domain' are set to the primary hostname
and domain at this point by whatever calls this
DTML method

POINT A
/dtml-comment

dtml-in "HDB_get_ip_aliases(ip=ip)"
  dtml-commentPOINT B/dtml-comment
  dtml-let name2=name
domain2=domain
dtml-with alias
  dtml-commentPOINT C/dtml-comment
  dtml-with "_.namespace(name=name2,domain=domain2)"
dtml-commentPOINT D/dtml-comment
dtml-var show
  /dtml-with
/dtml-with
  /dtml-let
/dtml-in

The folder structure is:

/root
  /alias
show
  /host
show

At the points marked B and D, dtml-var name and dtml-var domain work
fine, but at point B, name and domain have been reset to what they were at
point A. Why? This is totally broken - I'm *this* far from downloading the
servlet engine and giving up completely. Zope appears to be completely
non-intuitive in many respects, and combined with the generally lamentable
documentation, is taking up more of my time than I'm willing to spend on a
theoretically simple task.

Regards,
Phil

+--+
| Phil Mayers, Network Support |
| Centre for Computing Services|
| Imperial College |
+--+  

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] REPOST: dtml-with doesn't work

2001-01-10 Thread Dieter Maurer

Usually, I complain that problem reports are too terse.
But, your's was very big, such that I did not read it
carefully. It is very difficult to get it right for everyone.

Just a remark:

  SQL methods do *NOT* look at the DTML namespace *AT ALL*,
  just at REQUEST (or the expliciitly passed keyword arguments).

  Thus, "dtml-with", "dtml-let" and friends are all ineffective
  with respect to ZSQL methods.

May be, that explains your problem.
May be not, as I am not sure, that you need the values indeed
inside a ZSQL method.

I can assure you: "dtml-with" does work.


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )