danieltellez | 29 Oct 11:21
Picon
Gravatar

how to create a directory programatically

Bonjour!!

I'm trying to create a directory programatically, but i'm getting errors 
when I try to use the _setObject() method.
This is my code:

dtool = context.portal_directories

dir = ZODBDirectory( ... )

# here i assert that ZODBDirectory is created correctly

dtool._setObject(dir.getId(),dir)

When I comment _setObject method, all runs correctly. But when I 
discomment it, I get the next error:

Traceback (innermost last):

  Module ZPublisher.Publish, line 115, in publish

  Module ZPublisher.mapply, line 88, in mapply

  Module ZPublisher.Publish, line 41, in call_object

  Module Products.CMFCore.FSPythonScript, line 108, in __call__

  Module Shared.DC.Scripts.Bindings, line 311, in __call__

  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec

  Module Products.CMFCore.FSPythonScript, line 142, in _exec

   - <FSPythonScript at /aselex/aselex_creardirectorio>

RuntimeError: PortalASELEX/skins/aselex_default/aselex_creardirectorio.py has errors.

 /home/conchimartin/instances/development/Products/CMFCore/FSPythonScript.py(142)_exec()

-> raise RuntimeError, '%s has errors.' % self._filepath

When I put this line nor even logger asserts are printed.

I've tried putting the next lines in a AllowModules script:

from AccessControl import ModuleSecurityInfo

ModuleSecurityInfo('Products.CPSDirectory.ZODBDirectory').declarePublic('ZODBDirectory')
ModuleSecurityInfo('Products.CPSDirectory.CPSDirectoryTool').declarePublic('_setObject')

... Nothing.

Of course, I've tried to use manage_addCPSDirectory... but i don't think 
this was a great idea...

Any smart people out there that could help me ?? Many thanks in advance.

--

-- 
Daniel Téllez Sabán. 
Director Dpto I+D.
Yerbabuena Software. 
danieltellez@...
http://www.yerbabuena.es
Tlf/Fax: 902 995 246 Móvil: 615 051 283

_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel


Gmane