Hello folks, Can anyone explain why my Zope apps generate loooooooooooong urls? It seems that each action (clicking a button or an href) results in the target (the object being called) being appended to the current url which is submitted to the server. I've pored over the various Zope references but nothing sticks out as obvious. I've tried specifying the path directly to a Zope object in both Python scripts and dtml documents, and also used relative linking where possible. The effect is always the same and apart from causing the server to overwork it also leads to problems with database operations. Any help will be much appreciated. cheers David
On Wed, 31 Jul 2002, David Beech wrote:
Hello folks,
Can anyone explain why my Zope apps generate loooooooooooong urls?
It seems that each action (clicking a button or an href) results in the target (the object being called) being appended to the current url which is submitted to the server.
I've pored over the various Zope references but nothing sticks out as obvious.
I've tried specifying the path directly to a Zope object in both Python scripts and dtml documents, and also used relative linking where possible. The effect is always the same and apart from causing the server to overwork it also leads to problems with database operations.
It is relative links that cause this problem. Absolute links don't have this behavior. Since making absolute links is so trivial I don't think I build sites anymore where every link is not absolute. object.absolute_url() will create an absolute url to an object in zope.
On Wed, 31 Jul 2002 14:54, you wrote:
On Wed, 31 Jul 2002, David Beech wrote:
Hello folks,
Can anyone explain why my Zope apps generate loooooooooooong urls?
It seems that each action (clicking a button or an href) results in the target (the object being called) being appended to the current url which is submitted to the server.
I've pored over the various Zope references but nothing sticks out as obvious.
I've tried specifying the path directly to a Zope object in both Python scripts and dtml documents, and also used relative linking where possible. The effect is always the same and apart from causing the server to overwork it also leads to problems with database operations.
It is relative links that cause this problem. Absolute links don't have this behavior. Since making absolute links is so trivial I don't think I build sites anymore where every link is not absolute. object.absolute_url() will create an absolute url to an object in zope.
Thanks for that. You're suggestion is in keeping with Chris McD's also. Great minds think alike. cheers
Use dynamically-generated absolute URLs, e.g.: <a href="&dtml-absolute_url;/something">Foo</a> Instead of relative ones, e.g.: <a href="something"> This is somewhat of a FAQ, although there's no document with an A. ;-) - C On Wed, 2002-07-31 at 00:58, David Beech wrote:
Hello folks,
Can anyone explain why my Zope apps generate loooooooooooong urls?
It seems that each action (clicking a button or an href) results in the target (the object being called) being appended to the current url which is submitted to the server.
I've pored over the various Zope references but nothing sticks out as obvious.
I've tried specifying the path directly to a Zope object in both Python scripts and dtml documents, and also used relative linking where possible. The effect is always the same and apart from causing the server to overwork it also leads to problems with database operations.
Any help will be much appreciated.
cheers
David
_______________________________________________ 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 )
Thanks Chris, I'll go and work along the lines you suggest. aaaaaaaaaaaaggggggggggh!!!!!!! cheers David On Wed, 31 Jul 2002 15:10, you wrote:
Use dynamically-generated absolute URLs, e.g.:
<a href="&dtml-absolute_url;/something">Foo</a>
Instead of relative ones, e.g.:
<a href="something">
This is somewhat of a FAQ, although there's no document with an A. ;-)
- C
On Wed, 2002-07-31 at 00:58, David Beech wrote:
Hello folks,
Can anyone explain why my Zope apps generate loooooooooooong urls?
It seems that each action (clicking a button or an href) results in the target (the object being called) being appended to the current url which is submitted to the server.
I've pored over the various Zope references but nothing sticks out as obvious.
I've tried specifying the path directly to a Zope object in both Python scripts and dtml documents, and also used relative linking where possible. The effect is always the same and apart from causing the server to overwork it also leads to problems with database operations.
Any help will be much appreciated.
cheers
David
_______________________________________________ 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 )
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ David Beech (MACS, B.App. Comp, Dip Voc Ed.) www.thesoftwaresmith.com.au www.codelearn.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hello folks, The saga continues ...
From a Python script I use a return statement like:
return container.xxx.yyy.zzz.aaa(container.REQUEST) aaa is a dtml doc and the REQUEST object has had some attributes set that aaa will use. aaa is nested down in the tree xxx.yyy.zzz The result of this is that it seems that Zope appends the return value to the calling URL, hence it gets longer and longer and when returned Zope does things I rather it didn't, like rerunning SQL methods. If I apply absolute_url to this as in: return container.xxx.yyy.zzz.aaa.absolute_url() I get a string returned not a renderable object. I try another strategy and do return context.xxx.yyy.zzz.absolute_url() + '/aaa' expecting to force a redirect but it fails. Deep sighs. I want to return object references from Python scripts as absolute urls and obviously I am doing something wrong, wiping out (if necessary) the original url (which I guess comes from the REQUEST). Any suggestions gratefully received and pursued. cheers David On Wed, 31 Jul 2002 15:10, you wrote:
Use dynamically-generated absolute URLs, e.g.:
<a href="&dtml-absolute_url;/something">Foo</a>
Instead of relative ones, e.g.:
<a href="something">
This is somewhat of a FAQ, although there's no document with an A. ;-)
- C
On Wed, 2002-07-31 at 00:58, David Beech wrote:
Hello folks,
Can anyone explain why my Zope apps generate loooooooooooong urls?
It seems that each action (clicking a button or an href) results in the target (the object being called) being appended to the current url which is submitted to the server.
I've pored over the various Zope references but nothing sticks out as obvious.
I've tried specifying the path directly to a Zope object in both Python scripts and dtml documents, and also used relative linking where possible. The effect is always the same and apart from causing the server to overwork it also leads to problems with database operations.
Any help will be much appreciated.
cheers
David
_______________________________________________ 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 )
David Beech wrote:
Hello folks,
The saga continues ...
From a Python script I use a return statement like:
return container.xxx.yyy.zzz.aaa(container.REQUEST)
aaa is a dtml doc and the REQUEST object has had some attributes set that aaa will use. aaa is nested down in the tree xxx.yyy.zzz
The result of this is that it seems that Zope appends the return value to the calling URL, hence it gets longer and longer and when returned Zope does things I rather it didn't, like rerunning SQL methods.
The above will return the result of rendering aaa, is that what you want?
If I apply absolute_url to this as in:
return container.xxx.yyy.zzz.aaa.absolute_url()
I get a string returned not a renderable object.
Well indeed, what were you expecting? Actually, your first example returns a string too, just a long one with lots of HTML in it ;-)
I try another strategy and do
return context.xxx.yyy.zzz.absolute_url() + '/aaa'
expecting to force a redirect but it fails. Deep sighs.
Why? You're just returning a very short string there, one which you'e appended '/aaa' to. If you want to redirect, you'd do: return context.REQUEST.RESPONSE.redirect(container.xxx.yyy.zzz.aaa.absolute_url()) ...but I don't think you do, since you're loose your current REQUEST object when you do that.
I want to return object references from Python scripts as absolute urls
Object references and absolute URLs are two very different things. What is it that you're trying to do? (high level, don't explain how you're trying to solve the problem which is somethign altogether different ;-) cheers, Chris
Hello Chris, On Wed, 31 Jul 2002 19:03, you wrote:
From a Python script I use a return statement like:
return container.xxx.yyy.zzz.aaa(container.REQUEST)
aaa is a dtml doc and the REQUEST object has had some attributes set that aaa will use. aaa is nested down in the tree xxx.yyy.zzz
The result of this is that it seems that Zope appends the return value to the calling URL, hence it gets longer and longer and when returned Zope does things I rather it didn't, like rerunning SQL methods.
The above will return the result of rendering aaa, is that what you want?
Of course, but the url gets appended to the calling url, thus http://fred.com/xxx/yyy/zzz/ would become http://fred.com/xxx/yyy/zzz/xxx/yyy/zzz/aaa or something like that. My meagre understanding of Zope is that Zope's acquisition will take care of this but at some cost. I'd like to get http://fred.com/xxx/yyy/zzz/aaa which is what I assumed return container.xxx.yyy.zzz.aaa(container.REQUEST) would translate to.
If I apply absolute_url to this as in:
return container.xxx.yyy.zzz.aaa.absolute_url()
I get a string returned not a renderable object.
Well indeed, what were you expecting? Actually, your first example returns a string too, just a long one with lots of HTML in it ;-)
Which is what I am expecting but it's not an absolute url unless we want to call an absolute url an url which contains much repetition of paths.
I try another strategy and do
return context.xxx.yyy.zzz.absolute_url() + '/aaa'
expecting to force a redirect but it fails. Deep sighs.
Why? You're just returning a very short string there, one which you'e appended '/aaa' to.
If you want to redirect, you'd do:
return context.REQUEST.RESPONSE.redirect(container.xxx.yyy.zzz.aaa.ab solute_url())
...but I don't think you do, since you're loose your current REQUEST object when you do that.
Hence these other efforts. But this was tinkering, looking for clues. Zope isn't my forte.
I want to return object references from Python scripts as absolute urls
Object references and absolute URLs are two very different things.
What is it that you're trying to do? (high level, don't explain how you're trying to solve the problem which is somethign altogether different ;-)
If a script executes return container.xxx.yyy.zzz.aaa(container.REQUEST) isn't that a reference to a Zope object? and doesn't that reference return an URL? The objective is (for example) to call a Python script as the action of a form element, do some work with the form fields, populate the REQUEST with results and then (via the return statement) push a page back to the user, in brief: 1 Web client views form, fills form fields, submits form 2 Submit calls Python script 3 Script does database op 4 Script returns another web page all of which works but the url gets longer and longer. Thanks Chris cheers David
On Wed, Jul 31, 2002 at 10:51:31PM +1000, David Beech wrote:
The objective is (for example) to call a Python script as the action of a form element, do some work with the form fields, populate the REQUEST with results and then (via the return statement) push a page back to the user, in brief:
1 Web client views form, fills form fields, submits form 2 Submit calls Python script 3 Script does database op 4 Script returns another web page
For step 4, I usually do a REQUEST.RESPONSE.redirect(url_of_final_display_page) In this case, it's not a problem that I lose the REQUEST when I go to the new page, as Chris warned, because the script has already done everything I need to do with REQUEST data, storing in the ZODB if necessary, and my final display page just reads anything it needs from the ZODB. (Would work with any other data store too, of course ... sql or whatever). -- Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"
David Beech wrote:
return container.xxx.yyy.zzz.aaa.absolute_url()
I get a string returned not a renderable object.
Well indeed, what were you expecting? Actually, your first example returns a string too, just a long one with lots of HTML in it ;-)
Which is what I am expecting but it's not an absolute url unless we want to call an absolute url an url which contains much repetition of paths.
That is strange... absolute_url is usually fairly good about this kindof thing unless you're doing any funny acquisition rewrapping. Are you?
If a script executes
return container.xxx.yyy.zzz.aaa(container.REQUEST)
isn't that a reference to a Zope object?
No, that just returns a string containing lots of HTML, rememer earlier? ;-)
and doesn't that reference return an URL?
No, 'cos it's just a string...
1 Web client views form, fills form fields, submits form
The above is your ZPT..
2 Submit calls Python script
And we're talking about this script, right?
3 Script does database op
fine.
4 Script returns another web page
SO, you _do_ want this at the bottom: return container.xxx.yyy.zzz.aaa(container.REQUEST) ...but I'd recommend that your ZPT gets its data from an SQL query rather than the REQUEST, as Paul suggested.
all of which works but the url gets longer and longer.
hmmm... I find this strange. Idea: Can you post the code that generates the FORM tag in your editing form? I'm interested to see what the action is... cheers, Chris
Thanks Chris
cheers
David
On Thu, Aug 01, 2002 at 10:02:46AM +0100, Chris Withers wrote:
all of which works but the url gets longer and longer.
hmmm... I find this strange.
I just remembered something: I had a similar problem with a zwiki site when using a misconfigured SiteRoot. You don't happen to have a SiteRoot around, do you? I have the problem and its solution somewhere in my mail archives... -- Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"
SO, you _do_ want this at the bottom:
return container.xxx.yyy.zzz.aaa(container.REQUEST)
...but I'd recommend that your ZPT gets its data from an SQL query rather than the REQUEST, as Paul suggested.
I do use much SQL and the REQUEST is necessary to pass session data and url parameters between requests.
all of which works but the url gets longer and longer.
hmmm... I find this strange.
Idea: Can you post the code that generates the FORM tag in your editing form? I'm interested to see what the action is...
Here is one use but the technique is used widely throughout a couple of applications: <form action="/grp/Forum/forumScripts/newMsg" method="post"> and the tail end of the action: ... body = context.grExternal.convertText(body) container.grp.Forum.forumSQL.sqlNewMsg(body=body, userid=userid, subject=subject, forumid=forumid) return container.grp.Forum.forumScripts.viewForum() and the tail end of the script called by newMsg: ... return container.grp.Forum.forumPages.forum_frontpage(container.grp, container.REQUEST) Here is part of the site structure: /grp/Forum /grp/Forum/forumPages /grp/Forum/forumScripts /grp/Forum/formSQL I discovered yesterday that the problem isn't evident if all scripts and pages are contained within one folder. cheers David
David Beech wrote:
Here is one use but the technique is used widely throughout a couple of applications:
<form action="/grp/Forum/forumScripts/newMsg" method="post">
try changing the abvoe to: <form action="/grp/Forum/forumScripts/newMsg" method="post" tal:attributes="here/grp/Forum/forumScripts/newMsg/absolute_url">
return container.grp.Forum.forumPages.forum_frontpage(container.grp, container.REQUEST)
I'm guessing there's a link to the form that includes the above on forum_frontpage? If so, can you give us the code which geenrates it? cheers, Chris
'Lo Chris, Problem resolved. I should have paid closer attention to the advice Chris McD and Kosh gave and the track you were following: - Use absolute urls Thanks for the help, all cheers David " 'Tis with our judgements as 'tis with our watches, none go just alike yet each believes his own" - Alexander Pope
participants (5)
-
Chris McDonough -
Chris Withers -
David Beech -
kosh@aesaeion.com -
Paul Winkler