This is one of those "if it doesn't work, don't do it" cases. Don't use
external methods. They're an anachronism left over from when it was more
difficult to integrate Python with Zope.

Instead, use a browser view. If you use ZopeSkel to create the basic
skeleton package, it's really just as easy as doing an external method, and
will cause you a lot less trouble.


On Thu, Nov 22, 2012 at 12:21 PM, Eggert Ehmke <[email protected]>wrote:

> Hello Steve,
>
> thanks.
>
> Am Mittwoch, 21. November 2012, 21:58:02 schrieben Sie:
> > http://plone.org/documentation/faq/restricted-python-scripts
>
> I understand I have to use external methods. So I installed an external
> method
> in the form folder. The test function in the ZMI works. But now when I open
> the PFG form in Plone (even without active validator refering to the
> external
> method) I get this: (see below). Similar errors have been reported here:
> http://plone.293351.n2.nabble.com/PloneFormGen-Error-when-External-Method-
> added-to-a-form-folder-within-ZMI-td315636.html
> Is there a solution?
>
> Traceback (innermost last):
>   Module ZPublisher.Publish, line 126, in publish
>   Module ZPublisher.mapply, line 77, in mapply
>   Module ZPublisher.Publish, line 46, in call_object
>   Module Products.CMFFormController.FSControllerPageTemplate, line 91, in
> __call__
>   Module Products.CMFFormController.BaseControllerPageTemplate, line 31, in
> _call
>   Module Shared.DC.Scripts.Bindings, line 322, in __call__
>   Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
>   Module Products.CMFCore.FSPageTemplate, line 237, in _exec
>   Module Products.CMFCore.FSPageTemplate, line 177, in pt_render
>   Module Products.PageTemplates.PageTemplate, line 79, in pt_render
>   Module zope.pagetemplate.pagetemplate, line 113, in pt_render
>    - Warning: Macro expansion failed
>    - Warning: <type 'exceptions.KeyError'>: 'macro'
>   Module zope.tal.talinterpreter, line 271, in __call__
>   Module zope.tal.talinterpreter, line 343, in interpret
>   Module zope.tal.talinterpreter, line 858, in do_defineMacro
>   Module zope.tal.talinterpreter, line 343, in interpret
>   Module zope.tal.talinterpreter, line 583, in do_setLocal_tal
>   Module zope.tales.tales, line 696, in evaluate
>    - URL:
> file:/srv/buildout/buildout-cache/eggs/Products.PloneFormGen-1.7.4-
> py2.7.egg/Products/PloneFormGen/skins/PloneFormGen/fg_base_view_p3.cpt
>    - Line 1, Column 0
>    - Expression: <PythonExpr here.fgFields(request)>
>    - Names:
>       {'container': <PloneSite at /testportal>,
>        'context': <FormFolder at /testportal/formular>,
>        'default': <object object at 0xb7d4e7e0>,
>        'here': <FormFolder at /testportal/formular>,
>        'loop': {},
>        'nothing': None,
>        'options': {'args': (),
>                    'state':
> <Products.CMFFormController.ControllerState.ControllerState object at
> 0xcf3548c>},
>        'repeat': <Products.PageTemplates.Expressions.SafeMapping object at
> 0xbed22ac>,
>        'request': <HTTPRequest,
> URL=http://www.myurl.de/formular/fg_base_view_p3>,
>        'root': <Application at >,
>        'template': <FSControllerPageTemplate at /testportal/fg_base_view_p3
> used for /testportal/formular>,
>        'traverse_subpath': [],
>        'user': <SpecialUser 'Anonymous User'>}
>   Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__
>    - __traceback_info__: here.fgFields(request)
>   Module PythonExpr, line 1, in <expression>
>   Module Products.PloneFormGen.content.form, line 463, in fgFields
>   Module Products.PloneFormGen.content.form, line 347, in _getFieldObjects
> AttributeError: portal_type
>
>
> > On Wed, Nov 21, 2012 at 3:18 PM, Eggert Ehmke <[email protected]
> >wrote:
> > > I have a PloneFormGen form with a file upload field. Assigned to the
> > > upload
> > > field I have a validator:
> > > python:folder.validator(value)
> > > In the ZMI I added a Python script to the PFG folder with name
> validator.
> > > In
> > > this script I try to determine the file content. The script works when
> I
> > > create simple test results. But when I add this import:
> > > from zope.contenttype import guess_content_type
> > > and call this function, running the script generates the error:
> > >
> > > Insufficient Privileges
> > > You do not have sufficient privileges to view this page. If you believe
> > > you
> > > are receiving this message in error, contact the site administration.
> > >
> > > I even have the Proxy role Manager assigned to the script, does not
> make a
> > > difference.
> > >
> > > This is with Plone 4.2.2, PFG 1.7.4, Products.Archetypes = 1.8.3
> > > Eggert
> > >
> > > _______________________________________________
> > > Setup mailing list
> > > [email protected]
> > > https://lists.plone.org/mailman/listinfo/plone-setup
>
_______________________________________________
Setup mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-setup

Reply via email to