dexterity custom edit form for fieldset of inherited schema

classic Classic list List threaded Threaded
7 messages Options
khink khink
Reply | Threaded
Open this post in threaded view
|

dexterity custom edit form for fieldset of inherited schema

I'm trying to modify an edit form for our dexterity IMember type. The
field to modify is 'email', which is definied to be on another fieldset
and inherited from the IUserAdministration schema:

class IUserAdministration(form.Schema):
     email = schema.TextLine(
         title=_(u"email_form_label"),
         description=_(u"moderators_email_form_help"),
         min_length=5,
         max_length=80,
         required=False,
     )
     form.fieldset(
             'administrative',
             label=_(u'administrative_form_title',
default='Administrative'),
             fields=('disabled', 'email', 'override_email',
                     'password', 'override_password',),
         )
interface.alsoProvides(IUserAdministration, IFormFieldProvider)

class IMember(form.Schema, IProfile, IUserAdministration):
     """Type for members
     """
     title = schema.TextLine(
         title=_(u"fullname_form_label"),
         description=_(u"fullname_form_help"),
     )

I tried the idea at
http://collective-docs.readthedocs.org/en/latest/content/dexterity.html#custom-edit-form:

from five import grok
from plone.directives import dexterity

class EditForm(dexterity.EditForm):

     grok.context(IUserAdministration)

     def updateWidgets(self):
         """ """
         dexterity.EditForm.updateWidgets(self)

         # XXX: customize widgets here

But in updateWidgets, self.widgets.items() lists only the widgets for
IProfile, not those for IUserAdministration.

Changing the order of the inheritance (class IMember(form.Schema,
IUserAdministration, IProfile)) doesn't change it.

How could i change the form for the fields on the "administrative" fieldset?


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
khink khink
Reply | Threaded
Open this post in threaded view
|

Re: dexterity custom edit form for fieldset of inherited schema

I'm wondering why this got no reply so far. Is my question badly
phrased? Is the solution so obvious that i should have found it easily?
Or is it just that no one feels certain enough to try an answer?

I'd be grateful for any pointers!

Kees

On 06/29/2012 12:24 PM, Kees Hink wrote:

> I'm trying to modify an edit form for our dexterity IMember type. The
> field to modify is 'email', which is definied to be on another fieldset
> and inherited from the IUserAdministration schema:
>
> class IUserAdministration(form.Schema):
>       email = schema.TextLine(
>           title=_(u"email_form_label"),
>           description=_(u"moderators_email_form_help"),
>           min_length=5,
>           max_length=80,
>           required=False,
>       )
>       form.fieldset(
>               'administrative',
>               label=_(u'administrative_form_title',
> default='Administrative'),
>               fields=('disabled', 'email', 'override_email',
>                       'password', 'override_password',),
>           )
> interface.alsoProvides(IUserAdministration, IFormFieldProvider)
>
> class IMember(form.Schema, IProfile, IUserAdministration):
>       """Type for members
>       """
>       title = schema.TextLine(
>           title=_(u"fullname_form_label"),
>           description=_(u"fullname_form_help"),
>       )
>
> I tried the idea at
> http://collective-docs.readthedocs.org/en/latest/content/dexterity.html#custom-edit-form:
>
> from five import grok
> from plone.directives import dexterity
>
> class EditForm(dexterity.EditForm):
>
>       grok.context(IUserAdministration)
>
>       def updateWidgets(self):
>           """ """
>           dexterity.EditForm.updateWidgets(self)
>
>           # XXX: customize widgets here
>
> But in updateWidgets, self.widgets.items() lists only the widgets for
> IProfile, not those for IUserAdministration.
>
> Changing the order of the inheritance (class IMember(form.Schema,
> IUserAdministration, IProfile)) doesn't change it.
>
> How could i change the form for the fields on the "administrative" fieldset?
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Dieter Maurer Dieter Maurer
Reply | Threaded
Open this post in threaded view
|

Re: dexterity custom edit form for fieldset of inherited schema

Kees Hink <[hidden email]> writes:

> I'm wondering why this got no reply so far. Is my question badly
> phrased? Is the solution so obvious that i should have found it easily?
> Or is it just that no one feels certain enough to try an answer?

I see potential other reasons: holiday season (thus, many potential experts
may be out of town), you are quite near the "bleeding edge" (thus, few
people might have never met your case).

I have not yet used "dexterity" and therefore cannot help.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
David Glick (GW) David Glick (GW)
Reply | Threaded
Open this post in threaded view
|

