Package Products :: Package zms :: Module ZMSGlobals :: Class ZMSGlobals
[frames] | no frames]

Class ZMSGlobals

Instance Methods
 
getPRODUCT_HOME(self)
Returns home-folder of this Product.
object
createBlobInContext(self, id, blob, container)
Creates a new Zope native-representative (Image/File) of given blob in container.
MyFile
FileFromData(self, data, filename='', content_type=None)
Creates a new instance of a file from given data.
MyImage
ImageFromData(self, data, filename='', content_type=None)
Creates a new instance of an image from given data.
 
inline_if(self, cond, v1, v2)
Inline conditional: - Java: cond?v1:v2 - Python >2.5: v1 if cond else v2
any
nvl(self, a1, a2, n=None)
Returns its first argument if it is not equal to third argument (None), otherwise it returns its second argument.
int
boolint(self, v)
Returns int (0/1) for Boolean Type new in Python 2.3.
any
dt_html(self, value, REQUEST)
Execute given DTML-snippet.
list
encrypt_schemes(self)
Available encryption-schemes.
string
encrypt_password(self, pw, algorithm='md5', hex=False)
Encrypts given password.
string
encrypt_ordtype(self, s)
Encrypts given string with entities by random algorithm.
int
rand_int(self, n)
Random integer in given range.
string
string_maxlen(self, s, maxlen=20, etc='...', encoding=None)
Returns string with specified maximum-length.
string
url_quote(self, string, safe='/')
Replace special characters in string using the %xx escape.
 
http_import(self, url, method='GET', auth=None, parse_qs=0)
string
url_append_params(self, url, dict, sep='&')
Append params from dict to given url.
string
url_inherit_params(self, url, REQUEST, exclude=[], sep='&')
Inerits params from request to given url.
string
id_quote(self, s)
Converts given string to identifier (removes special-characters and replaces German umlauts).
string
get_id_prefix(self, s)
Returns prefix from identifier (which is the non-numeric part at the beginning).
 
js_quote(self, text, charset=None)
Replace special characters in string for javascript.
Boolean
isPreviewRequest(self, REQUEST)
Checks if given request is preview.
string
getDataSizeStr(self, len)
Returns display string for file-size (KB).
string
getMimeTypeIconSrc(self, mt)
Returns the absolute-url of an icon representing the specified MIME-type.
 
writeStdout(self, info)
Write to standard-out (only allowed for development-purposes!).
list
tree_parents(self, l, i='id', r='idId', v='', deep=1, reverse=1)
Returns parents for linked list.
string
str_json(self, i)
Returns a json-string representation of the object.
string
str_item(self, i)
Returns a string representation of the item.
 
pilutil(self)
Returns util with PIL functions.
 
getZipArchive(self, f)
 
extractZipArchive(self, f)
 
buildZipArchive(self, files, get_data=True)
 
set_response_headers(self, fn, mt='application/octet-stream')
Set content-type and -disposition to response-headers.
string
getXmlHeader(self, encoding='utf-8')
Returns XML-Header (encoding=utf-8)
string
toXmlString(self, v, xhtml=False, encoding='utf-8')
Serializes value to ZMS XML-Structure.
any
parseXmlString(self, xml, mediadbStorable=True)
Parse value from ZMS XML-Structure.
 
xslProcess(self, xsl, xml)
Process xml with xsl transformation.
 
processData(self, processId, data, trans=None)
Process data with custom transformation.
dict
xmlParse(self, xml)
Parse arbitrary XML-Structure into dictionary.
list
xmlNodeSet(self, mNode, sTagName='', iDeep=0)
Retrieve node-set for given tag-name from dictionary of XML-Node-Structure.
 
getPlugin(self, path, REQUEST, pars={})
Executes plugin.
 
getLangFmtDate(self, t, lang=None, fmt_str='SHORTDATETIME_FMT')
Formats date in locale-format
struct_time
parseLangFmtDate(self, s, lang=None, fmt_str=None, recflag=None)
Parse date in locale-format
int
compareDate(self, t0, t1)
Compare two dates.
int
daysBetween(self, t0, t1)
Calculate days between two dates.
    Local File-System
string
localfs_package_home(self)
Returns package_home on local file-system.
string
localfs_tempfile(self)
Creates temp-folder on local file-system.
string or filestream_iterator
localfs_read(self, filename, mode='b', REQUEST=None)
Reads file from local file-system.
 
