Back to index

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

List of all members.

Public Member Functions

def isConstructionAllowed
def manage_setMethodAliases
def Title
def Description
def Metatype
def getIcon
def allowType
def getId
def allowDiscussion
def globalAllow
def listActions
def constructInstance
def getMethodAliases
def setMethodAliases
def queryMethodID

Public Attributes

 id

Static Public Attributes

tuple security = ClassSecurityInfo()
string product = ''
string factory = ''
tuple manage_options
string title = ''
string description = ''
string i18n_domain = ''
string content_meta_type = ''
string content_icon = ''
string immediate_view = ''
 filter_content_types = True
tuple allowed_content_types = ()
 allow_discussion = False
 global_allow = True
tuple manage_aliases = PageTemplateFile( 'typeinfoAliases.zpt', _wwwdir )

Private Member Functions

def _getFactoryMethod
def _queryFactoryMethod
def _constructInstance

Static Private Attributes

 __implements__ = z2ITypeInformation
tuple _properties

Detailed Description

Portal content factory.

Definition at line 336 of file TypesTool.py.


Member Function Documentation

def CMFCore.TypesTool.FactoryTypeInformation._constructInstance (   self,
  container,
  id,
  args,
  kw 
) [private]
Build a bare instance of the appropriate type.

Does not do any security checks.

Returns the object without calling _finishConstruction().

Definition at line 431 of file TypesTool.py.

00431 
00432     def _constructInstance(self, container, id, *args, **kw):
00433         """Build a bare instance of the appropriate type.
00434 
00435         Does not do any security checks.
00436 
00437         Returns the object without calling _finishConstruction().
00438         """
00439         # XXX: this method violates the rules for tools/utilities:
00440         # it depends on self.REQUEST
00441         id = str(id)
00442 
00443         if self.product:
00444             # oldstyle factory
00445             m = self._getFactoryMethod(container, check_security=0)
00446 
00447             if getattr(aq_base(m), 'isDocTemp', 0):
00448                 kw['id'] = id
00449                 newid = m(m.aq_parent, self.REQUEST, *args, **kw)
00450             else:
00451                 newid = m(id, *args, **kw)
00452             # allow factory to munge ID
00453             newid = newid or id
00454 
00455         else:
00456             # newstyle factory
00457             factory = getUtility(IFactory, self.factory)
00458             obj = factory(id, *args, **kw)
00459             rval = container._setObject(id, obj)
00460             newid = isinstance(rval, basestring) and rval or id
00461 
00462         return container._getOb(newid)
00463 
00464 InitializeClass(FactoryTypeInformation)
00465 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.TypesTool.FactoryTypeInformation._getFactoryMethod (   self,
  container,
  check_security = 1 
) [private]

Definition at line 359 of file TypesTool.py.

00359 
00360     def _getFactoryMethod(self, container, check_security=1):
00361         if not self.product or not self.factory:
00362             raise ValueError, ('Product factory for %s was undefined' %
00363                                self.getId())
00364         p = container.manage_addProduct[self.product]
00365         m = getattr(p, self.factory, None)
00366         if m is None:
00367             raise ValueError, ('Product factory for %s was invalid' %
00368                                self.getId())
00369         if not check_security:
00370             return m
00371         if getSecurityManager().validate(p, p, self.factory, m):
00372             return m
00373         raise AccessControl_Unauthorized( 'Cannot create %s' % self.getId() )

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.TypesTool.FactoryTypeInformation._queryFactoryMethod (   self,
  container,
  default = None 
) [private]

Definition at line 374 of file TypesTool.py.

00374 
00375     def _queryFactoryMethod(self, container, default=None):
00376 
00377         if not self.product or not self.factory or container is None:
00378             return default
00379 
00380         # In case we aren't wrapped.
00381         dispatcher = getattr(container, 'manage_addProduct', None)
00382 
00383         if dispatcher is None:
00384             return default
00385 
00386         try:
00387             p = dispatcher[self.product]
00388         except AttributeError:
00389             logger.exception("_queryFactoryMethod raised an exception")
00390             return default
00391 
00392         m = getattr(p, self.factory, None)
00393 
00394         if m:
00395             try:
00396                 # validate() can either raise Unauthorized or return 0 to
00397                 # mean unauthorized.
00398                 if getSecurityManager().validate(p, p, self.factory, m):
00399                     return m
00400             except zExceptions_Unauthorized:  # Catch *all* Unauths!
00401                 pass
00402 
00403         return default

Here is the call graph for this function:

Here is the caller graph for this function:

    Can this type of object support discussion?

Definition at line 247 of file TypesTool.py.

00247 
00248     def allowDiscussion( self ):
00249         """
00250             Can this type of object support discussion?
00251         """
00252         return self.allow_discussion

