All,
Here is another interesting issue that I have encountered while trying to process cookies in Zope.
On a different app. server I have a Java class which generates an encrypted cookie when a user logs into the site. When the user navigates over to my Zope site, I wish to check the value of the UID. I do this by retrieving the cookie within the following snippet of DTML:
<dtml-if "REQUEST.cookies.has_key('UID')"> <dtml-call "REQUEST.set('cookie', REQUEST.cookies.values())"> <dtml-var "validateCookie(REQUEST, REQUEST['REMOTE_ADDR'])"> </dtml-if>
This DTML calls a DTML method (validateCookie) which in turn is calling the following External Python Method:
import xmlrpclib, base64
def validateUID(self, REQUEST, ipaddr): cookie = REQUEST.get('cookie') servlet = xmlrpclib.Server("http://salesnet-dev.appl.ge.com/geaservlet/X mlRpcTest") cookie = repr(cookie) cookie = cookie[2:] cookie = cookie[:-2] return servlet.validateCookie.check(cookie, ipaddr)
This XML-RPC call attempts to invoke the Java decrypt method. Herein lies the problem:
Upon investigation of the value contained in the UID cookie, Zope returned the following: \316\313\321\310\316\315\314\311\321\312\316\317\317\223\310\321\315\317\3 13\316\317'
If I print out each character created during the Java encrypt method, the following values are returned:
\206\203\209\200\etc.etc.
A colleague of mine pointed out that Zope was returning the values in Octal rather than decimal.
Is this behavior by design? Is there another mechanism I can use to retrieve the raw cookie value before Zope places it in a dictionary? Rather than code a string parsing routine in Java, are there any suggestions as to how to convert each character back to decimal, or obtain the string prior to being converted into octal?
Once again, I appreciate the assistance/responses. Everyone on this group has been wonderful to interact with.
-Brian
On Thu, 16 Mar 2000 17:19:40 -0500, "Pearson, Brian Edward (GEA, 056278)" <BRIAN.PEARSON@APPL.GE.COM> wrote: <snip problem details>
A colleague of mine pointed out that Zope was returning the values in Octal rather than decimal.
Is this behavior by design?
You tell us - your code is performing the conversion ;-)
Is there another mechanism I can use to retrieve the raw cookie value before Zope places it in a dictionary?
cookie = REQUEST.get('cookie')
You had the raw cookie in the string variable called 'cookie' at this point in your source. The next line creates the octal.
cookie = repr(cookie)
The entry in the python manual for the repr function says.... <quote> Return a string containing a printable representation of an object. This is the same value yielded by conversions (reverse quotes). It is sometimes useful to be able to access this operation as an ordinary function. For many types, this function makes an attempt to return a string that would yield an object with the same value when passed </quote> Python 1.5.2 (#0, Oct 11 1999, 09:59:20) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
print 'hello world' hello world print repr('hello world\n') 'hello world\012' * notice the quotes and octal
Hope this helps, Toby Dickenson tdickenson@geminidataloggers.com
participants (2)
-
Pearson, Brian Edward (GEA, 056278) -
Toby Dickenson