Back to index

plone3  3.1.7
Functions
PlonePAS.utils Namespace Reference

Functions

def unique
def getCharset
def cleanId
def decleanId

Function Documentation

def PlonePAS.utils.cleanId (   id)
'url_quote' turns strange chars into '%xx', which is not a valid char
for ObjectManager. Here we encode '%' into '-' (and '-' into '--' as escaping).
De-clean is possible; see 'decleanId'.
Assumes that id can start with non-alpha(numeric), which is true.

Definition at line 37 of file utils.py.

00037 
00038 def cleanId(id):
00039     """'url_quote' turns strange chars into '%xx', which is not a valid char
00040     for ObjectManager. Here we encode '%' into '-' (and '-' into '--' as escaping).
00041     De-clean is possible; see 'decleanId'.
00042     Assumes that id can start with non-alpha(numeric), which is true.
00043     """
00044     __traceback_info__ = (id,)
00045     if id:
00046         # note: we provide the 'safe' param to get '/' encoded
00047         return url_quote(id, '').replace('-','--').replace('%','-')
00048     return ''

Here is the caller graph for this function:

Reverse cleanId.

Definition at line 49 of file utils.py.

00049 
00050 def decleanId(id):
00051    """Reverse cleanId."""
00052    if id:
00053        id = id.replace('--', '\x00').replace('-', '%').replace('\x00', '-')
00054        return url_unquote(id)
00055    return ''

Here is the caller graph for this function:

def PlonePAS.utils.getCharset (   context)
Returns the site default charset, or utf-8.

Definition at line 28 of file utils.py.

00028 
00029 def getCharset(context):
00030     """Returns the site default charset, or utf-8.
00031     """
00032     properties = getToolByName(context, "portal_properties")
00033     site_properties = getattr(properties, 'site_properties', None)
00034     if site_properties is not None:
00035         return site_properties.getProperty('default_charset')
00036     return 'utf-8'

Here is the call graph for this function:

def PlonePAS.utils.unique (   iterable)

Definition at line 22 of file utils.py.

00022 
00023 def unique(iterable):
00024     d = {}
00025     for i in iterable:
00026         d[i] = None
00027     return d.keys()