Hi, I have 2 questions: I'm trying to replicate the following php code in zope: $code = $HTTP_POST_VARS["CODE"]; $codemd5 = md5($code); I believe that in straight python, this would be: hcode = sha.new(code).hexdigest() (because as far as I know, there's no md5 equivalent of "hexdigest"). But when I run this in a python script, which recieves such a value from a dtml method with a form in it, it complains that it's not allowed to run "new". I'm sorry if this is a well known security restriction, and the page of the zope book or of some manual to get around it would be enough for me thanks! Second problem is a lot easier: I've looked at the relational database chapter of the zope book, but have not found exactly how to do a call to a zsql method from within a python script. Is there somewhere where I can get examples of the dtml/python script code behind a database backed website? The code in particular wouldn't be to display something, but for operations such as inserting, deleting, cacheing queries, storing variables, etc. Thanks so much! Ale -- Alejandro Fernandez Electronic Group Interactive --+34-65-232-8086--
just call it like a normal fiunction: path = container.<path to sql method> # path to sql method might need aq_parent (look up aquisition in zope book) path.sqlmethod(arg1=val1,arg2=val2...) then look up this to see how to use it... http://www.zope.org/Members/spinwing/ZSQL_Results http://www.zope.org/Members/jpenny/DTML_in_zsql_methods hth AM
Second problem is a lot easier: I've looked at the relational database chapter of the zope book, but have not found exactly how to do a call to a zsql method from within a python script. Is there somewhere where I can get examples of the dtml/python script code behind a database backed website? The code in particular wouldn't be to display something, but for operations such as inserting, deleting, cacheing queries, storing variables, etc.
Thanks so much!
Ale
-- ================================================================== Aseem Mohanty Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231 ================================================================== "I saw `cout' being shifted "Hello world" times to the left and stopped right there!!" -- Steve Gonedes ==================================================================
Alejandro Fernandez writes:
I have 2 questions:
I'm trying to replicate the following php code in zope:
$code = $HTTP_POST_VARS["CODE"]; $codemd5 = md5($code);
I believe that in straight python, this would be:
hcode = sha.new(code).hexdigest()
(because as far as I know, there's no md5 equivalent of "hexdigest"). There is also an "md5" module in the standard Python library.
But when I run this in a python script, which recieves such a value from a dtml method with a form in it, it complains that it's not allowed to run "new". I'm sorry if this is a well known security restriction, and the page of the zope book or of some manual to get around it would be enough for me thanks! Please read the "README" tab in "Control_Panel -> Product Management -> PythonScripts.
Second problem is a lot easier: I've looked at the relational database chapter of the zope book, but have not found exactly how to do a call to a zsql method from within a python script. Is there somewhere where I can get examples of the dtml/python script code behind a database backed website? The code in particular wouldn't be to display something, but for operations such as inserting, deleting, cacheing queries, storing variables, etc. It's almost the same for DTML and PythonScripts. The only differences are the magic DTML name lookup and automatic DTML rendering.
ZSQL Methods are functions that either take there arguments (automatically) from the request object or (exclusively!) get them passed as keyword (!) parameters. Thus, in a Python Script, you have something like mySQLMethod= context.mySQLMethod # explicit name lookup # of "mySQLMethod", done # automatically in DTML mySQLMethod() # call, arguments in REQUEST mySQLMethod(arg1=val1, arg2=val2, ...) # call, arguments passed as # keyword parameters When the ZSQL Method contains a query (rather than only "insert", "update" and friends), then the result behaves as a sequence of records. Each record behaves as an object with the result columns as attributes. That's all about calling Z SQL Methods from Python Scripts. Dieter
participants (3)
-
Alejandro Fernandez -
Aseem Mohanty -
Dieter Maurer