I have installed Zope on my Linux Box, and I am struggling with Zope publishing. On the document "A Technical Introduction to Object Publishing" there is the Hello.py example. Could someone tell me how to publish this module with Zope? The documents says "simply place this module on a Web Server with the apropriate Zope support files and it becomes a fully functional application". I beg your pardon but I have no idea how to do this, nor it is explained in the referred document or any other (at least in a way that I can understand -- you can call me stuoid if you like--) how are are those aprppriate files generated/writeen or its format. thanx in advance, Saludos, IvO
On Sun, 29 Aug 1999, IvO wrote:
I beg your pardon but I have no idea how to do this, nor it is explained in the referred document or any other (at least in a way that I can understand -- you can call me stuoid if you like--) how are are those aprppriate files generated/writeen or its format.
IvO - The document that you have read explains how to publish python modules on the web and is not needed to run Zope (which is ... a big python module). Begin by firing Zope (usually running the start script in the Zope directory) and see if you can access the main page. The relevant documents are at: http://www.zope.org/Documentation/Guides Pavlos
Pavlos Christoforou wrote:
On Sun, 29 Aug 1999, IvO wrote:
I beg your pardon but I have no idea how to do this, nor it is explained in the referred document or any other (at least in a way that I can understand -- you can call me stuoid if you like--) how are are those aprppriate files generated/writeen or its format.
IvO -
The document that you have read explains how to publish python modules on the web and is not needed to run Zope (which is ... a big python module). Begin by firing Zope (usually running the start script in the Zope directory) and see if you can access the main page.
Thanks for your reply, in fact Zope works. Then I would like to publish python objects in the WEB either with Zope (preferable) or without, how do I do that?. Let's say I just want to publish the Hello.py example (using PCGI or Zope). Saludos, IvO
On Sun, 29 Aug 1999, IvO wrote:
Then I would like to publish python objects in the WEB either with Zope (preferable) or without, how do I do that?. Let's say I just want to publish the Hello.py example (using PCGI or Zope).
If you have already a large collection of Python objects that you need to publish on the web then my opinion is to use ZPublisher directly and skip Zope. Zope products have to implement at least parts of the Zope management interface which can be complicated initially. Alternatively you can use ZClasses together with a number of external methods and achieve the same results. In any case I have a complete example that uses ZPublisher directly and contains all the neccessary components from DC to publish it. You can download it from: http://starship.python.net/crew/pavlos/Webftp.tar.gz
I am sure either the PUB or the Zopatistas will get me for revealing this, but at least the information will be out there. You can't stop the truth! :) Your question reminded me of the comment I had read in the z2.py module when I was trying to figure this out myself. I had been misled by various comments in that module which claimed only the "Main" and "Zope" modules are valid values for the MODULE variable. A little testing and the method for directly publishing secondary python modules appears... around line # 412 in z2.py (in the latest beta) you will find the following: if HTTP_PORT: hs = zhttp_server( ip=IP_ADDRESS, port=HTTP_PORT, resolver=rs, logger_object=lg) # Handler for a published module. zhttp_handler takes 3 arguments: # The name of the module to publish, and optionally the URI base # which is basically the SCIRPT_NAME, and optionally a dictionary # with CGI environment variables which override default # settings. The URI base setting is useful when you want to # publish more than one module with the same HTTP server. The CGI # environment setting is useful when you want to proxy requests # from another web server to ZServer, and would like the CGI # environment to reflect the CGI environment of the other web # server. zh = zhttp_handler(MODULE, '', HTTP_ENV) hs.install_handler(zh) if you add this: # testing secondary module publisher... zh = zhttp_handler('hellozope', '/hellozope', HTTP_ENV) hs.install_handler(zh) You will get the module "hellozope" published under the universal resource identifier "/hellozope". I think a command-line option that allowed specifying an arbitrary list of modules to publish might be added to z2.py . Any comments? Something like: -modules = "Zope;hellozope;someweirdmodule" -baseModuleURIs = "/;/hellozope/;/weird/" At the very least, this should be entered in the FAQ, as anyone coming from a Python/Bobo background (or reading the documentation which was written for Bobo) will spend quite some time trying to figure it out. Oh, and remember to use the debug flag when you first start out, can save a great deal of headache. Do note, you will have to manually support (for instance) object persistence etc. which is normally handled by Zope. This will be familiar to you if you've used Bobo before. You can get access to the Zope persistence mechanisms by poking around inside the guts of Zope and importing Zope's mechanisms directly into your modules. I wound up creating a large product for lack of such a mechanism. In general, I would suggest this if you're dealing with a production product (or even a demonstration (such as I'm working on)). For learning, I think this level of direct access is very useful for those coming from a programming background. I hope this helps, Mike With the above alteration to z2.py, put this module on your python path as hellozope.py . Access it with the url: http://server:port/hellozope/v/sayHello where you substitute server and port with your Zope HTTP server's values. It should print "Hello world!" in your browser window. 8<_____ hellozope.py ... ___ class Test: ''' An example object (this string required)... ''' def sayHello (self, REQUEST = None): "Says hello to the world (this string required)" return "Hello world!" v = Test()
participants (3)
-
IvO -
Mike Fletcher -
Pavlos Christoforou