Mark Phillips wrote:
I created my own remember object patterned after sampleremember. In the
schema is a string field that the user selects a value from a list.
These values happen to be the names of the various groups defined in the
site. How (and where) do I write the code to add this user to the group
he/she has selected in this field?
well, if you named the field "groups" and used AT's default "getGroups" for
the accessor then it should Just Work(tm). here are some details about how it
works, though:
Membrane registers a groups plugin that uses the membrane_tool to find any
content in the site that can be adapted to the IMembraneUserGroups interface.
Remember's BaseMember class implements the IRememberGroupsProvider
interface, and Remember registers an adapter from IRememberGroupsProvider ->
IMembraneUserGroups. this adapter is trivial, it simply calls 'getGroups' on
the context (i.e. the adapted Member object) and returns the results:
http://tinyurl.com/3g7ngw
if your custom member class inherits from BaseMember then it probably still
implements the IRememberGroupProvider interface, and so the 'groups' field
value would be checked.
if you want to use a different fieldname, you can create an
IYourOwnCustomGroupsProvider interface, subclassing IRememberGroupsProvider,
and make sure your member class implements the interface. then register a
different adapter from IYourOwnCustomGroupsProvider -> IMembraneUserGroups.
this adapter registration will beat the other one, since yours will be a more
specific interface, and you can retrieve the set of groups from your custom field.
Would I do this in the sampleremember.py code?
not really, see above.
How do I add a user to a group?
by using the Users/Groups configlet in Plone's control panel, or by setting
the value of the field directly on the member object (either UI or
programmatically).
If the user is not approved in the workflow, do I have to do
something special in the code to "remove" him/her from the groups
selected, or does that just happen magically?
i just checked and it looks like a user _will_ still show up as "in" the group
when a Manager uses Plone's control panel interface, even if his account is
in one of the inactive workflow states. this could maybe be considered a UI
bug, though, b/c if a user is in an inactive workflow state, then he can't log
in at all... the group membership won't do him any good.
Or should I add the user to the selected groups in a script on a
workflow transition when the user is approved? How would I code this
scenario?
probably a better idea would be to either improve the adapter i linked to
above, or to write your own custom adapter, so that it checks to see if the
member is in an active state before returning the value of the groups field.
-r
--
Archive:
http://www.openplans.org/projects/remember/lists/remember/archive/2008/09/1221199822945
To unsubscribe send an email with subject "unsubscribe" to [EMAIL PROTECTED]
Please contact [EMAIL PROTECTED] for questions.