Welcome to Xierpa. This is the stable 1.2 version which was developed by Petr van Blokland + Claudia Mens (buro@petr.com) and is maintained by Michiel Kauw-A-Tjoe. It is subclassed by the Museum Meermanno and American Express applications.

SiteBuilder

The SiteBuilder class implements templates of methods that are often used when building a site application.
The class is self contained and running without additional methods. All methods called from within the SiteBuilder are implemented by the class, included parts or by parent classes. This allows the SiteBuilder class to be used as a final application. However it also very well possible to extend the class by redefining one or more of its methods.
Typically the following code implements a full functional website (without content):
Python example
from xpyth.xierpa.builders.sitebuilder import SiteBuilder class MySite(SiteBuilder):     pass MySite(e, result).build()

The hierarchy of called methods is as follows:
  • getxsltemplatename
  • subscribeajaxevents
  • build
    • setup
      • installsession
        • getprotectedsessionflag (default answers True)
      • initializeapplication (default empty)
      • initializeevents (default empty)
      • initializecommand (default empty)
      • initializeconstants (default empty)
      • initializesession
        • copyform2session
        • initializelanguage
        • initializesessionvalues (default empty)
      • opendatabase Depending if there is a database name defined.
        • getdatabasename (default answers None)
        • getgrafflepath
        • initializedatabase (default empty)
        • initializedatabasesessionvalues (default empty)
      • databaseauthorization
      • dispatchcommand Depending in the value of the answered mode.
        • getcommandmode
        • handle_xxx
        • handle_default
      • readdatabase
        • readanchorrecords
        • (getanchorrecord)
        • readselectedrecords
        • (getselectedrecords)
      • initializesessiondb
      • initializecms
      • updateAssociation
    • dispatchdocumenttype
      • isajaxrequest
      • isgethtmlupdaterequest
      • iscssrequest
      • isbinaryrequest
      • checkauthorization (default answers ['guest'])
        Depending on the authorization and ajax flag.
      • buildcachedocument
        • buildhtmldocument
          • buildhead
            • buildpagerefreshtime
            • buildrellinks
            • buildmeta
            • buildtitle
            • buildapplicationheadelements (default empty)
            • buildcss
              • buildcsscontent
              • iscssrequest
            • buildremotecss
              • buildcsscontent
              • iscssrequest
              • getcssmode
            • buildlayoutcss
            • buildjs
              • buildglobalbehavioursjs
              • buildcolorpickerjs
              • buildimagingjs
              • buildmochikitjs
                • usemochikit
              • buildcmsbuilderjs
              • buildhoverjs
                • usehover
              • buildeajaxdispatcherjs
                • useajaxdispatcher
              • buildsapplicationjs (default empty)
            • buildbody
              • initializepage
              • buildcolorpickerpopups
                • ispagewrapper
                • buildpage
                  Depending on the availability of a layout structure:
                  • getlayoutid
                  • tablelayout
                  • buildcontent (default warning)
              • finalizepage
              • buildgoogleanalytics
            • getgoogleid
      • buildajax
        • getajaxdict
          • dispatchajaxevent (Depending in the value of the ajax event)
            • getnewevent
      • buildcss
        • getcss
      • buildbinary
      • buildtransfer
        • transfer
          • getunauthorizedpath
    • getunauthorizedpath
    • close
      • closedatabase (default empty)
      • closeapplication (default empty)

An overview

The SiteBuilder class contains the following tags:
Open tagClose tagAttributesDocstring or default value
AJAXDISPATCHERPATH '/_root/_lib2/javascripts/xierpa/cms/cmsajaxdispatcher.js'
AJAXMODE 'ajax'
APPLICATIONNAME 'SiteBuilderApp'
BACKGROUNDCOLOR 'white'
BINARYMODE 'binary'
CLASS_GOOGLETRANSLATE 'googletranslate'
CLASS_PLAINTEXTAREA 'plaintextarea'
CLASS_WRAPPER 'wrappercss'
CMSLAYOUTS {}
CMS_VALIDELEMENTS 'a[href|target=_blank],strong,b,i,div[align],ul,ol,li,br,p,h1,h2,h3,h4,h5,img[src|width|height]'
CSSEXTENSION '.css'
CSSMODE 'css.css'
CSVMODE 'csv.csv'
DA 'da'
DATABASE None
DEBUG True
DEFAULTAUTHORIZATION ['guest']
DEFAULTCMSLAYOUT 1
DEFAULTLANGUAGE None
DEFAULTUSERID 'Guest'
DEFAULTVIEWERLAYOUT 1
DK 'dk'
DOCTYPE 'xhtml-transitional'
EN 'en'
ES 'es'
FONTFACE 'fontface'
FONTFACE_CONVERTTTF2EOT True
FONTFACE_EOT 'eot'
FONTFACE_EOTLITE 'eotlite'
FONTFACE_EXTENSIONS ('ttf', 'woff', 'otf', 'eot', 'eotlite', 'svg')
FONTFACE_OTF 'otf'
FONTFACE_SVG 'svg'
FONTFACE_TTF 'ttf'
FONTFACE_WOFF 'woff'
FR 'fr'
GETHTMLUPDATEMODE 'gethtmlupdate'
GLOBALBEHAVIOURSPATH '/_root/_lib2/javascripts/globalbehaviors.js'
GOOGLEANALYTICID {}
GOOGLEID None
GRAFFLEPATH './_graffles/datamodel.graffle'
HOVERPOPUPPATH '/_root/_lib2/javascripts/hoverpopup.js'
HTMLUPDATEPATH '/_root/_lib2/javascripts/gethtmlupdate.js'
IMAGECROPPATH '/_root/_lib2/javascripts/imagecroparea2.js'
IMAGESLIDETRANSITIONPATH '/_root/_lib2/javascripts/imageSlidesTransition.js'
IMAGINGJSPATH '/_root/_lib2/javascripts/raphael-min.js'
JQUERY_THEME 'base'
LABEL_FIND {'en': u'Find', 'nl': u'Zoek', 'dk': u'Z\xf8ek'}
LABEL_GOOGLETRANSLATECAPTION 'Disclaimer
We are fully aware that Google translation is not flawless for every text or language.\n\tStill it is better than nothing. Google keeps on improving on the translation, faster than we can do that. Over time we will add manual translations for English to the pages.'
LANGUAGEDEFAULT 'en'
LANGUAGEKEY 'language'
LANGUAGES ('nl', 'en', 'dk')
MOCHIKITPATH '/_root/_xsl2/js/MochiKit/MochiKit.js'
NL 'nl'
PAGEBACKGROUNDCOLOR 'white'
PAGEREFRESHTIME 0
PAGEWIDTH 1000
PARAM_EXITSERVER 'exitserver'
PARAM_GOOGLETRANSLATE 'g'
PATH_CROPLET '/_root/_lib2/javascripts/cropper/croplet.js'
PATH_CROPPER '/_root/_lib2/javascripts/cropper/cropper.js'
PATH_FONTFACE 'http://cloud.webtype.com/css/67c6930e-19d0-4591-94af-78aefd8f4ebe.css'
PATH_JQUERYMIN_JS '/_root/_lib2/javascripts/jquery/jquery-1.4.2.min.js'
PATH_JQUERYUI_CORE '/_root/_lib2/javascripts/jquery/ui/jquery.ui.core.js'
PATH_JQUERYUI_CSS '/_root/_lib2/javascripts/jquery/themes/%s/jquery.ui.all.css'
PATH_JQUERYUI_DRAGGABLE '/_root/_lib2/javascripts/jquery/ui/jquery.ui.draggable.js'
PATH_JQUERYUI_DROP '/_root/_lib2/javascripts/jquery/ui/jquery.effects.drop.js'
PATH_JQUERYUI_DROPPABLE '/_root/_lib2/javascripts/jquery/ui/jquery.ui.droppable.js'
PATH_JQUERYUI_JS '/_root/_lib2/javascripts/jquery/jquery-ui-1.8.custom.min.js'
PATH_JQUERYUI_MOUSE '/_root/_lib2/javascripts/jquery/ui/jquery.ui.mouse.js'
PATH_JQUERYUI_RESIZABLE '/_root/_lib2/javascripts/jquery/ui/jquery.ui.resizable.js'
PATH_JQUERYUI_WIDGET '/_root/_lib2/javascripts/jquery/ui/jquery.ui.widget.js'
PATH_JQUERY_DEMOCSS '/_root/_lib2/javascripts/jquery/css/demos.css'
PATH_JQUERY_JS '/_root/_lib2/javascripts/jquery/jquery-1.4.2.js'
PATH_JQUERY_TIMER '/_root/_lib2/javascripts/jquery/jquery.timer.js'
PATH_JS '/_root/_lib2/javascripts'
PATH_OTFONTS '/_root/_lib2/sys/otfonts'
PATH_PROTOTYPE '/_root/_lib2/javascripts/scriptaculous-js-1.8.3/lib/prototype.js'
PATH_READPERFECT '/_root/_lib2/javascripts/xierpa/cms/readperfect.js'
PATH_SCRIPTACULOUS '/_root/_lib2/javascripts/scriptaculous-js-1.8.3/src/scriptaculous.js'
PATH_TTF2EOTAPP '/_root/_lib2/sys/apps/osxintel/ttf2eot'
PROTECTEDSESSIONFLAG True
REDIRECTS {}
REFRESHONSESSIONEXPIRE True
REMOTECSS True
SERVERTYPE 'xierpa'
TARGETID_GOOGLETRANSLATE 'target_googletranslate'
UNAUTHORIZEDPATH './unauthorized'
UNPROTECTEDSESSIONKEYS ['language']
USEAJAXDISPATCHER False
USECOLORPICKER False
USECSSSESSIONID False
USEDATABASEINCSSMODE False
USEFLOATINGWINDOW False
USEGLOBALBEHAVIOURS False
USEGOOGLETRANSLATE True
USEHOVER False
USEIMAGECROP False
USEIMAGESLIDETRANSITIONS False
USEIMAGINGJS False
USEJQUERY False
USEJQUERYCSS True
USEJQUERYMIN False
USEMOCHIKIT False
USEPAGEWRAPPER False
USEREADPERFECT False
USESIMPLEX False
USETABLELAYOUT True
VIEWERLAYOUTS {}
WRAPPERCSS 'wrappercss'
XSLTEMPLATEPATH './_xsl/template.xsl'
XSL_XMLCONVERSIONS (, , , , , , )
build
The build tag is an example/template of the most common of page building method. It checks on authorization.
If authorized the call dispatchdocumenttype to find the right document to generate.
If not authorized, then call buildtransfer. Finally the close is called.
buildGoogleLanguageChoice class_
The buildGoogleLanguageChoice method builds the container that will be filled by the google translator with the language choice popup. The optional class attribute class_ defines the style of the enclosing div tag. The default value is self.CLASS_GOOGLETRANSLATE.
buildajax
This method only runs when the page is called in ajax mode.
The buildajaxbuilds checks if the Ajax application is using the same session a the content of the “json” structure to be interpreted by a JavaScript Ajax application. csjon must be included.
The default behaviour is to answer the “json” export of the dictionary result of self.getajaxdict().
See also http://python.cx.hu/python-cjson, http://www.json.org/JSONRequest.html and http://www.json.org/fatfree.html.
Warning: The getajaxdict() may do writing operations on the database, when the event handlers are called. So if there are taggling operation in there, it only should be performed once, even for debugging.

