At 03:29 PM 1/21/99 PST, Bruce Perens wrote:
From: katz@wam.umd.edu (Roey Katz)
I don't understand if example.cgi should be under the Principia object heirarchy or under the actual filesystem.
There's an echo in here - I asked this morning. In the filesystem. And then connect up external methods.
Wouldn't I have to 'import Globals; import Acquisition; ...' within the example's source code in order to access the Zope ORB?
I think they are already in the name space when your module is imported into it. You are going under the assumption that your module is the top level entity, it is not.
They tell me they don't want to put python code in the object database. Just why should be put on the zope web site.
Where to put your source files all depends on what you are trying to do. Let's take some example scenarios. Questions: 1. How do I publish my own Python modules with ZPublisher, but *without* the Zope management framework? 2. How do I publish my own Python methods and classes within the Zope Framework? Answers: (BTW, these two scenarios are detailed on http://www.zope.org/Documentation/Reference) 1. You can publish your own Python modules by setting up your web server to use ZPublisher to publish them. This can be done most easily with ZopeHTTPServer like so: ZopeHTTPServer.py myModule In this case, you can place your Python files anywhere you want. Just tell ZopeHTTPServer where to find them (ZopeHTTPServer.py /path/to/my/Module) or else cd to the directory where your module is located and run ZopeHTTPServer. Find out more about ZopeHTTPServer in its long doc string, or by running it without any arguments. There are other ways to do it, for example, using CGI or PCGI, etc. If you are serious about publishing your own modules you will probably be interesting in: * The ZPublisher Component release which is geared to people who want to publish their own modules. It contains the ZPublisher and other things you will need. http://www.zope.org/Download/ZPublisher * Tutorials on how to publish your own Python modules. These tutorials assume that your are not using the Zope management framework. http://www.zope.org/Documentation/Reference/ObjectPublishingIntro http://www.zope.org/Documentation/Reference/Trinkets 2. You can publish your own Python code with the Zope framework by fitting it to the framework. Your choices are: * External Methods * Product API These two methods of extending the Zope framework are detailed on the Zope site: External Methods Documentation http://www.zope.org/Documentation/Reference/ExternalMethods Product API Documentation http://www.zope.org/Documentation/Reference/API http://www.zope.org/Documentation/Reference/Tutorial In both cases you have some choice about where to locate your source files. See the documentation for more details but here's my quick rule of thumb: * Put general modules and packages in the Shared Package. Things in the Shared package are available to all of Zope. For example, I might want to put some general purpose xml module in /usr/local/Zope/lib/python/Shared/AmosL/xml-rpc.py. * If you are making an External Method, put your module in the Extensions directory. For example, you might want to define an External Method in /usr/local/Zope/Extensions/amosMethods.py * If you are making a Product your Product will be a Python package located in the lib/python/Products directory. For example you might locate your SuperDocument product in the /usr/local/Zope/lib/python/Product/SuperDocument directory. Make sense? This is how things stand right now. However, there is lively debate about other possibilities for extending Zope with your own Python Code. Right now there is *no* support for locating Python code in the object database. This has been debated before on the list (check egroups). The conservative forces believe it to be security issue. Others say it would be convenient to allow code in the object database and through-the-web editing of code. No one to my knowledge has put together a Product to allow such a beast. If anyone decides to go down this road, they should probably look into controlled execution or something... Right now there is only experimental support for publishing your own modules without the Zope management framework with the management framework. Yes, this is a bit of an oxymoron ;-) That experiment is called ExternalObjects, and is available on the Contrib page. http://www.zope.org/Download/Contrib It comes with some instructions in the doc strings. I hope this clears things up a little. -Amos