Back to index

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

List of all members.

Public Member Functions

def __init__
def listPredicateTypes
def doAddPredicate
def doUpdatePredicate
def doMovePredicateUp
def doMovePredicateDown
def doRemovePredicate
def doTestRegistry
def getPredicate
def listPredicates
def getTypeObjectName
def addPredicate
def updatePredicate
def removePredicate
def reorderPredicate
def assignTypeName
def findTypeName

Public Attributes

 predicate_ids
 predicates

Static Public Attributes

string meta_type = 'Content Type Registry'
string id = 'content_type_registry'
tuple manage_options
tuple security = ClassSecurityInfo()
tuple manage_predicates = DTMLFile( 'registryPredList', _dtmldir )
tuple manage_testRegistry = DTMLFile( 'registryTest', _dtmldir )

Static Private Attributes

 __implements__ = z2IContentTypeRegistry

Detailed Description

    Registry for rules which map PUT args to a CMF Type Object.

Definition at line 331 of file ContentTypeRegistry.py.


Constructor & Destructor Documentation

Definition at line 353 of file ContentTypeRegistry.py.

00353 
00354     def __init__( self ):
00355         self.predicate_ids  = ()
00356         self.predicates     = PersistentMapping()


Member Function Documentation

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.addPredicate (   self,
  predicate_id,
  predicate_type 
)
    Add a predicate to this element of type 'typ' to the registry.

Definition at line 484 of file ContentTypeRegistry.py.

00484 
00485     def addPredicate( self, predicate_id, predicate_type ):
00486         """
00487             Add a predicate to this element of type 'typ' to the registry.
00488         """
00489         if predicate_id in self.predicate_ids:
00490             raise ValueError, "Existing predicate: %s" % predicate_id
00491 
00492         klass = None
00493         for key, value in _predicate_types:
00494             if key == predicate_type:
00495                 klass = value
00496 
00497         if klass is None:
00498             raise ValueError, "Unknown predicate type: %s" % predicate_type
00499 
00500         self.predicates[ predicate_id ] = ( klass( predicate_id ), None )
00501         self.predicate_ids = self.predicate_ids + ( predicate_id, )

Here is the caller graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.assignTypeName (   self,
  predicate_id,
  typeObjectName 
)
    Bind the given predicate to a particular type object.

Definition at line 538 of file ContentTypeRegistry.py.

00538 
00539     def assignTypeName( self, predicate_id, typeObjectName ):
00540         """
00541             Bind the given predicate to a particular type object.
00542         """
00543         pred, oldTypeObjName = self.predicates[ predicate_id ]
00544         self.predicates[ predicate_id ] = ( pred, typeObjectName )

Here is the caller graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.doAddPredicate (   self,
  predicate_id,
  predicate_type,
  REQUEST 
)

Definition at line 370 of file ContentTypeRegistry.py.

00370 
00371     def doAddPredicate( self, predicate_id, predicate_type, REQUEST ):
00372         """
00373         """
00374         self.addPredicate( predicate_id, predicate_type )
00375         REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00376                               + '/manage_predicates'
00377                               + '?manage_tabs_message=Predicate+added.'
00378                               )

Here is the call graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.doMovePredicateDown (   self,
  predicate_id,
  REQUEST 
)

Definition at line 411 of file ContentTypeRegistry.py.

00411 
00412     def doMovePredicateDown( self, predicate_id, REQUEST ):
00413         """
00414         """
00415         predicate_ids = list( self.predicate_ids )
00416         ndx = predicate_ids.index( predicate_id )
00417         if ndx == len( predicate_ids ) - 1:
00418             msg = "Predicate+already+last."
00419         else:
00420             self.reorderPredicate( predicate_id, ndx + 1 )
00421             msg = "Predicate+moved."
00422         REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00423                               + '/manage_predicates'
00424                               + '?manage_tabs_message=%s' % msg
00425                               )

Here is the call graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.doMovePredicateUp (   self,
  predicate_id,
  REQUEST 
)

