Hi all, i'm a new user of Zope; i'm studing it since two weeks and i think it's very interesting, 'cause has the same power of j2ee application server but it is much more easy to use! While i was developing my first Zope application i fell into this trouble: i would like to write a script that create a folder, put some file in it, and set some properties. The code i've writed imports date object from datetime package: this makes it doesn't work like a script (python), so i adapt code as an external method; but when i run the method Zope says that he can't find symbol 'container'... (mumble) Well, 2 are the questions: First, what i've to do to get service variable like like container, context, request, etc.. ? Which are differences between script and external method coding? i remember that the zope book indicates only imports. Ok, thank you for reading.. Valerio --------------------------------------------------------------------- Principiante? Fedora a mani basse. Esperto? Slackware. Talebano? Debian. Asceta misantropo? Linux from scratch --------------------------------------------------------------------- Unless unavoidable, no Word, Excel or PowerPoint attachments, please. See http://www.fsf.org/philosophy/no-word-attachments.html --------------------------------------------------------------------- ___________________________________ Nuovo Yahoo! Messenger: E' molto più divertente: Audibles, Avatar, Webcam, Giochi, Rubrica Scaricalo ora! http://it.messenger.yahoo.it
On Mon, Apr 04, 2005 at 12:49:30AM +0200, debugworld-linux@yahoo.it wrote:
The code i've writed imports date object from datetime package: this makes it doesn't work like a script (python), so i adapt code as an external method;
Maybe you could use Zope's own DateTime, which can be used in Scripts?
Well, 2 are the questions: First, what i've to do to get service variable like like container, context, request, etc.. ? Which are differences between script and external method coding? i remember that the zope book indicates only imports.
It's maybe not obvious, but implicit in the book is that the bindings described for Scripts (container, context, etc.) apply only to Scripts, and not for External Methods. With External Methods, if the first argument to the function is named "self", you can treat "self" as being equivalent to a python script's "context". The request can be acquired as self.REQUEST. The container of the external method... don't know. I never yet had a case for an external method where I cared about the difference between context and container. -- Paul Winkler http://www.slinkp.com
debugworld-linux@yahoo.it wrote:
Hi all, i'm a new user of Zope; i'm studing it since two weeks and i think it's very interesting, 'cause has the same power of j2ee application server but it is much more easy to use! While i was developing my first Zope application i fell into this trouble: i would like to write a script that create a folder, put some file in it, and set some properties. The code i've writed imports date object from datetime package: this makes it doesn't work like a script (python), so i adapt code as an external method; but when i run the method Zope says that he can't find symbol 'container'... (mumble)
Well, 2 are the questions: First, what i've to do to get service variable like like container, context, request, etc.. ? Which are differences between script and external method coding? i remember that the zope book indicates only imports.
Python scripts (the TTW kind) have security restrictions and have special procedures for setting the name and the parameters of a method. (Via the TTW forms: notice that you don't write def methodname() et al.) There are also some special names bound, like context and so forth. External methods are regular Python methods in a Python module which are made available to be used live in Zope. Just as in any Python method, you can get to the context in which it was called through the 'self' parameter, which you will define as the first param. This is the same as 'context' in a Python script. So you can say:: def getThisId(self): return self.getId() You can get the request like 'self.REQUEST'. The container can be found with self.aq_inner.aq_parent or something like that. Alternately, you can allow modules in Python scripts. See zope/lib/python/Products/PythonScripts/README or http://svn.zope.org/Zope/trunk/lib/python/Products/PythonScripts/README.txt?... --jcc
Congratulations: You immediately ran into a limitation of Python Scripts, and then equally quickly into one of external methods. That's good, because that means you don't get stuck into the wrong way of programming. :-) The "right" way of doing Zope development is with filesystem python products. Not Python Scripts, not External Methods, not ZClasses and not DTML. Each of these may have their place, the best generic way is file system products. I don't know what is the best starting point nowadays, but I think doing the Boring Product tutorial still seems popular: http://www.zope.org/Members/gtk/Boring/HowTo-Boring For Zope development there is today basicaly two and a half different paths to go: One: Zope2 (which is what you started with now). This gives you access to loads of products and a huge community to support you. This is the right way to go if you are interested in using Zope for creating a web site. Primarily you have a whole bunch of different content management systems to select from (CPS, Plone and several more) to get you started. There are also blog software and wikis and stuff that can be used with these. Two: Zope3. If you are more interested in developing the system, and you want a good development framework as your reference to j2ee indicates, then Zope 3 may be the path for you. It doesn't have that much of all this modules like Zope2 does, but the development framework is SO much better. I sincerely doubt there is anything even remotely this cool anywhere else in the webworld. The drawbacks of Zope 3 is that you'll have to develop more yourself, and it is a bit harder to get started with. Two and a half: Five/Zope2.8. This is a way to use the Zope3 framework under Zope2. It's mostly of interest for people who have legacy products under Zope2. On Apr 4, 2005 12:49 AM, debugworld-linux@yahoo.it <debugworld-linux@yahoo.it> wrote:
Hi all, i'm a new user of Zope; i'm studing it since two weeks and i think it's very interesting, 'cause has the same power of j2ee application server but it is much more easy to use! While i was developing my first Zope application i fell into this trouble: i would like to write a script that create a folder, put some file in it, and set some properties. The code i've writed imports date object from datetime package: this makes it doesn't work like a script (python), so i adapt code as an external method; but when i run the method Zope says that he can't find symbol 'container'... (mumble)
Well, 2 are the questions: First, what i've to do to get service variable like like container, context, request, etc.. ? Which are differences between script and external method coding? i remember that the zope book indicates only imports.
Ok, thank you for reading..
Valerio
-- Lennart Regebro, Nuxeo http://www.nuxeo.com/ CPS Content Management http://www.cps-project.org/
debugworld-linux@yahoo.it wrote at 2005-4-4 00:49 +0200:
... The code i've writed imports date object from datetime package: this makes it doesn't work like a script (python), so i adapt code as an external method; but when i run the method Zope says that he can't find symbol 'container'... (mumble)
You may use my "TrustedExecutables" product. It gives you PythonScripts without security restrictions (and you can forget about ExternalMethods). <http://www.dieter.handshake.de/pyprojects/zope> -- Dieter
participants (5)
-
debugworld-linux@yahoo.it -
Dieter Maurer -
J Cameron Cooper -
Lennart Regebro -
Paul Winkler