[Zope-dev] Import Libraries into Python Script
Brian Lloyd
brian@digicool.com
Thu, 15 Feb 2001 10:05:18 -0500
This needs to be documented (and made a little easier), but
heres a quick primer:
o Create a new directory in your 'Products' directory
(called ModuleAssertions or something like that - the
name is unimportant).
o Create an '__init__.py' file in the new directory.
o Add module assertions like the example below to __init__.py:
# Site-wide module security assertions
from AccessControl.SecurityInfo import ModuleSecurityInfo
import string
def allow_module(module_name):
module = __import__(module_name)
sec_info=ModuleSecurityInfo(module)
sec_info.setDefaultAccess(1)
sec_info.apply(module.__dict__)
for part in string.split(module_name, '.')[1:]:
module=getattr(module, part)
sec_info=ModuleSecurityInfo(module)
sec_info.setDefaultAccess(1)
sec_info.apply(module.__dict__)
# Allow access to base64 module
allow_module('base64')
# Allow access to imaplib
allow_module('imaplib')
o Restart Zope
Brian Lloyd brian@digicool.com
Software Engineer 540.371.6909
Digital Creations www.digicool.com
> -----Original Message-----
> From: zope-dev-admin@zope.org [mailto:zope-dev-admin@zope.org]On Behalf
> Of Chris Withers
> Sent: Thursday, February 15, 2001 6:49 AM
> To: zope-dev@zope.org
> Subject: [Zope-dev] Import Libraries into Python Script
>
>
> Hi,
>
> What's the 'approved' way of validating standard python modules
> so they can be
> imported in Python Scripts?
>
> I want to import imaplib but can't find out how :-(
>
> cheers,
>
> Chris
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )
>