Re: [Zope-dev] __before_publishing_traverse__ calls RESPONSE.redirect(): is there another way to change the browser URL?

2002-09-27 Thread Florent Guillaume

Craeg K Strong  [EMAIL PROTECTED] wrote:
 However, I would like to distinguish between two cases:
 
 a) Direct Navigation:   e.g.I am a user and I just typed in
 
 http://acme.com/myapp/contracts/TRW-001/taskorders/TO-01/invoices/DSDC-001-9301
 
 into my browser
 
 b) Application-Controlled:   e.g. I am the application, I did some processing
 based on a button the user pressed in some form somewhere and determined
 that the next URL should be
 
 http://acme.com/myapp/contracts/TRW-001/taskorders/TO-01/invoices/DSDC-001-9301
 
 Now here is the issue
 
 In both cases above, the REQUEST object looks identical.   Is there any way
 that I can distinguish a GET that is the result of a REDIRECT from one that
 is not?
 
 I would think this would be of interest to others.  For example, if I move my
 web page and put a redirect from the old address, I could track how many
 people came to my web page directly versus those that are still using the
 old address and are getting redirected.

You could try to do a POST and distinguish that from the GET when the
user just types the URL. But it's probably better to add a special
hidden field in your form to distinguish the two.

Florent




-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:[EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] __before_publishing_traverse__ calls RESPONSE.redirect():is there another way to change the browser URL?

2002-09-27 Thread Craeg K Strong

I believe HTTP_REFERER will list the place from whence you were redirected,
but unfortunately it does not distinguish between

  redirect  and

following HTML link

Of which my application has many :-(

--Craeg

Casey Duncan wrote:
 On Friday 27 September 2002 12:49 pm, Craeg K Strong wrote:
 [snip]
 
Now here is the issue

In both cases above, the REQUEST object looks identical.   Is there any way
that I can distinguish a GET that is the result of a REDIRECT from one that
is not?

I would think this would be of interest to others.  For example, if I move 
 
 my
 
web page and put a redirect from the old address, I could track how many
people came to my web page directly versus those that are still using the
old address and are getting redirected.

Any advice?
 
 
 How about the HTTP_REFERER value? I'm not sure how a redirect affects this 
 though.
 
 -Casey



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] __before_publishing_traverse__ calls RESPONSE.redirect():is there another way to change the browser URL?

2002-09-27 Thread Craeg K Strong

Hello:

This is a good idea, and would solve the problem as stated.

Unfortunately, it conflicts with my other (heretofore unstated)
requirement that

all URLs shown in the browser should be bookmarkable
at all times.

Once a user bookmarks foo?I_am_an_application_controlled_redirect=1
and comes back to it, it is no longer telling the truth ;-)

--Craeg

Oliver Bleutgen wrote:
 Craeg K Strong wrote:
 
 However, I would like to distinguish between two cases:

 a) Direct Navigation:   e.g.I am a user and I just typed in

 http://acme.com/myapp/contracts/TRW-001/taskorders/TO-01/invoices/DSDC-001-9301 


 into my browser

 b) Application-Controlled:   e.g. I am the application, I did some 
 processing
 based on a button the user pressed in some form somewhere and determined
 that the next URL should be

 http://acme.com/myapp/contracts/TRW-001/taskorders/TO-01/invoices/DSDC-001-9301 


 Now here is the issue

 In both cases above, the REQUEST object looks identical.   Is there 
 any way
 that I can distinguish a GET that is the result of a REDIRECT from one 
 that
 is not?

 I would think this would be of interest to others.  For example, if I 
 move my
 web page and put a redirect from the old address, I could track how many
 people came to my web page directly versus those that are still using the
 old address and are getting redirected.
 
 
 raise 'Redirect', newURL+'?I_am_an_application_controlled_redirect=1'
 
 
 HTH,
 oliver



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] __before_publishing_traverse__ calls RESPONSE.redirect(): is there another way to change the browser URL?

2002-09-27 Thread Craeg K Strong

Thanks for the advice!

Unfortunately, I don't know how to do what you suggest.

I believe that a redirect always causes a GET, rather than a POST, no?