localfs_write(self, filename, v, mode='b', REQUEST=None)
Writes file to local file-system.
 
localfs_remove(self, path, deep=0)
Removes file from local file-system.
list
localfs_readPath(self, filename, data=False, recursive=False, REQUEST=None)
Reads path from local file-system.
    Logging
 
writeLog(self, info)
Log debug-information.
 
writeBlock(self, info)
Log information.
    Mappings
list
intersection_list(self, l1, l2)
Intersection of two lists (li & l2).
list
difference_list(self, l1, l2)
Difference of two lists (l1 - l2).
list
concat_list(self, l1, l2)
Concatenates two lists (l1 + l2).
dict
dict_list(self, l)
Converts list to dictionary: key=l[x*2], value=l[x*2+1]
list
distinct_list(self, l, i=None)
Returns distinct values of given field from list.
list
sort_list(self, l, qorder=None, qorderdir='asc', ignorecase=1)
Sorts list by given field.
list
string_list(self, s, sep='\n')
Split string by given separator and trim items.
list
tree_list(self, l, i='id', r='idId', v='', deep=0)
Returns children for linked list.
list
filter_list(self, l, i, v, o='%')
Filters list by given field.
list
copy_list(self, l)
Copies list l.
 
sync_list(self, l, nl, i)
Syncronizes list l with new list nl using the column i as identifier.
 
aggregate_list(self, l, i)
Aggregates given field in list.
    Operators
type
operator_absattr(self, v)
Returns absolute-attribute of given value.
type
operator_gettype(self, v)
Returns python-type of given value.
dict
operator_setitem(self, a, b, c)
Applies value for key in python-dictionary.
any
operator_getitem(self, a, b)
Retrieves value for key from python-dictionary.
 
operator_delitem(self, a, b)
Delete key from python-dictionary.
object
operator_setattr(self, a, b, c)
Applies value for key to python-object.
any
operator_getattr(self, a, b, c=None)
Retrieves value for key from python-object.
 
operator_delattr(self, a, b)
Delete key from python-object.
    Styles / CSS
dict
parse_stylesheet(self)
Parses default-stylesheet and returns elements.
dict
get_colormap(self)
Parses default-stylesheet and returns color-map.
    Regular Expressions
string
re_sub(self, pattern, replacement, subject, ignorecase=False)
Performs a search-and-replace across subject, replacing all matches of regex in subject with replacement.
 
re_search(self, pattern, subject, ignorecase=False)
Scan through string looking for a location where the regular expression pattern produces a match, and return a corresponding MatchObject instance.
Class Variables
  security = ClassSecurityInfo()
  PAGES = 0
virtual meta_type for all Pages (Containers)
  PAGEELEMENTS = 1
virtual meta_type for all Page-Elements
  NOREF = 4
virtual meta_type-flag for resolving meta-type of ZMSLinkElement-target-object.
  NORESOLVEREF = 5
virtual meta_type-flag for not resolving meta-type of ZMSLinkElement-target-object.
Method Details

createBlobInContext(self, id, blob, container)

 

Creates a new Zope native-representative (Image/File) of given blob in container.

Returns: object
New instance of Zope-object.

FileFromData(self, data, filename='', content_type=None)

 

Creates a new instance of a file from given data.

Parameters:
  • data (string) - File-data (binary)
  • filename (string) - Filename
Returns: MyFile
New instance of file.

ImageFromData(self, data, filename='', content_type=None)

 

Creates a new instance of an image from given data.

Parameters:
  • data (string) - Image-data (binary)
  • filename (string) - Filename
Returns: MyImage
New instance of image.

inline_if(self, cond, v1, v2)

 

Inline conditional:
- Java: cond?v1:v2
- Python >2.5: v1 if cond else v2

@param v1: 1st argument
@type v1: C{any}
@param v2: 2nd argument
@type v2: C{any}
@rtype: C{any}

nvl(self, a1, a2, n=None)

 

Returns its first argument if it is not equal to third argument (None), otherwise it returns its second argument.

Parameters:
  • a1 (any) - 1st argument
  • a2 (any) - 2nd argument
Returns: any

boolint(self, v)

 

Returns int (0/1) for Boolean Type new in Python 2.3.

Parameters:
  • v (bool) - Value
Returns: int
New instance of file.

Deprecated: use int instead!

dt_html(self, value, REQUEST)

 

Execute given DTML-snippet.

