Re: [Zope] How to import a basic class in Script (Python)
(Wed, Jul 18, 2007 at 12:26:06PM +0300) Tudor Gabriel wrote/schrieb/egrapse: To learn zope I am trying to write a basic library page. I wrote a book_py class ... and from search_books_py try to return a list of books to show in a ZPT. now let's suppose all the files (all the py and zpt files) are in the same directory:Library Please save yourself some time and read http://wiki.zope.org/zope2/ZopeStarter for pointers to valuable information as you start out. If there isn't, and i have to make a custom Product for my Book class... please give me a basic example of how can i make that. http://papakiteliatziar.gr/BetaBoring also the stuff linked from the ZopeStarter page. Hope this helps! Regards, Sascha ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to import a basic class in Script (Python)
--On 18. Juli 2007 12:26:06 +0300 Tudor Gabriel [EMAIL PROTECTED] wrote: To learn zope I am trying to write a basic library page. I wrote a book_py class ... and from search_books_py try to return a list of books to show in a ZPT. now let's suppose all the files (all the py and zpt files) are in the same directory:Library in search_books_py i tried importing the book class in this ways: from book_py import * from Library.book_py import * from here.book_py import * from container.book_py import * Move your code into a Product (see Zope Developers Guide) or use an external method. PythonScripts are not equal to an unrestricted Python environment. -aj pgpCZGLho3usV.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to import a basic class in Script (Python)
On Wed, Jul 18, 2007 at 12:26:06PM +0300, Tudor Gabriel wrote: I've searched Zope Help and it mentions in there that i have to make a new dir in Products called whatever and add to __init__.py the allowimport or something like that, for my package. i tried that too ... same error (haven't restarted zope after... should i?) . Yes. Changes to filesystem code require a restart. -- Paul Winkler http://www.slinkp.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to import a basic class in Script (Python)
Tudor Gabriel wrote at 2007-7-18 12:26 +0300: ... now let's suppose all the files (all the py and zpt files) are in the same directory:Library in search_books_py i tried importing the book class in this ways: from book_py import * from Library.book_py import * from here.book_py import * from container.book_py import * The import * is not very good style: You do not see where names come from -- this may drastically affect readability of your code A later import * may accidentally override names imported in a previous import. I have seen cases where considerable analysis time was caused by such constructs. If at all, you should have at most a single import * -- the first import. Your names look funny. Why do they all end in _py? Your Zope folders cannot be reached by the Python interpreter. You cannot import from objects places in Zope's Web hiearachy. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )