Subject: Re: Tracker updates for Zope 2.4
From: Steve Alexander <[email-masked]>
To: Ken Manheimer <[email-masked]>
Date: Sat, 07 Jul 2001 18:39:52 +0100

Ken Manheimer wrote:

> 
> Yes - i'd be glad to get a diff!  The tracker probably has a limited life
> around here, but we're still using it, and there are other folks out in
> the community also using it.  At some point i may have to forego even this
> minimal maintenance - but i expect that will be when we have a viable
> option to offer, like a CMF-based tracker.  In any case - thanks!

Here's a diff!

I'm running this on Zope 2.4, and it appears to work ok.

I haven't tested it for backwards compatibility with Zope 2.3 though, 
but it should work just fine, except for the bit in TrackerMisc.py where 
I took out the stuff for authenticating root users. I'm not sure what to 
do there.

--
Steve Alexander
Software Engineer
Cat-Box limited

*** TrackerMethods.py.original
--- TrackerMethods.py
***************
*** 1371,1400 ****
      self._v_threshold = 0
  
      self._catalog.addColumn('type')
!     self._catalog.addIndex('type', 'FieldIndex')
      ## XXX Eventually: self._catalog.manage_addColumn('type')
  
-     self._catalog.addIndex('numid', 'FieldIndex')
- 
-     self._catalog.addIndex('exemptions', 'FieldIndex')
- 
-     self._catalog.addIndex('text_content', 'TextIndex')
- 
-     self._catalog.addIndex('date', 'FieldIndex')
- 
-     self._catalog.addIndex('stage', 'FieldIndex')
- 
-     self._catalog.addIndex('priority', 'FieldIndex')
- 
-     self._catalog.addIndex('private', 'FieldIndex')
- 
-     self._catalog.addIndex('issueOwners', 'KeywordIndex')
- 
-     self._catalog.addIndex('requester', 'FieldIndex')
- 
-     self._catalog.addIndex('subscribers', 'KeywordIndex')
- 
-     self._catalog.addIndex('from', 'FieldIndex')
  
      # XXX Eventually this will need to be a separate index for each trait.
      #     Problem is that the collection of traits is dynamic, and the names
--- 1371,1404 ----
      self._v_threshold = 0
  
      self._catalog.addColumn('type')
!     field_indexes=('type', 'numid', 'exemptions', 'date', 'stage', 'priority',
!                    'requester', 'from', 'private')
!     keyword_indexes=('issueOwners','subscribers','traitVals')
!     text_indexes=('text_content',)
!     addIndex=self._catalog.addIndex
!     # try to add indexes in Zope 2.3 style. If this fails
!     # then add them in Zope 2.4 style
!     try: 
!         for name in field_indexes:
!             addIndex(name, 'FieldIndex')
!         for name in keyword_indexes:
!             addIndex(name, 'KeywordIndex')
!         for name in text_indexes:
!             addIndex(name, 'TextIndex')
!     except TypeError:
!         from SearchIndex.UnIndex import UnIndex
!         from SearchIndex.UnTextIndex import UnTextIndex
!         from SearchIndex.UnKeywordIndex import UnKeywordIndex
!     
!         for name in field_indexes:
!             addIndex(name, UnIndex(name))
!         for name in keyword_indexes:
!             addIndex(name, UnKeywordIndex(name))
!         for name in text_indexes:
!             addIndex(name, UnTextIndex(name))
!       
      ## XXX Eventually: self._catalog.manage_addColumn('type')

      # XXX Eventually this will need to be a separate index for each trait.
      #     Problem is that the collection of traits is dynamic, and the names
***************
*** 1404,1410 ****
      #     only get an 'or' style search within traits.  If we had some easy
      #     'and'ing mechanism for search results, we would have a way to do
      #     multiple passes, refiningthe search to the desired results.
!     self._catalog.addIndex('traitVals', 'KeywordIndex')
  
      tracker_path = self.absolute_url()
      for issue in self.values():
--- 1408,1414 ----
      #     only get an 'or' style search within traits.  If we had some easy
      #     'and'ing mechanism for search results, we would have a way to do
      #     multiple passes, refiningthe search to the desired results.
!     #self._catalog.addIndex('traitVals', 'KeywordIndex')
  
      tracker_path = self.absolute_url()
      for issue in self.values():

*** TrackerMisc.py.original
--- TrackerMisc.py
***************
*** 2,8 ****
          
  import string
  import re
! from DocumentTemplate import html_quote
  import smtplib, socket
  from DateTime import DateTime
  import urllib
--- 2,8 ----
          
  import string
  import re
! from DocumentTemplate.DT_Util import html_quote
  import smtplib, socket
  from DateTime import DateTime
  import urllib
***************
*** 161,168 ****
      if not user:
          user = REQUEST.AUTHENTICATED_USER
      acl_users = user.acl_users
!     root_users = filter(None, [str(getattr(acl_users, '_emergency_user', '')),
!                                str(getattr(acl_users, '_super', ''))])
      for i in roles:
          if (string.lower(i) in ["anonymous", "anonymous user"]
              and str(acl_users._nobody) == str(user)):
--- 161,172 ----
      if not user:
          user = REQUEST.AUTHENTICATED_USER
      acl_users = user.acl_users
!     # This doesn't work in Zope 2.4, and I'm not sure why.
!     # There's probably a better way of doing this anyway!
!     #root_users = filter(None, [str(getattr(acl_users, '_emergency_user', '')),
!     #                           str(getattr(acl_users, '_super', ''))])
!     root_users=[]
!     
      for i in roles:
          if (string.lower(i) in ["anonymous", "anonymous user"]
              and str(acl_users._nobody) == str(user)):