using VirtualHostMonster in a ZPublisher python module?
Hi all, Can I somehow get a VirtualHostMonster inserted into a ZPublisher-based python module published through changes to z2.py? Am having problems with "<base href…>" with apache proxying for this python module. Have scoured past discussions but haven't found an answer to this. I have two areas declared to zhttp_handler(): 1. /z -- standard managed zope area 2. /app -- my python module which is a ZPublisher-based app that doesn't have /manage or the other "managed zope" stuff For #2 I modified z2.py per Amos' write up: "How to Publish Your Own Python Modules" (http://www.zope.org/Members/Amos/ZPublisher) ... (thanks, Amos!). But I can't get the "base href" set properly for this. Changes to z2.py shown below. I really appreciate any light people can shed on this. Am willing to pay for help on this. Thanks! Royce p.s. alternately I could import the python module as an ExternalMethod but have had serious import problems when doing so. ~~~~~~~~~~~ In z2.py I have: zh = zhttp_handler(MODULE, 'z', HTTP_ENV) hs.install_handler(zh) # royce 8/22/04 sys.path.insert(0,'/app') # add MyModule to the Python path # create a handler my_handler = zhttp_handler('webapp/sessionMgr', 'ex/sessionMgr', HTTP_ENV) hs.install_handler(my_handler) # install it in the http server
Hi, Am So, den 19.09.2004 schrieb Royce um 19:27:
Hi all,
Can I somehow get a VirtualHostMonster inserted into a ZPublisher-based python module published through changes to z2.py? Am having problems with "<base href…>" with apache proxying for this python module. Have scoured past discussions but haven't found an answer to this.
I have two areas declared to zhttp_handler():
1. /z -- standard managed zope area 2. /app -- my python module which is a ZPublisher-based app that doesn't have /manage or the other "managed zope" stuff
For #2 I modified z2.py per Amos' write up: "How to Publish Your Own Python Modules" (http://www.zope.org/Members/Amos/ZPublisher) ... (thanks, Amos!). But I can't get the "base href" set properly for this.
Changes to z2.py shown below. I really appreciate any light people can shed on this. Am willing to pay for help on this.
Thanks! Royce
p.s. alternately I could import the python module as an ExternalMethod but have had serious import problems when doing so.
What is this module doing? The feature you use is rarely used by anyone. If you need the functionality of VHM there, I guess you have to write your own or hardcode URL references somehow. If you strictly use URLs relative to server root (that is, all starting with /) there is no problem. Regards Tino Wildenhain
On Sun, 19 Sep 2004 20:14:24 +0200, Tino Wildenhain <tino@wildenhain.de> wrote:
Am So, den 19.09.2004 schrieb Royce um 19:27:
Can I somehow get a VirtualHostMonster inserted into a ZPublisher-based python module published through changes to z2.py? Am having problems with "<base href…>" with apache proxying for this python module. Have scoured past discussions but haven't found an answer to this.
I have two areas declared to zhttp_handler():
1. /z -- standard managed zope area 2. /app -- my python module which is a ZPublisher-based app that doesn't have /manage or the other "managed zope" stuff
For #2 I modified z2.py per Amos' write up: "How to Publish Your Own Python Modules" (http://www.zope.org/Members/Amos/ZPublisher) ... (thanks, Amos!). But I can't get the "base href" set properly for this.
Changes to z2.py shown below. I really appreciate any light people can shed on this. Am willing to pay for help on this.
Thanks! Royce
p.s. alternately I could import the python module as an ExternalMethod but have had serious import problems when doing so.
What is this module doing? The feature you use is rarely used by anyone. If you need the functionality of VHM there, I guess you have to write your own or hardcode URL references somehow.
If you strictly use URLs relative to server root (that is, all starting with /) there is no problem.
The module is a full website. It started way back when as a Bobo app and I've never learned of a good way to bring it into managed zope land. It's remained a ZPublisher app. Believe me, I know I'm not mainstream with this. Would like to bring it mainstream but practically speaking have to do it a bit at a time. My URLs do not all start with a / -- some are relative to current location. Are you saying that if I change them all to be absolute paths for the site it will work? Not the greatest practice but I'm looking for practical solutions. Thanks, Royce
Am So, den 19.09.2004 schrieb Royce um 23:55: ...
The module is a full website. It started way back when as a Bobo app and I've never learned of a good way to bring it into managed zope land. It's remained a ZPublisher app. Believe me, I know I'm not mainstream with this. Would like to bring it mainstream but practically speaking have to do it a bit at a time.
My URLs do not all start with a / -- some are relative to current location. Are you saying that if I change them all to be absolute paths for the site it will work? Not the greatest practice but I'm looking for practical solutions.
Either you set the <base> tag yourself or you fix your relative links to starting with /. Both is a goot Idea for a zope app as well. Regards Tino Wildenhain
On Mon, 20 Sep 2004 09:39:02 +0200, Tino Wildenhain <tino@wildenhain.de> wrote:
Am So, den 19.09.2004 schrieb Royce um 23:55: ...
The module is a full website. It started way back when as a Bobo app and I've never learned of a good way to bring it into managed zope land. It's remained a ZPublisher app. Believe me, I know I'm not mainstream with this. Would like to bring it mainstream but practically speaking have to do it a bit at a time.
My URLs do not all start with a / -- some are relative to current location. Are you saying that if I change them all to be absolute paths for the site it will work? Not the greatest practice but I'm looking for practical solutions.
Either you set the <base> tag yourself or you fix your relative links to starting with /. Both is a goot Idea for a zope app as well.
I am setting <base> tag myself in my standard header. However this does not fix REQUEST.URL[0-3] and .BASE[0-3]. Is there a good way to clean them up? Was hoping to hear of a way to insert a VHM into my zpublisher app object tree or something. Could just hack in hardwired cleanup for URL and BASE but that seems ugly. Royce
Em Ter, 2004-09-21 às 12:17, Royce escreveu:
Was hoping to hear of a way to insert a VHM into my zpublisher app object tree or something. Could just hack in hardwired cleanup for URL and BASE but that seems ugly.
The code in VHM is really not that complicated. I recommend you read it so that you understand how to change your application to emulate or integrate it. Basically it hooks itself up into __bobo_traverse__ so that it gets called when the request comes in, before all objects in the path (after the root) are looked up. When called, VHM alters the request information (server and path, and as a consequence BASE* and URL*) which has the consequence of changing what objects are looked up to handle the request (i.e. no need for objects called VirtualHostBase or VirtualHostRoot). This is done thru Request methods that where created exactly for this purpose: .setServerURL() and .setVirtualRoot() Documentation for those can be found in the Zope Online Help and other places. Cheers, Leo -- Leonardo Rochael Almeida <leo@hiper.com.br>
Em Ter, 2004-09-21 às 12:17, Royce escreveu:
Was hoping to hear of a way to insert a VHM into my zpublisher app object tree or something. Could just hack in hardwired cleanup for URL and BASE but that seems ugly.
The code in VHM is really not that complicated. I recommend you read it so that you understand how to change your application to emulate or integrate it.
Thank you, Leonardo! I appreciate your concise summary of it. Hope this'll do it for me. Off I go. Royce
participants (3)
-
Leonardo Rochael Almeida -
Royce -
Tino Wildenhain