Re: [Zope] sql query results - DTML method problem

2000-12-18 Thread Dieter Maurer

"Manuel Amador (Rudd-O) writes:
   #8 dtml-in expr=\"findClassTitle(code=52.139)\"
  
  RING: dont do that, dtml wont work in python namespace
  instead, remember that in python namespace all vars present in dtml namespace 
  are inherited.
I do not see a reason, why not to use this
(except, that " should not be escaped, of cause).

  do this:
   dtml-in expr=\"findClassTitle(code=_.(\'class_code\'))\"
  the __.() construct is required since underscore arent allowed in python 
  variable names. if the var was called classcode, you could do
"_" are allowed in Python names. They are treated in the same
way as a letter.

DTML restricts the use of "_":

  A name must not *START* with an "_" (unless it is the special
  name "_").
  Inside name, you can use "_" freely.

   dtml-in expr=\"findClassTitle(code=classcode)\"
  dats it.
That said, you can also use:
dtml-in expr="findClassTitle(code=class_code)"

   dtml-in expr=\"findClassTitle(code=dtml-var class_code)\" *** syntax
   error
I agree with Manuel:
  you cannot nest DTML.
And it is this nesting, that triggered his "RING: do not do that!"

Use:

 dtml-in expr="findClassTitle(code=class_code)"

I.e. you can simply use the name of the variable.

Manuel is right, too, that DTML allows much more characters
in names than Python does. If you have a name with a character
forbidden in Python names, such as e.g. a "-", then you
can use "_[name]" or "_.getitem(name)" (as Manuel said).
It is only, that "_" (unlike "-") is allowed in Python names.



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 )




Re: [Zope] sql query results - DTML method problem

2000-12-16 Thread Pavel V. Piankov

#8 dtml-in expr="findClassTitle(code=52.139)"

you might wanna try 
either dtml-in expr="findClassTitle(code=_['class_code'])"
or dtml-in expr="findClassTitle(code=_.getitem('class_code'))"

dtml-in expr="findClassTitle(code=dtml-var class_code)" *** syntax
error

regards.
-- 
pashah


___
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] sql query results - DTML method problem

2000-12-16 Thread Manuel Amador (Rudd-O) Gerente de desarrollo Alpha

Quoting Lee Reilly CS1997 [EMAIL PROTECTED]:

 Hi,
 
 I have a TINY problem, which I think there is a simple solution too...
 but for the life of me, I can\'t find it! I\'d be grateful if someone
 could point me in the right direction.
 
 I have a database setup containing details of classes, students 
 lecturers. The user is prompted to enter a class code (a unique key)
 which is used to query the database and return the class title. Simple.
 
 A DTML method prompts me for the class code
 -- I enter 52.139 and it posts to a method \'enterClassCodeAction\',
 below.
 
 #1dtml-var standard_html_header
 #2h2Confirm/h2
 #3pYou entered idtml-var class_code/i/p
 #4
 #5p
 #6Our records show that dtml-var class_code is called
 #7
 #8dtml-in expr=\"findClassTitle(code=52.139)\"

RING: dont do that, dtml wont work in python namespace
instead, remember that in python namespace all vars present in dtml namespace 
are inherited.

do this:
dtml-in expr=\"findClassTitle(code=_.(\'class_code\'))\"
the __.() construct is required since underscore arent allowed in python 
variable names. if the var was called classcode, you could do
dtml-in expr=\"findClassTitle(code=classcode)\"
dats it.

 #9dtml-var title
 #10   /dtml-in
 #11   
 #12
 #13   /p
 #14   dtml-var standard_html_footer
 
 ^ The method works fine when the class code is manually inserted (line
 #8) but when I try to pass the variable from the previou post, held in
 dtml-var class_code I have probs.
 
 dtml-in expr=\"findClassTitle(code=dtml-var class_code)\" *** syntax
 error
 
 findClassTitle is a ZSQL method for returning the class title given a
 class code:
   
   select title from classes 
   where dtml-sqltest code op=eq type=float
 
 Hmm... anyone see the problem?
 
 Thanks a lot :)
 
 - Best regards,
 
 Lee
 
 ___
 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 )
 

--
   Universidad Federico Santa Maria - Campus Guayaquil
 Enviado por:  www.usm.edu.ec/computacion

___
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 )