[Zope] Impossibly long urls

David Beech dbeech@bigpond.net.au
Wed, 31 Jul 2002 22:51:31 +1000


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