relating members and events in plone
This post was written 7 years ago.
Wed, 22 Jun 2005
i've made some good progress on this, as I couldn't find any "out of the box" products to do it for me. The requirement is fairly simple - when viewing an event, a logged in member should be able to subscribe to the event just by clicking a link, or remove themselves if they are already subscribed.
In a typical asp/php/jsp + relational database setup this would be done by having a table that stores member ids against event id's and scripts to add and remove the relationships as appropriate. For those of you that don't know, Zope doesn't work like that. Zope (which plone runs on top of) uses it's own object database for most content storage, rather that hooking up to a relational database (well it can, but that's not the point). Therefore the usual way to do something like this is to store the cross references as a list, tuple or dict within a field in an object instance (my terminology may be a bit out here - feel free to correct me).
Anyway, without getting too deep into that, my next challenge was that the standard event content type in plone 2.0.5 is not an archetypes content type, which makes it more tricky (for me) to monkey around with. So I installed calendaring, which has a Archetypes based replacement for Events, which handily enough already has a field for attendees. It also has loads of nice calendaring stuff (as the name suggests) including iCal import, but I won't list all of that here...
so, moving on, I created a portlet that displays when you are logged in and in the context of an event, which will list all current attendees, with a link to add yourself or remove yourself as appropriate. The links point to python scripts which are proxied to run as manager (ordinary members by default can't edit events) and this gets the attendees list (using the getAttendees method that is generated by Archetypes), converts it from a tuple to a list (because you can't manipulate tuples as I found out yesterday), adds/removes the currently logged in members id and then passes it back to the object instance using setAttendees.
This solves my problem, and i'm sure other people must have similar requirements, so I will (at some point - promise!) package this up as an installable product when i've finished it - I want to do some other things first such as looking up members names from the id's, and cleaning itself up automatically if a member is deleted.
in the meantime i'm happy to send people the code so far if they want it :)
UPDATE: i've just been pointed in the direction of this (thanks Shane), which sounds like it does pretty much what I was trying to achieve, i'd better try it out! oh well, at worst i've learnt something about manipulating linefields programatically...
I wonder how I failed to find that when I was looking before?
UPDATE 2: I installed EventRegistration and it is much more complex than what I was trying to build - to register, members would need to fill out a form rather than the "click to subscribe, click to unsubscribe" I was looking for. I am also keen to utilize the functionality that Calendaring gives me so will carry on with my product (maybe call it something like QuickSubscribePortlet ) Still useful to know about EventRegistration though.
In a typical asp/php/jsp + relational database setup this would be done by having a table that stores member ids against event id's and scripts to add and remove the relationships as appropriate. For those of you that don't know, Zope doesn't work like that. Zope (which plone runs on top of) uses it's own object database for most content storage, rather that hooking up to a relational database (well it can, but that's not the point). Therefore the usual way to do something like this is to store the cross references as a list, tuple or dict within a field in an object instance (my terminology may be a bit out here - feel free to correct me).
Anyway, without getting too deep into that, my next challenge was that the standard event content type in plone 2.0.5 is not an archetypes content type, which makes it more tricky (for me) to monkey around with. So I installed calendaring, which has a Archetypes based replacement for Events, which handily enough already has a field for attendees. It also has loads of nice calendaring stuff (as the name suggests) including iCal import, but I won't list all of that here...
so, moving on, I created a portlet that displays when you are logged in and in the context of an event, which will list all current attendees, with a link to add yourself or remove yourself as appropriate. The links point to python scripts which are proxied to run as manager (ordinary members by default can't edit events) and this gets the attendees list (using the getAttendees method that is generated by Archetypes), converts it from a tuple to a list (because you can't manipulate tuples as I found out yesterday), adds/removes the currently logged in members id and then passes it back to the object instance using setAttendees.
This solves my problem, and i'm sure other people must have similar requirements, so I will (at some point - promise!) package this up as an installable product when i've finished it - I want to do some other things first such as looking up members names from the id's, and cleaning itself up automatically if a member is deleted.
in the meantime i'm happy to send people the code so far if they want it :)
UPDATE: i've just been pointed in the direction of this (thanks Shane), which sounds like it does pretty much what I was trying to achieve, i'd better try it out! oh well, at worst i've learnt something about manipulating linefields programatically...
I wonder how I failed to find that when I was looking before?
UPDATE 2: I installed EventRegistration and it is much more complex than what I was trying to build - to register, members would need to fill out a form rather than the "click to subscribe, click to unsubscribe" I was looking for. I am also keen to utilize the functionality that Calendaring gives me so will carry on with my product (maybe call it something like QuickSubscribePortlet ) Still useful to know about EventRegistration though.
This post was written 7 years ago, which in internet time is really, really old. This means that what is written above, and the links contained within, may now be obsolete, inaccurate or wildly out of context, so please bear that in mind :)
Comments