Package qm :: Package external :: Package DocumentTemplate :: Module DT_String :: Class String
[show private | hide private]
[frames | no frames]

Class String

Known Subclasses:
File, HTML

Document templates defined from strings.

Document template strings use an extended form of python string formatting. To insert a named value, simply include text of the form: '%(name)x', where 'name' is the name of the value and 'x' is a format specification, such as '12.2d'.

To intrduce a block such as an 'if' or an 'in' or a block continuation, such as an 'else', use '[' as the format specification. To terminate a block, ise ']' as the format specification, as in:
 %(in results)[
   %(name)s
 %(in results)]

Method Summary
  __init__(self, source_string, mapping, __name__, **vars)
Create a document template from a string.
  __call__(self, client, mapping, **kw)
Generate a document from a document template.
  __getstate__(self, _special)
  __str__(self)
  cook(self, cooklock)
  default(self, name, **kw)
Change or query default values in a document template.
  errQuote(self, s)
  id(self)
  initvars(self, globals, vars)
  manage_edit(self, data, REQUEST)
  munge(self, source_string, mapping, **vars)
Change the text or default values for a document template.
  name(self)
  parse(self, text, start, result, tagre)
  parse_block(self, text, start, result, tagre, stag, sloc, sargs, scommand)
  parse_close(self, text, start, tagre, stag, sloc, scommand, sa)
  parse_error(self, mess, tag, text, start)
  parseTag(self, match_ob, command, sargs)
Parse a tag using an already matched re Return: tag, args, command, coname where: tag is the tag, args is the tag's argument string, command is a corresponding command info structure if the tag is a start tag, or None otherwise, and coname is the name of a continue tag (e.g.
  read(self, raw)
  read_raw(self, raw)
  setName(self, v)
  skip_eol(self, text, start, eol)
  SubTemplate(self, name)
  tagre(self)
  var(self, name, **kw)
Change or query a variable in a document template.
  varExtra(self, match_ob)
  ZDocumentTemplate_afterRender(self, md, result)
  ZDocumentTemplate_beforeRender(self, md, default)

