importing md5 module in python script
hi! i want to use the md5 module, i made a folder Imports, and a file __init__.py in it, containing: from Products.PythonScripts.Utility import allow_module, allow_class from AccessControl import ModuleSecurityInfo, ClassSecurityInfo from Globals import InitializeClass allow_module("md5") now i can import md5, and use m=md5.new(), but still cant use m.hexdigest(), it keeps on giving 401 unauthorized replies ... i tried to add ModuleSecurityInfo('md5').declarePublic('hexdigest') to __init__.py but didnt help. what am i doing wrong? thanks, k
This is because the object returned by new() is unprotected (you can't make any security assertions on things of its type because it is returned only by a factory method) and unprotectable (it is a C-defined Python object rather than a Python-defined Python object). This is Zope protecting you from yourself in a cheerfully annoying way. ;-) Workaround: use an external method instead. HTH, - C On Mon, 2002-10-21 at 00:35, keo wrote:
hi!
i want to use the md5 module,
i made a folder Imports, and a file __init__.py in it, containing:
from Products.PythonScripts.Utility import allow_module, allow_class from AccessControl import ModuleSecurityInfo, ClassSecurityInfo from Globals import InitializeClass
allow_module("md5")
now i can import md5, and use m=md5.new(), but still cant use m.hexdigest(), it keeps on giving 401 unauthorized replies ...
i tried to add ModuleSecurityInfo('md5').declarePublic('hexdigest') to __init__.py but didnt help.
what am i doing wrong?
thanks,
k
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hello Chris, Monday, October 21, 2002, 7:07:04 AM, you wrote: CM> This is because the object returned by new() is unprotected (you can't CM> make any security assertions on things of its type because it is CM> returned only by a factory method) and unprotectable (it is a C-defined CM> Python object rather than a Python-defined Python object). This is Zope CM> protecting you from yourself in a cheerfully annoying way. ;-) CM> Workaround: use an external method instead. thanks for your answer. is there a way of using md5 anyway in scripts? or do i really have to use external methods? (thats not so easy;() or get a purely python defined object from somewhere, and make a product from it ... or anything ... thanks, k CM> HTH, CM> - C CM> On Mon, 2002-10-21 at 00:35, keo wrote:
hi!
i want to use the md5 module,
i made a folder Imports, and a file __init__.py in it, containing:
from Products.PythonScripts.Utility import allow_module, allow_class from AccessControl import ModuleSecurityInfo, ClassSecurityInfo from Globals import InitializeClass
allow_module("md5")
now i can import md5, and use m=md5.new(), but still cant use m.hexdigest(), it keeps on giving 401 unauthorized replies ...
i tried to add ModuleSecurityInfo('md5').declarePublic('hexdigest') to __init__.py but didnt help.
what am i doing wrong?
thanks,
k
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
CM> _______________________________________________ CM> Zope maillist - Zope@zope.org CM> http://lists.zope.org/mailman/listinfo/zope CM> ** No cross posts or HTML encoding! ** CM> (Related lists - CM> http://lists.zope.org/mailman/listinfo/zope-announce CM> http://lists.zope.org/mailman/listinfo/zope-dev ) -- don't believe everything you think
The only way to do it is to "wrap" an MD5 object in someting that also returned a wrapped object from new() in a Product. At that point, it's much easier to just write an external method or ditch the whole "through the web" thing and write what you're doing in a Product. So "no" is the short answer, sorry. ;-) - C On Mon, 2002-10-21 at 07:43, 3205 5361 1215 9784 wrote:
Hello Chris,
thanks for your answer.
is there a way of using md5 anyway in scripts? or do i really have to use external methods?
(thats not so easy;()
or get a purely python defined object from somewhere, and make a product from it ... or anything ...
thanks,
k
participants (3)
-
3205 5361 1215 9784 -
Chris McDonough -
keo