[Zope-CMF] A CMF Forum issue!

Ibrahim Mubarak ibmub80 at yahoo.com
Tue Oct 28 09:59:56 EST 2003


Hi,

Thank you, Mitch Pirtle and Seb Bacon for your help about my excel spread sheet problem. The CSV
module looks like the solution I have been looking for. 

However, I have another concern, not actually a problem as I found a workaround, with CMF Forums
and a subscription tool that has been developed for it.

The setup is the following: Zope 2.6.1, Python 2.1, Plone 1.0.1, CMF Forum 0.1beta2

An intern who came before me set all this up a few months ago. He added a thread-level
subscription option.

I was asked to implement the same idea but for the forum level. The forum section of the site
contains a few forums grouped by category.
Here is a bit of the code used to add and delete a user from the list, and check to see if the
user is in the list:

In post.py I found the following:

CODE """
    def addNotifyUser(self,member_id):
        top_mess = self.thread_top()

        if hasattr(top_mess,'post_notification_list'):
            top_mess.post_notification_list.append(member_id)
        else:
            top_mess.post_notification_list = [member_id]
    
    def getNotifyUser(self,member_id):
        top_mess = self.thread_top()

        if hasattr(top_mess,'post_notification_list'):
            for id in top_mess.post_notification_list:
                if id == member_id:
                    return 1
            return 0
        else:
            return 0
    
    def deleteNotifyUser(self,member_id):
        top_mess = self.thread_top()

        if hasattr(top_mess,'post_notification_list'):
            top_mess.post_notification_list.remove(member_id)
""" /CODE

In forum.py, I followed the above code and added the following:

CODE """
    def addForumNotifyUser(self,member_id):
        """Add a user to the notification list of this forum"""

        if hasattr(self,'forum_notification_list'):
            self.forum_notification_list.append(member_id)
        else:
            self.forum_notification_list = [member_id]
    
    def getForumNotifyUser(self,member_id):
        """Check if a user is in the notification list of this forum"""

        if hasattr(self,'forum_notification_list'):
            return member_id in self.forum_notification_list
        
        return 0
    
    def deleteForumNotifyUser(self,member_id):
        """Remove a user from the notification list of this forum"""

        if hasattr(self,'forum_notification_list'):
            self.forum_notification_list.remove(member_id)
""" /CODE

BTW: I just followed the existent naming scheme, so don't blame me ;)

All these functions are called from Scripts (Python) [Zope Objects] which, in their turn, are
called by Page Templates within Zope.
The thread level (post.py) subscription works just fine. However, the forum level has given me a
few headache :)
I made a python script (inside Zope) that spits out (as part of the page template) the
forum_notification_list every time a user is logged in and is looking at the forums.
I tested this feature using four profiles: an Admin and three regular users. All these users have
custom-defined roles in the Plone site and are declared in an acl_users in the Plone site level
and not at Zope's root.
I created a new forum with Admin, created a new thread with user 1, and subscribed him/her to the
forum. I then subscribed user 2 and made him/her reply to that thread.
After that, I made user 3 reply to the message and created a new thread. I then started randomly
adding and removing users' subscription to the forums.
Right at step five or six I started seeing some weird values for the subscription list. Users that
were there are no longer there, users that removed their subscription are still there (affecting
the number of e-mails being sent), etc ...
I would sometimes get something similar to "list.remove(x) error: x not in list" when trying to
remove a user's subscription, noting that I can only reach the deleteForumNotifyUser method if
getForumNotifyUser method returns true [using a tal:condition block!] It is only if I hit F5
(refresh) that it works as it should for that session (no guarantees that the effect of the
deletion will last :( )
I am using Opera to manage Zope and using IE 5 and Netscape 7 to log in users. One thing I noticed
is that after the list starts going crazy it only takes for a browser (IE, NS, Opera) to render
the intranet homepage (Plone site homepage, no user logged in yet) for the list to change.

What is going on? Can anyone tell me? If you need more info, let me know, I'll be happy to help in
figuring out what is messing everything up. Yes, I tried my best to disable cache, and I even
tried to log in users one at a time closing the browser between each log in.

I tried to use a dictionary instead of a list. I also tried to wrap the list in a new class, and
then add an instance of the the new class to the forum instance, but no luck (yes, I create the
notification_list in the __init__ method using the self arg).
I also made forum.py write to a log file every time the three functions are called indicating the
action being taken, by whom, and the resulting new list.
They are called with the right args and only when they are supposed to be called, but the list
also acts weird there too. I am out of ideas so I tried a different approach.

My work around is to use Zope's API. I used the PropertySheet's methods on the Forum instances
adding the users as new Properties (each user is a separate property) and deleting them as needed.
I had to create a proxy script to handle this, but it seems to work :)

Did anyone else face a similar problem? Has anyone developed a subscription tool too? I would be
interested in knowing what technique you used!

I already checked the Zope-CMF mailing-list archives (I even saw the future: June 2010 :D ) but I
could not find anything related to this problem. To be honest, I just downloaded the whole
archives and did a text search for CMF Forum!

Thank you for reading my whole post ;)
Ibrahim

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/



More information about the Zope-CMF mailing list