本文を読み飛ばす

ZopeとPIL

とにかく、PILの実行を許可するのが大変。 今でも新しい関数を使うときは エラーがでそうでドキドキです。

とりあえず、今日のProducts/MyModule/init.pyを書いておく。

家のZopeは公開してないからいいか。

ちなみにreとStringIOもいれてます。

from Products.PythonScripts.Utility import allow_module, allow_class
from AccessControl import ModuleSecurityInfo, ClassSecurityInfo, allow_type
from Globals import InitializeClass


# 使用を許可したいモジュールを列挙します。
ModuleSecurityInfo("re").declarePublic("compile", "findall", "match",
"search", "split", "sub", "subn", "error",
"I", "IGNORECASE", "L", "LOCALE", "M", "MUTILINE",
"S", "DOTALL", "X", "VERBOSE")
import re
allow_module("re")
allow_type(type(re.compile("")))
allow_type(type(re.match("x","x")))

allow_module("PIL")
#from Image import *
from PIL import Image, ImageDraw

#allow_module("Image")
#allow_module("ImageDraw")
#allow_module("ImageFile")

#allow_type( type( Image.new('1',(1,1)) ) )
allow_class( Image )
allow_class( Image.Image )
allow_class( ImageDraw.ImageDraw )
allow_class( ImageDraw.Draw )

allow_module("StringIO")
from StringIO import *
allow_class( StringIO )

コメント

Comments powered by Disqus
宣伝: