RE: [Zope] How to use RESPONSE.redirect ?

2000-08-17 Thread Stuart Foster

Thanks for the input. I ended up putting the info I needed into the url

dtml-var "someurl?a=blah"

I put it in a method that is usuble from a couple of forms and it seems to
work.

Thanks again.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Kapil
Thangavelu
Sent: Tuesday, August 15, 2000 3:44 PM
To: Stuart Foster
Cc: Zope List
Subject: Re: [Zope] How to use RESPONSE.redirect ?


Stuart Foster Wrote:
 I want to use redirect to call another form passing the current form, how
 can I do that.

 dtml-call RESPONSE.redirect('otherform'+?)


Hi Stuart,

i ran into the same problem a little while ago. i was trying to pass the
user around to the proper displayprocess page(with inputs inplace)
after a logic page that determined where they should go based on their
inputs. IMO, The crux of the problem is that Zope as a web development
platform should include the urlparse lib from the python core more over
this problem and others like it should be remedied i believe by a
standard method of extending the modules in the _ namespace with thread
safe modules that a developer deems nesc. OK enough soap box... i ended
up reimplementing the nesc. functionality in a python method and created
another method to implement complete form insertion in much the same the
style that of some ACS(arsdigita) utiltiy methods do. here they are,
usage examples are included in the code.

of course this solution requires evan simpson's python methods product
be installed on your zope.

Cheers Kapil

method 1 note="depends on method2"
name: url_encode_form_vars
args: namespace
code
# depends on url_encode_vars

try:
vars=namespace['REQUEST'].form
method =  namespace.getitem('url_encode_vars', 0)
return method(vars)
except:
pass



#example call to above
#dtml-call "RESPONSE.redirect(URL1+'?'+url_encode_form_vars(_))"
/code

/method 1


method 2

name: url_encode_vars
args:

code

'''
Code straight from urllib minor
changes to get around assignment to sub_scripts,
access to string module, and namepace issues

expects a dictionary of key value pairs to be encoded

example call

dtml-call
"RESPONSE.redirect(URL1+'?'+url_encode_vars({vars={'squishy':1,
'bad_input':'user=root'}) )"
'''

global always_safe, quote, quote_plus
always_safe = _.string.letters + _.string.digits + '_,.-'

def quote(s, safe = '/'):
global always_safe
safe = always_safe + safe
res = []
for c in s:
if c not in safe:
res.append('%%%02x'%ord(c))
else:
res.append(c)
return _.string.joinfields(res, '')


def quote_plus(s, safe='/'):
global quote
if ' ' in s:
res = []
# replaec ' ' with '+'
l = _.string.split(s, ' ')
for i in l:
res.append(quote(i, safe))
return _.string.join(res, '+')
else:
return quote(s, safe)


def urlencode(dict):
 global quote_plus
 l = []
 for k, v in dict.items():
 k = quote_plus(str(k))
 v = quote_plus(str(v))
 l.append(k + '=' + v)
 return _.string.join(l, '')


return urlencode(vars)
/code
/method 2


___
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] How to use RESPONSE.redirect ?

2000-08-17 Thread Stuart Foster

Thanks for the input.

-Original Message-
From: Curtis Maloney [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 15, 2000 5:59 PM
To: Stuart Foster; Zope List
Subject: Re: [Zope] How to use RESPONSE.redirect ?


On Wed, 16 Aug 2000, Stuart Foster wrote:
 I want to use redirect to call another form passing the current form, how
 can I do that.

 dtml-call RESPONSE.redirect('otherform'+?)

 If I do
 dtml-call RESPONSE.redirect('otherform')
 The current form isn't being passed ?

If you want to pass the form variables, you're in for a fight. (o8
otherwise, you could simply try :

dtml-var "otherform(_.None, _)" instead of a redirect.

If you want to make sure only the correct form vars are passed, you could
flub it with something like:

dtml-call "RESPONSE.redirect('otherform?var1=%svar2=%s' % (var1, var2) )"

If this doesn't help, some more detail on your part might. (o8

 Any ideas..

 TIA
 Stuart


Have a better one,
Curtis.


___
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] How to use RESPONSE.redirect ?

2000-08-16 Thread Kapil Thangavelu

"R. David Murray" wrote:
 
 On Tue, 15 Aug 2000, Kapil Thangavelu wrote:
  #example call to above
  #dtml-call "RESPONSE.redirect(URL1+'?'+url_encode_form_vars(_))"
 
 If your original form submits using the GET method, then QUERY_STRING
 will contain the already URL encoded parameters that the browser
 sent originally.

True. However, the GET method is of limited utility which is not
appropiate for many situations mainly because of size constraints.
Examples, file upload, most anything with text area, stuff with a user
passwd. Granted the above example is something that is going to stick
the whole thing in the URL anyways. But the two python methods can be
used for both GETs and POSTs and if you use the second method
url_encode_vars you can pass it a  dict of only those values you want to
receive in the next page example.
dtml-call "RESPONSE.redirect(url_encode_vars({'var1':var1,
'metoo':metoo}))"

 DTML also has a url_encode format you can use to cause a string to
 be url encoded if it isn't already.  Check the dtml reference.

been there, done that.

DTML fmts are useful only for inserting text into a page or link with a
dtml-var  or the entity syntax. there are no functions that will
encode a var in a pythonish expression("") which is what you need when
doing this with a redirect. 


Cheers

Kapil

___
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] How to use RESPONSE.redirect ?

2000-08-15 Thread Stuart Foster