def CMFCore.TypesTool.TypeInformation.allowType (   self,
  contentType 
) [inherited]
    Can objects of 'contentType' be added to containers whose
    type object we are?

Definition at line 223 of file TypesTool.py.

00223 
00224     def allowType( self, contentType ):
00225         """
00226             Can objects of 'contentType' be added to containers whose
00227             type object we are?
00228         """
00229         if not self.filter_content_types:
00230             ti = self.getTypeInfo( contentType )
00231             if ti is None or ti.globalAllow():
00232                 return 1
00233 
00234         #If a type is enabled to filter and no content_types are allowed
00235         if not self.allowed_content_types:
00236             return 0
00237 
00238         if contentType in self.allowed_content_types:
00239             return 1
00240 
00241         return 0

Here is the call graph for this function:

def CMFCore.TypesTool.TypeInformation.constructInstance (   self,
  container,
  id,
  args,
  kw 
) [inherited]
Build an instance of the type.

Builds the instance in 'container', using 'id' as its id.
Returns the object.

Definition at line 267 of file TypesTool.py.

00267 
00268     def constructInstance(self, container, id, *args, **kw):
00269         """Build an instance of the type.
00270 
00271         Builds the instance in 'container', using 'id' as its id.
00272         Returns the object.
00273         """
00274         if not self.isConstructionAllowed(container):
00275             raise AccessControl_Unauthorized('Cannot create %s' % self.getId())
00276 
00277         ob = self._constructInstance(container, id, *args, **kw)
00278 
00279         return self._finishConstruction(ob)

Here is the call graph for this function:

    Textual description of the class of objects (intended
    for display in a "constructor list").

Definition at line 196 of file TypesTool.py.

00196 
00197     def Description(self):
00198         """
00199             Textual description of the class of objects (intended
00200             for display in a "constructor list").
00201         """
00202         if self.description and self.i18n_domain:
00203             return Message(self.description, self.i18n_domain)
00204         else:
00205             return self.description

Here is the caller graph for this function:

def CMFCore.TypesTool.TypeInformation.getIcon (   self) [inherited]
    Returns the icon for this content object.

Definition at line 216 of file TypesTool.py.

00216 
00217     def getIcon(self):
00218         """
00219             Returns the icon for this content object.
00220         """
00221         return self.content_icon

Here is the caller graph for this function:

def CMFCore.TypesTool.TypeInformation.getId (   self) [inherited]

Definition at line 243 of file TypesTool.py.

00243 
00244     def getId(self):
00245         return self.id

Get method aliases dict.

Definition at line 296 of file TypesTool.py.

00296 
00297     def getMethodAliases(self):
00298         """ Get method aliases dict.
00299         """
00300         aliases = self._aliases
00301         # for aliases created with CMF 1.5.0beta
00302         for key, method_id in aliases.items():
00303             if isinstance(method_id, tuple):
00304                 aliases[key] = method_id[0]
00305                 self._p_changed = True
00306         return aliases.copy()

Should this type be implicitly addable anywhere?

Definition at line 254 of file TypesTool.py.

00254 
00255     def globalAllow(self):
00256         """
00257         Should this type be implicitly addable anywhere?
00258         """
00259         return self.global_allow

a. Does the factory method exist?

b. Is the factory method usable?

c. Does the current user have the permission required in
order to invoke the factory method?

Definition at line 405 of file TypesTool.py.

00405 
00406     def isConstructionAllowed(self, container):
00407         """
00408         a. Does the factory method exist?
00409 
00410         b. Is the factory method usable?
00411 
00412         c. Does the current user have the permission required in
00413         order to invoke the factory method?
00414         """
00415         if self.product:
00416             # oldstyle factory
00417             m = self._queryFactoryMethod(container)
00418             return (m is not None)
00419 
00420         elif container is not None:
00421             # newstyle factory
00422             m = queryUtility(IFactory, self.factory, None)
00423             if m is not None:
00424                 for d in container.all_meta_types():
00425                     if d['name'] == self.content_meta_type:
00426                         sm = getSecurityManager()
00427                         return sm.checkPermission(d['permission'], container)
00428 
00429         return False

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.TypesTool.TypeInformation.listActions (   self,
  info = None,
  object = None 
) [inherited]
Return a sequence of the action info objects for this type.

Definition at line 261 of file TypesTool.py.

00261 
00262     def listActions(self, info=None, object=None):
00263         """ Return a sequence of the action info objects for this type.
00264         """
00265         return self._actions or ()

Here is the caller graph for this function:

def CMFCore.TypesTool.TypeInformation.manage_setMethodAliases (   self,
  REQUEST 
) [inherited]
Config method aliases.

Definition at line 162 of file TypesTool.py.

