[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Zope] Zope Questions


On Mon, May 06, 2002 at 09:46:52PM -0400, George M. Ellenburg wrote:

| Here's what I'm trying to do:
|
| I'm trying to create a "tool-tip" (which is actually contained in a
| frame) and would like to pass a parameter to the DTML document which
| contains the HTML, etc. for the tool-tip.  Something like:
|       <a href="show_tip?a=b&amp;c=d">
| Q: Is there a magical Zope variable that contains the arguments
| passed on a GET URI (as in PHP?)

Take a look at the REQUEST object.  It will contain all the form
parameters and other information.  It is always (and only) available
when an object is "called from the web".

| Q: Must any variable be declared first?

Variables are not declared[1] in python; but accessing a non-existant
variable is an error.  I'm not sure with dtml, but is probably the
same way.


[1] :  C, C++ and Java require variable declarations.  They are
       separate statements from assignment.

|  - "case" statement
|       Q: Does there exist the equivalent of a shell "case" statement in Zope?
|       (This is in line with my previous questions).

Python does not have a case statement.  You can use an if-else ladder
instead, or use a dictionary with function objects as the values.

The dictionary technique is often done like this :


def handler1() :
    print "block 1"
def handler2() :
    print "block 2"
def handler3() :
    print "block 3"

switch = { 'a' : handler1 , 'b' : handler2 , 'c' : handler3 }

choice = raw_input( "Choose a, b, or c " )
if not switch.has_key( choice ) :
    print "invalid choice"
else :
    # this is the switch/case statement here
    switch[choice]()


I don't know if that fits in to your framework at all or not.  I'm
still quite inexperienced at web app design and development, though
I've done a fair amount of python and java programming.

HTH,
-D

-- 

I tell you the truth, everyone who sins is a slave to sin.  Now a slave
has no permanent place in the family, but a son belongs to it forever.
So if the Son sets you free, you will be free indeed.
        John 8:34-36
 
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg

Attachment: pgpGSwTlqTcsX.pgp
Description: PGP signature



This mailing list archive is a service of Copilotco.