I want to use redirect to call another form passing the current form, how
can I do that.

dtml-call RESPONSE.redirect('otherform'+?)

If I do
dtml-call RESPONSE.redirect('otherform')
The current form isn't being passed ?

Any ideas..

TIA
Stuart


___
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] How to use RESPONSE.redirect ?

2000-08-15 Thread Jonothan Farr

HTTP is stateless. You'll have to build the entire query string and put it into
your redirect URL.
--jfarr

- Original Message -
From: Stuart Foster [EMAIL PROTECTED]
To: Zope List [EMAIL PROTECTED]
Sent: Tuesday, August 15, 2000 10:19 AM
Subject: [Zope] How to use RESPONSE.redirect ?


 I want to use redirect to call another form passing the current form, how
 can I do that.

 dtml-call RESPONSE.redirect('otherform'+?)

 If I do
 dtml-call RESPONSE.redirect('otherform')
 The current form isn't being passed ?

 Any ideas..

 TIA
 Stuart



___
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] How to use RESPONSE.redirect ?

2000-08-15 Thread Peter Bengtsson

dtml-call "REQUEST.redirect('foo.html')"
Should do it!
or maybe
dtml-call "REQUEST.redirect(strPage+'.html')"


 dtml-call RESPONSE.redirect('otherform'+?)
 
 If I do
 dtml-call RESPONSE.redirect('otherform')
 The current form isn't being passed ?
 
 Any ideas..
 
 TIA
 Stuart
 
 
 ___
 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 )




Re: [Zope] How to use RESPONSE.redirect ?

2000-08-15 Thread Curtis Maloney

On Wed, 16 Aug 2000, Stuart Foster wrote:
 I want to use redirect to call another form passing the current form, how
 can I do that.

 dtml-call RESPONSE.redirect('otherform'+?)

 If I do
 dtml-call RESPONSE.redirect('otherform')
 The current form isn't being passed ?

If you want to pass the form variables, you're in for a fight. (o8
otherwise, you could simply try :

dtml-var "otherform(_.None, _)" instead of a redirect.

If you want to make sure only the correct form vars are passed, you could 
flub it with something like:

dtml-call "RESPONSE.redirect('otherform?var1=%svar2=%s' % (var1, var2) )"

If this doesn't help, some more detail on your part might. (o8

 Any ideas..

 TIA
 Stuart


Have a better one,
Curtis.

___
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] How to use RESPONSE.redirect ?

2000-08-15 Thread Kapil Thangavelu

Stuart Foster Wrote:
 I want to use redirect to call another form passing the current form, how
 can I do that.
 
 dtml-call RESPONSE.redirect('otherform'+?)
 

Hi Stuart,

i ran into the same problem a little while ago. i was trying to pass the
user around to the proper displayprocess page(with inputs inplace)
after a logic page that determined where they should go based on their
inputs. IMO, The crux of the problem is that Zope as a web development
platform should include the urlparse lib from the python core more over
this problem and others like it should be remedied i believe by a
standard method of extending the modules in the _ namespace with thread
safe modules that a developer deems nesc. OK enough soap box... i ended
up reimplementing the nesc. functionality in a python method and created
another method to implement complete form insertion in much the same the
style that of some ACS(arsdigita) utiltiy methods do. here they are,
usage examples are included in the code.

of course this solution requires evan simpson's python methods product
be installed on your zope.

Cheers Kapil

method 1 note="depends on method2"
name: url_encode_form_vars
args: namespace
code
# depends on url_encode_vars

try:
vars=namespace['REQUEST'].form
method =  namespace.getitem('url_encode_vars', 0)
return method(vars)
except:
pass



#example call to above
#dtml-call "RESPONSE.redirect(URL1+'?'+url_encode_form_vars(_))"
/code

/method 1


method 2

name: url_encode_vars
args:

code

'''
Code straight from urllib minor
changes to get around assignment to sub_scripts,
access to string module, and namepace issues

expects a dictionary of key value pairs to be encoded

example call 

dtml-call
"RESPONSE.redirect(URL1+'?'+url_encode_vars({vars={'squishy':1,
'bad_input':'user=root'}) )"
'''

global always_safe, quote, quote_plus
always_safe = _.string.letters + _.string.digits + '_,.-'

def quote(s, safe = '/'):
global always_safe
safe = always_safe + safe
res = []
for c in s:
if c not in safe:
res.append('%%%02x'%ord(c))
else:
res.append(c)
return _.string.joinfields(res, '')


def quote_plus(s, safe='/'):
global quote
if ' ' in s:
res = []
# replaec ' ' with '+'
l = _.string.split(s, ' ')
for i in l:
res.append(quote(i, safe))
return _.string.join(res, '+')
else:
return quote(s, safe)


def urlencode(dict):
 global quote_plus
 l = []
 for k, v in dict.items():
 k = quote_plus(str(k))
 v = quote_plus(str(v))
 l.append(k + '=' + v)
 return _.string.join(l, '')


return urlencode(vars)
/code
/method 2

___
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] How to use RESPONSE.redirect ?

2000-08-15 Thread R. David Murray

On Tue, 15 Aug 2000, Kapil Thangavelu wrote:
 #example call to above
 #dtml-call "RESPONSE.redirect(URL1+'?'+url_encode_form_vars(_))"

If your original form submits using the GET method, then QUERY_STRING
will contain the already URL encoded parameters that the browser
sent originally.

DTML also has a url_encode format you can use to cause a string to
be url encoded if it isn't already.  Check the dtml reference.

--RDM


___
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 )