[Zope] python script containing userid and ip address help

Jason Leach jason.leach at gmail.com
Wed Oct 27 16:53:54 EDT 2004


After re-reading I see you already have the info. I still think it
will need to be an external method since you can't import md5 into
Zope (security).  (Use your digest funciton call if you like.)

####### External Method #########
import md5, string

def _formatHex(str):
    "Generate a MD5 string's HEX code."

    d = map(None, str)
    d = map(ord, d)
    d = map(lambda x:"%02x" % x, d)

    return string.join(d, "")
#

add the external method, and call it in your PythonScript (something like):

myHash = container.mhtools_getHexHash('%s%s%s' % (member.getProperty('uid'),
REQUEST['REMOTE_ADDR'],  passphrase))

then return a string to your ZPT to fill in the link:

return a string as your url:
     return 'http://url?action=sso:portal&userid=%s&session=%s'
% (userid,    myHash)

This is just to give you the idea.  It's not the actual code you shoud
use, but hopfully it helps get the gears truning.

Jason.


More information about the Zope mailing list