On Tue, 8 Dec 1998, Michel Pelletier wrote:
It's quite easy. [60 lines of Python expunged]
Thank you for the help, but...this must be some new definition of the word "easy" with which I was previously unfamiliar. :-)
Ever try to write a Windows program in ANSI C? :) I think the two dozen or so lines of overhead is trivialized by the abilities it gives you. Like I said in my previous post, these things become clearer the more you look at them.
Further questions spring to mind: a) where do you stick this file - lib/python/Products/Cal/Cal.py, along with __init__.py etc a la other directories under lib/python/Products ?
Make a new subdirectory under Products with the name of your product. For exmaple, I keep Trove in lib/python/Products/Trove/ where is where you'll find all the relevent files.
b) how do you add it to Zope? Under Control Panel I see Products, and from there I can add a product, for whatever that's worth. Now I see a menu which allows you to add "Principia Factory", ... "External Method", "Mail Host". At this point I'm completely lost... (if it's an External Method then where is Zope looking for the Python module file? If it isn't an external method, what is it? What's a Principia Factory?)
After you add the files in the directory of your choice, simple restarting the process loads the product *if you have a well formed package* see below.
c) once you've done that, how do you create an object instance? Does your new class just get added to the list of things you can "Add"?
The __init__.py file in your package is loaded by Zope when the process starts. __init__.py does a few things: imports your product. This is where you catch syntax errors, the Zope process will spit up a traceback and exit. Zope cannot run if a product has a syntax error (digifolk, perhaps this should be wrapped in a try: except block?) hooks into the Zope 'Add' menu a function that displays the 'add' screen where you can type in at least an id, the title might be required too I've never ommited it to try. This function is usualy just a DTML method that spits a a form, whose 'action' is to... ...call another function that __init__ hooks into Zope that does the actual adding of your Product object To where ever you add it. This is all detailed in the Sample Product __init__.py file which I highly suggest anyone writing a Product should d/l and study. It's only about a page long and took me just a few minutes to grok.
d) how do you test the product you're working on? e.g. change its definition and have that reflected in Zope
Restart the process. :| Jim mentioned complications in geting this to work in-band, it would be nice if objects could reload themselves or be manualy reloaded from say, the Control Panel; all in good time.
e) are the naming conventions documented anywhere?
Not really, I'm kinda coming up with my own, in most cased I try to follow the conventions of the Zope source. Functions and Documents that deal with the management interface are usualy prefixed with 'manage_', functions and form that deal with your specific user interface are your discretion.
f) how are products distributed? A tar file of lib/python/Products/yourproductname?
Yep.
Is there any documentation on all of this or are we just supposed to wade through all the source code and guess? Maybe I'm just missing the wonderful "Everything You Ever Wanted To Know About Creating Products" tutorial...if not, is something of this sort in the works?
Why yes, I'll have something shortly for you. 'Till then get out the wading boots. :) Michel
-- James Strickland Perforce Software