[Zope] Formulator - How to set up security to create fields inside a python script

Gabriel Genellina gagenellina@softlab.com.ar
Mon, 18 Nov 2002 14:25:56 -0300


Hi

I want to create and use a Formulator field inside a Python Script. That 
is, by example:

	from Products.Formulator.StandardFields import StringField
	MyField = StringField('alias', title='Alias', description='Alias de la 
columna')

(The idea is to dynamically create and manage the field list).

But I was unable to find out the right security assertions. I've tried (in 
the __init__.py module of another product):

	allow_module('Products.Formulator.StandardFields')

or

	ModuleSecurityInfo('Products').declarePublic('Formulator')
	ModuleSecurityInfo('Products.Formulator').declarePublic('StandardFields')
	ModuleSecurityInfo('Products.Formulator.StandardFields').declarePublic("StringField")

or even more esoteric approaches, but I always end with this security 
violation.
 >From the stupid_log_file:

PROBLEM(100) Zope Security Policy '<Python Method object at 01956728>' 
passed as roles during validation of 'CheckBoxField' is not a sequence.

This is generated by the validate() method in ZopeSecurityPolicy. As far as 
I can tell, the "roles" argument is expected to be None or a list,
not a Python Method. I have no idea of what method it is, or why is it used 
instead of the true role. (The Zope security machinery is far
beyond my current Python knowledge and it's a kind of magic for me :) ).

Any help, please?

Gabriel Genellina
Softlab SRL