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

Class String
source code

Known Subclasses:
DT_HTML.HTML, File

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)
  parse_error(self, mess, tag, text, start)
  SubTemplate(self, name)
  tagre(self)
  _parseTag(self, match_ob, command=None, sargs='', tt=<type 'tuple'>)
  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.
  varExtra(self, match_ob)
  parse(self, text, start=0, result=None, tagre=None)
  skip_eol(self, text, start, eol=re.compile('[ \t]*\n'))
  parse_block(self, text, start, result, tagre, stag, sloc, sargs, scommand)
  parse_close(self, text, start, tagre, stag, sloc, scommand, sa)
  __init__(self, source_string='', mapping=None, __name__='<string>', **vars)
Create a document template from a string.
  name(self)
  id(self)
  setName(self, v)
  default(self, name=None, **kw)
Change or query default values in a document template.
  var(self, name=None, **kw)
Change or query a variable in a document template.
  munge(self, source_string=None, mapping=None, **vars)
Change the text or default values for a document template.
  manage_edit(self, data, REQUEST=None)
  read_raw(self, raw=None)
  read(self, raw=None)
  cook(self, cooklock=thread.allocate_lock())
  initvars(self, globals, vars)
  ZDocumentTemplate_beforeRender(self, md, default)
  ZDocumentTemplate_afterRender(self, md, result)
  __call__(self, client=None, mapping={}, **kw)
Generate a document from a document template.
  __str__(self)
  __getstate__(self, _special=('_v_','_p_'))

Class Variables [hide private]
isDocTemp  
func_code  
func_defaults__roles__  
func_defaults  
errQuote__roles__  
parse_error__roles__  
commands__roles__  
commands  
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  

Method Details [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='')

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

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('[ \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)
(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.

name(self)

source code 

id(self)

source code 

setName(self, v)

source code 

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.

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

source code 
Change the text or default values for a document template.

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)
(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.

__str__(self)
(Informal representation operator)

source code 

__getstate__(self, _special=('_v_','_p_'))

source code 

Class Variable Details [hide private]

isDocTemp

Value:
1                                                                     
      

func_code

Value:
<qm.external.DocumentTemplate.DT_String.func_code instance at 0xb7a34e\
6c>                                                                    
      

func_defaults__roles__

Value:
()                                                                     
      

func_defaults

Value:
()                                                                     
      

errQuote__roles__

Value:
()                                                                     
      

parse_error__roles__

Value:
()                                                                     
      

commands__roles__

Value:
()                                                                     
      

commands

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

SubTemplate__roles__

Value:
()                                                                     
      

tagre__roles__

Value:
()                                                                     
      

_parseTag__roles__

Value:
()                                                                     
      

parseTag__roles__

Value:
()                                                                     
      

varExtra__roles__

Value:
()                                                                     
      

parse__roles__

Value:
()                                                                     
      

skip_eol__roles__

Value:
()                                                                     
      

parse_block__roles__

Value:
()                                                                     
      

parse_close__roles__

Value:
()                                                                     
      

shared_globals__roles__

Value:
()                                                                     
      

shared_globals

Value:
{}                                                                     
      

setName__roles__

Value:
()                                                                     
      

default__roles__

Value:
()                                                                     
      

var__roles__

Value:
()                                                                     
      

munge__roles__

Value:
()                                                                     
      

manage_edit__roles__

Value:
()                                                                     
      

read_raw__roles__

Value:
()                                                                     
      

read__roles__

Value:
()                                                                     
      

cook__roles__

Value:
()                                                                     
      

initvars__roles__

Value:
()                                                                     
      

ZDocumentTemplate_beforeRender__roles__

Value:
()                                                                     
      

ZDocumentTemplate_afterRender__roles__

Value:
()                                                                     
      

validate__roles__

Value:
()                                                                     
      

validate

Value:
{}