Table of Contents

Class: String qm/external/DocumentTemplate/DT_String.py

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)]

Methods   
SubTemplate
ZDocumentTemplate_afterRender
ZDocumentTemplate_beforeRender
__call__
__getstate__
__init__
__str__
_parseTag
cook
default
errQuote
initvars
manage_edit
munge
name
parse
parseTag
parse_block
parse_close
parse_error
read
read_raw
setName
skip_eol
tagre
var
varExtra
  SubTemplate 
SubTemplate ( self,  name )

  ZDocumentTemplate_afterRender 
ZDocumentTemplate_afterRender (
        self,
        md,
        result,
        )

  ZDocumentTemplate_beforeRender 
ZDocumentTemplate_beforeRender (
        self,
        md,
        default,
        )

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

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:

  • Keyword arguments,

  • The client argument,

  • The mapping argument,

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

  • The mapping argument provided when the template was created.

Exceptions   
SystemError, ( 'infinite recursion in document template' )
  __getstate__ 
__getstate__ ( self,  _special=( '_v_', '_p_' ) )

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

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.

  __str__ 
__str__ ( self )

  _parseTag 
_parseTag (
        self,
        tagre,
        command=None,
        sargs='',
        tt=type(() ),
        )

  cook 
cook ( self,  cooklock=ts_regex.allocate_lock() )

  default 
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.

  errQuote 
errQuote ( self,  s )

  initvars 
initvars (
        self,
        globals,
        vars,
        )

  manage_edit 
manage_edit (
        self,
        data,
        REQUEST=None,
        )

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

Change the text or default values for a document template.

  name 
name ( self )

  parse 
parse (
        self,
        text,
        start=0,
        result=None,
        tagre=None,
        )

  parseTag 
parseTag (
        self,
        tagre,
        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

Exceptions   
ParseError, ( 'Unexpected tag', tag )
ParseError, ( 'unexpected end tag', tag )
  parse_block 
parse_block (
        self,
        text,
        start,
        result,
        tagre,
        stag,
        sloc,
        sargs,
        scommand,
        )

  parse_close 
parse_close (
        self,
        text,
        start,
        tagre,
        stag,
        sloc,
        scommand,
        sa,
        )

  parse_error 
parse_error (
        self,
        mess,
        tag,
        text,
        start,
        )

Exceptions   
ParseError, "%s, for tag %s, on line %s of %s

" %(mess, self.errQuote( tag ), len(split( text [ : start ], '\n' ) ), self.errQuote( self.__name__ ) )

  read 
read ( self,  raw=None )

  read_raw 
read_raw ( self,  raw=None )

  setName 
setName ( self,  v )

  skip_eol 
skip_eol (
        self,
        text,
        start,
        eol=regex.compile( '[ \t]*\n' ),
        )

  tagre 
tagre ( self )

  var 
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.

  varExtra 
varExtra ( self,  tagre )


Table of Contents

This document was automatically generated on Mon Jan 3 09:42:36 2005 by HappyDoc version 2.1