I have some pages within zope which are linked to externally (from non-zope pages). I want to have some sort of internal index so that I can move the zope pages around completely within zope (move a page and change its index) without breaking or having to change the external in-pointing links. This mechanism will come into play for nearly every page in my system so I'm looking for the most efficient code to do this. My thinking about possibilities for the index :- methods in a folder properties of a folder properties of a dtml-doc some other sort of data structure For the redirection its obviously more efficient to do it something like dtml-var rather than redirect back to the client but (as my other posts show) I'm often really struggling to get my object references right (only partial understanding - looking forward to better documentation) I'd appreciate some help here too. What's the most efficient way? Andy -- ------------------------------------------------- Andy Heath a.k.heath@open.ac.uk The Open University +44 (0) 114 2885738
Take a look at my Redirector product, which does this very thing -- it lets you create Redirector folders which, when rendered, simply redirect to somewhere else. It uses regexps to let you apply patterns, such as saying that "/Parrot" should redirect to "/PetShop" but than "/Parrot/Fish" should redirect to "/Aquarium". It allows 1:1 redirects as well as many:1 redirects. Dylan Jay has derived an improved version that supports simpler group replacements using replace(). Both versions are on zope.org. Alexander Staubo mailto:alex@mop.no http://www.mop.no/~alex/
-----Original Message----- From: cmsakh@zope.org [mailto:cmsakh@zope.org]On Behalf Of Andy Heath Sent: Monday, March 13, 2000 9:13 AM To: zope@zope.org Subject: [Zope] efficient internal redirect
I have some pages within zope which are linked to externally (from non-zope pages). I want to have some sort of internal index so that I can move the zope pages around completely within zope (move a page and change its index) without breaking or having to change the external in-pointing links.
This mechanism will come into play for nearly every page in my system so I'm looking for the most efficient code to do this.
My thinking about possibilities for the index :-
methods in a folder properties of a folder properties of a dtml-doc some other sort of data structure
For the redirection its obviously more efficient to do it something like dtml-var rather than redirect back to the client but (as my other posts show) I'm often really struggling to get my object references right (only partial understanding - looking forward to better documentation) I'd appreciate some help here too.
What's the most efficient way?
Andy -- ------------------------------------------------- Andy Heath a.k.heath@open.ac.uk The Open University +44 (0) 114 2885738
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Take a look at my Redirector product, which does this very thing -- it
Thankyou for replying Whilst this is I'm sure a useful mechanism redirecting whole folders is overkill for what I need to do. I have many links into a tree and wish to have a very simple format for the external links and an internal mapping mechanism which maps each link to its real URL. My question remains. What's the most run-time-efficient (not development-time-efficient) way of doing it? I think you gave me the quickest development route which is not quite what I was asking. Full question below:
I have some pages within zope which are linked to externally (from non-zope pages). I want to have some sort of internal index so that I can move the zope pages around completely within zope (move a page and change its index) without breaking or having to change the external in-pointing links.
This mechanism will come into play for nearly every page in my system so I'm looking for the most efficient code to do this.
My thinking about possibilities for the index :-
methods in a folder properties of a folder properties of a dtml-doc some other sort of data structure
For the redirection its obviously more efficient to do it something like dtml-var rather than redirect back to the client but (as my other posts show) I'm often really struggling to get my object references right (only partial understanding - looking forward to better documentation) I'd appreciate some help here too.
Andy -- ------------------------------------------------- Andy Heath a.k.heath@open.ac.uk The Open University +44 (0) 114 2885738
Whilst this is I'm sure a useful mechanism redirecting whole folders is overkill for what I need to do. I have many links into a tree and wish to have a very simple format for the external links and an internal mapping mechanism which maps each link to its real URL. My question remains. What's the most run-time-efficient (not development-time-efficient) way of doing it? I think you gave me the quickest development route which is not quite what I was asking.
Why can't they be the one and the same? Redirector is fast -- I suspect the difference in speed between Redirector and something else would be negigible. Remember that a Redirector folder is in itself just an index (of regexps -- it's not hard to wire the lookup so that, if the term is not a regexp, then it will use a dictionary, which is a lot faster). It does not need to contain anything, and you need only one Redirector folder to accomplish what you ask for. Let's say you have three areas that others link to: Downloads, Registration, and News. First, create a Redirector folder called, say, /Targets. Then edit the folder's redirection mappings to look like so: From To Downloads /Downloads Registration /Snark News /News Notice that the Registration name maps to /Snark -- this to illustrate the mappings have nothing to do with the *names*. Now, having done this, you can access your mappings like so: http://www.myserver.com/Targets/Downloads which will redirect to http://www.myserver.com/Downloads Isn't this what you want? Alexander Staubo mailto:alex@mop.no http://www.mop.no/~alex/
Why can't they be the one and the same? Redirector is fast -- I suspect the difference in speed between Redirector and something else would be negigible.
I confess, what you have is a very good idea. The reason I'm hesitating is because there won't be two or three areas and its wrong to call them areas. They will be single documents and a little bit further down the road there may be hundreds of them needed and not in any homogenous flat structure but at different places in a tree. Also, I really do need every last inch of speed out of this part. Hardwiring your code to use a dictionary looks like a good idea for the present. Some questions: 1. does your product redirect back to the client or within zope? 2. assuming it were hardwired as you suggest what would be the runtime cost over just having folder methods in zope do the redirection? 3. I haven't touched python for 2 years now (though I did use it a lot then) - I'm very rusty. Could you supply a patch to hardwire in a dictionary instead of the regex code? Assuming 2. is satis this *could* be a good answer. 4. still looking for an answer to my orginal q - what's the most efficient way? Andy
Remember that a Redirector folder is in itself just an index (of regexps -- it's not hard to wire the lookup so that, if the term is not a regexp, then it will use a dictionary, which is a lot faster). It does not need to contain anything, and you need only one Redirector folder to accomplish what you ask for. Let's say you have three areas that others link to: Downloads, Registration, and News. First, create a Redirector folder called, say, /Targets. Then edit the folder's redirection mappings to look like so:
From To Downloads /Downloads Registration /Snark News /News
Notice that the Registration name maps to /Snark -- this to illustrate the mappings have nothing to do with the *names*. Now, having done this, you can access your mappings like so:
http://www.myserver.com/Targets/Downloads
which will redirect to
http://www.myserver.com/Downloads
Isn't this what you want?
Alexander Staubo mailto:alex@mop.no http://www.mop.no/~alex/
-- ------------------------------------------------- Andy Heath a.k.heath@open.ac.uk The Open University +44 (0) 114 2885738
From: cmsakh@zope.org [mailto:cmsakh@zope.org]On Behalf Of Andy Heath Sent: Monday, March 13, 2000 11:50 AM To: alex Cc: zope@zope.org Subject: Re: [Zope] efficient internal redirect
Why can't they be the one and the same? Redirector is fast -- I suspect the difference in speed between Redirector and something else would be negigible.
I confess, what you have is a very good idea. The reason I'm hesitating is because there won't be two or three areas and its wrong to call them areas. They will be single documents and a little bit further down the road there may be hundreds of them needed and not in any homogenous flat structure but at different places in a tree. Also, I really do need every last inch of speed out of this part.
Why not derive a specialized version of my product ("Redirector Method") that descends from not Folder, but SimpleItem? If each such method represents only a single "mapping", you get what you ask for. Of course, if you have plugged your Zope into Apache, then it would be more efficient to use mod_rewrite anyway.
Some questions:
1. does your product redirect back to the client or within zope?
Yes. It forces an HTTP redirect. I don't if Zope is re-entrant; that is, whether you can emulate symbolic links by passing the request, modified, back into Zope.
2. assuming it were hardwired as you suggest what would be the runtime cost over just having folder methods in zope do the redirection?
Not sure if the word "hardwired" is correct here. After all, what I just described to you in the previous email was not about changing the product itself -- that's hardwiring -- but changing the parameters to the product's *folder instance* -- that's Zope. ;-) What I suggested about using a dict for non-regexp mappings does not involve any hardwiring, either -- I meant patching the product to support dicts *in addition* to the existing regexps. Basically in the folder's management interface you'd simply specify whether a mapping used a regexp or not. Runtime cost: You would have to time it. Marginal, unless you're expecting a gazillion hits.
3. I haven't touched python for 2 years now (though I did use it a lot then) - I'm very rusty. Could you supply a patch to hardwire in a dictionary instead of the regex code? Assuming 2. is satis this *could* be a good answer.
Let me think about it. I'm pretty busy -- perhaps Dylan is up to the task, he did the previous patch.
4. still looking for an answer to my orginal q - what's the most efficient way?
mod_rewrite. Alexander Staubo mailto:alex@mop.no http://www.mop.no/~alex/
Why not derive a specialized version of my product ("Redirector Method") that descends from not Folder, but SimpleItem? If each such method represents only a single "mapping", you get what you ask for.
Of course, if you have plugged your Zope into Apache, then it would be more efficient to use mod_rewrite anyway.
You have misunderstood what I'm asking completely (probably my fault). I am using apache and zope, some pages served via the zope-->apache route, some directly from Zserver (faster than going via apache) and some just with apache. Some addresses are already being rewritten by apache - that's not a problem. The mechanism I am seeking to use is just something like <dtml-var destinationPage>. Since this doesn't go back to the client between it has to be faster than going back to the client and doing another request for these particular pages (which are in this database anyway). Please can people reply to my original post without recommending the redirector product. I've reproduced the post below in the hope someone can answer it for me. Please don't reply telling me how marvellous the redirector is - yes its a good idea but its not what I'm looking for here - I'm just looking for some help to know what's the fastest method and how to code it. Original post ------------- I have some pages within zope which are linked to externally (from non-zope pages). I want to have some sort of internal index so that I can move the zope pages around completely within zope (move a page and change its index) without breaking or having to change the external in-pointing links. This mechanism will come into play for nearly every page in my system so I'm looking for the most efficient code to do this. My thinking about possibilities for the index :- methods in a folder properties of a folder properties of a dtml-doc some other sort of data structure For the redirection its obviously more efficient to do it something like dtml-var rather than redirect back to the client but (as my other posts show) I'm often really struggling to get my object references right (only partial understanding - looking forward to better documentation) I'd appreciate some help here too. What's the most efficient way? Andy -- ------------------------------------------------- Andy Heath a.k.heath@open.ac.uk The Open University +44 (0) 114 2885738
-----Original Message----- From: cmsakh@firewall.mop.no [mailto:cmsakh@firewall.mop.no]On Behalf Of Andy Heath Sent: Monday, March 13, 2000 1:04 PM To: alex Cc: zope@zope.org Subject: Re: [Zope] efficient internal redirect
[snip]
You have misunderstood what I'm asking completely (probably my fault).
If I were you, I'd definitely go over that original post of yours again and consider how it can be rephrased -- because from what you say, this is how I see your problem: 1) Pages within Zope 2) External sites or pages that link to these pages 3) You'd like the underlying pages to be separate from the URLs to which these external pages refer, so that you can move the actual data around. 4) You want this to perform really well.
From this specification, it sounds like, aside from the marginal performance loss incurred, you should be able to make do by using plain old HTTP redirection. Did I get any part wrong?
You could use a kind of hub method like so: <dtml-let Mappings="{ 'Downloads': PARENTS[-1].Downloads, 'Foo': PARENTS[-1].Bar, 'Snarf': PARENTS[-1].Smurf.Snark }"> <dtml-var "Mappings[REQUEST.Where]"> </dtml-let> Assuming the method is called /Hub, then you can invoke it like so: http://www.andysserver.com/Hub?Where=Snarf and it will display, in this case, the object "Snarf" in the root-level "Smurf" container. While this works (you can also use a TinyTable instead of a dictionary), this has a few gotchas, such as causing trouble with proxy roles. No HTTP redirects, but not as elegant. Oh, and did I mention how absolutely marvellous the Redirector product is? ;-) -- Alexander Staubo http://alex.mop.no
1) Pages within Zope 2) External sites or pages that link to these pages 3) You'd like the underlying pages to be separate from the URLs to which these external pages refer, so that you can move the actual data around. 4) You want this to perform really well.
From this specification, it sounds like, aside from the marginal performance loss incurred, you should be able to make do by using plain old HTTP redirection. Did I get any part wrong?
Yes. Plain old inclusion (like #include in C) would work faster because it doesn't go back to the client in the same sense as HTTP redirection. There is some way of doing this in dtml, I know because I had something working at one point but I can't remember what it is. I do remember it only worked if the objects that were redirected to (equivalent of included) were methods not documents. <dtml-var "whatever.whateverelse.object> gets the right object but it doesn't get rendered. Andy -- ------------------------------------------------- Andy Heath a.k.heath@open.ac.uk The Open University +44 (0) 114 2885738
----- Original Message ----- From: "Andy Heath" <a.k.heath@open.ac.uk> To: "alex" <alex@mop.no> Cc: <zope@zope.org> Sent: Monday, March 13, 2000 8:23 AM Subject: Re: [Zope] efficient internal redirect
<dtml-var "whatever.whateverelse.object> gets the right object but it doesn't get rendered.
If it's a DTML Method, you could do <dtml-var "whatever.whateverelse.object(_.None, _)"> There is also a _.render method that I've never had occasion to use. Also, if you want to make things a bit more generic and work somewhat like the Redirector, you could also do a <dtml-var "REQUEST.resolve_url(the_new_complete_url)(_.None, _)"> All untested, but will hopefully help you along... Kevin
Andy, I may also be barking up the wrong tree here, but forgive me if so. Have you tried something like (untested) <dtml-call "RESPONSE.redirect(destinationPage.absolute_url())"> HTH Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Andy Heath" <a.k.heath@open.ac.uk> To: "alex" <alex@mop.no> Cc: <zope@zope.org> Sent: Monday, March 13, 2000 12:03 PM Subject: Re: [Zope] efficient internal redirect
Why not derive a specialized version of my product ("Redirector Method") that descends from not Folder, but SimpleItem? If each such method represents only a single "mapping", you get what you ask for.
Of course, if you have plugged your Zope into Apache, then it would be more efficient to use mod_rewrite anyway.
You have misunderstood what I'm asking completely (probably my fault). I am using apache and zope, some pages served via the zope-->apache route, some directly from Zserver (faster than going via apache) and some just with apache. Some addresses are already being rewritten by apache - that's not a problem. The mechanism I am seeking to use is just something like
<dtml-var destinationPage>.
Since this doesn't go back to the client between it has to be faster than going back to the client and doing another request for these particular pages (which are in this database anyway).
Please can people reply to my original post without recommending the redirector product. I've reproduced the post below in the hope someone can answer it for me. Please don't reply telling me how marvellous the redirector is - yes its a good idea but its not what I'm looking for here - I'm just looking for some help to know what's the fastest method and how to code it.
Original post ------------- I have some pages within zope which are linked to externally (from non-zope pages). I want to have some sort of internal index so that I can move the zope pages around completely within zope (move a page and change its index) without breaking or having to change the external in-pointing links.
This mechanism will come into play for nearly every page in my system so I'm looking for the most efficient code to do this.
My thinking about possibilities for the index :-
methods in a folder properties of a folder properties of a dtml-doc some other sort of data structure
For the redirection its obviously more efficient to do it something like dtml-var rather than redirect back to the client but (as my other posts show) I'm often really struggling to get my object references right (only partial understanding - looking forward to better documentation) I'd appreciate some help here too.
What's the most efficient way?
Andy
-- ------------------------------------------------- Andy Heath a.k.heath@open.ac.uk The Open University +44 (0) 114 2885738
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Mon, Mar 13, 2000 at 08:13:29AM +0000, Andy Heath wrote:
I have some pages within zope which are linked to externally (from non-zope pages). I want to have some sort of internal index so that I can move the zope pages around completely within zope (move a page and change its index) without breaking or having to change the external in-pointing links.
This mechanism will come into play for nearly every page in my system so I'm looking for the most efficient code to do this.
My thinking about possibilities for the index :-
methods in a folder properties of a folder properties of a dtml-doc some other sort of data structure
For the redirection its obviously more efficient to do it something like dtml-var rather than redirect back to the client but (as my other posts show) I'm often really struggling to get my object references right (only partial understanding - looking forward to better documentation) I'd appreciate some help here too.
What's the most efficient way?
Check out http://www.zope.org/Members/cba/URL_subfolder for a way to redirect without the browser noticing. -- Stephen Pitts smpitts@midsouth.rr.com
I don't know if this is do-able, but here goes. I'd like to do something like the following: <dtml-var main_header> <dtml-var "external site"> <dtml-var main_footer> I know, this defeats the purpose of Zope to some degree, but in this case I'd like to include an external site instead of employing frames. Let's say, for example, that I'd like to showcase a resource located on another namespace. I've tried: <dtml-var "REQUEST.resolve_url(my_external_url)(_.None, _)"> but I get a namespace error for obvious reasons. I realize that the header's <body> tags would conflict with the external resources' and hence, I'm not banking on anything. I also looked at Redirector and found it to be great for redirection within the same namespace, but I'm unsure on its ability to redirect to external resources (or namespaces). My dilemma is that I am using Zope to design a site and require Zope's numerous features, but I need to include a CGI-rendered page within Zope header and footers without using frames. Ultimately, I intend to re-write the CGI as a Zope object, but at present I'm at a loss. Thanks in advance, Mike
At 7:59 pm -0500 14/3/00, Michael Oas wrote:
I don't know if this is do-able, but here goes. I'd like to do something like the following:
<dtml-var main_header> <dtml-var "external site"> <dtml-var main_footer>
I know, this defeats the purpose of Zope to some degree, but in this case I'd like to include an external site instead of employing frames. Let's say, for example, that I'd like to showcase a resource located on another namespace.
You might be able to do something with urllib.urlretrieve (in an external method) and feed that back into Zope *vaguely tested* def doit(self, your_url): import urllib fn, h = urllib.urlretrieve(your_url) if h: fp = open(fn, "rb") data = fp.read() return data You'll get junk like <HTML> and </HTML> in it, but it's a start... hth Tone ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
If I understand what you need, you might want to check out ZPublisher/Client.py and the HowTo: http://www.zope.org/Members/lstaffor/ZClientMethod -- Loren ----- Original Message ----- From: Michael Oas <dell7000@thot.net> To: <zope@zope.org> Sent: March 14, 2000 04:59 PM Subject: [Zope] external redirects
I don't know if this is do-able, but here goes. I'd like to do something like the following:
<dtml-var main_header> <dtml-var "external site"> <dtml-var main_footer>
I know, this defeats the purpose of Zope to some degree, but in this case I'd like to include an external site instead of employing frames. Let's say, for example, that I'd like to showcase a resource located on another namespace.
I've tried:
<dtml-var "REQUEST.resolve_url(my_external_url)(_.None, _)">
but I get a namespace error for obvious reasons. I realize that the header's <body> tags would conflict with the external resources' and hence, I'm not banking on anything. I also looked at Redirector and found it to be great for redirection within the same namespace, but I'm unsure on its ability to redirect to external resources (or namespaces).
My dilemma is that I am using Zope to design a site and require Zope's numerous features, but I need to include a CGI-rendered page within Zope header and footers without using frames. Ultimately, I intend to re-write the CGI as a Zope object, but at present I'm at a loss.
Thanks in advance,
Mike
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Loren Stafford wrote:
If I understand what you need, you might want to check out ZPublisher/Client.py and the HowTo: http://www.zope.org/Members/lstaffor/ZClientMethod
Or use an external method that uses urllib. -- Itamar S.T. itamars@ibm.net
Much appreciated to all who replied to my original post. Cheers, Mike -----Original Message----- From: itamar@localhost.localdomain [mailto:itamar@localhost.localdomain]On Behalf Of Itamar Shtull-Trauring Sent: March 15, 2000 12:58 PM To: Michael Oas Cc: zope@zope.org Subject: Re: [Zope] external redirects Loren Stafford wrote:
If I understand what you need, you might want to check out ZPublisher/Client.py and the HowTo: http://www.zope.org/Members/lstaffor/ZClientMethod
Or use an external method that uses urllib. -- Itamar S.T. itamars@ibm.net _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (10)
-
Alexander Staubo -
Andy Heath -
Itamar Shtull-Trauring -
Kevin Dangoor -
Loren Stafford -
Michael Oas -
Michael Oas -
Phil Harris -
Stephen Pitts -
Tony McDonald