Re: dexterity custom edit form for fieldset of inherited schema

In reply to this post by khink
On 7/2/12 6:59 AM, Kees Hink wrote:

> I'm wondering why this got no reply so far. Is my question badly
> phrased? Is the solution so obvious that i should have found it easily?
> Or is it just that no one feels certain enough to try an answer?
>
> I'd be grateful for any pointers!
>
> Kees
>
> On 06/29/2012 12:24 PM, Kees Hink wrote:
>> I'm trying to modify an edit form for our dexterity IMember type. The
>> field to modify is 'email', which is definied to be on another fieldset
>> and inherited from the IUserAdministration schema:
>>
>> class IUserAdministration(form.Schema):
>>        email = schema.TextLine(
>>            title=_(u"email_form_label"),
>>            description=_(u"moderators_email_form_help"),
>>            min_length=5,
>>            max_length=80,
>>            required=False,
>>        )
>>        form.fieldset(
>>                'administrative',
>>                label=_(u'administrative_form_title',
>> default='Administrative'),
>>                fields=('disabled', 'email', 'override_email',
>>                        'password', 'override_password',),
>>            )
>> interface.alsoProvides(IUserAdministration, IFormFieldProvider)
>>
>> class IMember(form.Schema, IProfile, IUserAdministration):
>>        """Type for members
>>        """
>>        title = schema.TextLine(
>>            title=_(u"fullname_form_label"),
>>            description=_(u"fullname_form_help"),
>>        )
>>
>> I tried the idea at
>> http://collective-docs.readthedocs.org/en/latest/content/dexterity.html#custom-edit-form:
>>
>> from five import grok
>> from plone.directives import dexterity
>>
>> class EditForm(dexterity.EditForm):
>>
>>        grok.context(IUserAdministration)
>>
>>        def updateWidgets(self):
>>            """ """
>>            dexterity.EditForm.updateWidgets(self)
>>
>>            # XXX: customize widgets here
>>
>> But in updateWidgets, self.widgets.items() lists only the widgets for
>> IProfile, not those for IUserAdministration.
>>
>> Changing the order of the inheritance (class IMember(form.Schema,
>> IUserAdministration, IProfile)) doesn't change it.
>>
>> How could i change the form for the fields on the "administrative" fieldset?
>>
>>
>>
Override update() instead of updateWidgets() and look at
self.groups...there should be a subform there for each fieldset.

Sorry for the slow response; I've been busy and on vacation lately.

David

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
khink khink
Reply | Threaded
Open this post in threaded view
|

Re: dexterity custom edit form for fieldset of inherited schema

Hi David, thanks for your reply.

When i override update(), self.groups() returns an empty tuple. To be
sure, i tried this both for IUserAdministration and for IMember.

Just to check: i have these methods/attributes:
(Pdb) self
<Products.Five.metaclass.EditForm object at 0x9a63d10>
(Pdb) self.context
<Container at /website/autoren/dummy_regular_user>
(Pdb) dir(self)
['_BrowserView__getParent', '_BrowserView__setParent',
'__ac_permissions__', '__call__', '__class__', '__delattr__',
'__dict__', '__doc__', '__format__', '__getattribute__', '__hash__',
'__implemented__', '__init__', '__module__', '__name__', '__new__',
'__of__', '__parent__', '__providedBy__', '__provides__', '__reduce__',
'__reduce_ex__', '__repr__', '__roles__', '__setattr__', '__sizeof__',
'__str__', '__subclasshook__', '__view_name__', '__weakref__',
'_render_template', 'accept', 'acceptCharset', 'action', 'actions',
'additionalSchemata', 'applyChanges', 'applyChanges__roles__',
'aq_acquire', 'aq_acquire__roles__', 'aq_base', 'aq_chain',
'aq_inContextOf', 'aq_inContextOf__roles__', 'aq_inner', 'aq_parent',
'aq_self', 'autoGroups', 'browserDefault', 'browserDefault__roles__',
'buttons', 'context', 'default_fieldset_label', 'default_namespace',
'default_namespace__roles__', 'description', 'enctype', 'extractData',
'extractData__roles__', 'fields', 'form', 'formErrorsMessage',
'form_instance', 'fti', 'getContent', 'getContent__roles__',
'getPrefix', 'getPrefix__roles__',
'grokcore.component.directive.context', 'groups', 'handleApply',
'handleCancel', 'handlers', 'id', 'ignoreContext', 'ignorePrefix',
'ignoreReadonly', 'ignoreRequest', 'label', 'labelRequired',
'martian.martiandirective.baseclass', 'method', 'mode', 'module_info',
'name', 'namespace', 'namespace__roles__', 'nextURL',
'nextURL__roles__', 'noChangesMessage', 'prefix', 'publishTraverse',
'publishTraverse__roles__', 'redirect', 'redirect__roles__',
'refreshActions', 'render', 'render__roles__', 'request',
'requiredInfo', 'response', 'schema', 'static', 'status',
'successMessage', 'template', 'update', 'updateActions',
'updateActions__roles__', 'updateFields', 'updateFieldsFromSchemata',
'updateFieldsFromSchemata__roles__', 'updateFields__roles__',
'updateWidgets', 'updateWidgets__roles__', 'update__roles__', 'url',
'url__roles__', 'widgets']

