Template

PyWPS Templating system

class pywps.Template.IfToken(type=None)

Special token used for IF/ELSE constructions. This token contains childs for the whole IF block as well as ELSE block. It’s childs do have assigned ifOrElseChild attribute, which indicates, whether the child token belongs to IF block or the ELSE block.

Note

Childs of this token should appear on the same level of nesting, as this token. So any child token with the same name will get the same value.

class pywps.Template.LoopToken(*args)

Special token used for LOOPing constructions

Note

Childs of this token should appear on the same level of nesting, as this token. So any child token with the same name will get the same value.

exception pywps.Template.TemplateError

General template exception

class pywps.Template.TemplateProcessor(fileName=None, compile=True)

Processor of the template class. This class is used for

  • loading template from text file
  • parsing (tokenizing) it to tokens object
  • setting values for each token
  • printing the result
getIncludedTokens(token)

Return list of tokens, which are taken from the included file

Parameters:token – input token of type include
Returns:list of tokens
getToken(statement)

Create new token object, based on input text statement

Parameters:statement (string) – some statement from the template
Returns:new token instance
isCompiled()

Check, if the template is compied – any *.tmplc file does exist

Return type:boolean
isUpToDate()

Check, if the template is up-to-date, the compiled file is younger, than the original template file.

Return type:boolean
readFromCompiled()

Set self.tokens from existing compiled file

recompile()

Set self.tokens from input text file and store them in compiled form for later usage.

set(key, value, tokens=None, parent=None)

Set value of some token

Parameters:
  • key (string) – key identificator
  • value (mixed (string, list, boolean, object) – the actual value of the token
  • tokens – list of tokens, where the search the right one, based on the token’s name
  • parent – expected parent token
Returns:

list of tokens (with value set to desired value)

tokenize(templateData)

Tokenize input text data.

Parameters:templateData (string) – input text
Returns:list of tokens
class pywps.Template.Token(type=None)

Base Token class. Token is snipplet of input template. Template consits from list of tokens.

addChild(childs)

Add child to this Token

Note

You can submit also only one child to this method, it will be converted to list automatically.

Parameters:child ([childs]) – list of child tokens
setParent(parent)

Set parent of this Token, assign it as child to other Token

Parameters:parent (Token) – parent
setValue(value)

Set value for this token

Parameters:value – any text or attribute, which will be assigned as value of this token
class pywps.Template.VarToken(type=None)

Token used for VAR constructions

Previous topic

Module Soap

Next topic

Module Wps

This Page