Back to index

plone3  3.1.7
utils.py
Go to the documentation of this file.
00001 """some common utilities
00002 """
00003 import logging
00004 from types import UnicodeType, StringType
00005 
00006 STRING_TYPES = (UnicodeType, StringType)
00007 
00008 class TransformException(Exception):
00009     pass
00010 
00011 FB_REGISTRY = None
00012 
00013 # logging function
00014 logger = logging.getLogger('PortalTransforms')
00015 
00016 def log(message, severity=logging.INFO):
00017     logger.log(severity, message)
00018 
00019 # directory where template for the ZMI are located
00020 import os.path
00021 _www = os.path.join(os.path.dirname(__file__), 'www')
00022 skins_dir = os.path.join(os.path.dirname(__file__), 'skins')
00023 
00024 # directory where template for the ZMI are located
00025 import os.path
00026 _www = os.path.join(os.path.dirname(__file__), 'www')
00027 skins_dir = None
00028 
00029 def safeToInt(value):
00030     """Convert value to integer or just return 0 if we can't"""
00031     try:
00032         return int(value)
00033     except ValueError:
00034         return 0
00035     except TypeError:
00036         return 0