Kees

On 07/03/2012 08:04 PM, David Glick wrote:

> On 7/2/12 6:59 AM, Kees Hink wrote:
>> I'm wondering why this got no reply so far. Is my question badly
>> phrased? Is the solution so obvious that i should have found it easily?
>> Or is it just that no one feels certain enough to try an answer?
>>
>> I'd be grateful for any pointers!
>>
>> Kees
>>
>> On 06/29/2012 12:24 PM, Kees Hink wrote:
>>> I'm trying to modify an edit form for our dexterity IMember type. The
>>> field to modify is 'email', which is definied to be on another fieldset
>>> and inherited from the IUserAdministration schema:
>>>
>>> class IUserAdministration(form.Schema):
>>>         email = schema.TextLine(
>>>             title=_(u"email_form_label"),
>>>             description=_(u"moderators_email_form_help"),
>>>             min_length=5,
>>>             max_length=80,
>>>             required=False,
>>>         )
>>>         form.fieldset(
>>>                 'administrative',
>>>                 label=_(u'administrative_form_title',
>>> default='Administrative'),
>>>                 fields=('disabled', 'email', 'override_email',
>>>                         'password', 'override_password',),
>>>             )
>>> interface.alsoProvides(IUserAdministration, IFormFieldProvider)
>>>
>>> class IMember(form.Schema, IProfile, IUserAdministration):
>>>         """Type for members
>>>         """
>>>         title = schema.TextLine(
>>>             title=_(u"fullname_form_label"),
>>>             description=_(u"fullname_form_help"),
>>>         )
>>>
>>> I tried the idea at
>>> http://collective-docs.readthedocs.org/en/latest/content/dexterity.html#custom-edit-form:
>>>
>>> from five import grok
>>> from plone.directives import dexterity
>>>
>>> class EditForm(dexterity.EditForm):
>>>
>>>         grok.context(IUserAdministration)
>>>
>>>         def updateWidgets(self):
>>>             """ """
>>>             dexterity.EditForm.updateWidgets(self)
>>>
>>>             # XXX: customize widgets here
>>>
>>> But in updateWidgets, self.widgets.items() lists only the widgets for
>>> IProfile, not those for IUserAdministration.
>>>
>>> Changing the order of the inheritance (class IMember(form.Schema,
>>> IUserAdministration, IProfile)) doesn't change it.
>>>
>>> How could i change the form for the fields on the "administrative" fieldset?
>>>
>>>
>>>
> Override update() instead of updateWidgets() and look at
> self.groups...there should be a subform there for each fieldset.
>
> Sorry for the slow response; I've been busy and on vacation lately.
>
> David
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
David Glick (GW) David Glick (GW)
Reply | Threaded
Open this post in threaded view
|

Re: dexterity custom edit form for fieldset of inherited schema

On 7/4/12 10:01 AM, Kees Hink wrote:
> Hi David, thanks for your reply.
>
> When i override update(), self.groups() returns an empty tuple. To be
> sure, i tried this both for IUserAdministration and for IMember.
>
>
You called the super class's update() first?
David

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
khink khink
Reply | Threaded
Open this post in threaded view
|

Re: dexterity custom edit form for fieldset of inherited schema

On 07/04/2012 04:16 PM, David Glick wrote:
> On 7/4/12 10:01 AM, Kees Hink wrote:
>> Hi David, thanks for your reply.
>>
>> When i override update(), self.groups() returns an empty tuple. To be
>> sure, i tried this both for IUserAdministration and for IMember.
>>
>>
> You called the super class's update() first?
> David

Did not. Great, this looks promising, thanks a lot!

Kees

> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users