[Zope-CMF] Patch to PortalFolder.py
Chris Withers
chrisw@nipltd.com
Mon, 4 Jun 2001 14:09:05 +0100
This is a multi-part message in MIME format.
------=_NextPart_000_0B7B_01C0ECFF.EA17AE50
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hi,
The attached patch cleans up PortalFolder.py a bit :-)
It removes the unused "always_incl_folders" logic, which made the filter
form on folder_contents unable to filter out folders.
It also removes an unneeded attribute of the ContentFilter class and
documents some of the filtering behaviour which took me a while to figure
out. This class also had a __str__ method which made no sense, so I removed
that too :-)
cheers,
Chris
------=_NextPart_000_0B7B_01C0ECFF.EA17AE50
Content-Type: application/octet-stream;
name="PortalFolder.py.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="PortalFolder.py.patch"
--- PortalFolder.py.original Mon Jun 04 12:05:28 2001
+++ PortalFolder.py Mon Jun 04 14:04:40 2001
@@ -228,16 +228,10 @@
result = []
append = result.append
get = self._getOb
- always_incl_folders = not filter.get('FilterIncludesFolders', 0)
for id in ids:
obj = get( id )
include = 0
- if (always_incl_folders and hasattr(obj, 'meta_type') and
- obj.meta_type == PortalFolder.meta_type):
- include = 1
- elif query(obj):
- include = 1
- if include:
+ if query(obj):
append( (id, obj) )
return result
@@ -466,7 +460,7 @@
Represent a predicate against a content object's metadata.
"""
MARKER = []
- filterSubject = filterType = []
+ filterSubject = []
def __init__( self
, Title=MARKER
, Creator=MARKER
@@ -518,7 +512,6 @@
if Type:
if type( Type ) == type( '' ):
Type = [ Type ]
- self.filterType = Type
self.predicates.append( lambda x, Type=Type:
x.Type() in Type )
@@ -532,22 +525,20 @@
return 0
def __call__( self, content ):
-
+
for predicate in self.predicates:
try:
if not predicate( content ):
return 0
- except: # XXX
+ except:
+ # This should mean the content being filtered is
+ # missing a required attribute or method and so
+ # should be filtered out. The blanket except will
+ # catch more than that though :-S
return 0
-
- return 1
- def __str__( self ):
- """
- """
- return "Subject: %s; Type: %s" % ( self.filterSubject,
- self.filterType )
+ return 1
manage_addPortalFolder = PortalFolder.manage_addPortalFolder
manage_addPortalFolderForm = HTMLFile( 'folderAdd', globals() )
------=_NextPart_000_0B7B_01C0ECFF.EA17AE50--