[Zope] More failed attempts with python

Bill Hewitt wphewitt at comcast.net
Sun Aug 17 01:16:45 EDT 2003


Hello again folks...
Below is what I have written in attempting to dynamically
construct a variable name, then retrieve the value of the 
variable from the namespace in python.

If anyone can tell me how, I'd appreciate it...

WPH
-----------------------------------------------------------

# Example code:

# Import a standard function, and get the HTML request and response
objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE =  request.RESPONSE

# Here I am trying to
# dynamically generate a property name (b) from a parameter called type
and a string "color"
newstring="%scolor" % (type)
 
# Next I want to 
# retrieve the *value* for preferredcolor by evaluating the string I
created in the variable newstring
# I cant seem to get this to work......
preferredcolor=container.newstring

# finally I print....
print type+"      {"
print "             background-color:"+preferredcolor+";"
print "             background-image: url(\""
print "             background-repeat: "
print "             font-family: "
print "             color: "
print "             font-size: "
print "             margin-top: "
print "             margin-bottom: "
print "             margin-left: "
print "             margin-right: "
print "           }"
return printed
-------------------------------------------------------------




More information about the Zope mailing list