> 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

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')">

Great thanks to all!!!



  Sorry, a site error occurred.<p>
Traceback (innermost last):
  File D:\zope\251\lib\python\ZPublisher\Publish.py, line 150, in
  File D:\zope\251\lib\python\ZPublisher\Publish.py, line 114, in publish
  File D:\zope\251\lib\python\Zope\__init__.py, line 159, in
    (Object: zzzkusebni)
  File D:\zope\251\lib\python\ZPublisher\Publish.py, line 98, in publish
  File D:\zope\251\lib\python\ZPublisher\mapply.py, line 88, in mapply
    (Object: skript)
  File D:\zope\251\lib\python\ZPublisher\Publish.py, line 39, in call_object
    (Object: skript)
  File D:\zope\251\lib\python\Shared\DC\Scripts\Bindings.py, line 252, in
    (Object: skript)
  File D:\zope\251\lib\python\Shared\DC\Scripts\Bindings.py, line 283, in
    (Object: skript)
  File D:\zope\251\lib\python\Products\PythonScripts\PythonScript.py, line
302, in _exec
    (Object: skript)
    (Info: ({'script': &lt;PythonScript instance at 02A97E50&gt;, 'context':
&lt;Folder instance at 0295ADA0&gt;, 'container': &lt;Folder instance at
0295ADA0&gt;, 'traverse_subpath': []}, ('YWxla2liYW5nb0B6dWcuY3o',), {},
  File Script (Python), line 19, in skript
  File D:\zope\251\lib\python\AccessControl\ZopeGuards.py, line 151, in
ImportError: import of &quot;Products.PythonScripts.Utility&quot; is

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to