From mj at zope.com Mon Mar 11 13:50:33 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/CMFDateIndexes Products/CMFDateIndexes - Imported sources Message-ID: <200203111850.g2BIoXJ01183@cvs.baymountain.com> Update of /cvs-zopeorg/Products/CMFDateIndexes In directory cvs.zope.org:/tmp/cvs-serv1170 Log Message: Initial setup Status: Vendor Tag: Products/CMFDateIndexes Release Tags: ZC start No conflicts created by this import From mj at zope.com Mon Mar 11 14:02:23 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes - __init__.py:1.3 RSCatalogTool.py:NONE Message-ID: <200203111902.g2BJ2NP04139@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes In directory cvs.zope.org:/tmp/cvs-serv2991 Modified Files: __init__.py Removed Files: RSCatalogTool.py Log Message: Split out CMF specific stuff into a seperate package - Remove RSCatalog tool - Remove DublinCore monkey patch === Products/DateIndexes/__init__.py 1.2 => 1.3 === import DateRangeIndex import DateIndex -import RSCatalogTool -import Products.CMFCore.utils - -from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl from DateTime.DateTime import DateTime DRI_CTORS = ( ( 'manage_addDateRangeIndexForm' @@ -17,35 +13,6 @@ , DateRangeIndex.addDateRangeIndex ) -tools = ( RSCatalogTool.RSCatalogTool - , - ) - -def better_effective( true_self ): - """ - Fix DublinCore element to return 'None' properly. - """ - marker = [] - date = getattr( true_self, 'effective_date', marker ) - - if type( date ) == type( '' ): - try: - date = DateTime( date ) - except: - date = None - - if date is marker: - date = getattr( true_self, 'creation_date', None ) - - return date - -def better_expires( true_self ): - """ - Fix DublinCore element to return 'None' properly. - """ - return getattr( true_self, 'expiration_date', None ) - - def initialize( context ): context.registerClass( DateRangeIndex.DateRangeIndex @@ -61,12 +28,3 @@ ) , icon='www/index.gif' ) - - Products.CMFCore.utils.ToolInit( 'DateRangeIndex Tool' - , tools=tools - , product_name='DateIndexes' - , icon='tool.gif' - ).initialize( context ) - - DefaultDublinCoreImpl.effective = better_effective - DefaultDublinCoreImpl.expires = better_expires === Removed File Products/DateIndexes/RSCatalogTool.py === From mj at zope.com Mon Mar 11 14:03:01 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/CMFDateIndexes - RSCatalogTool.py:1.1 __init__.py:1.1 Message-ID: <200203111903.g2BJ31M04202@cvs.baymountain.com> Update of /cvs-zopeorg/Products/CMFDateIndexes In directory cvs.zope.org:/tmp/cvs-serv4154 Added Files: RSCatalogTool.py __init__.py Log Message: Split out CMF specific tools from DateIndexes package. === Added File Products/CMFDateIndexes/RSCatalogTool.py === from Products.CMFCore.CatalogTool import CatalogTool from Products.CMFCore.utils import _getAuthenticatedUser, _checkPermission from Products.CMFCore import CMFCorePermissions from Products.ZCatalog.ZCatalog import ZCatalog from DateTime.DateTime import DateTime class RSCatalogTool( CatalogTool ): """ Override CMFCore's catalog to use a DataRangeIndex for the always-and-everywhere effective range query """ meta_type = 'RSCatalog' # inherited security assertions def enumerateIndexes( self ): # Return a list of ( index_name, type ) pairs for the initial # index set. return ( CatalogTool.enumerateIndexes( self ) + ( ( 'effectiveRange', 'DateRangeIndex' ) , ) ) def _initIndexes( self ): CatalogTool._initIndexes( self ) er_index = self._catalog.indexes[ 'effectiveRange' ] er_index._edit( since_field='effective', until_field='expires' ) # inherited security assertions def searchResults(self, REQUEST=None, **kw): ''' Calls ZCatalog.searchResults() with extra arguments that limit the results to what the user is allowed to see. ''' if REQUEST is None: REQUEST = self.REQUEST user = _getAuthenticatedUser(self) kw['allowedRolesAndUsers'] = list(user.getRoles()) + \ ['Anonymous', 'user:'+user.getUserName()] if not _checkPermission( CMFCorePermissions.AccessInactivePortalContent, self ): kw[ 'effectiveRange' ] = DateTime() results = apply( ZCatalog.searchResults, ( self, REQUEST ), kw ) return results __call__ = searchResults === Added File Products/CMFDateIndexes/__init__.py === import RSCatalogTool import Products.CMFCore.utils from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl tools = ( RSCatalogTool.RSCatalogTool , ) def better_effective( true_self ): """ Fix DublinCore element to return 'None' properly. """ marker = [] date = getattr( true_self, 'effective_date', marker ) if type( date ) == type( '' ): try: date = DateTime( date ) except: date = None if date is marker: date = getattr( true_self, 'creation_date', None ) return date def better_expires( true_self ): """ Fix DublinCore element to return 'None' properly. """ return getattr( true_self, 'expiration_date', None ) def initialize( context ): Products.CMFCore.utils.ToolInit( 'DateRangeIndex Tool' , tools=tools , product_name='DateIndexes' , icon='tool.gif' ).initialize( context ) DefaultDublinCoreImpl.effective = better_effective DefaultDublinCoreImpl.expires = better_expires From mj at zope.com Mon Mar 11 14:04:00 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: INSTALL.txt,1.2,1.3 INSTALL.txt,1.2,1.3 Message-ID: <200203111904.g2BJ40p04297@cvs.baymountain.com> Update of /cvs-zopeorg In directory cvs.zope.org:/tmp/cvs-serv4275 Modified Files: INSTALL.txt Log Message: Reflect the fact that DateIndexes has been split into two packages. From mj at zope.com Mon Mar 11 14:07:47 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes - tool.gif:NONE Message-ID: <200203111907.g2BJ7lr05605@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes In directory cvs.zope.org:/tmp/cvs-serv5594 Removed Files: tool.gif Log Message: Forgot to move this file. === Removed File Products/DateIndexes/tool.gif === From mj at zope.com Mon Mar 11 14:08:22 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/CMFDateIndexes - tool.gif:1.1 Message-ID: <200203111908.g2BJ8MM05721@cvs.baymountain.com> Update of /cvs-zopeorg/Products/CMFDateIndexes In directory cvs.zope.org:/tmp/cvs-serv5708 Added Files: tool.gif Log Message: Forgot to move this file. === Added File Products/CMFDateIndexes/tool.gif === From mj at zope.com Mon Mar 11 14:17:59 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/CMFDateIndexes - __init__.py:1.2 Message-ID: <200203111917.g2BJHxM08375@cvs.baymountain.com> Update of /cvs-zopeorg/Products/CMFDateIndexes In directory cvs.zope.org:/tmp/cvs-serv8367 Modified Files: __init__.py Log Message: Correct the registered tool and product names === Products/CMFDateIndexes/__init__.py 1.1 => 1.2 === def initialize( context ): - Products.CMFCore.utils.ToolInit( 'DateRangeIndex Tool' + Products.CMFCore.utils.ToolInit( 'CMF DateRangeIndex Tool' , tools=tools - , product_name='DateIndexes' + , product_name='CMFDateIndexes' , icon='tool.gif' ).initialize( context ) From mj at zope.com Mon Mar 11 14:32:36 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/CMFDateIndexes - RSCatalogTool.py:1.2 Message-ID: <200203111932.g2BJWaS12341@cvs.baymountain.com> Update of /cvs-zopeorg/Products/CMFDateIndexes In directory cvs.zope.org:/tmp/cvs-serv12333 Modified Files: RSCatalogTool.py Log Message: Make indexes that contain dates, DateIndexes. === Products/CMFDateIndexes/RSCatalogTool.py 1.1 => 1.2 === from DateTime.DateTime import DateTime +DATE_INDEXES = 'Date effective expires created'.split() class RSCatalogTool( CatalogTool ): """ @@ -17,11 +18,13 @@ def enumerateIndexes( self ): # Return a list of ( index_name, type ) pairs for the initial # index set. - return ( CatalogTool.enumerateIndexes( self ) - + ( ( 'effectiveRange', 'DateRangeIndex' ) - , - ) - ) + idxs = CatalogTool.enumerateIndexes(self) + new = () + for name, type in idxs: + if name in DATE_INDEXES: type = 'DateIndex' + new += ((name, type),) + + return new + (('effectiveRange', 'DateRangeIndex'),) def _initIndexes( self ): From mj at zope.com Mon Mar 11 14:57:52 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes/dtml - dri_add.dtml:1.2 dri_properties.dtml:1.2 Message-ID: <200203111957.g2BJvq018965@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes/dtml In directory cvs.zope.org:/tmp/cvs-serv18955 Modified Files: dri_add.dtml dri_properties.dtml Log Message: Fix DateRangeIndex DTML: - Update to use Zope form styleguide - Add 'id' field to add form. === Products/DateIndexes/dtml/dri_add.dtml 1.1 => 1.2 === - -