00162 
00163     def manage_setMethodAliases(self, REQUEST):
00164         """ Config method aliases.
00165         """
00166         form = REQUEST.form
00167         aliases = {}
00168         for k, v in form['aliases'].items():
00169             v = v.strip()
00170             if v:
00171                 aliases[k] = v
00172 
00173         _dict = {}
00174         for k, v in form['methods'].items():
00175             if aliases.has_key(k):
00176                 _dict[ aliases[k] ] = v
00177         self.setMethodAliases(_dict)
00178         REQUEST.RESPONSE.redirect('%s/manage_aliases' % self.absolute_url())

Here is the call graph for this function:

def CMFCore.TypesTool.TypeInformation.Metatype (   self) [inherited]
    Returns the Zope 'meta_type' for this content object.
    May be used for building the list of portal content
    meta types.

Definition at line 207 of file TypesTool.py.

00207 
00208     def Metatype(self):
00209         """
00210             Returns the Zope 'meta_type' for this content object.
00211             May be used for building the list of portal content
00212             meta types.
00213         """
00214         return self.content_meta_type

def CMFCore.TypesTool.TypeInformation.queryMethodID (   self,
  alias,
  default = None,
  context = None 
) [inherited]
Query method ID by alias.

Definition at line 323 of file TypesTool.py.

00323 
00324     def queryMethodID(self, alias, default=None, context=None):
00325         """ Query method ID by alias.
00326         """
00327         aliases = self._aliases
00328         method_id = aliases.get(alias, default)
00329         # for aliases created with CMF 1.5.0beta
00330         if isinstance(method_id, tuple):
00331             method_id = method_id[0]
00332         return method_id
00333 
00334 InitializeClass(TypeInformation)
00335 

def CMFCore.TypesTool.TypeInformation.setMethodAliases (   self,
  aliases 
) [inherited]
Set method aliases dict.

Definition at line 308 of file TypesTool.py.

00308 
00309     def setMethodAliases(self, aliases):
00310         """ Set method aliases dict.
00311         """
00312         _dict = {}
00313         for k, v in aliases.items():
00314             v = v.strip()
00315             if v:
00316                 _dict[ k.strip() ] = v
00317         if not getattr(self, '_aliases', None) == _dict:
00318             self._aliases = _dict
00319             return True
00320         else:
00321             return False

Here is the caller graph for this function:

def CMFCore.TypesTool.TypeInformation.Title (   self) [inherited]
    Return the "human readable" type name (note that it
    may not map exactly to the 'portal_type', e.g., for
    l10n/i18n or where a single content class is being
    used twice, under different names.

Definition at line 183 of file TypesTool.py.

00183 
00184     def Title(self):
00185         """
00186             Return the "human readable" type name (note that it
00187             may not map exactly to the 'portal_type', e.g., for
00188             l10n/i18n or where a single content class is being
00189             used twice, under different names.
00190         """
00191         if self.title and self.i18n_domain:
00192             return Message(self.title, self.i18n_domain)
00193         else:
00194             return self.title or self.getId()

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

CMFCore.TypesTool.FactoryTypeInformation.__implements__ = z2ITypeInformation [static, private]

Definition at line 342 of file TypesTool.py.

Initial value:
(TypeInformation._basic_properties + (
        {'id':'product', 'type': 'string', 'mode':'w',
         'label':'Product name'},
        {'id':'factory', 'type': 'string', 'mode':'w',
         'label':'Product factory'},
        ) + TypeInformation._advanced_properties)

Definition at line 346 of file TypesTool.py.

Definition at line 117 of file TypesTool.py.

Definition at line 116 of file TypesTool.py.

string CMFCore.TypesTool.TypeInformation.content_icon = '' [static, inherited]

Definition at line 113 of file TypesTool.py.

string CMFCore.TypesTool.TypeInformation.content_meta_type = '' [static, inherited]

Definition at line 112 of file TypesTool.py.

string CMFCore.TypesTool.TypeInformation.description = '' [static, inherited]

Definition at line 110 of file TypesTool.py.

Definition at line 354 of file TypesTool.py.

Definition at line 115 of file TypesTool.py.

Definition at line 118 of file TypesTool.py.

string CMFCore.TypesTool.TypeInformation.i18n_domain = '' [static, inherited]

Definition at line 111 of file TypesTool.py.

Definition at line 122 of file TypesTool.py.

string CMFCore.TypesTool.TypeInformation.immediate_view = '' [static, inherited]

Definition at line 114 of file TypesTool.py.

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

Definition at line 159 of file TypesTool.py.

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

Definition at line 65 of file TypesTool.py.

Definition at line 353 of file TypesTool.py.

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

Reimplemented from CMFCore.TypesTool.TypeInformation.

Definition at line 344 of file TypesTool.py.

string CMFCore.TypesTool.TypeInformation.title = '' [static, inherited]

Definition at line 109 of file TypesTool.py.


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