mentby.com
Blog | Jobs | Help | Signup | Login

Extending user schema - collective.examples.userdata



 Hi,

 
I am using collective.examples.userdata package ( http://plone.org/products/collective.examples.userdata ), it seems as per instructions in the
 
documentation. I have added three new fields, each of which appear on the
 
self-registration page and also in the personal details screen. When viewing
 
the personal details screen the actual values that a user has entered are not
 
displayed in the boxes. I can add new values, click save and the page reloads
  without the values in the boxes.

 
Also, I try to query the user object using:

 
if hasattr(member, "customfield"):

 
and each of the custom fields are not found on the user, despite appearing on
 
the self-registration and personal information screens.

 
Can you please advise what may be missing, and how to test?

 
Kind regards,
 
Richard


Richard Lewis Thu, 10 Nov 2011 02:31:22 -0800

Hi,

just a shot in the dark:

Did you adjust to the new fields in all places? Eg. not only
userdataschema.py, but also adapter.py and the files in profiles/default?

Kind regards,
--Toni++


Toni Mueller Thu, 10 Nov 2011 03:29:53 -0800

Hi,

I think so...my files look like this. I also checked the member attributes after logging in in login_next.cpy
and the custom variables added by the adapter are not on the schema.

Any help would be much appreciated.

Thanks,

class IEnhancedUserDataSchema(IUserDataSchema):
    """ Use all the fields from the default user data schema, and add various
    extra fields.
    """
     
    firstname = schema.TextLine(
        title=_(u'label_firstname', default=u'First name'),
        description=_(u'help_firstname',
                      default=u"Fill in your given
name."),
        required=True,
        )

class EnhancedUserDataPanelAdapter(UserDataPanelAdapter):
    """
    """
    def _getProperty(self, name):
        """ PlonePAS encodes all unicode coming from PropertySheets.
            Decode before sending to formlib. """
        value = self.context.getProperty(name, '')
        if value:
            return safe_unicode(value)
        return value
       
    def
get_firstname(self):
        return self._getProperty('firstname')
       
    def set_firstname(self, value):
        return self.context.setMemberProperties({'firstname': value})
       
    firstname = property(get_firstname, set_firstname)

<componentregistry>
 <adapters/>
 <subscribers/>
 <utilities>
  <utility interface="plone.app.users.userdataschema.IUserDataSchemaProvider"
     factory="UserFieldsAdapter.UserDataSchemaProvider"/>
 </utilities>
</componentregistry>

<object name="portal_memberdata" meta_type="PlonePAS MemberData Tool">
 <property
name="email" type="string"></property>
 <property name="portal_skin" type="string"></property>
 <property name="listed" type="boolean">True</property>
 <property name="login_time" type="date">2000/01/01 00:00:00</property>
 <property name="last_login_time" type="date">2000/01/01 00:00:00</property>
 <property name="firstname" type="string"></property>
 <property name="lastname" type="string"></property>
 <property name="fullname" type="string"></property>
 <property name="error_log_update" type="float">0.0</property>
 <property name="home_page" type="string"></property>
 <property name="location" type="string"></property>
 <property name="preferredlocation" type="string"></property>
 <property name="description"
type="text"></property>
 <property name="language" type="string"></property>
 <property name="ext_editor" type="boolean">False</property>
 <property name="wysiwyg_editor" type="string"></property>
 <property name="visible_ids" type="boolean">False</property>
</object>

 <property name="user_registration_fields" type="lines">
   <element value="firstname"/>
   <element value="lastname"/>
   <element value="username"/>
   <element value="email"/>
   <element value="password"/>
   <element value="mail_me"/>
   <element value="preferredlocation"/>
  </property>


Richard Lewis Thu, 10 Nov 2011 07:23:28 -0800

Did you also re-install the product (using the portal_quickinstaller) after you
put the additional member fields in profiles/default?

Do you see the properties on the "properties" tab of the portal_memberdata tool?

What version of Plone do you use, by the way?

Kees


Kees Hink Thu, 10 Nov 2011 07:55:27 -0800

Hi,

I'm not using the product directly, I've copied the files into my default site profile and registered there. I've tried re-installing this and get the same problem.

I checked the portal_memberdata tool and the custom fields are not listed there. I'm using Plone 4109.

The additional fields do show up on the self-registration page (and pass validation to create an account). The fields also show up on the personal-preferences view for the logged-in user, but the values entered for the fields are not persisted.

Thanks,
Richard


Richard Lewis Thu, 10 Nov 2011 08:04:35 -0800

What about:

member.getProperty('customfield')

I don't think they're stored as attributes necessarily.

You probably need to do some pdb love where it's getting set.

Martin


Martin Aspeli Thu, 10 Nov 2011 10:42:03 -0800



Related Topics

Post a Comment