buildajaxdispatcherjs
The buildajaxdispatcher method installs the dispatcher as Ajax Javascript if self.useajaxdispatcher() answers True.
buildapplicationheadelements
The buildapplicationheadelements method can be used the add additional, application header elements, such as metatags. This method needs to be redefined by the inheriting application class. Default behaviour is to do nothing.
buildapplicationjs
The buildapplicationjs mthod can be used the add additional, application specific JavaScript. This method needs to be redefined by the inheriting application class. Default behaviour is to do nothing.
buildbinary
The buildbinary tag is called when a binary request is received as there was a True answer to the self.isbinaryrequest() call. This method allows to answer the binary content of files. Default behaviour is to do nothing. This method should be redefined by the inheriting application class.
buildbody
buildcachedocument
The buildhtmldocument tag builds the standard HTML page with doctype self.DOCTYPE, directly called from build if the authorization is checked and if the request is not an Ajax call.
The standard behaviour is create a xhtml-transitional document and to call buildhead and buildbody. SiteBuilder calls self.buildcachedocument, which by default is identical to self.buildhtmldocument, so there is no wasted time passing the call through. However, when self.buildcachedocument is redefined by the inheriting application class, it allows the application to detect if the XHTML for page already exists in cache and then use this existing code instead.
buildcmsbuilderjs
The buildcmsbuilderjs method includes the standard cmsbuilder.js JavaScript and builds the CmsBuilder JavaScript class. This is defined in the inheriting CmsBuilder class.
By default the method does nothing.
buildcolorpickerjs
The buildcolorpickerjs method includes the standard colorconvert.js and colorpicker.js JavaScript.
buildcolorpickerpopups
The buildcolorpickerjs method includes the standard colorconvert.js and colorpicker.js JavaScript.
buildcontent
The buildcontent tag does build that actual content of the page. It is called when there are no layouts defined (as self.getviewerlayouts() answers an empty dictionary.
This method needs to be redefined, if used, by the inheriting application class.
buildcss
The buildcss method builds a standard css set if self.useremotecss() answers False (default is True).
It’s usage is for css sources that contain random values to be recalculated for every page or for debugging.
In general it is better to use buildremotecss (by making self.useremotecss()), which code is generated only once and allows the browser to optimize by reading the css only once.
The default behaviour is to do nothing. If redefined by the inheriting application class, then don’t forget to include a surround style tag.

buildcsscontent
The buildcsscontent method builds the CSS output. It can be called from either buildcss of buildremotecss (in remote mode), depending on the result of self.useremotecss().
If nothing is done, this CSS will be identical to the CSS of the main page..
buildcssfontface
The buildcssfontface method builds the external style reference to an @font-face CSS, if the path self.PATH_FONTFACE is defined. Otherwise the method does nothing. The default value for self.PATH_FONTFACE is None, it needs to be redefined by the inheriting application class.
buildgethtmlupdate
buildglobalbehavioursjs
The buildglobalbehavioursjs method includes the standard self.GLOBALBEHAVIOURSPATH JavaScript if the result of self.useglobalbehaviours() is True.
The image slide transitions JavaScript is included if self.USEIMAGESLIDETRANSITIONS is True.
buildgoogleanalytics
The buildgoogleanalytics method tries to get the Google Analytics Id from the site as result of self.getgoogleid.
buildgoogleanalyticsjs
buildgoogletranslatejs
The buildgoogletranslatejs method adds the Google translate javascript, if USEGOOGLETRANSLATE is True. Add <div id="self.TARGETID_GOOGLETRANSLATE">...</div> to the page to implement the position of the language popup. See also translate.google.com/translate_tools.
buildhead
The buildhead tag builds the head part of the HTML page by calling respectively buildpagerefreshtime, self.buildtitle(), self.buildcss(), buildremotecss, self.buildlayoutcss() and self.buildjs().
self.buildgoogleanalyticsjs() must the last element in the head part.

buildhoverjs
The buildhoverjs method conditionally on the boolean result of self.usehover() includes the standard hoverpopup.js JavaScript.
buildhtmldocument
The buildhtmldocument tag builds the standard HTML page with doctype self.DOCTYPE, directly called from build if the authorization is checked and if the request is not an Ajax call.
The standard behaviour is create a xhtml-transitional document and to call buildhead and buildbody. SiteBuilder calls self.buildcachedocument, which by default is identical to self.buildhtmldocument, so there is no wasted time passing the call through. However, when self.buildcachedocument is redefined by the inheriting application class, it allows the application to detect if the XHTML for page already exists in cache and then use this existing code instead.
buildimagecropjs
The buildimagecropjs method includes the standard self.IMAGECROP JavaScript.
buildimagingjs
The buildimagingjs method includes the standard self.IMAGINGPATH JavaScript (currently referring to 'raphael-min.js'.
buildjqueryjs
The buildjqueryjs method includes the standard self.PATH_JQUERY_JS JavaScript.
If self.USEJQUERYCSS is True the jquery theme css is included. The default theme is base, that can be changed with locally by self.JQUERY_THEME. See also: http://jqueryui.com/themeroller

buildjs
The buildjs includes MochiKit and the required Ajax JavaScript.

buildlayoutcss
The buildlayoutcss tag tests if there is a layout available. If so then the self.tablelayoutcss(layout) constructor from the LayoutBuilder is used to build the CSS from the application’s layout definition. Otherwise nothing is done.
If self.USETABLELAYOUT is True use the “table” layout strategy. Otherwise use the “div” layout strategy.
buildmeta
The buildmeta method allows the inheriting application class to defined the self.meta to be called if the method is defined. Default behaviour is to do nothing.
buildmochikitjs
The buildmochikitjs method includes the standard self.MOCHIKITPATH JavaScript.
buildpage
The buildpage tag builds the content of the page. If there is a layout defined, then the self.tablelayout(layout) is used to build the page content from the application’s layout definition. Otherwise it does call the self.buildcontent.
If self.USETABLELAYOUT is True use the “table” layout strategy. Otherwise use the “div” layout strategy.
buildpagerefreshtime
The buildpagerefreshtime method builds a <meta http-equiv="Refresh" content="30"/> if the result of self.getpagerefreshtime() is larger than zero.
The actual building of the meta tag is done byXierpaBuilder.reloadpage().
See also www.web-wise-wizard.com/html-tutorials/html-meta-tag-search-tutorial.html
buildreadperfectjs
The buildreadperfectjs method builds the JavaScript for the ReadPerfect toolbox. To use ReadPerfect, the inheriting application class should have self.usereadperfect() answer True. The default behaviour is to call self.initializereadperfect() and to include self.PATH_READPERFECT if the application is using the ReadPerfect interface.
buildredirect
The buildredirect builds the transfer page with self.getredirectpath()
buildrellinks
The buildrellinks method allows the inheriting application class to defined the self.rellink (in HTNML <link>) to be called if the method is defined. Default behaviour is to do nothing.
buildremotecss
The buildremotecss method (executed only if self.REMOTECSS = True) responds to two situations:
  • If the result of iscssrequest is False (default), then make the method build an external style reference to itself;
  • If iscssrequest is True, then the method builds a single css syntax document as return to the style reference it created itself.
It is possible to give the css parameter another value than 1. In that case the css builder can decide on the mode which css to build.
Note: Note that we build the url including the current session id if self.useremotecssid() answers True (default).
This make the url only valid inside the current session. But otherwise we don't have the session available while calculating the content of the css.
If self.useremotecss() answers False by the inheriting application class, then the sid is not included as parameter.

buildrss
The buildrss runs the page as rss. To be defined local.
buildsapplicationjs
The buildapplicationjs mthod can be used the add additional, application specific JavaScript. This method needs to be redefined by the inheriting application class. Default behaviour is to do nothing.
buildsimplexjs
The buildsimplexjs method builds the JavaScript for the Simplex (help) functions. To use Simplex, the inheriting application class should set self.USESIMPLEX to True. The JavaScript code is implemented in the 'simplex.py' source.
Default behaviour of this method is to nothing.
buildtitle
The buildtitle builds the title of the page inside the head tag. By default is shows the result getapplicationname.
buildtransfer
The buildtransfer tag builds a transfer HTML page width doctype self.DOCTYPE, directly called from build if the authorization is not valid or any other recjection for a standard built.
The standard behaviour is create a xhtml-transitional document and to call tranfer to the the url that is the result of self.getunauthorizedpath().

buildxml
The buildxml runs the page as xml and render either with _py/template.py or _xsl2/template.xsl. Note: Not yet working.

checkauthorization
The checkauthorization method answers a list of roles, if the current user is authorized to view the page.
If the user is not authorized, then an empty list is answered. Default behaviour is to answer the content of self.DEFAULTAUTHORIZATION as ['guest']. Note that this method cannot use the database for gathering the user roles, since it is not yet initialized in this stage of processing the page. The inheriting application class can have a more refined check on the authorization and roles, e.g.
as implemented in the CmsBuilder/Login class.
For individual roles this method needs to be redefined by the inheriting application class.
cleanupdatabase
The cleanupdatabase method can be used to do in-page database verification and cleaning. This method needs to be redefined by the inheriting application class. The default behaviour is to do nothing. Note that since this activity is performed inside initialization of a single page, the task should not take too long. The class contact self.USECLEANUPDATABASE and url parameter self.e.form[self.PARAM_CLEANUPDATABASE] can be used to secure that unauthorized users cannot perform the function.
close
The close tag does all closing activities of the page. By default is calls the closedatabase method and the closeapplication.
closeapplication
The closeapplication tag wraps up all pending matters of the running application (except closing the database which is done by closedatabase. The default behaviour is to do nothing. This tag needs to be redefined by the inheriting application class.
closedatabase
The closedatabase method is called to do some optional closing of the database. Default behaviour is to do nothing.
This tag needs to be redefined by the inheriting application class.
Note: There is no need to implemenent the closing of a database connection is no longer required. We keep the lines open for efficiency reasons. Only when the application explictely wants to close a database connection, then the method should be redefined.

copyform2session
The copyform2session method copies a selected set of e.form parameters to e.session.
The keys to copy are derived from the resulting string list of getunprotectedsessionkeys.
The values are only copied if the key really exists in e.form. Otherwise the session values remain untouched.
databaseauthorization
The databaseauthorization method is called after open database and before dispatchcommand.
The default behaviour to do nothing.
dispatchajaxevent
This method only runs when the page is called in ajax mode.
The dispatchajaxevent method calls all (target, hook) combinations that are subscribed to the event. A subscribed method should be able to take the result of a self.newevent(...) as attribute.
This called answers the structure {'targets': (('target1', xhtml1), ('target2', xhtml2), ...)} that can be translated into JSON.
The method expects one or more of the following form variables to be set in the Ajax call: appid, table, anchorid, table, mode, data and event.
If e.form['target'] is defined, the target value of the subscripion is None, then use that as target.
If the target value of the event subscription is None and the e.form['target'] is not defined, then hook is expected to have not result. So it will be excecuted without storing the result in the answering result dictionary.
dispatchcommand
The dispatchcommand method handles the all form stuff of the previous page, e.g. by saving to the database. The typical response is to call self.preparehandle_xxx and self.handle_xxx commands, were “xxx” is the name of the command.
This handling is done before any reading of the database and before anything of the current page is processed.
In order to allow data be modified by the application class, before saving by CmsBuilder, the self.preparehandle_xxx is called. This call is ignored if the prepare handler does not exist.
The command is directly related to the name of a standard method called. Save relates to self.handle_save(mode).
The value of mode is the result of the call self.getcommandmode() from the XierpaBuilder class. This value might not be initialized when the event is issued by a different source than the standard set of buttons. The default value for mode is the result of self.getmode(command) (which is None by default).
If the handler does not exist, then a warning message is send to the output.
If there is no command defined, then respectively preparehandle_default and handle_default are called.
dispatchdocumenttype
The dispatchdocumenttype method decides from available form parameters what type of document is requested.
If the result of isajaxrequest is True then it makes “json” output by calling buildajax.
If the result of iscssrequest is True (e.g. as made by the buildremotecss itself, then make “css-only” output by calling buildremotecss. Otherwise standard HTML output is generated by calling buildhtmldocument.
event_dispatcher event
The event_dispatcher is called by Ajax on a button event. If event.mode is not defined, it will dispatch on the application id 'abc' and the event 'xyz' by calling self.event_abc_xyz(event). If event.mode has a value '123', then the called hook is self.event_abc_xyz_123(event).
If the method does not exist, a warning is generated.
finalizepage
The finalizepage tag allows to execute code right after the body tag is written.
This method can be used, e.g. to write the content of hovers to the page.
This method needs to be redefined by the inheriting application class. Default behaviour is to do nothing.
getajaxdict
This method only runs when the page is called in ajax mode.
The getajaxdict method answers a Python dict instance that will be converted to “json” output.
If not self.DEBUG and e.form['_sid'] != self.getsid() then answer an empty dictionary, since the session id does not match.
The self.DEBUG is there so we can debug single ajax url’s without the right session id.
If self.useajaxdispatcher() answers True, then execute all hooks that subscribed to the current event e.form['event'].
getajaxeventnames
The getajaxeventnames method answers a unsorted list with unique names of all subscribed events.
getajaxeventtargethooks eventname
The getajaxeventtargethooks method answers the list of target hooks that are subscribed under eventname.
If there is no subscription, answer None.
getajaxresult
The getajaxresult method answers the ajax result list self.ajaxevent_result. If it does not exist yet, then create it first as empty list.
getajaxurldict params
url
The getajaxurldict method answers the result of an Ajax call to an external url that delivers Ajax json data. This method must be used if a page needs information outside of the original domain, likely to be another server in the admin range that we control the software one, since browser policy does not allow the reading done from a JavaScript.
The url must be a complet url and the params is a dictionary with parameters to add.
If there is an error reading the url, then None is answered.
getanchorrecord mode
readonly
The getanchorrecord tag answers the current anchor record for the specified mode as read and stored by the self.readanchorrecords() call in self.readdatabase().
The optional readonly attribute is available to direct the status of the record. Default value is True.
If readanchortrecords has not been called at this point, then do that first.
The method answers a NoneRecord if the mode does not exist in the self.anchorrecords dictionary.
getapplicationname
The getapplicationname method answers the name of the application. By default it answers the content of self.APPLICATION.
getcmslayouts
The getcmslayouts method answers a dictionary of gnode structure that defines the layout of the cms as defined in self.CMSLAYOUTS.
getcssmode
The getcssmode method answers the mode of the css flag. Default is 1 but it allows the inheriting application to add differente modes of css requests.
getdatabasename
The getdatabasename method does return name of the SQL database as defined in self.DATABASE.
This method needs ony to be redefined by the inheriting application class if the database is conditional.
Default value is self.DATABASE.
getdefaultauthorization
The getdefaultauthorization answer the list with default roles. Default behaviour is to answer self.DEFAULTAUTHORIZATION.
getdefaultlanguage
The getdefaultlanguage method answers the default language(code).
If no language parameteris available and If self.DEFAULTLANGUAGE is defined, then use that as language.
Otherwise answer the first language from list self.getlanguages().
getgoogleid
The getgoogleid method answers the Google Analytics Id of the site. The default behaviour is to answer self.GOOGLEID. If the site does not used Google Analytics, then the value should be None.
getgrafflepath
The getgrafflepath method does return the relative path of the datamodel graffle file. Typically this is defined in self.GRAFFLEPATH as './_graffles/datamodel.graffle'.
getlayout
The getlayout method answers the default layout as defined by self.DEFAULTVIEWERLAYOUT and if it exists in the resulting dictionary of layouts of self.getviewerlayouts(). In an editor application this method can be redefined to answer on of the layout from the resulting dictionary of self.getcmslayouts() if in CMS mode.
getnewevent anchorid
appid
data
jscallback
mode
name
table
target
The getnewevent method answers an instance of a event that has the optional attribute name, appid, table, anchorid, table, mode, data and target.
Note that is may be important to set the appid and mode if an application is selected by an outside source, or else the application parameters cannot be used during initial building of the page, since the event does not have the right mode set using self.geteventui(event, key).
The default behaviour is to answer an instance of AjaxEvent. For other result instances or additional attributes this method can be redefined by the inheriting application class.
getpagerefreshtime
The getpagerefreshtime method answers the refresh time of the page. By default it answers the exipiration time of the session plus 2 minutes (if self.REFRESHONSESSIONEXPIRE is True), so we are sure it is expired by then.
If there is no session then it answers the value of self.PARAM_PAGEREFRESHTIME.
Because open windows, that have the 'exitserver' parameter set, do expire at a certain time, so the server stops. If the e.form['exitserver'] is define, then we don’t want an expiration time in the page.
getprotectedsessionflag
The getprotectedsessionflag method answers a boolean to indicate if a protected session should be created.
If the flag is the content self.PROTECTEDSESSIONFLAG as True (default), then no automatic copying from e.form to e.session is performed. The copying is then optionally done by copyform2session.
getredirectpath
The getredirectpath returns the value of the key e['server'] in self.REDIRECTS.
e['path'] is added to the redirection url
getselectedrecords mode
The getselectedrecords tag answers the selected records for the specified mode as read and stored by the self.readselectedrecords() call in self.readdatabase().
If readanchortrecords has not been called at this point, then do that first.
The method answers aNoneSelection if the mode does not exist in the self.anchorrecords dictionary.
getservertype
The getservertype method ansers the type of application. The default behaviour is to answer self.SERVERTYPE.
This value can be used to determine if the application is running on a Xierpa server, as Google server or standalone application.
getunauthorizedpath
The getunauthorizedpath method answers the relative path of the page to show that the current has no authorization for the requested page. Default value is the content of self.UNAUTHORIZEDPATH as './unauthorized'.
getunprotectedsessionkeys
The getunprotectedsessionkeys method answers the list of keys of which the values should be copied from e.form to e.session upon page initialization. Default is [self.LANGUAGEKEY].
Note: Beware that CmsBuilder redefines this method, so it is no enough to redefine UNPROTECTEDSESSIONKEYS on the level of an inheriting application class.

getuserid
The getuserid method answers the user id of the current user. The default behaviour is to answer self.DEFAULTUSERID. The inheriting application class can answer the record id of the user that logged in, if there is a database available.
getviewerlayouts
The getcmslayouts method answers a dictionary of gnode structure that defines the layout of the cms as defined in self.VIEWERLAYOUTS.
getxsltemplatename mode
The getxsltemplatename method answers the relative path of the template used in this mode.
The default behaviour is to answer the content of self.XSLTEMPLATEPATH as ./_xsl/template.xsl.
handle_default
The handle_default method is called when the page is called without a self.XIERPACOMMAND. This method can be used to handle page calls that don’t generate a command such as the submit of a checkbox.
To be redefined by the inheriting application class. The default behaviour to do nothing.
hasauthorization role
The hasauthorization method answers a boolean if the role is authorized in the current setting of the page and session. Default behaviour is to check if role is inside the result of self.checkauthorization(). Note that the used method self.checkauthorization is running in a phase that no database connection is available yet. So this level of checking can only be based on static parameters.
Otherwise the inheriting application class needs to check the roles on another level (e.g. in the CmsBuilder class).
initializeapplication
The initializeapplication tag can be used to initialize the application. This is done before anything else is executed. The default behaviour is to do nothing. This tag needs to be redefined by the inheriting application class. This could be setting cookiesession.

Python example
def initializeapplication(self): self.e.savecookiesession = True


initializecms
The initializecms method is used to cms initialization.
The default behaviour of the method is to do nothing. If required this method needs to be redefined by the inheriting application class.
initializecommand
The initializecommand tag can be used to redefine the form commands of the previous page.
This is especially useful if url’s with simple parameters must be interpreted as the result of the form submit.
In general we don’t want these visible parameters not grow too complex. This method allows to construct the form parameters from simple parameters.
The default behaviour is to do nothing. This tag needs to be redefined by the inheriting application class.
initializeconstants
The initializeconstants tag can be used to define constant values of the page.
The default behaviour is to do nothing. This tag needs to be redefined by the inheriting application class.
initializedatabase
The initializedatabase method makes sure that the database is ready to read or write page data.
This may in practice include create any records (such as a project) that are assumed to be in place when writing activity or module data. Also caching of the normalized table content is issued in this method.
To be redefined by the inheriting application class. The default behaviour to do nothing.
initializedatabasesessionvalues
The initializedatabasesessionvalues tag can be used to test and (re)define any current session and form value.
This method does the initialization of session values using the database. See also the initializesessionvalues method to initialize the post-database session.
The default behaviour is to do nothing. This tag needs to be redefined by the inheriting application class.
initializeevents
The initializeevents method subscribes a (target, hook, event) tripled to be called on the firing of a named event. This method can be redefined by the inheriting application class. The default behaviour is to do nothing.
initializelanguage
The initializelanguage method does initialize self.language if one of the following is set: e.session[self.LANGUAGE] == language, e.session[language], e.form[self.LANGUAGE] == language or e.form[language], where self.LANGUAGE by default is equal to 'language' and language is one of the language codes of the resulting list self.getlanguages() (from XierpaBuilder).
If no language parameter availalbe and if the e['recveivedheader'] contains an indicator of the browser, that use that as language.
Otherwise if there is no language specified in either the session or the form, then use the first in the list that is answered by self.getlanguages().
The copying of e.form[self.LANGUAGEKEY] to the session is done by the default version of copyform2session with the default session key set answered by getunprotectedsessionkeys.
Always set the e.session[self.LANGUAGEKEY] to the calculated language code if there is a session.
initializepage
The initializepage tag allows to execute code right after the body tag is written.
This method needs to be redefined by the inheriting application class. Default behaviour is to do nothing.
initializereadperfect
The initializereadperfect method builds the JavaScript with global values for the readperfect interface. This method needs to be redefined by the inheriting application class. The default behaviour is to do nothing.
initializesession
The initializesession method assumes that there is a session installed by the self.installsession() at the start of the application. If the session does not exist or when the user is not authorized, then do nothing.
The method self.initializesessionvalues() is called (default empty) to allow the application test and define any current session value.
If no session is required for the site, then redefine this method with pass content.
Note: Different from the behaviour of older applications, the protected attribute of the session is set to True.
This means that for security reasons the content of e.form is no longer automatic copied to e.session. The copying (and modifying) of the form parameters should be done in the copyform2session method.

initializesessiondb
The initializesessiondb method is used to do any session initialization that needs the database to be opened (unlike that initializesession that runs before the initialization of the database.
The default behaviour of the method is to do nothing. If required this method needs to be redefined by the inheriting application class.
initializesessionvalues
The initializesessionvalies tag can be used to test and (re)define any current session and form value.
This method does the post-database initialization of session values. See also the initializedatabasesessionvalues method to initialize the session values that need the database connection such as reading normalization fields.
The default behaviour is to do nothing. This tag needs to be redefined by the inheriting application class.
installsession
If the result of call self.checkauthorization() is not an empty list of roles, then the initializesession method does initialize the session if it does not exist.
At this time it is too early to set the user of the session, since there is no database open or parameters are not defined. So it is up to the applicaiton to store the user in the session (as id, the result of self.getuserid() in a later stage.
isajaxrequest
The isajaxrequest tag answers a boolean of the current request is of type “ajax”, default equal to the status of e.session[self.AJAXMODE].
isbinaryrequest
The isbinary tag answers the binary name if the current request is of type "binary", default equal to the status of e.form[self.BINARYMODE + '.' + EXTENSION] where EXTENSION is equal to one of the valid binary extensions in BINARYEXTENSIONS. Otherwise None is answered.
When the binary parameter use used at the end of an url, then for a browser this url looks like a valid binary document such as an image, making display and download work.
Example http://www.petr.com/mysite/-/code-1234/status-xyz/binary.png will answer 'png'.
iscssrequest
The iscssrequest tag answers a boolean if the current request is of type “css”. The default behaviour is to scan the form parameters if there is a key that ends with self.CSSEXTENSION. We can trust that this is save, since a CSS request always must and with this extension and it is very unlikely that there will be a plain url with no parameters used in the site. We can not longer just check on self.CSSCODE, since other libraries
isgethtmlupdaterequest
The isgethtmlupdaterequest tag answers a boolean of the current request is of type "gethtmlupdate", default equal to the status of e.session[self.GETHTMLUPDATEMODE].
isgoogletranslate
The isgoogletranslate method answers the boolean flag if the page is in google translate mode, depending on the e.form[self.PARAM_GOOGLETRANSLATE]. Note that in order for the tranlation result to be cached, the self.PARAM_GOOGLETRANSLATE is derived from e.form, not from e.session. This way we get different caching urls.
Note that in case the page is not in translation mode, None instead of the usual boolean False is answered, so the result of the method can be used as url parameter, where it will not be added.
ispagewrapper
isredirectrequest
The isredirectrequest answers True if e['server'] is in self.REDIRECTS.

isrssequest
The isrssequest tag answers True if path is rss.

isxmlrequest
The isxmlrequest tag answers True if path is xml.
Note: Not yet working.

opendatabase
The opendatabase method standard opens the database assuming the that self.getgrafflepath() (optional, the default value is './_graffles/datamodel.graffle') and the result of self.getdatabasename() are defined.
The graffle path may also point to server root if the path starts with /_root, e.g. '/_root/_graffles/datamodel.graffle'.
The closing tag is the closedatabase finally called by the close method.
If the database name is not defined, the self.agent is set to None.
postajaxevent event
The postajaxevent method handles the event by calling the hooks of the subscriptions to event.
This method allows hooks post their own events (e.g. by using an adjusted copy of event). Beware that this should posting should not be looping. If there is no target/hook defined for this event, then call self.event_dispatcher(event) for default event handling or warning that the appropriate method should be defined.
readanchorrecords readonly
The readanchorrecords tag does read and store the main record for the current session.
In case getanchorrecord is code in an earlier stage, then the call to readanchorrecords is executed there.
The optional readonly attribute is available to direct the status of the record. Default value is True.
To be redefined by the inheriting application class. The default behaviour is to create an application attribute anchorrecord holding a NoneRecord instance.
readdatabase
The readdatabase tag is the method where the main anchor point records are read from the database. Optionally this method can be redefined by the inheriting application class. Default is to call self.readanchorrecords() and self.readselectedrecords() are called.
readselectedrecords
The readselectedrecords tag does read and store the selected records as read and stored by the self.readselectedrecords() call in the self.readdatabase().
In case getselectedrecords is code in an earlier stage, then the call to readselectedrecords is executed there.
To be redefined by the inheriting application class. The default behaviour is to create an application attribute selectedrecords holding a NoneSelection instance.
setup
The setup tag initializes the builder before any HTML page processing/building is done.
Typically the setup is use to initialize the command, initialize session values, validation, open a database connection and do any necessary writings through the self.dispatchcommand() call. This is by default a dispatcher for the various known commands and their modes.
If self.USEDATABASEINCSSMODE is set (defailt is False), then open then open the database for use in the CSS building as well. It is assumed that in most cases it is not required to open and initialize the database session for just the CSS building. In some cases the usage may be conditional, so the inheriting application class can redefine self.usedatabaseincssmode.
showdebug
The showdebug is called e.g. by the CmsBuilder instance. This method should be redefined by an inheriting application class. Default behaviour is to do nothing.
simplenavigation path
THIS METHOD IS DEPRICATED
simplesite bgcolor
csspath
font
fontsize
path
template
title
THIS METHOD IS DEPRICATED The simplesite is a tiny, tiny example of the next generation of page builders (dating 2007 in writing this). It only needs some core parameters as input such as title, font and fontsize.
It then builds a complete website with that, creating virtual pages, navigation, etc.
The simplesite tag assumes that there is the relative path in the the path attribute (default ./_m/) refers to the directory of the XML document. The name of the specific document is referred to by a /-/page-xxx parameter in the url.
The XML document is translated by the XSL document in attribute template. Default template file is ./_xsl/template.xsl.
All XML tags should either be defined as xsl:template matching template or be defined as Python methods in the running site class.
If the csspath attribute is defined, then link use that as css. Otherwise build a small generic CSS with ids body, #navigation and #content.
The navigation is automatically built from the content of the _m directory. Optioanally an inheriting class can define another simplesubnavigation to show additional navigation below the main navigation.

Python example
self.simplesite(title='My Xierpa Website')

Todo: In the future, this tag source should be replaced by a new class PageBuilder

subscribeajaxevents events
hook
target
This method only runs when the page is called in ajax mode.
The subscribeajaxevents method takes the target and hook pair and subscribes it in the self.ajaxevent_subscribers to be called by every firing of one of the events in events list.
This mechanism is similar to the standard “MVC” model, which stands for Model-View-Controller.
If there is an ajax event, then the subscribed hook is rendered to XHTML and answered as target result to the calling page.
Initialize the self.ajaxevent_subscribers dictionary for {event:[(target, method), ...], ...} sets.
updateAssociation
The updateAssociation method allows the inheriting application to increment the count of the relation between the current page and the previous page. This method must be redefined by the inheriting application class. The default behaviour is to do nothing.
useajaxdispatcher
By default the useajaxdispatcher method answers the boolean flag self.USEAJAXDISPATCHER indicating if the AjaxDispatcher library is used in the page.
The typical usage of Ajax in a SiteBuilder instance is in combination with the 'cmsajaxdispatcher.js' JavaScript.
The application is calling the dispatcher with special links as self.ajaxlink and self.ajaxformlink. These will call the current page in Ajax mode (with e.form['ajax'] defined). The application does recognize that and calls the subscribed event-target-method sets that match e.form['event'].
usecolorpicker
The usecolorpicker method answers the boolean flag self.USECOLORPICKER indicating if the buildcolorpickerjs library is used in the page.
It also ensures that the popups for colorpicker are build into the html body. So the colorpicker() can be called from the html body.
See also: colorpicker in sitebuilder.

usedatabaseincssmode
The usedatabaseincssmode method answers the boolean flag if the application needs an open database when building the CSS (remotely). This saves the unnecessary the handling of the database. It is assumed that in most cases it is not required to open and initialize the database session for just the CSS building. In some cases the usage may be conditional, so the inheriting application class can redefine this method.
usefloatingwindow
The usefloatingwindow method answers the boolean flag if the application is using a floating window. The default behaviour is to answer self.USEFLOATINGWINDOW. The use of this method is that it can be redefined, so the usage of the window can be conditional (e.g. depending on the state of the self.session[self.PARAM_EDIT] paremeter.
useglobalbehaviours
The useglobalbehaviours method answers the boolean flag self.USEGLOBALBEHAVIOURS indicating if the globalbehaviors.js library are used in the page.
usegoogleanalytics
usehover
The usehover method answers the boolean flag self.USEHOVER in dicating if hovers are used in the page.
useimagecrop
The useimagecrop method answers the boolean flag self.USEIMAGECROP indicating if the cropimagearea library is used in the page.

useimagingjs
The useimagingjs method answers the boolean flag self.USEIMAGINGJS indicating if the buildimagingjs library is used in the page.

usejquery
The usejquery method answers the boolean flag self.USEJQUERY or self.USEJQUERYMIN indicating if the Mochikit library is used in the page. This is a separate method, to allow applications to load JQuery conditionally.
usemochikit
The usemochikit method answers the boolean flag self.USEMOCHIKIT indicating if the Mochikit library is used in the page. This is a separate method, to allow applications to load Mochikit conditionally.
usereadperfect
The usereadperfect method answers the flag if the application is using the ReadPerfect toolbox. The method checks if self.USEFLOATINGWINDOW is enabled. The default behaviour is to answer self.USEREADPERFECT.
useremotecss
The useremotecss method answers the flag if a remote css file should be used. Default is the value of self.REMOTECSS.
useremotecssid
The useremotecssid method answers the flag if a remote css file call should contains the session id. Default is the value of self.USECSSSESSIONID.