Jaroslav Lukesh wrote:
>> From: Andreas Jung [mailto:[EMAIL PROTECTED]
>>> import cStringIO
>>> import mimetools
>>> import binascii
>>> binascii.a2b_base64('YWxla2liYW5nb0B6dWcuY3o=\n')
>>>
>>> in commandline python works OK.
>>>
>> Move such code inside a PythonScript..such code does not belong into
>> DTML..
>> it just bad style.
>
> I was try this PythonScript (parameter: xemail):
>
> import cStringIO
> import mimetools
> from Products.PythonScripts.Utility import allow_module
> allow_module("base64")
>
> xe=xemail + '=\n'
> print xe.decode('base64')
> return printed
>
> ... but it give me import error (bottom of that page).
>
> So I try to write External method. Many rewrites, many tries, here are
> working one - note that allow_module does not work:
>
>
> import binascii
> def preved64(xemail):
> xe=xemail + '=\n'
> return binascii.a2b_base64(xe)
>
>
> Using: <dtml-var "externalmethodname('kjsdjhf_base64_lkskd')">
I'd just use "base64encodedstring".decode("base64")
since this is part of the unicode api (see "rot13"
and such for other excotic "encodings")
Regards
Tino
_______________________________________________
Zope maillist - [email protected]
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )