Back to index

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

List of all members.

Public Member Functions

def all_meta_types
def manage_addTypeInformation
def manage_setTIMethodAliases
def getTypeInfo
def listTypeInfo
def listContentTypes
def constructContent
def listActions
def listMethodAliasKeys

Static Public Attributes

string id = 'portal_types'
string meta_type = 'CMF Types Tool'
tuple security = ClassSecurityInfo()
tuple manage_options
tuple manage_overview = DTMLFile( 'explainTypesTool', _dtmldir )
tuple manage_aliases = PageTemplateFile( 'typesAliases.zpt', _wwwdir )

Static Private Attributes

tuple __implements__ = (z2ITypesTool, ActionProviderBase.__implements__)
tuple _product_interfaces = (ITypeInformation,)

Detailed Description

Provides a configurable registry of portal content types.

Definition at line 531 of file TypesTool.py.


Member Function Documentation

def CMFCore.TypesTool.TypesTool.all_meta_types (   self,
  interfaces = None 
)

Definition at line 566 of file TypesTool.py.

00566 
00567     def all_meta_types(self, interfaces=None):
00568         # this is a workaround and should be removed again if allowedTypes
00569         # have an interface we can use in _product_interfaces
00570         all = TypesTool.inheritedAttribute('all_meta_types')(self)
00571         others = [ mt for mt in Products.meta_types
00572                    if mt['name'] in allowedTypes ]
00573         return tuple(all) + tuple(others)

Here is the call graph for this function:

def CMFCore.TypesTool.TypesTool.constructContent (   self,
  type_name,
  container,
  id,
  RESPONSE = None,
  args,
  kw 
)
    Build an instance of the appropriate content class in
    'container', using 'id'.

Definition at line 707 of file TypesTool.py.

00707 
00708                         ):
00709         """
00710             Build an instance of the appropriate content class in
00711             'container', using 'id'.
00712         """
00713         info = self.getTypeInfo( type_name )
00714         if info is None:
00715             raise ValueError('No such content type: %s' % type_name)
00716 
00717         ob = info.constructInstance(container, id, *args, **kw)
00718 
00719         if RESPONSE is not None:
00720             immediate_url = '%s/%s' % ( ob.absolute_url()
00721                                       , info.immediate_view )
00722             RESPONSE.redirect( immediate_url )
00723 
00724         return ob.getId()

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.TypesTool.TypesTool.getTypeInfo (   self,
  contentType 
)
    Return an instance which implements the
    TypeInformation interface, corresponding to
    the specified 'contentType'.  If contentType is actually
    an object, rather than a string, attempt to look up
    the appropriate type info using its portal_type.

Definition at line 618 of file TypesTool.py.

00618 
00619     def getTypeInfo( self, contentType ):
00620         """
00621             Return an instance which implements the
00622             TypeInformation interface, corresponding to
00623             the specified 'contentType'.  If contentType is actually
00624             an object, rather than a string, attempt to look up
00625             the appropriate type info using its portal_type.
00626         """
00627         if not isinstance(contentType, basestring):
00628             if hasattr(aq_base(contentType), 'getPortalTypeName'):
00629                 contentType = contentType.getPortalTypeName()
00630                 if contentType is None:
00631                     return None
00632             else:
00633                 return None
00634         ob = getattr( self, contentType, None )
00635         if ITypeInformation.providedBy(ob):
00636             return ob
00637         if getattr(aq_base(ob), '_isTypeInformation', 0):
00638             # BBB
00639             warn("The '_isTypeInformation' marker attribute is deprecated, "
00640                  "and will be removed in CMF 2.3.  Please mark the instance "
00641                  "with the 'ITypeInformation' interface instead.",
00642                  DeprecationWarning, stacklevel=2)
00643             return ob
00644         else:
00645             return None

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.TypesTool.TypesTool.listActions (   self,
  info = None,
  object = None 
)
List all the actions defined by a provider.

Definition at line 726 of file TypesTool.py.

00726 
00727     def listActions(self, info=None, object=None):
00728         """ List all the actions defined by a provider.
00729         """
00730         actions = list( self._actions )
00731 
00732         if object is None and info is not None:
00733             object = info.object
00734         if object is not None:
00735             type_info = self.getTypeInfo(object)
00736             if type_info is not None:
00737                 actions.extend( type_info.listActions(info, object) )
00738 
00739         return actions

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.TypesTool.TypesTool.listContentTypes (   self,
  container = None,
  by_metatype = 0 
)
List type info IDs.

Passing 'by_metatype' is deprecated (type information may not
correspond 1:1 to an underlying meta_type). This argument will be
removed when CMFCore/dtml/catalogFind.dtml doesn't need it anymore.

Definition at line 674 of file TypesTool.py.

00674 
00675     def listContentTypes(self, container=None, by_metatype=0):
00676         """ List type info IDs.
00677 
00678         Passing 'by_metatype' is deprecated (type information may not
00679         correspond 1:1 to an underlying meta_type). This argument will be
00680         removed when CMFCore/dtml/catalogFind.dtml doesn't need it anymore.
00681         """
00682         typenames = {}
00683         for t in self.listTypeInfo( container ):
00684 
00685             if by_metatype:
00686                 warn('TypeInformation.listContentTypes(by_metatype=1) is '
00687                      'deprecated.',
00688                      DeprecationWarning)
00689                 name = t.Metatype()
00690             else:
00691                 name = t.getId()
00692 
00693             if name:
00694                 typenames[ name ] = None
00695 
00696         result = typenames.keys()
00697         result.sort()
00698         return result

Here is the call graph for this function:

List all defined method alias names.

Definition at line 741 of file TypesTool.py.

00741 
00742     def listMethodAliasKeys(self):
00743         """ List all defined method alias names.
00744         """
00745         _dict = {}
00746         for ti in self.listTypeInfo():
00747             aliases = ti.getMethodAliases()
00748             for k, v in aliases.items():
00749                 _dict[k] = 1
00750         rval = _dict.keys()
00751         rval.sort()
00752         return rval
00753 
00754 InitializeClass(TypesTool)

Here is the call graph for this function:

def CMFCore.TypesTool.TypesTool.listTypeInfo (   self,
  container = None 
)
    Return a sequence of instances which implement the
    TypeInformation interface, one for each content
    type registered in the portal.

Definition at line 647 of file TypesTool.py.

00647 
00648     def listTypeInfo( self, container=None ):
00649         """
00650             Return a sequence of instances which implement the
00651             TypeInformation interface, one for each content
00652             type registered in the portal.
00653         """
00654         rval = []
00655         for t in self.objectValues():
00656             # Filter out things that aren't TypeInformation and
00657             # types for which the user does not have adequate permission.
00658             if ITypeInformation.providedBy(t):
00659                 rval.append(t)
00660             elif getattr(aq_base(t), '_isTypeInformation', 0):
00661                 # BBB
00662                 warn("The '_isTypeInformation' marker attribute is deprecated, "
00663                      "and will be removed in CMF 2.3.  Please mark the "
00664                      "instance with the 'ITypeInformation' interface instead.",
00665                      DeprecationWarning, stacklevel=2)
00666                 rval.append(t)
00667         # Skip items with no ID:  old signal for "not ready"
00668         rval = [t for t in rval if t.getId()]
00669         # check we're allowed to access the type object
00670         if container is not None:
00671             rval = [t for t in rval if t.isConstructionAllowed(container)]
00672         return rval

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.TypesTool.TypesTool.manage_addTypeInformation (   self,
  add_meta_type,
  id = None,
  typeinfo_name = None,
  RESPONSE = None 
)
Create a TypeInformation in self.

Definition at line 579 of file TypesTool.py.

00579 
00580                                   typeinfo_name=None, RESPONSE=None):
00581         """Create a TypeInformation in self.
00582         """
00583         # BBB: typeinfo_name is ignored
00584         if not id:
00585             raise BadRequest('An id is required.')
00586         for mt in Products.meta_types:
00587             if mt['name'] == add_meta_type:
00588                 klass = mt['instance']
00589                 break
00590         else:
00591             raise ValueError, (
00592                 'Meta type %s is not a type class.' % add_meta_type)
00593         id = str(id)
00594         ob = klass(id)
00595         self._setObject(id, ob)
00596         if RESPONSE is not None:
00597             RESPONSE.redirect('%s/manage_main' % self.absolute_url())

Here is the call graph for this function:

Here is the caller graph for this function:

Config method aliases.

Definition at line 599 of file TypesTool.py.

00599 
00600     def manage_setTIMethodAliases(self, REQUEST):
00601         """ Config method aliases.
00602         """
00603         form = REQUEST.form
00604         aliases = {}
00605         for k, v in form['aliases'].items():
00606             v = v.strip()
00607             if v:
00608                 aliases[k] = v
00609 
00610         for ti in self.listTypeInfo():
00611             _dict = {}
00612             for k, v in form[ ti.getId() ].items():
00613                 if aliases.has_key(k):
00614                     _dict[ aliases[k] ] = v
00615             ti.setMethodAliases(_dict)
00616         REQUEST.RESPONSE.redirect('%s/manage_aliases' % self.absolute_url())

Here is the call graph for this function:


Member Data Documentation

tuple CMFCore.TypesTool.TypesTool.__implements__ = (z2ITypesTool, ActionProviderBase.__implements__) [static, private]

Definition at line 537 of file TypesTool.py.

tuple CMFCore.TypesTool.TypesTool._product_interfaces = (ITypeInformation,) [static, private]

Definition at line 541 of file TypesTool.py.

string CMFCore.TypesTool.TypesTool.id = 'portal_types' [static]

Definition at line 539 of file TypesTool.py.

tuple CMFCore.TypesTool.TypesTool.manage_aliases = PageTemplateFile( 'typesAliases.zpt', _wwwdir ) [static]

Definition at line 561 of file TypesTool.py.

Initial value:
( Folder.manage_options[:1]
                     + ( {'label':'Aliases',
                          'action':'manage_aliases'}, )
                     + ActionProviderBase.manage_options
                     + ( {'label':'Overview',
                          'action':'manage_overview'}, )
                     + Folder.manage_options[1:]
                     )

Definition at line 545 of file TypesTool.py.

tuple CMFCore.TypesTool.TypesTool.manage_overview = DTMLFile( 'explainTypesTool', _dtmldir ) [static]

Definition at line 558 of file TypesTool.py.

string CMFCore.TypesTool.TypesTool.meta_type = 'CMF Types Tool' [static]

Definition at line 540 of file TypesTool.py.

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

Definition at line 543 of file TypesTool.py.


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