Is there such a method as PythonScript()
I there a method called PythonScript() that works like DTMLFile()? IF so, how does one use it? How about ZSQLMethod()? I would like to include ZSQLMethods and PythonScripts as methods in my python Class..... TIA WPH
Bill Hewitt wrote:
I there a method called PythonScript() that works like DTMLFile()?
IF so, how does one use it?
How about ZSQLMethod()?
I would like to include ZSQLMethods and PythonScripts as methods in my python Class.....
PythonScripts are generally not necessary to use when you write a Python Product, because you can write Python methods directly on your class. The way Python methods work is a bit diffrent from Python Scripts, for one thing you don't have context variables (context, container, etc.). But on the other hand you arn't required to use restricted code, which means the full power of Zope (read more about writing Python Products in the Zope book :-) ZSQLMethods can't be used in Python Products, but... I've written a Product that let's you do just that. I've uploaded it at:: http://zope.org/Members/johanc/DCDSQL/DCDSQL-0-0-1-beta.tgz The documentation is not that great but there is an example how to use it in the readme.txt. Basically a connection object is created on module level and ZSQL Methods are created in the class code (no external file). The Methods can take a "brain" class as an argument, the brain class is used to wrap the object in the result that the methods returns, allowing you to add methods and attributes to the result objects. (Well it's not a new feature but it's really useful in the context of Python Products.) Any questions, send them to zope@zope.org. I really would like others to review and improve the code :-) Regards, Johan -- Johan Carlsson Tel: + 46 8 31 24 94 Colliberty Mob: + 46 70 558 25 24 Torsgatan 72 Email: johanc@easypublisher.com SE-113 37 STOCKHOLM
Johan Carlsson wrote at 2004-9-11 09:56 +0200:
... ZSQLMethods can't be used in Python Products,
I use them ;-) from Products.ZSQLMethods.SQL import SQL class MyClass: myZSQLMethod = SQL('myZSQLMethod', myTitle, myConnectionId, myArguments, myTemplate) -- Dieter
Dieter Maurer wrote:
Johan Carlsson wrote at 2004-9-11 09:56 +0200:
... ZSQLMethods can't be used in Python Products,
I use them ;-)
Your quite right, my bad :-) Connections couldn't be defined from Python Products (or?). That's what my product was supposted to solve. Anyway, I got it releasted on Zope.org :-) Cheers, Johan -- Johan Carlsson Tel: + 46 8 31 24 94 Colliberty Mob: + 46 70 558 25 24 Torsgatan 72 Email: johanc@easypublisher.com SE-113 37 STOCKHOLM
Johan Carlsson wrote at 2004-9-12 20:33 +0200:
... Connections couldn't be defined from Python Products (or?).
The same trick would work for DA (Database Adapter) instances (which are the representations of database connections) as well. However, it would be a good idea only for instances that are as rarely instantiated as normal DA instances are, because each instance could have several real database connections, each of them using scares resources in the client and on the server. -- Dieter
Bill Hewitt wrote at 2004-9-10 19:48 -0700:
I there a method called PythonScript() that works like DTMLFile()?
The CMF comes with "FSPythonScript" (together with lots of other "FS*" objects). This is a PythonScript living on the file system. There is also a "FSZSQLMethod". -- Dieter
participants (3)
-
Bill Hewitt -
Dieter Maurer -
Johan Carlsson