Definition at line 395 of file ContentTypeRegistry.py.

00395 
00396     def doMovePredicateUp( self, predicate_id, REQUEST ):
00397         """
00398         """
00399         predicate_ids = list( self.predicate_ids )
00400         ndx = predicate_ids.index( predicate_id )
00401         if ndx == 0:
00402             msg = "Predicate+already+first."
00403         else:
00404             self.reorderPredicate( predicate_id, ndx - 1 )
00405             msg = "Predicate+moved."
00406         REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00407                               + '/manage_predicates'
00408                               + '?manage_tabs_message=%s' % msg
00409                               )

Here is the call graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.doRemovePredicate (   self,
  predicate_id,
  REQUEST 
)

Definition at line 427 of file ContentTypeRegistry.py.

00427 
00428     def doRemovePredicate( self, predicate_id, REQUEST ):
00429         """
00430         """
00431         self.removePredicate( predicate_id )
00432         REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00433                               + '/manage_predicates'
00434                               + '?manage_tabs_message=Predicate+removed.'
00435                               )

Here is the call graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.doTestRegistry (   self,
  name,
  content_type,
  body,
  REQUEST 
)

Definition at line 440 of file ContentTypeRegistry.py.

00440 
00441     def doTestRegistry( self, name, content_type, body, REQUEST ):
00442         """
00443         """
00444         # XXX: this method violates the rules for tools/utilities:
00445         # it depends on a non-utility tool
00446         typeName = self.findTypeName( name, content_type, body )
00447         if typeName is None:
00448             typeName = '<unknown>'
00449         else:
00450             types_tool = getToolByName(self, 'portal_types')
00451             typeName = types_tool.getTypeInfo(typeName).Title()
00452         REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00453                                + '/manage_testRegistry'
00454                                + '?testResults=Type:+%s'
00455                                        % urllib.quote( typeName )
00456                                )

Here is the call graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.doUpdatePredicate (   self,
  predicate_id,
  predicate,
  typeObjectName,
  REQUEST 
)

Definition at line 385 of file ContentTypeRegistry.py.

00385 
00386                          ):
00387         """
00388         """
00389         self.updatePredicate( predicate_id, predicate, typeObjectName )
00390         REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
00391                               + '/manage_predicates'
00392                               + '?manage_tabs_message=Predicate+updated.'
00393                               )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.findTypeName (   self,
  name,
  typ,
  body 
)
    Perform a lookup over a collection of rules, returning the
    the name of the Type object corresponding to name/typ/body.
    Return None if no match found.

Definition at line 548 of file ContentTypeRegistry.py.

00548 
00549     def findTypeName( self, name, typ, body ):
00550         """
00551             Perform a lookup over a collection of rules, returning the
00552             the name of the Type object corresponding to name/typ/body.
00553             Return None if no match found.
00554         """
00555         for predicate_id in self.predicate_ids:
00556             pred, typeObjectName = self.predicates[ predicate_id ]
00557             if pred( name, typ, body ):
00558                 return typeObjectName
00559 
00560         return None
00561 
00562 InitializeClass( ContentTypeRegistry )
00563 

Here is the caller graph for this function:

    Find the predicate whose id is 'id';  return the predicate
    object, if found, or else None.

Definition at line 461 of file ContentTypeRegistry.py.

00461 
00462     def getPredicate( self, predicate_id ):
00463         """
00464             Find the predicate whose id is 'id';  return the predicate
00465             object, if found, or else None.
00466         """
00467         return self.predicates.get( predicate_id, ( None, None ) )[0]

    Find the predicate whose id is 'id';  return the name of
    the type object, if found, or else None.

Definition at line 476 of file ContentTypeRegistry.py.

00476 
00477     def getTypeObjectName( self, predicate_id ):
00478         """
00479             Find the predicate whose id is 'id';  return the name of
00480             the type object, if found, or else None.
00481         """
00482         return self.predicates.get( predicate_id, ( None, None ) )[1]

List '(id, (predicate, typeObjectName))' tuples for all predicates.

