Skip to main content

Introduction

pfg.drafts adds support for Plone users to save copies of PloneFormGen forms in progress and restore the saved values later. This removes the need for users to fill out a lengthy form in one sitting.

The package adds a new display option for Form Folders, called “Form View with Drafts”. If selected, a message is shown prompting the user to save a draft of the form. (It also adds an additional button at the bottom of the form which does the same thing.) If the user clicks this, they are presented with a registration form to create a site account with which to associate the saved data. After registration, the form is saved.

When the user returns to the form, if logged in, the form will be repopulated with the saved values automatically. If logged out, the user can click a link to log in and restore their values. Then the form can be submitted normally when the form is complete.

Compatibility

pfg.drafts has been tested with Plone 4 and PloneFormGen 1.6.0.

Installation

  1. Add pfg.drafts to your buildout, and activate it via the Plone Add-ons control panel.

  2. Go to the Security control panel and turn on “Enable self-registration” and “Let users select their own passwords”. (If the latter is off, users will not be able to immediately register. You may want to add captcha to the registration form to prevent mechanical registrations.)

  3. Go to the form for which you want to enable drafts, and change its display layout to “Form View with Drafts”, using the Display menu.

Implementation Details

Drafts are stored in a BTree in a custom tool (portal_fg_drafts), keyed by form UID and user id.

To save form values, Javascript changes the action of the form to go to the custom @@fg_save_draft view, which writes the values to portal_fg_drafts. Any FileUpload objects are marshalled specially into a pickleable FakeFieldStorage object.

When the form is visited, the custom display template (pfg_draft_view.cpt) calls the portal_fg_draft tool’s retrieveDraft method to repopulate the request form with any saved data for the current form and user. Values in the request take precedence over values from the draft, so the saved values won’t clobber new values after a validation error.

When the form is submitted, it is processed via the custom pfg_draft_validate.vpy script. This augments the submitted values with values from the draft (such as fileuploads that were saved but cannot be repopulated) and then processes the form normally. If the form passes validation, the saved draft (if any) is deleted from the portal_fg_drafts tool.

Credits

pfg.drafts was created by Web Collective and David Glick. Thanks to Bryan Wilson and Fulvio Casali.

Changelog

1.1.2 (2011-01-12)

  • Add registerClass to declare an add permission for PFGDraftStorage so that it can be pasted. [davisagli]

1.1.1 (2011-01-06)

  • Fix missing import. [davisagli]

1.1 (2011-01-06)

  • Make it possible for Managers to load another user’s draft for debugging, by adding debug_user=[username] to the query string. If a draft loaded in this way is submitted, the draft is not removed from the draft storage. [davisagli]

1.0.1 (2011-01-06)

  • Make sure file uploads don’t get lost when a draft is saved a second time. [davisagli]

  • Fill the correct slot to inject javascript for main_templates based on the classic Plone theme instead of sunburst. [davisagli]

1.0 (2010-12-20)

  • Fix error in including widget javascript. [davisagli]

1.0b1 (2010-12-09)

  • Initial release

Metadata

Release files for pfg.drafts 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pfg.drafts 1.1.2
File Size Uploaded Provenance Actions
pfg.drafts-1.1.2.zip 29.1 kB Without provenance Details for pfg.drafts-1.1.2.zip

Release files / pfg.drafts-1.1.2.zip

Download URL pfg.drafts-1.1.2.zip
Size 29.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7d413e2fd0b27aa8327f655d79f31e06928f87538bbf10d75faf010f4eda978e
BLAKE2b-256 checksum
How to use checksums
3e13798cde04a70de2c3828b932de0cac5dae1ca876733ce811e11339c72a1ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pfg.drafts 1.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page