Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7179259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:06:17+00:00 2026-05-28T17:06:17+00:00

Currently I’m trying to set up a Form to create a News-Item from. The

  • 0

Currently I’m trying to set up a Form to create a News-Item from. The Script works fine so far. Problems arise with the File-Field: As soon as I try to access the file via request.form[‘pub-core-cover’] I get an “Module AccessControl.ZopeGuards, line 67, in guarded_getitem”.

I was advised to use a HelperView to bypass RestrictedPython which seems to be the issue here. This is pretty difficult for me due to the fact I have not developed an add-on product so far. Somehow I’m wondering as well if there is another possibility to make the File-Field feature in PFG work again within RestrictedPython. Otherwise the file-field becomes somehow obsolet.

CustomScript-Adapter (don’t mind the german comments):

form = request.form

# ID des Zielverzeichnisses ist publikationen
target = context.publikationen

# Einmalige ID für das neu zu erstellende Objekt erstellen anhand des Datums + Uhrzeit
from DateTime import DateTime
uid = str(DateTime().millis())

# Titel und ID festlegen und damit News-Objekt erzeugen (Titel + Beschreibung)
title = form['author-prename'] + " " + form['author-surname']
desc = form['pub-core-title'] + " " + form['pub-core-subtitle']

target.invokeFactory("News Item", id = uid, title = title.upper(), description = desc, image = form['pub-core-cover'])

# Objekt aufspüren und ContentType festlegen
obj = target[uid]
obj.setContentType('text/html')

# Inhalt des News-Items setzen
obj.setText("<p>"+ form['pub-core-description'] +"<br /><br />Veröffentlicht: "+ form['pub-tech-year'] +"<br />ISBN: "+ form['pub-tech-isbn'] +"<br />Preis: "+ form['pub-tech-price'] +"<br />" + form['pub-tech-pages'] + " Seiten, " + form['pub-tech-binding'] + "</p>")

# Objekt veröffentlichen ohne den Initial-State im Workflow zu verändern
obj.portal_workflow.doActionFor(obj, 'publish', comment='Dieser Inhalt wurde über den PythonScriptAdapter von PloneFormGen automatisch publiziert.')

# Content reindexieren, um das neue Objekt anzuzeigen
obj.reindexObject()

Traceback:

Traceback (innermost last):
  Module ZPublisher.Publish, line 127, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 47, in call_object
  Module Products.CMFFormController.FSControllerPageTemplate, line 91, in __call__
  Module Products.CMFFormController.BaseControllerPageTemplate, line 26, in _call
  Module Products.CMFFormController.FormController, line 384, in validate
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 47, in call_object
  Module Products.CMFFormController.FSControllerValidator, line 58, in __call__
  Module Products.CMFFormController.Script, line 145, in __call__
  Module Products.CMFCore.FSPythonScript, line 130, in __call__
  Module Shared.DC.Scripts.Bindings, line 324, in __call__
  Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec
  Module Products.PythonScripts.PythonScript, line 344, in _exec
  Module script, line 20, in fgvalidate_base
   - <FSControllerValidator at /breyer_verlag/fgvalidate_base used for /breyer_verlag/publikationen/publikation-hinzufuegen>
   - Line 20
  Module Products.PloneFormGen.content.form, line 566, in fgvalidate
  Module Products.PloneFormGen.content.form, line 607, in fgProcessActionAdapters
  Module Products.PloneFormGen.content.customScriptAdapter, line 187, in onSuccess
  Module Products.PloneFormGen.content.customScriptAdapter, line 218, in executeCustomScript
  Module Shared.DC.Scripts.Bindings, line 324, in __call__
  Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec
  Module Products.PythonScripts.PythonScript, line 344, in _exec
  Module script, line 27, in create-publication
   - <PythonScript at /breyer_verlag/publikationen/publikation-hinzufuegen/create-publication/create-publication>
   - Line 27
  Module AccessControl.ZopeGuards, line 67, in guarded_getitem
KeyError: 'pub-core-cover'

I had no difficulties using an pretty similar code in Plone3. I would appreciate any help that gets me out of my misery.

Edit:
By the way:
Plone 4.05
PFG 1.72a

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:06:18+00:00Added an answer on May 28, 2026 at 5:06 pm

    As vangheem stated it is not a RestrictedPython-Problem put has to do how PloneFormGen handles the data field. It is important to add _file to the variable name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am trying to use a bunch of custom perl modules, test.pm as
Currently after my form has passed validation it forwards to an html page. I
Currently I'm trying to parse some html and return an array with the values
Currently I am borrowing java.math.BigInteger from the J# libraries as described here . Having
Currently using Oracle/BEA/Plumtree ALUI Portal 6.1, and am trying to display a client's IP
currently I am trying to replace a simple HTML element to alert the user
Currently, I have this selector: .form .mid td p:last-child:not(:only-child) { margin-bottom: 0; } It's
Currently I have two projects that are separate from one another. The first is
Currently, these are my codes to create a picker view genderPicker = [[UIPickerView alloc]
Currently I am trying to make my app available for iOS4, to increase the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.