[Zope] CorpCalendar 1.4 and 1.7 issues

Thomas Bennett bennetttm at appstate.edu
Thu Mar 22 14:09:00 EDT 2007


Long story short:

Is it appropriate to change 
  self.REQUEST.AUTHENTICATED_USER.name
to
  self.REQUEST.REMOTE_USER
?

It appears to work but I'm not sure if there may be repercussions on this.

Thomas


Long story:

I had to make the change in getUserVariable(self, key, default=None) to view 
events CorpCalender 1.4 that was exported from Zope 2.6.1 and make the change 
in rememberUserVariable(self, key, value) to be able to add events in 
CorpCalendar 1.7 newly created calendars in Zope 2.9.6.
                         
I can't manage/edit any events in the imported CorpCalendar but I'm not real 
concerned about that because we can add the new calendars to carry on from 
the last dates on the old ones.


Current configuration on server I am moving to:

Zope Version 	(Zope 2.9.6-final, python 2.4.4, linux2) 
Python Version 	2.4.4 (#1, Oct 23 2006, 13:58:00) [GCC 4.1.1 20061011 (Red Hat 
4.1.1-30)] 
System Platform 	linux2 
Using ZEO

I am moving CorpCalendar 1.4 calendars from Zope 2.6.1 to CorpCalendar 1.7 on 
Zope 2.9.6

Traceback said 'name' was not an attribute of AUTHENTICATED_USER
when trying to view events or add events

The change I made was
from
        user = self.REQUEST.AUTHENTICATED_USER
        username = user.name
to
        user = self.REQUEST.AUTHENTICATED_USER
        username = self.REQUEST.REMOTE_USER

in the functions 
   def rememberUserVariable(self, key, value):
and 
   def getUserVariable(self, key, default=None):

as shown below. 


    def rememberUserVariable(self, key, value):
        """ set in stone """
        cookiekey = '__corpcal_%s'%key.replace(' ','')
        user = self.REQUEST.AUTHENTICATED_USER
        username = self.REQUEST.REMOTE_USER
#        username = user.name
        # cookie
        then = DateTime()+300
        then = then.rfc822()
        response = self.REQUEST.RESPONSE
        response.setCookie(cookiekey, value, expires=then, path='/')
        if username.lower().replace(' ','') != 'anonymoususer':
            _user_vs = self._user_variables
            if not self._user_variables.has_key(username):
                _user_vs[username] = {}
            _user_vs[key] = value
            self._user_variables = _user_vs


    def getUserVariable(self, key, default=None):
        """ get from stone """
        cookiekey = '__corpcal_%s'%key.replace(' ','')
        user = self.REQUEST.AUTHENTICATED_USER
        username = self.REQUEST.REMOTE_USER
#        username = user.name
        # cookie
        if self.REQUEST.cookies.has_key(cookiekey):
            return self.REQUEST.cookies.get(cookiekey)
        if username.lower().replace(' ','') != 'anonymoususer':
            if self._user_variables.has_key(username):
                if self._user_variables[username].has_key(key):
                    return self._user_variables[username][key]

        return default


Thomas
                     
-- 
====================================================================
Thomas McMillan Grant Bennett		Appalachian State University
Computer Consultant III			P O Box 32026
University Library				Boone, North Carolina 28608
(828) 262 6587

If it's not as simple as possible to try it, then the barrier to entry is too 
high.

Library Systems Help Desk: http://www.library.appstate.edu/help/
====================================================================


More information about the Zope mailing list