Skip to main content

Introduction

This package was created after encountering a problem with the plone.app.users.userdataschema.IUserDataSchemaProvider utilty override. As this utility is unnamed, you can override it only once in all packages. We had to add extra fields on our personal-information form from various packages, so this package was created with the idea of managing multiple sources overrides of the personal-information form and properties.

This eggs allows to override as many times as you want the personal preferences of your users by adding extra fields by using adapters. By adding extra fields, you can specify your own getters & setters if you don’t want your field to be manage as a user property. You’ll also be able to add comptabile widgets for the personal preferences’ form fields.

The docs directory contains all necessary steps about server configuration before to install this egg. These documents can be distributed separately under the specified license in each of them.

These package was initiated by Quadra Informatique <plone@quadra-informatique.fr>.

How-to

There are three interfaces you need to know:

collective.customizablePersonalizeForm.adapters.interfaces.IExtendedUserDataSchema(Interface):

def getSchema(self,):

collective.customizablePersonalizeForm.adapters.interfaces.IExtendedUserDataPanel(Interface):

def getProperties(self,):

collective.customizablePersonalizeForm.adapters.interfaces.IExtendedUserDataWidgets(Interface):

def getWidgets(self,):

An adapter providing the IExtendedUserDataSchema allows to add additional fields by returning an Interface through its getSchema method.

Carefull ! If you ever add a field on your form, you’ll also need to declare a property with the same name as your field, allowing you to get and set your property. That’s why we use IExtendedUserDataPanel. An adapter providing this interface will return a list of strings through the getProperties method. These strings are the names of the fields provided by your custom interface, like ‘portrait’ or ‘fullname’. By default the getters and setters of your fields will use Plone’s member.getProperty and member.setProperty methods, using the memberdata to store the values. If you ever need to use your own getters and setters, you can return a dict instead of the name of your field, using this format:

{‘name’ : ‘your_field_name’, ‘getter’: your_own_getter_method, ‘setter’: your_own_setter_method}

Simple Override Example

A simple interface providing our field:

class ITestAdditionalDataSchema(Interface):

test_field = schema.Bool(

title=_(u’label_test_field_title’, default=u’Test field’), description=_(u’label_test_field_description’, default=u’’), required=False, )

A simple adapter that adapts the context and request, returning our interface

class TestSchemaAdapter(object):

adapts(object, IBrowserRequest) implements(IExtendedUserDataSchema)

def __init__(self, context, request):

self.context = context self.request = request

def getSchema(self):

return ITestAdditionalDataSchema

Now we create an adapter that will declare a ‘test_field’ property, we didn’t specify a getter and setter so this property will act as a memberdata property (be sure to declare it via memberdata_properties.xml)

class TestPropertiesAdapter(object):

adapts(object, IBrowserRequest) implements(IExtendedUserDataPanel)

def __init__(self, context, request):

self.context = context self.request = request

def getProperties(self):

return [‘test_field’]

Let’s susbscribe to the collective.customizablePersonalizeForm’s interfaces to provide the personal-information form with our field

<adapter factory=”.adapters.TestSchemaAdapter”

name=”test.ExtraField”/>

<adapter factory=”.adapters.TestPropertiesAdapter”

name=”test.ExtraProperties”/>

Congratulations, a simple boolean field named ‘test_field’ should now be displayed in your form.

Custom Widgets

You may want to use a widget for your field. It can be done through the IExtendedUserDataWidgets interface. All you have to do is mapping a field id with a valid custom_widget factory like the following example.

class TestWidgetAdapter(object):

adapts(object, IBrowserRequest) implements(IExtendedUserDataWidgets)

def __init__(self, context, request):

self.context = context self.request = request

def getWidgets(self):
return [{‘field’: ‘test_field’, ‘factory’CheckBoxWidget},

]

<adapter factory=”.adapters.TestWidgetAdapter”

name=”test.ExtraWidgets”/>

Your test_field will now use the widget factory you declared in the getWidgets method. You can also override the default Plone fields widgets using this method if you ever need to.

Changelog

2.0 (2011-09-07)

  • Now working for Plone 4.x [jstegle]

  • Added 3 interfaces for subscription, provider schema, properties and widgets overrides [jstegle]

  • Overrides the default personal-information to manage widget customization [jstegle]

  • Overrides the default IUserDataSchemaProvider [jstegle]

  • Overrides the account-macro view to manage FileUpload fields that handles pictures [jstegle]

  • Added isImage constraint on the portrait field, allowing only images to be uploaded [jstegle]

  • Added tests and examples [jstegle]

1.0.1 (2011-05-04)

  • Added documentation [jstegle]

1.0 (2011-04-XX)

  • Added viewletmanager for the personalize_form [jstegle]

  • Added adaptor interfaces for validators and actions [jstegle]

  • Added self personalize_form, validation and action scripts [jstegle]

  • Works for Plone 3.x [jstegle]

Release files for collective.customizablePersonalizeForm 2.0

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

Source distribution (sdist)

Source distribution for collective.customizablePersonalizeForm 2.0
File Size Uploaded
collective.customizablePersonalizeForm-2.0.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for collective.customizablePersonalizeForm 2.0
File Interpreter ABI Platform
collective.customizablePersonalizeForm-2.0-py2.6.egg Legacy Egg format - - Details

Total release size: 43.2 kB

Release files / collective.customizablePersonalizeForm-2.0.tar.gz

Download URL collective.customizablePersonalizeForm-2.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4f89082e248cbd779073be4b6db05c3dc9810e3c459b1659d2cfcc7e86cdf1cb
BLAKE2b-256 checksum
How to use checksums
b0e87e30b637e0e92c5d3d40d814a41a96d195c3a6559efd6ac28b01d2e974da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / collective.customizablePersonalizeForm-2.0-py2.6.egg

Download URL collective.customizablePersonalizeForm-2.0-py2.6.egg
Size 29.5 kB
Tags Egg
SHA-256 checksum
How to use checksums
41d04687afcc79e62cb86f9b8ef2f9a7718e6f6db24db8359316f443e1938703
BLAKE2b-256 checksum
How to use checksums
fbd84434316e4b494df715e0907233d9c29c988c3076f1c7c4fc3c2ea487d0f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

2.0 This release

2 release files

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