Also, hidden form fields are filled in on the original request, but the redirect
flushes the request.  All of my fields are gone!  :-(

Perhaps I could do something really nasty and override the Python method
in urllib2 that handles HTTP redirects?

Today, that code creates a new REQUEST object, throwing away the old request.
I could cause it to insert some value that I would then test for,
to distinguish the two cases.

That would be the king of all hacks, but it might work :-}

--Craeg

Florent Guillaume wrote:
 Craeg K Strong  [EMAIL PROTECTED] wrote:
 
However, I would like to distinguish between two cases:

a) Direct Navigation:   e.g.I am a user and I just typed in

http://acme.com/myapp/contracts/TRW-001/taskorders/TO-01/invoices/DSDC-001-9301

into my browser

b) Application-Controlled:   e.g. I am the application, I did some processing
based on a button the user pressed in some form somewhere and determined
that the next URL should be

http://acme.com/myapp/contracts/TRW-001/taskorders/TO-01/invoices/DSDC-001-9301

Now here is the issue

In both cases above, the REQUEST object looks identical.   Is there any way
that I can distinguish a GET that is the result of a REDIRECT from one that
is not?

I would think this would be of interest to others.  For example, if I move my
web page and put a redirect from the old address, I could track how many
people came to my web page directly versus those that are still using the
old address and are getting redirected.
 
 
 You could try to do a POST and distinguish that from the GET when the
 user just types the URL. But it's probably better to add a special
 hidden field in your form to distinguish the two.
 
 Florent



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] __before_publishing_traverse__ calls RESPONSE.redirect(): is there another way to change the browser URL?

2002-09-27 Thread Casey Duncan

What you are looking for sounds like stateful through-the-web functionality.

I think you should use sessions to remember the form fields and/or whether the 
user has been to this URL before.

I am suspect of an app design that makes a single URL mean different things in 
this way, however. I suspect there is a much easier way to accomplish what 
you want that does not use traversal hooks or magic redirect descrimination.

I'm still not sure I'm seeing the big picture of what you are really trying to 
accomplish here.

-Casey

On Friday 27 September 2002 02:53 pm, Craeg K Strong wrote:
 Hello:
 
 This is a good idea, and would solve the problem as stated.
 
 Unfortunately, it conflicts with my other (heretofore unstated)
 requirement that
 
 all URLs shown in the browser should be bookmarkable
 at all times.
 
 Once a user bookmarks foo?I_am_an_application_controlled_redirect=1
 and comes back to it, it is no longer telling the truth ;-)
 
 --Craeg
 
 Oliver Bleutgen wrote:
  Craeg K Strong wrote:
  
  However, I would like to distinguish between two cases:
 
  a) Direct Navigation:   e.g.I am a user and I just typed in
 
  
http://acme.com/myapp/contracts/TRW-001/taskorders/TO-01/invoices/DSDC-001-9301 
 
 
  into my browser
 
  b) Application-Controlled:   e.g. I am the application, I did some 
  processing
  based on a button the user pressed in some form somewhere and determined
  that the next URL should be
 
  
http://acme.com/myapp/contracts/TRW-001/taskorders/TO-01/invoices/DSDC-001-9301 
 
 
  Now here is the issue
 
  In both cases above, the REQUEST object looks identical.   Is there 
  any way
  that I can distinguish a GET that is the result of a REDIRECT from one 
  that
  is not?
 
  I would think this would be of interest to others.  For example, if I 
  move my
  web page and put a redirect from the old address, I could track how many
  people came to my web page directly versus those that are still using the
  old address and are getting redirected.
  
  
  raise 'Redirect', newURL+'?I_am_an_application_controlled_redirect=1'
  
  
  HTH,
  oliver
 
 
 
 ___
 Zope-Dev maillist  -  [EMAIL PROTECTED]
 http://lists.zope.org/mailman/listinfo/zope-dev
 **  No cross posts or HTML encoding!  **
 (Related lists - 
  http://lists.zope.org/mailman/listinfo/zope-announce
  http://lists.zope.org/mailman/listinfo/zope )
 


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] __before_publishing_traverse__ calls RESPONSE.redirect():is there another way to change the browser URL?

2002-09-27 Thread Craeg K Strong



Andreas Kostyrka wrote:
 Am Fre, 2002-09-27 um 20.58 schrieb Craeg K Strong:
 
Thanks for the advice!

Unfortunately, I don't know how to do what you suggest.