Parameters:
  • value (string) - DTML-snippet
  • REQUEST (ZPublisher.HTTPRequest) - the triggering request
Returns: any
Result of the execution or None

encrypt_schemes(self)

 

Available encryption-schemes.

Returns: list
list of encryption-scheme ids

encrypt_password(self, pw, algorithm='md5', hex=False)

 

Encrypts given password.

Parameters:
  • pw (string) - Password
  • algorithm (string) - Encryption-algorithm (md5, sha-1, etc.)
  • hex (bool) - Hexlify
Returns: string
Encrypted password

encrypt_ordtype(self, s)

 

Encrypts given string with entities by random algorithm.

Parameters:
  • s (string) - String
Returns: string
Encrypted string

rand_int(self, n)

 

Random integer in given range.

Parameters:
  • n (int) - Range
Returns: int
Random integer

string_maxlen(self, s, maxlen=20, etc='...', encoding=None)

 

Returns string with specified maximum-length. If original string exceeds maximum-length '...' is appended at the end.

Parameters:
  • s (string) - String
  • maxlen (int) - Maximum-length
  • etc (string) - Characters to be appended if maximum-length is exceeded
  • encoding (string) - Encoding
Returns: string

url_quote(self, string, safe='/')

 

Replace special characters in string using the %xx escape. Letters, digits, and the characters '_.-' are never quoted. By default, this function is intended for quoting the path section of the URL. The optional safe parameter specifies additional characters that should not be quoted, its default value is '/'.

Returns: string
the quoted string

url_append_params(self, url, dict, sep='&')

 

Append params from dict to given url.

Parameters:
  • url (string) - Url
  • dict (dict) - dictionary of params (key/value pairs)
Returns: string
New url

url_inherit_params(self, url, REQUEST, exclude=[], sep='&')

 

Inerits params from request to given url.

Parameters:
  • url (string) - Url
  • REQUEST (ZPublisher.HTTPRequest) - the triggering request
Returns: string
New url

id_quote(self, s)

 

Converts given string to identifier (removes special-characters and replaces German umlauts).

Parameters:
  • s (string) - String
Returns: string
Identifier

get_id_prefix(self, s)

 

Returns prefix from identifier (which is the non-numeric part at the beginning).

Parameters:
  • s (string) - Identifier
Returns: string
Prefix

isPreviewRequest(self, REQUEST)

 

Checks if given request is preview.

Parameters:
  • REQUEST (ZPublisher.HTTPRequest) - the triggering request
Returns: Boolean

getDataSizeStr(self, len)

 

Returns display string for file-size (KB).

Parameters:
  • len (int) - length (bytes)
Returns: string

getMimeTypeIconSrc(self, mt)

 

Returns the absolute-url of an icon representing the specified MIME-type.

Parameters:
  • mt (string) - MIME-Type (e.g. image/gif, text/xml).
Returns: string

operator_absattr(self, v)

 

Returns absolute-attribute of given value.

Parameters:
  • v (any) - Value
Returns: type

operator_gettype(self, v)

 

Returns python-type of given value.

Parameters:
  • v (any) - Value
Returns: type

operator_setitem(self, a, b, c)

 

Applies value for key in python-dictionary. This is a convenience-function since it is not possible to use expressions like a[b]=c in DTML.

Parameters:
  • a (dict) - Dictionary
  • b (any) - Key
  • c (any) - Value
Returns: dict

operator_getitem(self, a, b)

 

Retrieves value for key from python-dictionary.

Parameters:
  • a (dict) - Dictionary
  • b (any) - Key
Returns: any

operator_delitem(self, a, b)

 

Delete key from python-dictionary.

Parameters:
  • a (dict) - Dictionary
  • b (any) - Key

operator_setattr(self, a, b, c)

 

Applies value for key to python-object. This is a convenience-function since the use expressions like setattr(a,b,c) is restricted in DTML.

Parameters:
  • a (any) - Object
  • b (string) - Key
  • c (any) - Value
Returns: object

operator_getattr(self, a, b, c=None)

 

Retrieves value for key from python-object. This is a convenience-function since the use expressions like getattr(a,b,c) is restricted in DTML.

Parameters:
  • a (any) - Object
  • b (any) - Key
  • c (any) - Default-Value
Returns: any

operator_delattr(self, a, b)

 

Delete key from python-object.

Parameters:
  • a (any) - Object
  • b (any) - Key

