Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
CMFCore.PortalFolder.ContentFilter Class Reference
Collaboration diagram for CMFCore.PortalFolder.ContentFilter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def hasSubject
def __call__
def __str__

Public Attributes

 predicates
 description
 filterSubject

Static Public Attributes

list MARKER = []
list filterSubject = []

Detailed Description

Represent a predicate against a content object's metadata.

Definition at line 511 of file PortalFolder.py.


Constructor & Destructor Documentation

def CMFCore.PortalFolder.ContentFilter.__init__ (   self,
  Title = MARKER,
  Creator = MARKER,
  Subject = MARKER,
  Description = MARKER,
  created = MARKER,
  created_usage = 'range:min',
  modified = MARKER,
  modified_usage = 'range:min',
  Type = MARKER,
  portal_type = MARKER,
  Ignored 
)

Definition at line 530 of file PortalFolder.py.

00530 
00531                 ):
00532 
00533         self.predicates = []
00534         self.description = []
00535 
00536         if Title is not self.MARKER:
00537             self.predicates.append( lambda x, pat=re.compile( Title ):
00538                                       pat.search( x.Title() ) )
00539             self.description.append( 'Title: %s' % Title )
00540 
00541         if Creator and Creator is not self.MARKER:
00542             self.predicates.append( lambda x, creator=Creator:
00543                                     creator in x.listCreators() )
00544             self.description.append( 'Creator: %s' % Creator )
00545 
00546         if Subject and Subject is not self.MARKER:
00547             self.filterSubject = Subject
00548             self.predicates.append( self.hasSubject )
00549             self.description.append( 'Subject: %s' % ', '.join(Subject) )
00550 
00551         if Description is not self.MARKER:
00552             self.predicates.append( lambda x, pat=re.compile( Description ):
00553                                       pat.search( x.Description() ) )
00554             self.description.append( 'Description: %s' % Description )
00555 
00556         if created is not self.MARKER:
00557             if created_usage == 'range:min':
00558                 self.predicates.append( lambda x, cd=created:
00559                                           cd <= x.created() )
00560                 self.description.append( 'Created since: %s' % created )
00561             if created_usage == 'range:max':
00562                 self.predicates.append( lambda x, cd=created:
00563                                           cd >= x.created() )
00564                 self.description.append( 'Created before: %s' % created )
00565 
00566         if modified is not self.MARKER:
00567             if modified_usage == 'range:min':
00568                 self.predicates.append( lambda x, md=modified:
00569                                           md <= x.modified() )
00570                 self.description.append( 'Modified since: %s' % modified )
00571             if modified_usage == 'range:max':
00572                 self.predicates.append( lambda x, md=modified:
00573                                           md >= x.modified() )
00574                 self.description.append( 'Modified before: %s' % modified )
00575 
00576         if Type:
00577             if isinstance(Type, basestring):
00578                 Type = [Type]
00579             self.predicates.append( lambda x, Type=Type:
00580                                       x.Type() in Type )
00581             self.description.append( 'Type: %s' % ', '.join(Type) )
00582 
00583         if portal_type and portal_type is not self.MARKER:
00584             if isinstance(portal_type, basestring):
00585                 portal_type = [portal_type]
00586             self.predicates.append( lambda x, pt=portal_type:
00587                                     hasattr(aq_base(x), 'getPortalTypeName')
00588                                     and x.getPortalTypeName() in pt )
00589             self.description.append( 'Portal Type: %s'
00590                                      % ', '.join(portal_type) )


Member Function Documentation

def CMFCore.PortalFolder.ContentFilter.__call__ (   self,
  content 
)

Definition at line 600 of file PortalFolder.py.

00600 
00601     def __call__( self, content ):
00602 
00603         for predicate in self.predicates:
00604 
00605             try:
00606                 if not predicate( content ):
00607                     return 0
00608             except (AttributeError, KeyError, IndexError, ValueError):
00609                 # predicates are *not* allowed to throw exceptions
00610                 return 0
00611 
00612         return 1

Here is the caller graph for this function:

    Return a stringified description of the filter.

Definition at line 613 of file PortalFolder.py.

00613 
00614     def __str__( self ):
00615         """
00616             Return a stringified description of the filter.
00617         """
00618         return '; '.join(self.description)
Converts Subject string into a List for content filter view.

Definition at line 591 of file PortalFolder.py.

00591 
00592     def hasSubject( self, obj ):
00593         """
00594         Converts Subject string into a List for content filter view.
00595         """
00596         for sub in obj.Subject():
00597             if sub in self.filterSubject:
00598                 return 1
00599         return 0


Member Data Documentation

Definition at line 533 of file PortalFolder.py.

Definition at line 517 of file PortalFolder.py.

Definition at line 546 of file PortalFolder.py.

Definition at line 516 of file PortalFolder.py.

Definition at line 532 of file PortalFolder.py.


The documentation for this class was generated from the following file: