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

Class String

source code

Known Subclasses:

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)]
Instance Methods [hide private]
 
errQuote(self, s) source code
 
parse_error(self, mess, tag, text, start) source code
 
SubTemplate(self, name) source code
 
tagre(self) source code
 
_parseTag(self, match_ob, command=None, sargs='', tt=<type 'tuple'>) source code
 
parseTag(self, match_ob, command=None, sargs='')
Parse a tag using an already matched re
source code
 
varExtra(self, match_ob) source code
 
parse(self, text, start=0, result=None, tagre=None) source code
 
skip_eol(self, text, start, eol=re.compile(r'[ \t]*\n')) source code
 
parse_block(self, text, start, result, tagre, stag, sloc, sargs, scommand) source code
 
parse_close(self, text, start, tagre, stag, sloc, scommand, sa) source code
 
__init__(self, source_string='', mapping=None, __name__='<string>', **vars)
Create a document template from a string.
source code
 
name(self) source code
 
id(self) source code
 
setName(self, v) source code
 
default(self, name=None, **kw)
Change or query default values in a document template.
source code
 
var(self, name=None, **kw)
Change or query a variable in a document template.
source code
 
munge(self, source_string=None, mapping=None, **vars)
Change the text or default values for a document template.
source code
 
manage_edit(self, data, REQUEST=None) source code
 
read_raw(self, raw=None) source code
 
read(self, raw=None) source code
 
cook(self, cooklock=thread.allocate_lock()) source code
 
initvars(self, globals, vars) source code
 
ZDocumentTemplate_beforeRender(self, md, default) source code
 
ZDocumentTemplate_afterRender(self, md, result) source code
 
__call__(self, client=None, mapping={}, **kw)
Generate a document from a document template.
source code
 
__str__(self) source code
 
__getstate__(self, _special=('_v_', '_p_')) source code
Class Variables [hide private]
  isDocTemp = 1
  func_code = func_code()
  func_defaults__roles__ = ()
  func_defaults = ()
  errQuote__roles__ = ()
  parse_error__roles__ = ()
  commands__roles__ = ()
  commands = {'var': Var, 'call': Call, 'in':('in', 'DT_In', 'In...
  SubTemplate__roles__ = ()
  tagre__roles__ = ()
  _parseTag__roles__ = ()
  parseTag__roles__ = ()
  varExtra__roles__ = ()
  parse__roles__ = ()
  skip_eol__roles__ = ()
  parse_block__roles__ = ()
  parse_close__roles__ = ()
  shared_globals__roles__ = ()
  shared_globals = {}
  setName__roles__ = ()
  default__roles__ = ()
  var__roles__ = ()
  munge__roles__ = ()
  manage_edit__roles__ = ()
  read_raw__roles__ = ()
  read__roles__ = ()
  cook__roles__ = ()
  initvars__roles__ = ()
  ZDocumentTemplate_beforeRender__roles__ = ()
  ZDocumentTemplate_afterRender__roles__ = ()
  validate__roles__ = ()
  validate = None
hash(x)
Method Details [hide private]

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

source code 
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

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

source code 

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.

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

source code 

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.

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

source code 

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.

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

source code 
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.


Class Variable Details [hide private]

commands

Value:
{'call': <class qm.external.DocumentTemplate.DT_Var.Call at 0x166bae0>\
,
 'comment': <class qm.external.DocumentTemplate.DT_Var.Comment at 0x16\
6bce8>,
 'else': ('else', 'DT_If', 'Else'),
 'if': ('if', 'DT_If', 'If'),
 'in': ('in', 'DT_In', 'In'),
 'let': ('let', 'DT_Let', 'Let'),
...