Class Variable Summary
tuple _parseTag__roles__ = ()
dict commands = {'comment': <class qm.external.DocumentTempla...
tuple commands__roles__ = ()
tuple cook__roles__ = ()
tuple default__roles__ = ()
tuple errQuote__roles__ = ()
func_code func_code = <qm.external.DocumentTemplate.DT_String.func...
tuple func_defaults = ()
tuple func_defaults__roles__ = ()
tuple initvars__roles__ = ()
int isDocTemp = 1                                                                     
tuple manage_edit__roles__ = ()
tuple munge__roles__ = ()
tuple parse__roles__ = ()
tuple parse_block__roles__ = ()
tuple parse_close__roles__ = ()
tuple parse_error__roles__ = ()
tuple parseTag__roles__ = ()
tuple read__roles__ = ()
tuple read_raw__roles__ = ()
tuple setName__roles__ = ()
dict shared_globals = {}
tuple shared_globals__roles__ = ()
tuple skip_eol__roles__ = ()
tuple SubTemplate__roles__ = ()
tuple tagre__roles__ = ()
NoneType validate = None                                                                  
tuple validate__roles__ = ()
tuple var__roles__ = ()
tuple varExtra__roles__ = ()
tuple ZDocumentTemplate_afterRender__roles__ = ()
tuple ZDocumentTemplate_beforeRender__roles__ = ()

Method Details

__init__(self, source_string='', mapping=None, __name__='<string>', **vars)
(Constructor)

Create a document template from a string.

The optional parameter, 'mapping', may be used to provide a mapping object containing defaults for values to be inserted.

__call__(self, client=None, mapping={}, **kw)
(Call operator)

Generate a document from a document template.

The document will be generated by inserting values into the
format string specified when the document template was
created.  Values are inserted using standard python named
string formats.

The optional argument 'client' is used to specify a object
containing values to be looked up.  Values will be looked up
using getattr, so inheritence of values is supported.  Note
that names beginning with '_' will not be looked up from the
client.

The optional argument, 'mapping' is used to specify a mapping
object containing values to be inserted.

Values to be inserted may also be specified using keyword
arguments.

Values will be inserted from one of several sources.  The
sources, in the order in which they are consulted, are:

  o  Keyword arguments,

  o  The 'client' argument,

  o  The 'mapping' argument,

  o  The keyword arguments provided when the object was
     created, and

  o  The 'mapping' argument provided when the template was
     created.

default(self, name=None, **kw)

Change or query default values in a document template.

If a name is specified, the value of the named default value before the operation is returned.

Keyword arguments are used to provide default values.

munge(self, source_string=None, mapping=None, **vars)

Change the text or default values for a document template.

parseTag(self, match_ob, command=None, sargs='')

Parse a tag using an already matched re

Return: tag, args, command, coname

where: tag is the tag,
       args is the tag's argument string,
       command is a corresponding command info structure if the
          tag is a start tag, or None otherwise, and
       coname is the name of a continue tag (e.g. else)
         or None otherwise

var(self, name=None, **kw)

Change or query a variable in a document template.

If a name is specified, the value of the named variable before the operation is returned.

Keyword arguments are used to provide variable values.

Class Variable Details

_parseTag__roles__

Type:
tuple
Value:
()                                                                     

commands

Type:
dict
Value:
{'call': <class qm.external.DocumentTemplate.DT_Var.Call at 0xb7c92b0c\
>,
 'comment': <class qm.external.DocumentTemplate.DT_Var.Comment at 0xb7\
c929bc>,
 'else': ('else', 'DT_If', 'Else'),
 'if': ('if', 'DT_If', 'If'),
 'in': ('in', 'DT_In', 'In'),
 'let': ('let', 'DT_Let', 'Let'),
...                                                                    

commands__roles__

Type:
tuple
Value:
()                                                                     

cook__roles__

Type:
tuple
Value:
()                                                                     

default__roles__

Type:
tuple
Value:
()                                                                     

errQuote__roles__

Type:
tuple
Value:
()                                                                     

func_code

Type:
func_code
Value:
<qm.external.DocumentTemplate.DT_String.func_code instance at 0xb7c856\
cc>                                                                    

func_defaults

Type:
tuple
Value:
()                                                                     

func_defaults__roles__

Type:
tuple
Value:
()                                                                     

initvars__roles__

Type:
tuple
Value:
()                                                                     

isDocTemp

Type:
int
Value:
1                                                                     

manage_edit__roles__

Type:
tuple
Value:
()                                                                     

munge__roles__

Type:
tuple
Value:
()                                                                     

parse__roles__

Type:
tuple
Value:
()                                                                     

parse_block__roles__

Type:
tuple
Value:
()                                                                     

parse_close__roles__

Type:
tuple
Value:
()                                                                     

parse_error__roles__

Type:
tuple
Value:
()                                                                     

parseTag__roles__

Type:
tuple
Value:
()                                                                     

read__roles__

Type:
tuple
Value:
()                                                                     

read_raw__roles__

Type:
tuple
Value:
()                                                                     

setName__roles__

Type:
tuple
Value:
()                                                                     

shared_globals

Type:
dict
Value:
{}                                                                     

shared_globals__roles__

Type:
tuple
Value:
()                                                                     

skip_eol__roles__

Type:
tuple
Value:
()                                                                     

SubTemplate__roles__

Type:
tuple
Value:
()                                                                     

tagre__roles__

Type:
tuple
Value:
()                                                                     

validate

Type:
NoneType
Value:
None                                                                  

validate__roles__

Type:
tuple
Value:
()                                                                     

var__roles__

Type:
tuple
Value:
()                                                                     

varExtra__roles__

Type:
tuple
Value:
()                                                                     

ZDocumentTemplate_afterRender__roles__

Type:
tuple
Value:
()                                                                     

ZDocumentTemplate_beforeRender__roles__

Type:
tuple
Value:
()                                                                     

Generated by Epydoc 2.1 on Thu Sep 27 15:49:07 2007 http://epydoc.sf.net