Back to index

plone3  3.1.7
Classes | Functions | Variables
ATContentTypes.configuration.datatype Namespace Reference

Classes

class  BaseFactory
class  MxTidy
class  Archetype
class  Feature

Functions

def _getValueFromModule
def _getValueFromDottedName
def permission_handler
def identifier_none
def byte_size_in_mb
def image_dimension
def image_dimension_or_no
def pil_algo

Variables

string __author__ = 'Christian Heimes <tiran@cheimes.de>'
string __docformat__ = 'restructuredtext'
tuple _marker = object()

Function Documentation

Definition at line 38 of file datatype.py.

00038 
00039 def _getValueFromDottedName(dotted_name):
00040     parts = dotted_name.split('.')
00041     module_name = '.'.join(parts[:-1])
00042     key = parts[-1]
00043     try:
00044         module = __import__(module_name, globals(), locals(), [key])
00045     except ImportError, msg:
00046         raise ValueError, str(msg)
00047     return _getValueFromModule(module, key)

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.configuration.datatype._getValueFromModule (   module,
  key 
) [private]

Definition at line 32 of file datatype.py.

00032 
00033 def _getValueFromModule(module, key):
00034     var = getattr(module, key, _marker)
00035     if key is _marker:
00036         raise ValueError, "%s doesn't have an attribute %s" % (module, key)
00037     return var

Here is the caller graph for this function:

Byte size handler for max size validator

Definition at line 72 of file datatype.py.

00072 
00073 def byte_size_in_mb(value):
00074     """Byte size handler for max size validator
00075     """
00076     if value.lower() == 'no':
00077         return 0.0
00078     byte_size = stock_datatypes["byte-size"]
00079     v = byte_size(value)
00080     return float(v) / (1024.0**2)

Definition at line 67 of file datatype.py.

00067 
00068 def identifier_none(value):
00069     if value == 'None':
00070         return None
00071     return IdentifierConversion()(value)

Image dimension data type

Splits a value of "200, 400" into two ints of (200, 400)

Definition at line 81 of file datatype.py.

00081 
00082 def image_dimension(value):
00083     """Image dimension data type
00084     
00085     Splits a value of "200, 400" into two ints of (200, 400)
00086     """    
00087     if value.count(',') != 1:
00088         raise ValueError, "Width and height must be seperated by a comma"
00089     w, h = value.split(',')
00090     w = int(w)
00091     h = int(h)
00092     return (w, h)

Here is the caller graph for this function:

Image dimension data type with support for no

Either "no" or (0, 0) results into None

Definition at line 93 of file datatype.py.

00093 
00094 def image_dimension_or_no(value):
00095     """Image dimension data type with support for no
00096     
00097     Either "no" or (0, 0) results into None
00098     """
00099     if value.lower() == 'no':
00100         return None
00101     w, h = image_dimension(value)
00102     if (w, h) == (0, 0):
00103         return None
00104     return (w, h)
    

Here is the call graph for this function:

Parse a permission

Valid value are:
    cmf.NAME - Products.CMFCore.permissions
    zope.NAME - AccessControl.Permissions
    aDottedName

Definition at line 48 of file datatype.py.

00048 
00049 def permission_handler(value):
00050     """Parse a permission
00051     
00052     Valid value are:
00053         cmf.NAME - Products.CMFCore.permissions
00054         zope.NAME - AccessControl.Permissions
00055         aDottedName
00056     """
00057     if value.startswith('cmf.'):
00058         permission = _getValueFromModule(CMFCorePermissions, value[4:])
00059     elif value.startswith('zope.'):
00060         permission = _getValueFromModule(ZopePermissions, value[5:])
00061     else:
00062         permission = _getValueFromDottedName(value)
00063     if not isinstance(permission, basestring):
00064         raise ValueError, 'Permission %s is not a string: %s' % (permission,
00065             type(permission))
00066     return permission

Here is the call graph for this function:

Get PIL image filter algo from PIL.Image

Definition at line 105 of file datatype.py.

00105 
00106 def pil_algo(value):
00107     """Get PIL image filter algo from PIL.Image
00108     """
00109     try:
00110         import PIL.Image
00111     except ImportError:
00112         return None
00113     
00114     value = value.upper()
00115     available = ('NEAREST', 'BILINEAR', 'BICUBIC', 'ANTIALIAS')
00116     if value not in available:
00117         raise ValueError, "unknown algo %s" % value
00118     import PIL.Image
00119     return getattr(PIL.Image, value)


Variable Documentation

string ATContentTypes.configuration.datatype.__author__ = 'Christian Heimes <tiran@cheimes.de>'

Definition at line 22 of file datatype.py.

Definition at line 23 of file datatype.py.

Definition at line 30 of file datatype.py.