Add DateRangeIndex

+ -
- +

+A DateRangeIndex takes the name of two input attributes; one containing the +start date of the range, the second the end of the range. This index is filled +with range information based on those two markers. You can then search for +objects for those where a given date falls within the range. +

+ +
- - + - - - + - - - + - + + + +
Since field: - + +
+ Id +
+
+
Until field: - + +
+ Since field +
+
+

- + +
+ Until field +
+
+
+ +
+ +
+
=== Products/DateIndexes/dtml/dri_properties.dtml 1.1 => 1.2 === -

DateRangeIndex Properties

+

+You can update this DateRangeIndex by editing the following field and clicking +. +

-
- - - - - @@ -39,7 +39,7 @@ From mj at zope.com Mon Mar 11 15:21:13 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes - __init__.py:1.4 Message-ID: <200203112021.g2BKLD025119@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes In directory cvs.zope.org:/tmp/cvs-serv25044 Modified Files: __init__.py Log Message: Make the indexes invisible to normal folders; they can now only be seen in the Indexes add list of a Catalog. === Products/DateIndexes/__init__.py 1.3 => 1.4 === , permission='Add Pluggable Index' , icon='www/index.gif' + , visibility=None ) context.registerClass( DateIndex.DateIndex @@ -27,4 +28,5 @@ , DateIndex.manage_addDateIndex ) , icon='www/index.gif' + , visibility=None ) From mj at zope.com Mon Mar 11 18:11:44 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes/tests - test_DateRangeIndex.py:1.4 Message-ID: <200203112311.g2BNBi503731@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes/tests In directory cvs.zope.org:/tmp/cvs-serv3723/tests Modified Files: test_DateRangeIndex.py Log Message: Remove misplaced (and disabled) tests. === Products/DateIndexes/tests/test_DateRangeIndex.py 1.3 => 1.4 === -from BTrees.OOBTree import OOBTree - -def _assertHas( tree, value, max ): - - keys = list( tree.items() ) - assert len( tree.items( value, max ) ), \ - "%s: %s" % ( value, keys ) - - -class BTreeTest( unittest.TestCase ): - - def useValues( self, values ): - - tree = OOBTree() - - for value in values: - - tree[ str( value ) ] = value - - for value in values: - - _assertHas( tree, str( value ), str( value + 1000 ) ) - - def test_sparse( self ): - - self.useValues( range( 0, 200, 3 ) ) - - def test_sequential( self ): - - self.useValues( range( 1000 ) ) - - def test_suite(): suite = unittest.TestSuite() - #suite.addTest( unittest.makeSuite( BTreeTest ) ) suite.addTest( unittest.makeSuite( DRI_Tests ) ) return suite From mj at zope.com Mon Mar 11 18:21:57 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes/tests - test_DateRangeIndex.py:1.5 Message-ID: <200203112321.g2BNLvh06306@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes/tests In directory cvs.zope.org:/tmp/cvs-serv6298/tests Modified Files: test_DateRangeIndex.py Log Message: Re-enable disabled test === Products/DateIndexes/tests/test_DateRangeIndex.py 1.4 => 1.5 === pass - def _test_empty( self ): + def test_empty( self ): empty = DateRangeIndex( 'empty' )
Since field: - + + + + - - - - - - - - + + + + +
+
+ Since field
Until field: - + +