Definition at line 469 of file ContentTypeRegistry.py.

00469 
00470     def listPredicates( self ):
00471         """List '(id, (predicate, typeObjectName))' tuples for all predicates.
00472         """
00473         return tuple([ (id, self.predicates[id])
00474                        for id in self.predicate_ids ])

Definition at line 361 of file ContentTypeRegistry.py.

00361 
00362     def listPredicateTypes( self ):
00363         """
00364         """
00365         return map( lambda x: x[0], _predicate_types )

    Remove a predicate from the registry.

Definition at line 515 of file ContentTypeRegistry.py.

00515 
00516     def removePredicate( self, predicate_id ):
00517         """
00518             Remove a predicate from the registry.
00519         """
00520         del self.predicates[ predicate_id ]
00521         idlist = list( self.predicate_ids )
00522         ndx = idlist.index( predicate_id )
00523         idlist = idlist[ :ndx ] + idlist[ ndx+1: ]
00524         self.predicate_ids = tuple( idlist )

Here is the caller graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.reorderPredicate (   self,
  predicate_id,
  newIndex 
)
    Move a given predicate to a new location in the list.

Definition at line 526 of file ContentTypeRegistry.py.

00526 
00527     def reorderPredicate( self, predicate_id, newIndex ):
00528         """
00529             Move a given predicate to a new location in the list.
00530         """
00531         idlist = list( self.predicate_ids )
00532         ndx = idlist.index( predicate_id )
00533         pred = idlist[ ndx ]
00534         idlist = idlist[ :ndx ] + idlist[ ndx+1: ]
00535         idlist.insert( newIndex, pred )
00536         self.predicate_ids = tuple( idlist )

Here is the caller graph for this function:

def CMFCore.ContentTypeRegistry.ContentTypeRegistry.updatePredicate (   self,
  predicate_id,
  predicate,
  typeObjectName 
)
    Update a predicate in this element.

Definition at line 503 of file ContentTypeRegistry.py.

00503 
00504     def updatePredicate( self, predicate_id, predicate, typeObjectName ):
00505         """
00506             Update a predicate in this element.
00507         """
00508         if not predicate_id in self.predicate_ids:
00509             raise ValueError, "Unknown predicate: %s" % predicate_id
00510 
00511         predObj = self.predicates[ predicate_id ][0]
00512         mapply( predObj.edit, (), predicate.__dict__ )
00513         self.assignTypeName( predicate_id, typeObjectName )

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

CMFCore.ContentTypeRegistry.ContentTypeRegistry.__implements__ = z2IContentTypeRegistry [static, private]

Definition at line 338 of file ContentTypeRegistry.py.

string CMFCore.ContentTypeRegistry.ContentTypeRegistry.id = 'content_type_registry' [static]

Definition at line 341 of file ContentTypeRegistry.py.

Initial value:
( { 'label'    : 'Predicates'
                       , 'action'   : 'manage_predicates'
                       }
                     , { 'label'    : 'Test'
                       , 'action'   : 'manage_testRegistry'
                       }
                     )

Definition at line 343 of file ContentTypeRegistry.py.

tuple CMFCore.ContentTypeRegistry.ContentTypeRegistry.manage_predicates = DTMLFile( 'registryPredList', _dtmldir ) [static]

Definition at line 367 of file ContentTypeRegistry.py.

tuple CMFCore.ContentTypeRegistry.ContentTypeRegistry.manage_testRegistry = DTMLFile( 'registryTest', _dtmldir ) [static]

Definition at line 437 of file ContentTypeRegistry.py.

string CMFCore.ContentTypeRegistry.ContentTypeRegistry.meta_type = 'Content Type Registry' [static]

Definition at line 340 of file ContentTypeRegistry.py.

Definition at line 354 of file ContentTypeRegistry.py.

Definition at line 355 of file ContentTypeRegistry.py.

tuple CMFCore.ContentTypeRegistry.ContentTypeRegistry.security = ClassSecurityInfo() [static]

Definition at line 351 of file ContentTypeRegistry.py.


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