writeStdout(self, info)

 

Write to standard-out (only allowed for development-purposes!).

Parameters:
  • info (any) - Object

writeLog(self, info)

 

Log debug-information.

Parameters:
  • info (any) - Debug-information

writeBlock(self, info)

 

Log information.

Parameters:
  • info (any) - Information

re_sub(self, pattern, replacement, subject, ignorecase=False)

 

Performs a search-and-replace across subject, replacing all matches of regex in subject with replacement. The result is returned by the sub() function. The subject string you pass is not modified.

Returns: string

re_search(self, pattern, subject, ignorecase=False)

 

Scan through string looking for a location where the regular expression pattern produces a match, and return a corresponding MatchObject instance. Return None if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string.

parse_stylesheet(self)

 

Parses default-stylesheet and returns elements. @deprecated

Returns: dict
Elements

get_colormap(self)

 

Parses default-stylesheet and returns color-map. @deprecated

Returns: dict
Color-map

intersection_list(self, l1, l2)

 

Intersection of two lists (li & l2).

Parameters:
  • l1 (list) - List #1
  • l2 (list) - List #2
Returns: list
Intersection list

difference_list(self, l1, l2)

 

Difference of two lists (l1 - l2).

Parameters:
  • l1 (list) - List #1
  • l2 (list) - List #2
Returns: list
Difference list

concat_list(self, l1, l2)

 

Concatenates two lists (l1 + l2).

Parameters:
  • l1 (list) - List #1
  • l2 (list) - List #2
Returns: list
Concatinated list

dict_list(self, l)

 

Converts list to dictionary: key=l[x*2], value=l[x*2+1]

Parameters:
  • l (list) - List
Returns: dict
Dictionary

distinct_list(self, l, i=None)

 

Returns distinct values of given field from list.

Parameters:
  • l (list) - List
Returns: list

sort_list(self, l, qorder=None, qorderdir='asc', ignorecase=1)

 

Sorts list by given field.

Returns: list
Sorted list.

filter_list(self, l, i, v, o='%')

 

Filters list by given field.

Parameters:
  • l (list) - List
  • i (string or int) - Field-name or -index
  • v (any) - Field-value
  • v (any) - Match-operator
Returns: list
Filtered list.

copy_list(self, l)

 

Copies list l.

Parameters:
  • l (list) - List
Returns: list
Copy of list.

localfs_package_home(self)

 

Returns package_home on local file-system.

Returns: string
package_home()

localfs_read(self, filename, mode='b', REQUEST=None)

 

Reads file from local file-system. You must grant permissions for reading from local file-system to directories in Config-Tab / Miscelleaneous-Section.

Parameters:
  • filename (string) - Filepath
  • filename (string) - Access mode
  • REQUEST (ZPublisher.HTTPRequest) - the triggering request
Returns: string or filestream_iterator
Contents of file

getXmlHeader(self, encoding='utf-8')

 

Returns XML-Header (encoding=utf-8)

Parameters:
  • encoding (string) - Encoding
Returns: string

parseXmlString(self, xml, mediadbStorable=True)

 

Parse value from ZMS XML-Structure.

Returns: any
list or dict

xslProcess(self, xsl, xml)

 

Process xml with xsl transformation.

Deprecated: Use ZMSGlobals.processData('xslt') instead.

xmlParse(self, xml)

 

Parse arbitrary XML-Structure into dictionary.

Returns: dict
Dictionary of XML-Structure.

xmlNodeSet(self, mNode, sTagName='', iDeep=0)

 

Retrieve node-set for given tag-name from dictionary of XML-Node-Structure.

Returns: list
List of dictionaries of XML-Structure.

getPlugin(self, path, REQUEST, pars={})

 

Executes plugin.

Parameters:
  • path (string) - the plugin path in $ZMS_HOME/plugins/
  • REQUEST (ZPublisher.HTTPRequest) - the triggering request
  • pars (dict) - the request parameters
Returns:
Result of the execution or error-message

getLangFmtDate(self, t, lang=None, fmt_str='SHORTDATETIME_FMT')

 

Formats date in locale-format

Parameters:
  • t (struct_time) - Datetime
  • lang (string) - Locale
  • fmt_str - Format-String, possible values SHORTDATETIME_FMT (default), SHORTDATE_FMT, DATETIME_FMT, DATE_FMT, DateTime, Day, Month, ISO8601, RFC2822