Back to index

plone3  3.1.7
Classes | Functions | Variables
CMFDynamicViewFTI.fti Namespace Reference

Classes

class  DynamicViewTypeInformation

Functions

def safe_hasattr
def safe_callable
def om_has_key

Variables

string fti_meta_type = 'Factory-based Type Information with dynamic views'

Function Documentation

def CMFDynamicViewFTI.fti.om_has_key (   context,
  key 
)
Object Manager has_key method with optimization for btree folders

Zope's OFS.ObjectManager has no method for checking if an object with an id
exists inside a folder.

Definition at line 45 of file fti.py.

00045 
00046 def om_has_key(context, key):
00047     """Object Manager has_key method with optimization for btree folders
00048 
00049     Zope's OFS.ObjectManager has no method for checking if an object with an id
00050     exists inside a folder.
00051     """
00052     klass = getattr(aq_base(context), '__class__', None)
00053     if hasattr(klass, 'has_key'):
00054         # BTreeFolder2 optimization
00055         if context.has_key(key):
00056             return True
00057     else:
00058         # standard ObjectManager api
00059         if key in context.objectIds():
00060             return True
00061     return False

Here is the caller graph for this function:

Make sure our callable checks are ConflictError safe.

Definition at line 34 of file fti.py.

00034 
00035 def safe_callable(obj):
00036     """Make sure our callable checks are ConflictError safe."""
00037     if safe_hasattr(obj, '__class__'):
00038         if safe_hasattr(obj, '__call__'):
00039             return True
00040         else:
00041             return isinstance(obj, ClassType)
00042     else:
00043         return callable(obj)
00044 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDynamicViewFTI.fti.safe_hasattr (   obj,
  name,
  _marker = object() 
)
Make sure we don't mask exceptions like hasattr().

We don't want exceptions other than AttributeError to be masked,
since that too often masks other programming errors.
Three-argument getattr() doesn't mask those, so we use that to
implement our own hasattr() replacement.

Definition at line 23 of file fti.py.

00023 
00024 def safe_hasattr(obj, name, _marker=object()):
00025     """Make sure we don't mask exceptions like hasattr().
00026 
00027     We don't want exceptions other than AttributeError to be masked,
00028     since that too often masks other programming errors.
00029     Three-argument getattr() doesn't mask those, so we use that to
00030     implement our own hasattr() replacement.
00031     """
00032     return getattr(obj, name, _marker) is not _marker
00033 

Here is the caller graph for this function:


Variable Documentation

string CMFDynamicViewFTI.fti.fti_meta_type = 'Factory-based Type Information with dynamic views'

Definition at line 62 of file fti.py.