- + +
+ Until field +
+
+
+ +
+
From mj at zope.com Mon Mar 11 14:58:05 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes - DateRangeIndex.py:1.4 Message-ID: <200203111958.g2BJw5o19052@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes In directory cvs.zope.org:/tmp/cvs-serv18995 Modified Files: DateRangeIndex.py Log Message: Fix permission === Products/DateIndexes/DateRangeIndex.py 1.3 => 1.4 === security.declareProtected( VIEW_PERMISSION - , 'getSinceField' + , 'getUntilField' ) def getUntilField( self ): """ From mj at zope.com Mon Mar 11 15:08:38 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes - DateRangeIndex.py:1.5 Message-ID: <200203112008.g2BK8ci21536@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes In directory cvs.zope.org:/tmp/cvs-serv21528 Modified Files: DateRangeIndex.py Log Message: Fix edit redirect target. === Products/DateIndexes/DateRangeIndex.py 1.4 => 1.5 === """ self._edit( since_field, until_field ) - REQUEST[ 'RESPONSE' ].redirect( '%s/manage_indexProperties' + REQUEST[ 'RESPONSE' ].redirect( '%s/manage_main' '?manage_tabs_message=Updated' - % self.absolute_url() + % REQUEST.get('URL2') ) security.declarePrivate( '_edit' ) From mj at zope.com Mon Mar 11 15:16:37 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes - DateRangeIndex.py:1.6 Message-ID: <200203112016.g2BKGbi23899@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes In directory cvs.zope.org:/tmp/cvs-serv23886 Modified Files: DateRangeIndex.py Log Message: Fix adding of DateRangeIndexes === Products/DateIndexes/DateRangeIndex.py 1.5 => 1.6 === since_field = until_field = None - def __init__( self, id, since_field=None, until_field=None ): + def __init__(self, id, since_field=None, until_field=None, + caller=None, extra=None): - self._setId( id ) - self._edit( since_field, until_field ) + if extra: + since_field = extra.since_field + until_field = extra.until_field + + self._setId(id) + self._edit(since_field, until_field) self.clear() security.declareProtected( VIEW_PERMISSION @@ -375,20 +380,11 @@ addDateRangeIndexForm = DTMLFile( 'dri_add', _dtmldir ) -def addDateRangeIndex( self - , id - , REQUEST=None - , RESPONSE=None - , URL3=None - ): +def addDateRangeIndex(self, id, extra=None, + REQUEST=None, RESPONSE=None, URL3=None): """ Add a date range index to the catalog, using the incredibly icky double-indirection-which-hides-NOTHING. """ - return self.manage_addIndex( id - , 'DateRangeIndex' - , extra=None - , REQUEST=REQUEST - , RESPONSE=RESPONSE - , URL1=URL3 - ) + return self.manage_addIndex(id, 'DateRangeIndex', extra, + REQUEST, RESPONSE, URL3) From mj at zope.com Mon Mar 11 15:16:37 2002 From: mj at zope.com (Martijn Pieters) Date: Sun Aug 10 17:02:06 2008 Subject: [zopeorg-checkins] CVS: Products/DateIndexes/dtml - dri_add.dtml:1.3 Message-ID: <200203112016.g2BKGbB23901@cvs.baymountain.com> Update of /cvs-zopeorg/Products/DateIndexes/dtml In directory cvs.zope.org:/tmp/cvs-serv23886/dtml Modified Files: dri_add.dtml Log Message: Fix adding of DateRangeIndexes === Products/DateIndexes/dtml/dri_add.dtml 1.2 => 1.3 ===
- +
- +