Re: [Zope] Form POST Question (and a QUERY_STRING Q.)

2000-06-02 Thread Daryl Tester

Stuart 'Zen' Bishop wrote:

> And another item from 'Sticky Tape & String Crackpot Solutions R Us':
> 
> Write an external method that calls Pythons urllib or httplib methods to
> suck in the desired URL and return it. You may be able to use
> this as a replacement to redirect.

A while ago, I wrote something like (well, actually, it was exactly like):

from urllib import urlencode

def addRequestURL(REQUEST, url, dict = {}):
"Return an URL with REQUEST.form encoded as a query string."
newREQ = {}
# Copy REQUEST.form
for key, val in REQUEST.form.items():
newREQ[key] = val
# Overwrite with supplied values.
for key, val in dict.items():
newREQ[key] = val
return url + '?' + urlencode(newREQ)

which allows you to add new/modify existing items in the query string.
Would that help, Mr Person Who Originally Started This Thread?

"Antipodean Hacks R Us"


Regards,
  Daryl Tester

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Form POST Question (and a QUERY_STRING Q.)

2000-06-02 Thread Stuart 'Zen' Bishop

On Thu, 1 Jun 2000, Andrew H. Chatham wrote:

> You can of course change it all into GET data and just join them
> together using:
>'%s=%s' % (url_quote_plus(name), url_quote_plus(data))
> and joinging with &, in which case you actually can do a redirect, but
> presumably someone made it POST for a reason, so I'm not going to mess
> with it. It's an inelegant solution and might not work for everything,
> but it's all I have for now!

And another item from 'Sticky Tape & String Crackpot Solutions R Us':

Write an external method that calls Pythons urllib or httplib methods to 
suck in the desired URL and return it. You may be able to use
this as a replacement to redirect.

-- 
Stuart Bishop  Work: [EMAIL PROTECTED]
Senior Systems Alchemist   Play: [EMAIL PROTECTED]
Computer Science, RMIT University


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] Form POST Question (and a QUERY_STRING Q.)

2000-06-01 Thread Andrew H. Chatham

> Is there a way for me to get the raw posted data and forward that
> too via the RESPONSE object?

What I ended up doing was following Zen's suggestion and creating an
external method that basically does (not an exact quote; it's on another
computer):

def generateForm(self):
outForm = []
for (name, value) in self.REQUEST.form:
outForm.append ('' % (name,
value)
return string.join (outForm, '\n')

It's a little more than that, but I don't have it in front of me. (this
wouldn't deal with quotes right).

I haven't run into the name="mynum:int" problem yet, but maybe that's
just luck, or maybe it's just because of my particular forms. The bad
part is that I don't know of any way to pass POST data on a redirect
(anybody know how to do this, or is this impossible?), so for now I just
have a form that's nothing but a Submit widget with all the other dat a
hidden. 

You can of course change it all into GET data and just join them
together using:
   '%s=%s' % (url_quote_plus(name), url_quote_plus(data))
and joinging with &, in which case you actually can do a redirect, but
presumably someone made it POST for a reason, so I'm not going to mess
with it. It's an inelegant solution and might not work for everything,
but it's all I have for now!

Andrew

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




RE: [Zope] Form POST question (and a QUERY_STRING Q.)

2000-06-01 Thread Marcus Collins

Hi,

There was a thread a week or so ago about passing POSTed variables after
authenticating, some of which will be useful -- see the archived message,
suggestions and caveats at: 

http://zope.nipltd.com/public/lists/zope-archive.nsf/47ba74c812dbc5dd8025687
f0024bb5f/3e46f2835c820eae802568eb002c802a?OpenDocument

Regarding your second question, REQUEST.QUERY_STRING works for me using
Zope; maybe someone else has some pointers regarding its use in "the old
bobo fashion" with which I'm not too familiar.

hth,

-- Marcus

> -Original Message-
> From: Yosef Gold [mailto:[EMAIL PROTECTED]]
> Sent: 01 June 2000 12:50
> To: [EMAIL PROTECTED]
> Subject: [Zope] Form POST question (and a QUERY_STRING Q.)
> 
> 
> I use Zope in the old bobo fashion.  I have a homegrown session
> management class that I use.  When a session is idle for a long
> while, I ask the user for his password again before allowing him to
> continue.  Generally, I then use the URL from the REQUEST object and
> RESPONSE.redirect() to send him where he was trying to go after he
> reenters his password (he never got there because I gave him a
> session timeout screen instead).  This works well except in one
> case.  If a user submits a form that uses POST to send it's data, I
> am not forwarding the posted data and so I get a Zope error that a
> parameter is missing.
> 
> Is there a way for me to get the raw posted data and forward that too
> via the RESPONSE object?
> 
> A seperate small side question.  I thought that all the paremeters
> after the "?" in an URL or a submitted form (using GET) are put into
> the QUERY_STRING variable within the REQUEST object.  I don't see
> this variable there at all.  Can someone explain when/where this
> variable is set/sent .
> 
> 
> Thanks,
> Yosef
> 
> --
> --
> ---
> Yosef Gold ([EMAIL PROTECTED])
> --
> --
> ---
> 
> 
> 
> ___
> Zope maillist  -  [EMAIL PROTECTED]
> 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 )
> 

___
Zope maillist  -  [EMAIL PROTECTED]
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 )




[Zope] Form POST question (and a QUERY_STRING Q.)

2000-06-01 Thread Yosef Gold

I use Zope in the old bobo fashion.  I have a homegrown session
management class that I use.  When a session is idle for a long
while, I ask the user for his password again before allowing him to
continue.  Generally, I then use the URL from the REQUEST object and
RESPONSE.redirect() to send him where he was trying to go after he
reenters his password (he never got there because I gave him a
session timeout screen instead).  This works well except in one
case.  If a user submits a form that uses POST to send it's data, I
am not forwarding the posted data and so I get a Zope error that a
parameter is missing.

Is there a way for me to get the raw posted data and forward that too
via the RESPONSE object?

A seperate small side question.  I thought that all the paremeters
after the "?" in an URL or a submitted form (using GET) are put into
the QUERY_STRING variable within the REQUEST object.  I don't see
this variable there at all.  Can someone explain when/where this
variable is set/sent .


Thanks,
Yosef


---
Yosef Gold ([EMAIL PROTECTED])

---



___
Zope maillist  -  [EMAIL PROTECTED]
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 )