I believe that a redirect always causes a GET, rather than a POST, no?

Also, hidden form fields are filled in on the original request, but the redirect
flushes the request.  All of my fields are gone!  :-(

Perhaps I could do something really nasty and override the Python method
in urllib2 that handles HTTP redirects?
 
 What to hell does urllib2 have to do with Zope?

Sorry for the non-sequitur..  I do not really know if Zope uses the urllib2
machinery or not.  Somewhere, however, there must be some code that catches

raise 'Redirect', myurl

and does the appropriate thing (creates a new request, etc.).

My find-grep caught   class HTTPRedirectHandler(BaseHandler):  (line 427 of 
urllib2.py)

But I have not looked into it enough to understand whether it is what
I am guessing it is, and-- even if so-- whether Zope uses it or not.

in any event, there are other, better solutions on the table, so at this point
it is no longer important...

 
Today, that code creates a new REQUEST object, throwing away the old request.
I could cause it to insert some value that I would then test for,
to distinguish the two cases.
 
 REQUEST.redirect sends a status code to the browser which then requests
 the new URL by itself, ...
 
That would be the king of all hacks, but it might work :-}
 
 Probably not. The only thing you can do with redirect is to urlencode
 your parameters, ...

You're probably right.  The browser is getting back a status code in the HTTP 
header that makes it generate a new request.  The question I had was: would
there be a way to stuff something in the HTTP header that the browser would
somehow copy over to the new HTTP header it sends back in response to the
redirect status code...?

After all, it *does* copy the URL to which it is being redirected, along with
all of its query parameters, etc

A thorough re-reading of the HTTP spec would probably give me an answer...

--Craeg

 
 Andreas


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] __before_publishing_traverse__ calls RESPONSE.redirect(): is there another way to change the browser URL?

2002-09-23 Thread Casey Duncan

- Original Message -
From: Craeg K Strong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, September 23, 2002 10:59 PM
Subject: [Zope-dev] __before_publishing_traverse__ calls
RESPONSE.redirect(): is there another way to change the browser URL?


 Hello:

 I have defined a __before_publishing__traverse__() method in my Zope
product.

 Its job is to redirect the URL displayed in the browser to a nice looking
 URL, something like

 ../myapp/invoices/123

 instead of

 ../myapp/execute

__before_publishing__traverse__() doesn't affect the way the url looks to
the browser. Although it can change the path being traversed inside Zope if
you wish. It effectively lets any traversed object affect the rest of the
traversal in some arbitrary way, or do some work before it is itself
traversed.

 That way all my ZPT forms can call the same method: execute(),
 and I don't hardcode any URLs in my ZPTs.  The objective is to
 encapsulate my resource-to-URL mapping so that it can be changed
 independently from the ZPT code.

 I don't want to use setVirtualRoot, because I want to change the entire
 URL, not just all but the leaf

I'm not following this.

 The problem is that __before_publishing_traverse__ is getting called
*twice*
 for each button press.

 *First* it gets called with the ../myapp/execute URL.  This is when I
 call RESPONSE.redirect()

 *Second* it gets called with the ../myapp/invoices/123 URL

 I am trying to understand how Zope works with the HTTP REDIRECT machinery.

__before_publishing_traverse__ is called once for any object that defines it
each time that object is traversed during a web request. A redirect
generates a whole new web request, so this causes another whole set of
object traversals.

 Is there a way to make the URL that is actually displayed in the browser
 *different* from the Zope method name you are calling, aside from using
 RESPONSE.redirect()?

Redirect would not do this. Redirect changes the URL and makes the browser
go to that URL. Whether that URL is a complete traversal to a method depends
on your application. For example, a humble Python script has a traversal
hook of the aforementioned variety that eats the rest of the URL path
elements and binds them to the script's namespace, by default under the name
traverse_subpath. For example, given a Python script pyscript in your
Zope root directory, then the following URL would call it:

http://zopeserver/pyscript/more/path/elements

When called, the script would have the traverse_subpath set to the value
['more','path','elements']. So the URL does not point to a method in this
case. This is the easiest way to gather data from URL path elements.

To do the same in external Python code, take a gander at the traversal hook
in {Zope}/lib/python/Shared/DC/Scripts/Bindings.py which is the code that
Python scripts use.

hth,

-Casey


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )