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.

XierpaBuilder

The XierpaBuilder class is builder where all the special Xierpa tags for goodies are defined.

Import

from xpyth.xierpa.builders.xierpabuilder import XierpaBuilder

An overview

The XierpaBuilder class contains the following tags:
Mismatch in closing tag "td", expected "col" in tree "['html', 'body', 'div', 'div', 'div', 'component', 'div', 'table', 'tr', 'row', 'td']".
Mismatch in closing tag "row", expected "td" in tree "['html', 'body', 'div', 'div', 'div', 'component', 'div', 'table', 'tr', 'row']".
Mismatch in closing tag "tr", expected "row" in tree "['html', 'body', 'div', 'div', 'div', 'component', 'div', 'table', 'tr']".
Open tagClose tagAttributesDocstring or default value
ALLOWED_DOCUMENTFORMATS ('pdf', 'txt', 'zip')
ALLOWED_IMAGEFORMATS ('jpg', 'png', 'gif')
ALLOWED_MOVIEFORMATS ('qt', 'mov', 'mp3', 'mpg', 'mpeg', 'wmv')
DOCUMENTTYPE_GIF 'gif'
DOCUMENTTYPE_JPG 'jpg'
DOCUMENTTYPE_MOV 'mov'
DOCUMENTTYPE_MP3 'mp3'
DOCUMENTTYPE_MPEG 'mpeg'
DOCUMENTTYPE_MPG 'mpg'
DOCUMENTTYPE_PDF 'pdf'
DOCUMENTTYPE_PNG 'png'
DOCUMENTTYPE_QUICKTIME 'qt'
DOCUMENTTYPE_TXT 'txt'
DOCUMENTTYPE_WMV 'wmv'
DOCUMENTTYPE_ZIP 'zip'
ENTRYTYPE_BUTTON 'button'
ENTRYTYPE_CHECKBOX 'checkbox'
ENTRYTYPE_PASSWORD 'password'
ENTRYTYPE_RADIO 'radio'
ENTRYTYPE_TEXT 'text'
ENTRYTYPE_TEXTAREA 'textarea'
EXTENSIONS_DOCUMENTS ('pdf', 'eps', 'zip', 'rar', 'tar', 'gz')
EXTENSIONS_IMAGES ('jpg', 'jpeg', 'png', 'gif')
EXTENSIONS_TEXT ('xml', 'xsl', 'txt')
EXTENSIONS_VALIDFILES ('jpg', 'jpeg', 'png', 'gif', 'pdf', 'eps', 'zip', 'rar', 'tar', 'gz')
EXTENSIONS_XML ('xml', 'xsl')
EXTENSION_EPS 'eps'
EXTENSION_GIF 'gif'
EXTENSION_GZ 'gz'
EXTENSION_JPEG 'jpeg'
EXTENSION_JPG 'jpg'
EXTENSION_PDF 'pdf'
EXTENSION_PNG 'png'
EXTENSION_RAR 'rar'
EXTENSION_TAR 'tar'
EXTENSION_TIF 'tif'
EXTENSION_TIFF 'tiff'
EXTENSION_TXT 'txt'
EXTENSION_XML 'xml'
EXTENSION_XSL 'xsl'
EXTENSION_ZIP 'zip'
ICONPATH_PDF '/_root/_lib2/images/icons/iconpdf.gif'
ICONPATH_TXT '/_root/_lib2/images/icons/new/file-text.png'
ICONPATH_ZIP '/_root/_lib2/images/icons/iconzip.gif'
ITEMLISTICONS {'pdf': '/_root/_lib2/images/icons/iconpdf.gif', 'txt': '/_root/_lib2/images/icons/new/file-text.png', 'zip': '/_root/_lib2/images/icons/iconzip.gif'}
LANGUAGES ['nl', 'en', 'dk']
NOTIFYERROR_DEFAULTMAIL 'r@petr.com'
NOTIFYERROR_ERROR 1
NOTIFYERROR_MAIL 3
NOTIFYERROR_RAISE 2
PARAM_PAGE 'page'
PATH_IMAGESBASE './_images'
SHOWTIME False
XIERPABUILDER_VISUALVERIFY_PATTERN 'xierpabuilder_visualverify_pattern'
XIERPACOMMAND 'xierpa_command'
XIERPA_SID '_sid'
XSL_XMLCONVERSIONS (, , , , , , )
addbutton accesskey
class_
enabled
label
mode
path
submit
Show an add button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.savebutton(path='address')





ajaxform _ajaxform anchorid
appid
data
event
id
jscallback
jsvalidator
mode
params
table
target
url
The ajaxform method implements a generic way to update part of the page on the submit of a form, using an AJAX call back on the application.
The page needs to include MochiKit and the javascript '/_root/_lib2/javascripts/xierpa/cms/cmsajaxdispatcher.js'.
(In SiteBuilder set self.USEMOCHIKIT = True and self.USEAJAXDISPATCHER = True to include the javascript.
The self.formsid is called by the method, so the AJAX call has the session available for security check.
The id attribute holds the id of the form.
The optional url defined the URL that AJAX can call to update the information on an area on the page. This URL needs to contain the 'ajax' parameter to make self resspond as an AJAX application. Also the SID number is added to the URL, so the AJAX response of the application can check if the requested SID matches his own. The default value of url is to call the self application. If there is a session, also include the “_sid” in the URL, to allow the called AJAX to check if the request is valid.
The optional table can hold the table name that the anchorid refers to.
The optional anchorid can hold the id of the anchor record of table. If defined, then table is obligatory.
The optional mode can hold the application use of a calling mode, e.g. for the selected table name of the record. The default value is an empty string.
The optional target holds the target for this event. If defined then this value will be substituted for every target that is set to None in the AJAX event subscription.
The optional event holds the application event code. The default value is an empty string in which case the AJAX application doesn't do anything and doesn't answer target content.
See also: ajaxlink

ajaxformlink _ajaxformlink alt
anchorid
appid
class_
currentcss
data
event
forcecurrent
id
iscurrent
jscallback
jsvalidator
mode
params
table
target
url
The ajaxformlink method builds an HTML link to the form with id id. For more information see the description of self.ajaxform and self.ajaxlink.
ajaxformlinkreloadable _ajaxformlinkreloadable alt
anchorid
appid
class_
currentcss
data
event
forcecurrent
id
iscurrent
jscallback
jsvalidator
mode
params
reloadable
table
target
url
The ajaxformlinkreloadable method builds an HTML link to the form with id id. For more information see the description of self.ajaxform and self.ajaxlink.
ajaxlink _ajaxlink alt
anchorid
appid
class_
currentcss
data
event
forcecurrent
iscurrent
jscallback
jsvalidator
mode
params
style
table
target
url
The ajaxlink implements a generic way to update part of the page on the mouseup of a link using an AJAX callback on the application.
The page needs to include MochiKit and the javascript '/_root/_lib2/javascripts/xierpa/cms/cmsajaxdispatcher.js'.
(In SiteBuilder set self.USEMOCHIKIT = True and self.USEAJAXDISPATCHER = True to include the javascript.
The optional url defined the URL that AJAX can call to update the information on an area on the page. This URL needs to contain the 'ajax' parameter to make self resspond as an AJAX application. Also the SID number is added to the URL, so the AJAX response of the application can check if the requested SID matches his own. The default value of url is to call the self application. If there is a session, then also include the “_sid” in the URL, to allow the called AJAX to check if the request is valid.
The method supplies a number of value for the application to interact with the AJAX application. It is up to the application to define their meaning.
The optional appid can hold an application ID. The default value is 0.
The optional table can hold the table name that the anchorid refers to.
The optional anchorid can hold the id of the anchor record of table. If defined, then table is obligatory.
The optional mode can hold the application use of a calling mode, e.g. for the selected table name of the record. The default value is an empty string.
The optional data can hold an application data string. The default value is an empty string.
The optional event holds the application event code. The default value is an empty string in which case the AJAX application doesn't do anything and doesn't answers target content.
The optional target holds the target for this event. If defined then this value will be substituted for every target that is set to None in the AJAX event subscription.
The optional params attribute can hold a dictionary or parameters (just as in any link tag) that are added to the URL as parameters. It is not allowed to use any of the parameter names that are part of the standard AJAX parameter set. The optional jscallback attribute can hold a Javascript snipppet or the name of a Javascript function that will be called client-side after the AJAX request is complete. A function used here must accept 2 parameters; the first one is true/false on success/failure, the second one contains the results set which MAY NOT CONTAIN SINGLE QUOTES! The optional jsvalidator attribute can hold a Javascript snipppet or the name of a Javascript function that will be called client-side before the AJAX request is made. This function must accept 1 parameter, which contains the DOM form object in case of ajaxformlink, or null in other cases. If this function returns false or nothing, the AJAX request will not be made. Function should return true or false which again MAY NOT CONTAIN SINGLE QUOTES! See also: ajaxform

Python example
# Inherit the application class from SiteBuilder
USEMOCHIKIT = True
USEAJAXDISPATCHER = True
USEGLOBALBEHAVIOURS = True
...
self.initializeapplication(self):
... (example if usage to be finished)


amp
The amp tag generates an XHTML "&" tag as <tag>.
animation border
cache
class_
delay
height
repeat
src
srclist
visible
width
Error while parsing docstring for xml
blank height
width
The blank tag adds a blank placeholder image. The width and height attributes define the size of the placeholder. Default value is 10 pixels.
buildDivJQuery acceptids
activeclass
draggable
droppable
droppedstring
hoverclass
id
resizable
buildJSON o
Note: DEPRECATED, use cjson instead
Build a JSON source from this object. This is used for output on AJAX requests.
See the special chapter on AJAX for more examples.

Python example
self.buildJSON(adictionary)

Note: The development of this JSON translator is deprecated, since not all unicode handling works right now. Better it is to use the python-cjson library instead. http://python.cx.hu/python-cjson

Python example
import cjson
...
self.text(cjson.encode(adictionary))


buildheadimage backgroundcolor
cachepath
color
content
font
fontsize
format
h
ib
leading
lines
offsetx
offsety
underline
underlinecolor
underlineposition
w
calendarmonth class_
day
hook
month
year
Show a table of this month. If the hook attribute is defined, then call this method for every aspect that might need a link, so the application can build it's own type of link or behaviour such as standard links or popups.
The parameters of the hook should have the following layout: hook(self, mode, y, yd, m, md, d, w).
Here is self the current builder, mode the type of hook, choice from month | week | day, y is the current year, yd the real year of the day (which might be a previous year or a next year on the overlap sides of the calendar), m the current month, md is the real month of the day (which might be a previous or next month on the overlap sides of the calendar), d is the day and w is the week of the running calendar day. If the hook attribute is not defined, then create links to the current page with specific parameters.
Any of the attributes year, month or day omitted will be filled with the current year, month or day value.
The columns generate a class name that is extended from the class_ attribute name. The default value for the class_ attribute us calendarmonth.

Calendar part class_
Table <class_>
Name of the calendar (month) <class_>_month
Header (week) <class_>_weekhead
Header (day) <class_>_dayhead
Week number <class_>_week
Day number <class_>_day
Day number in previous month <class_>_dayprev
Day number in next month <class_>_daynext
Current day <class_>_today

Note that in case a hook is defined all row and col tag building must be done inside the hook.
If there is no hook method defined, then standard links are genereated to the current page, using the URL parameters cm.mode for mode, cm.y for year, cm.m for month, cm.d for day and cm.w for week.
If the day is the current day, then use today as class_ for the link.
The month attribute runs from 1 <= month <= 12.
Todo: Rework for DateTime. Currently there is a bug in the last week number of 2007-12-31

Python example
self.calendarmonth()
self.calendarmonth(2007, 6, 22)

We can actually run the method from XML/XSL (without using the hook) as <calendarmonth>
2012 | May
WkMonTueWedThuFriSatSun
18 30 1 2 3 4 5 6
19 7 8 9 10 11 12 13
20 14 15 16 17 18 19 20
21 21 22 23 24 25 26 27
22 28 29 30 31 1 2 3

calendarmonth2 class_
date
daynames
hook
monthnames
Show a table of this month. If the hook(mode, currentdate, runningdate) attribute is defined, then call this method for every aspect that might need a link, so the application can build it's own type of link or behaviour such as standard links or popups.
The parameters of the hook should have the following layout: hook(self, mode, date).
Here is self the current builder, mode the type of hook, choice from month | week | day, date is a DateTime object of the current date of this calendar, If the hook attribute is not defined, then create links to the current page with specific parameters.
The columns generate a class name that is extended from the class_ attribute name. The default value for the class_ attribute is calendarmonth.

Calendar part class_
Table <class_>
Name of the calendar (month) <class_>_month
Header (week) <class_>_weekhead
Header (day) <class_>_dayhead
Week number <class_>_week
Day number <class_>_day
Day number in previous month <class_>_dayprev
Day number in next month <class_>_daynext
Weekend <class_>_weekend
Current day <class_>_today
Week row -

Note that in case a hook is defined all row and col tag building must be done inside the hook.
If the hook is defined, the it is called with mode weekrow at the end of every week row. This way other content can be filled by the application. Note that the application must add the <row> tags then.
If there is no hook method defined, then standard links are genereated to the current page, using the URL parameters cm.mode for mode, cm.y for year, cm.m for month, cm.d for day and cm.w for week.
If the running day is the current day, then use today as class_ for the link.
The month attribute runs from 1 <= month <= 12.
The daynames and monthnames attributes are optional lists of day names and month names.
If omitted, the standard names of the DateTime object is used.

Python example
self.calendarmonth2()
d = DateTime(date='now')
self.calendarmonth2(date=d)
self.calendarmonth2(date='2007-12-31', daynames=['Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo'])

We can actually run the method from XML/XSL (without using the hook) as <calendarmonth2 date="2008-2-29">
2012 | May
WkMonTueWedThuFriSatSun
18 30 1 2 3 4 5 6
19 7 8 9 10 11 12 13
20 14 15 16 17 18 19 20
21 21 22 23 24 25 26 27
22 28 29 30 31 1 2 3
2008 | February
Wk['Ma',
5 28 29 30 31 1 2 3
6 4 5 6 7 8 9 10
7 11 12 13 14 15 16 17
8 18 19 20 21 22 23 24
9 25 26 27 28 29 1 2

calendarpopup path
popupcellwidth
readonly
values
width
Build a calendar popup. The page head should contain: self.calendarpopupinit() The tag is calling the window popup at URL: http://127.0.0.1/_root/_lib2/calendarpopup/-/datetime-1183494510257/id-0/language-nl/current-1183494510257/cellwidth-30
calendarpopupinit
cancelbutton accesskey
class_
enabled
label
mode
path
submit
Show a cancel button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.cancelbutton(path='address')



checkfolderexists folder
checkpasswordquality debug
debugalert
failalert
quality
sum
Add a javascript that checks for password fields. If any password fields, the function chPwdQualitySubmit() is added to the field's form onsubmit attribute.
If the calculated quality of the typed password if below the quality level the form is not submitted.
quality is an integer for the quality level - default is 6, which for instance correspond to 8 different lowercase characters.
failalert is the string alert that pops up when the test fails. Default alert is 'Sorry, the password is too simple ... please, try again.' debug: if True the debug alert is displayed on submitting.
debugalert should be a list (or tuple) of 3 strings. Default alert is: ['Your password is quality checked to: ','The password failed to pass current quality level.','The password is approved to the current quality level.'] It may optionally be comma separated string.
sum is optional to display the quality sum while typing.

Python example
self.checkpasswordquality()
self.checkpasswordquality(8,'Sorry, het wachtwoord is te eenvoudig ... probeert u opnieuw alstublieft.')

Note: in this test debug is True, so you get an alert with check result, when you blur the password field.
Password examples
origintwistedscore

clearvariable name
Clear the variable (if it exists) as created by the variable tag.
clientlanguage key
languages
Returns a single language code, e.g. en, nl or dk, either from e.form.keys(), e.session['language'] or the http-header from client.
Input languages is a list or comma separated string with the available languages for the page. Default language is 'en'.

Python example
language = self.clientlanguage('en,nl')


clipimage backgroundcolor
cachedpath
class_
format
h
hook
id
mode
offsetx
offsety
scale
showerror
src
visible
w
The clipimage tag creates an image of size w/h. It then draws part of the image referenced by the src attribute on optional position (offsetx, offsety) in scale 100% or another scale if the scale is defined. If scale == 'fit' then make the image fit in the defined size. An XHTML img is written to output as reference to the cached image file.
If either the offsetx or offsety attributes are omitted then try to position the image symmetric on the defined area.
The format attribute defines the type of image file. Default value is 'png'.
If the hook is defined, that call it with the created ImageBuilder instance and the application defined mode as attributes.
The method answers the actual (w, h) size of the image generated. This may differ from the requested size, e.g. when scale is 'max'.
The id attribute is part of the cached file name, so it can be used to make filename unique.
The optional showerror defines if an error is shown. Default value is True.
The optional backgroundcolor defines the color of the background if the image fitting does not fill the entire area.
The optional cachepath overwrites the automatic cache patch calculation. This can be used in combination with the optional visible in case the clipped image must be generated but not shown, e.g. as used in a image slider.
If an error was encountered, the method with answer None. If the image was created successfully, a tuple with the actual width and height is answered.

Python example
self.clipimage(src=self.PATH_IMAGESBASE + '/myimage.png', w=40, h=40, offsetx=20, offsety=20)
self.clipimage(src=self.PATH_IMAGESBASE + '/myimage.png', w=40, h=40, scale='fit')
self.clipimage(src=self.PATH_IMAGESBASE + '/myimage.png', w=40, h=40, scale=0.5)


closebutton accesskey
class_
enabled
label
mode
path
submit
Show a close button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.closebutton(path='address')



col _col align
backgroundimage
class_
colspan
height
id
nowrap
rowspan
style
valign
width
The col tag is equivalent to the XHTML td tag, so a separate output of the text and the _col tag is required.
See also: col_, colhead, colhead_, colheadorder and colheadorder_.

Python example
self.col(colspan=2)
...
self._col()


col_ align
backgroundimage
class_
colspan
height
id
nowrap
rowspan
style
text
valign
width
The col is equivalent to the XHTML td tag, so a separate output of the text and the _col tag is required.
See also: col, colhead, colhead_, colheadorder and colheadorder_.

Python example
self.col(colspan=2, text='Content of the cell')


colhead _colhead align
backgroundimage
class_
colspan
height
nowrap
rowspan
style
valign
width
The colhead is equivalent to the XHTML th tag.
See also: col, col_, colhead_, colheadorder and colheadorder_.

Python example
self.colhead(colspan=2)
...
self.colhead()


colhead_ align
backgroundimage
class_
colspan
height
nowrap
rowspan
style
text
valign
width
The colhead_ tag (underscore at the end of the tag name, so equivalent to <colhead/>) uses the text attribute value as string in the head calling self.textlabel(text) and does close the tag. Otherwise the colhead_ is equivalent to the XHTML th tag, so a separate output of the text and the _colhead tag is required.
See also: col, col_, colhead, colheadorder and colheadorder_.

Python example
self.colhead_(colspan=2, head='Title of the column')


colheadorder _colheadorder align
backgroundimage
class_
colspan
height
nowrap
order
orderdir
params
prefix
rowspan
style
valign
width
The colhead is equivalent to the colhead and XHTML th tag. The difference is that the content of the head is a link to the current page with an additional order URL parameter that will be used to sort the list in the table. The option orderdir determines the directions of the ordering. It has one of the two values ASC (ascending) or DESC (descending). If the orderdir is omitted, then check if e.session['orderdir'] exists. If it does, then swap the value. If not then ASC is default value.
An initial params dictionary can be defined to use in the link. If omitted, then the initial params directory is empty.
The params dictionary is used in creating the link, so it is possible to add user defined parameters to the link. Note: Note that the tag will always make a copy of the params attribute, so no change is made to the original.
Note: Note that the tag content, used as label, needs an initial space to separate it from the arrow that is shown by the tag itself.
The content of the optional prefix attribute is added to the order and orderdir to make a difference, if needed, between settings for various parts of an application.
See also: col, col_, colhead, colhead_ and colheadorder_.

Python example
self.colheadorder(colspan=2, order='modificationdate')
...
self.colheadorder()


colheadorder_ align
backgroundimage
class_
colspan
height
nowrap
order
orderdir
params
prefix
rowspan
style
text
valign
width
The colheadorder_ is equivalent to the colhead and XHTML th tag. The difference is that the content of the head is a link to the current page with an additional order URL parameter that will be used to sort the list in the table. The option orderdir determines the directions of the ordering. It has one of the two values ASC (ascending) or DESC (descending). If the orderdir is omitted, then check if e.session['orderdir'] exists. If it does, then swap the value. If not then ASC is default value.
An initial params dictionary can be defined to use in the link. If omitted, then the initial params directory is empty.
The params dictionary is used in creating the link, so it is possible to add user defined parameters to the link. Note: Note that the tag will always make a copy of the params attribute, so no change is made to the original.
Note: Note that the tag content, used as label, needs an initial space to separate it from the arrow that is shown by the tag itself.
The content of the optional prefix attribute is added to the order and orderdir to make a difference, if needed, between settings for various parts of an application.
See also: col, col_, colhead, colhead_ and colheadorder.

Python example
self.colheadorder(colspan=2, order='modificationdate', text='Title of the column')


colorpicker color
field
hls
hook
lightness
picker
saturation
Colorpicker offers a visual selection of a hex color to an input field.
Call the functions colorpickerjs() from html header, and colorpickerpopup() from the top of the html body to activate the use of colorpicker.
field is the fieldname.
color is the initial color. Default is white.
picker is the type of colorpicker. Default is simple. Optional is hls which is 'advanced' with saturation bar.
lightness, saturation and hls are attributes for simple colorpicker mode.
If hls is True (default), the result color has the same lightness and saturation as the input color.
Otherwise the applied values for lightness (default=0.5, range 0.0-1.0) saturation (default=1.0, range 0.0-1.0) used, no matter which input color.
See also: usecolorpicker in sitebuilder

Python example
self.colorpicker('thehlscolorpickerfield',color='#978346',picker='hls')
self.colorpicker('thesimplecolorpickerfield',color='#978346')
self.colorpicker('thesimplecolorpickerfield',color='#978346', lightness=0.8, hls=False)




colorpickerjs
Call the function from html header to load colorpicker js libraries.
Note: When using sitebuilder, this is done automatically.

colorpickerpopup
Call the function from top of html body to load the popups for colorpicker Note: When using sitebuilder, this is done automatically.

column _column width
x
y
The column method builds a div HTML tag on fixed position on the page, using the x and y attributes as position. The default position is respectively (12,12). The width attribute defines the width of the column. The default value is 300.
comment s
The comment method add the s string attribute as comment to the output.

component _component class_
cols
id
params
rows
src
static
style
template
The component tag is equivalent to the HTML div tag when the attribute src is empty. The id, class_ and style attributes can be used to refer to CSS definitions. In this case the tag does not require a closing tag.
If the src tag is defined, then the component tag is equivalent to the include tag when the extension is .xml, using the static attribute.
When the extension of src is .py, then the component tag is equivalent to the self.xml(), using the template attribute. Default template is './_xsl/defaultxsl.xsl'.
The form parameters “edit” will add an icon and filename as link on top of the rendered XML. If clicked on the link, then the related module opens as editable text area width a save button. In that case the option id, class_ and style attribute are applied on the HTML text area tag. It is up to the application to detect the save event and write the changed source back into the file. Dont’t forget to test if the file really exists and that the filename starts with a './' or else it would be possible to write elsewhere in the file system.

Python example
self.component(id="content")
...
self_component()


Python example
self.component(src='./_p/app.py) self.component(src='./_m/module.xml)


confirmbutton accesskey
class_
enabled
label
mode
path
submit
Show a confirm button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.confirmbutton(path='address')



copybutton accesskey
class_
enabled
label
mode
path
submit
Show a copy button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.copybutton(path='address')



cssborderradiuscornervalue leftright
topbottom
value
The cssborderradiuscornervalue method answers browser dependent css border-radius value ib a specific corner.

cssborderradiusvalue value
The cssborderradiusvalue method answers browser dependent css border-radius value.

cssboxshadowvalue blur
color
inout
object
x
y
The cssboxshadowvalue method answers browser dependent css box-shadow value.
The value can be a list or tuple, as in self.css(ids="...", bowshadow=("#888888", 6, 6, 20))
Or it may be separate arguments as can be used in a style attribute:
self.div(style=self.cssboxshadowvalue("#888888", 6, 6, 20))
self.div(style=self.cssboxshadowvalue("inset 6px 6px 20px #888888")

cssopacityvalue value
The cssopacityvalue method answers browser dependent css border-radius value.

cssrotatevalue value
The cssrotatevalue method answers browser dependent css transform:rotate value.

filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
cutbutton accesskey
class_
enabled
label
mode
path
submit
Show a cut button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.cutbutton(path='address')



datepopup class_
default
path
reverseyears
showday
submit
values
years
The datepopup tag builds a date selector from 3 popups.
The years attribute is a list of years to use.
The default attribute is a 'yyyy-mm-dd' formatted string for the date to selection. If defined then it is used instead of the - option. It the default attribute is now, then the current date is used as default. If it is form then the corresponding e.form[path] is used if it exists. If the default value is session then the corresponding e.session[path] is used if it exists. Otherwise the default value for all three popups is -.
See also: popup
The values attribute is a dictionary that holds value to compare the current value againts. If omitted, the an empty dictionary is used.
If the reverseyears is True (default is False) then the years are shown in decreasing order.
If the submit attribute is True, then the javascript submit() will be called if all of the three popups contain a value.
If the showday attribute is False, the don’t show a day popup, the value of the day is then set to 1. Default value of this attribute is True.
The tag always create a hidden input with name and id set to path.
Note that the datepopup needs Mochikit to be included in the head tag as self.script(src="/_root/_xsl2/js/MochiKit/MochiKit.js") The three popups are built inside a table to avoid wrapping in too narrow columns. The CSS class name for table and column tags the value of the class_ attribute is used.
Todo: Make the constrains of the day popup adapt to the choice of month and (leap)year.

Python example
self.datepopup('address@birthdate', years=range(e.now.year-100, e.now.year+10), default="form"/>

Click the savebutton to see the resulting form values.

Resulting form values

[address@birthdate]:
[address@birthdate_year]:
[address@birthdate_month]:
[address@birthdate_day]:

deletebutton accesskey
class_
enabled
id
label
mode
onclick
path
submit
Show a delete button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.deletebutton(path='address')



deletecookie name
path
The deletecookie deletes a names cookie.

deleteelementicon size
The deleteelementicon tag shows a standard icon to delete an element.
The size can be used to change the size of the icon. Standard is 10 pixels.

Python example
self.deleteelementicon()
self.deleteelementicon(20)


div_ backgroundimage
class_
href
id
image
javascript
name
onclick
onmousedown
onmouseout
onmouseover
onmouseup
params
relation
style
text
The div_ is equivalent to the XHTML div tag, except for the closing tag is included.
If one of the href, params or javascript attributes is present, a link will be added to the text.
Python example
self.div_(text='Content of the div')


doctype type
This tag sets the doctype of the document on the first line of the page source. Use this as first tag only.
Options for the type attributes are html-strict | html-transitional | html-frameset | xhtml-strict | xhtml-transitional | xhtml-frameset
See also: www.w3schools.com/tags/tag_doctype.asp


Python example
self.doctype(type='xhtml-transitional')


downarrow size
The downarrow tag shows a standard down arrow, to be used in editors.
The size can be used to change the size of the icon. Standard is 10 pixels.
See also: uparrow, rightarrow and leftarrow

Python example
self.downarrow()
self.downarrow(20)


download src
target
width
The download tag builds a link to download a document. It is the equivalent of image with a link to a downloadable file, as showing in the extension.
The optional target attributes defines if a pdf files should be opened in another window.

Python example
self.download(src='./_downloads/mydocument.pdf', target='pdfwindow')


draggable _draggable acceptids
activeclass
class_
draggable
droppable
droppedstring
hoverclass
id
params
resizable
style
target
useajax
The component method builds a standard HTML self.div() If one of the attributes resizable, draggable or droppable is set, then use that as parameter to define the jQuery behaviour of the resulting div. If any of the jQuery functions is used, then the id attributes must be defined and correspond with a defined #id in CSS. The method checks if there if the id attrinbute is defined, but cannot see if it exists in the CSS.
The resizable, draggable and droppable attributes can be either a boolean or a string, fitting the function syntax as decribed in http://jqueryui.com/demos/resizable.
duplicatebutton accesskey
class_
enabled
label
mode
path
submit
Show a duplicate button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.duplicatebutton(path='address')



em _em
Overwrite the standard XHTML em (still available in the HtmlBuilder though) because we don’t want the italic behaviour of that. Use the “buro joke” im that renders to an italic.

Python example
self.em()
...
self._em()


email bcc
cc
class_
content
iconsrc
mailto
spamsafe
subject
Generate a link as "mailto:" to a local email form.
If the content attribute is set, then show this string as link. Otherwise show the mailto attribute content as link.
Make a spam-safe email link in javascript: If spamsafe is True the email is not displayed, neither in the browser window or in the source. If the content attribute is set, then that value is shown as link. Of if the iconsrc relative path is defined then that image is used. Or if the subject is defined then the subject is displayed as link string. Or if not subject the first element of the email is shown.
javascript /_root/_lib2/javascripts/globals.js must be included. Otherwise the email address itself is shown as link.

Python example
self.email('buro@petr.com')
self.email(mailto='buro@petr.com')
self.email(mailto='buro@petr.com', content='Mail me')
self.email(mailto='buro@petr.com,torben@wil.dk', subject='Open mail with javascript', spamsafe=True)
self.email(mailto='buro@petr.com', subject='Open mail with javascript', cc='torben@wil.dk', spamsafe=True)

Examples on spam-safe mail link Open mail with javascript Open mail with javascript If you want to supply the email address in an XML block as in <email>buro@petr.com</email>, then there should be an XSL template for email using an XSL variable to collect the content of the block.
The XSL template could be something like this:
XSL example
<xsl:template match="email">
	<xsl:variable name="block">
		<xsl:apply-templates/>
	</xsl:variable>
	<xsl:copy>
		<xsl:attribute name="mailto">
			<xsl:value-of select="$block"/>
		</xsl:attribute>
		<xsl:for-each select="@*">
			<xsl:copy/>
		</xsl:for-each>
	</xsl:copy>
</xsl:template>

The XSL code above is available as standard Xierpa library. Add the following line to your template.xsl:
XSL example
<xsl:include href="xierpa/email.xsl"/>

This template then can be used in XML as buro@petr.com
XML example
<email>buro@petr.com</email>


entry accesskey
checked
class_
disabled
id
name
onblur
onchange
onclick
ondblclick
onfocus
onkeydown
onkeypress
onkeyup
onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
onselect
onsubmit
path
readonly
relation
style
submit
tabindex
type
value
values
width
De entry tag build the standard HTML input.
If the value is not is not defined, then try to get the value from values[path] The checked attribute of a radio/checkbox can also be explicitely set if the checked parameter is not None.
The checked value then comes from the comparison unicodify(values[fieldname]) == unicodify(value).strip().
The disabled boolean value defines if this control is enabled or not. The default value is False meaning that the control is visible and enabled if the attribute is omitted.
The type attribute has the default value text.

Javascript

Remember to define the id attribute when the entry tag must be found by Javascript (e.g. in AJAX applications).
If the submit is set to True then the form is submited upon change. This is equivalent to onchange='javascript:submit().

Python example
self.entry(type=self.ENTRYTYPE_CHECKBOX, path='address@openonselect')
self.entry(path='address@firstname')

The validation of submitted values can be done by resident Javascript.

Validation

When the relation attribute is set, then Javascript will check inside the page if the current entered value fits then requested type. The page need to include the following Python code in the block of the head tag.

Python example
# Set text and color for validation alerts
# Include form validation JavaScript
e['xierpa_formvalidate_declinealert'] = 'The form could not be sent. Please check the marked fields.'
e['xierpa_formvalidate_declinealertcolor'] ='#f3ec2b'
self.include('/_lib2/py/javascripts/formvalidate.py', static=True)

If now the attribute relation is set, e.g. to relation='validate.integer' the any Submit will fail if the entered value is not an integer. The following types of checking are currently available: validate.text, validate.integer, validate.integer_or_empty, validate.float, validate.passwd, validate.checked, validate.email, validate.select and validate.other. The lattter allows a local Javascript to add custom checking routines. See /_lib2/javascripts/formvalidate.js for examples.
error class_
s
style
The error tag can be used with a single string attribute s. To use it as an XML tag, include the xierpa/unknown.xsl template library. It generates a standard XHTML span with class attribute error unless the class_ is defined instead. This allows the appearance of errors be defined in CSS.

Python example
self.error('This is an error message')
self.error({NL: u'Dit is een error bericht', EN: u'This is an error message'})


XML example
<error>This is an error message</error>


This is an error message

error_imagenotfound message
src
The error_imagenotfound method shows message by calling self.error.
The inheriting application class redefined the method of other behaviour is required. The application may choose to show a default image instead if the image at src is missing.
favicon src
Show the favicon.ico in the browser URL box as indicated by the (relative)path src. If omitted most browsers will look for the icon at /favicon.ico by default.
field class_
default
path
values
findallbutton accesskey
class_
enabled
label
mode
path
Show a find all button with a default or defined label.
Todo: Make this tag call findallbutton so the result is standard.
This may have some effect on existing sites.

Python example
self.findallbutton(path='address')


findbox class_
width
The findbox methods builds a find box that will POST the find value of a pagin by name 'xierpa_find'. The default value is e.find['xierpa_find'] or e.session['xierpa_find']. The width is defined by width.
findbutton accesskey
class_
enabled
label
mode
path
Show a find button with a default or defined label.
Todo: Make this tag call findbutton so the result is standard.
This may have some effect on existing sites.

Python example
self.findbutton(path='address')


findtypeahead ajaxpath
app
functionname
id
language
mode
path
slice
userid
value
width
The findtypeahead tag builds a text entry that will call an AJAX javascript on every key-up.
The app attribute holds the name of the Mochikit/JavaScript “application”. The application javascript should contain a function named by the functionname attributem, default is doajax.
The id must be a unique identifier within the page. The id does connect the div areas with the type ahead action. If the id is xyz, then there should be a self.div(id='xyz_targetid') be defined to receive the AJAX output as transformed by the Mochkit application. The JavasScript has to check if this div really exists, otherwise no action should be taken.
The ajaxpath attribute holds the (relative) path to the AJAX “page” that will answer the JSON data. Default value is the current page The path attribute is the (relative) path to the current page. Default of this value is the value of path or e['path'] The width attribute copies to the entry attribute with the same name.
The slice attribute defines the amount of JSON records to return from the AJAX call.
If the value is defined then use that instead of e.session[sourceid] (where sourceid is derived from "'%s_sourceid' % id") as value to search for.
The mode value is used as an application specific code that is passed to in the request, so the AJAX application knows what task to perform. Default value is 'typeahead'.
The userid attribute is the record id of the current user, so AJAX knows where to store the current requested search string. The default value for userid is 0. Note that for security reasons the userid itself is not part of the AJAX request. Instead it is stored in the session and the key to that value (userkey) is supplied in the request instead.
The language attribute is used to feed the JavaScript through the AJAX page, in order to decide on the language when the layout is generated by the JavaScript. The default value for language is 'en'.

Python example
self.head()
...
self.script(src="/_root/_xsl2/js/MochiKit/MochiKit.js")
self.script(src='./_js/myapp.js')
self._head()
self.body()
...
MYAPP = 'MyApp'
self.findtypeahead('myapp', 'doajax', MYAPP, './_py/getajax')
...
self.div(id=MYAPP + '_targetid')
# Main target will be placed here by AJAX
self._div()
...
self.div(id=MYAPP + '_errorid')
# Error content will be placed here by AJAX
self._div()

The typical content of the ./_js/myapp.js is then as follows.

Python example
...


formsid _formsid action
class_
enctype
id
method
name
onreset
onsubmit
style
target
The formsid is identical to the HTML form tag, if the current session id was read from a cookie.
But if there is a new session or the browser did not allow reading from the cookie, then add a hidden field with the sid. The tag is testing on the e.iscookiesession flag.

Python example
self.formsid(onsubmit=True)
...
self._formsid()


formvalue name
The formvalue tag shows the name current value of name in e.form.
This tag is mainly used to access the form values from an XML text. It is equivalent to e.form[name].
getExtension src
getcommand
The getcommand method answers the content for the current issued form command.
The root of the command is derived from the class constant self.getcommandname(), optionally overwritten by the inheriting application class. The value of e.form[self.getcommandname()] is used as the key in e.form where the command can be found (in case it was generated by a form button). Otherwise the commandkey itself is used as command, as normally generated in a link parameter.

getcommandlabelname command
The getcommandlabel method answers the session key to find - indirect - the command in a session.
This is done to allow buttons have a different label than their actual command code.
getcommandmode
The getcommandmode method answers the content for the current issued form command mode.
The root of the command is derived from the class constant self.getcommandname(), optionally overwritten by the inheriting application class.
getcommandname
The getcommandname method answers the root name, used as key in e.form for the command of a submitted form. The default value is self.XIERPACOMMAND.
getcommandpath
The getcommandpath method answers the content for the current issued form command path.
The root of the command is derived from the class constant self.getcommandname(), optionally overwritten by the inheriting application class.
getcssboxshadowvalues blur
color
inout
x
y
getlanguages
The getlanguages method aswers list of codes of the available languages in the system. Default is the content of self.LANGUAGES as ['nl', 'en', 'dk']. Optionally to be redefined but the inheriting application class.
getpath2fspath path
The getpath2fspath method is a wrapper around e['domainroot'] + self.e.path2basedpath(path). It answers full file system path name, expanding the based path with the domain root. This way virtual domain paths can be mapped to the file system.
If the path is already a valid fspath, then answer it unaltered.
getsid
The getsid method answers the session id or None if there is no session defined.
gettruncatelength truncate
getvalueofvariable name
The valueof tag answers dicerted output.
Note that the block is immediately executed. The diverted output needs to exist when the call is done.
It is not allowed to nest diversions, attempts will result in an error.
See also: variable
See also: getvalueofvariable
See also: record

google _google target
words
The google creates a link to the Google site to find information about a set of space or comma separated words.

Python example
self.google('Python', target='example')
...
self._google()

How to program in Python?
googleanalytics googleid
The googleanalytics method adds the right javascript to the page to use www.google.com/analytics with the site. Make sure to add the call just before self._body().

Python example
...
self.googleanalytics, 'UA-12345678-1')
self._body()


googlemap height
scrolling
search
width
The googlemap builds an XHTML iframe with the content of the googlemaps page using the s as search string.

Python example
self.googlemap('rietveld 56, delft, the netherlands')
self.googlemap('2611 LM, the netherlands')


headimage backgroundcolor
cachepath
color
content
font
fontsize
format
h
leading
offsetx
offsety
underline
underlinecolor
underlineposition
unique
visible
w
The headimage tag is a simple and fast way to create heading images, without the hassle of making pages and columns. The content attribute contains the string to display in the image. If the content attribute string contains a “¶” character, then split the lines and use leading as line distance.
The format attribute can be one of png, gif, jpg or pdf.
If the visible attribute is False, then the image is generated, but no img is sent to the output.
The w and h attributes define the size in pixels of the image to build. If the h is omitted or None, then the h value is calculated from (len(lines) + 1) * leading.
The offsetx and offsety attributes form the position of the baseline of the first text line.
The leading attribute is the distance between the lines. Default value is the fontsize attribute value.
The font is a font name from the current list of fonts. Default is “Productus-Medium”.
The cachepath attribute defines the relative path (with a trailing "./") to store cached image files.
Default is self.PATH_IMAGESBASE + '/_thumbnails/'. If the cachepath ends with a / the a unique name filename is calculated. Otherwise the cachepath is used as filepath.
Todo: Make text lines wrap and use inclosed tags for styles

Python example
self.headimage('The text of the head.', w=300, h=40, fontsize=30, font='Productus-Medium', color='green', backgroundcolor='yellow')
self.headimage('Multiple¶lines¶of¶text.', offsetx=10, w=300, fontsize=14, font='Productus-Medium', color='white', backgroundcolor='black')

Mismatch in closing tag "col", expected "div" in tree "['html', 'body', 'div', 'div', 'div', 'component', 'div', 'table', 'tr', 'row', 'td', 'col']".
hidden class_
default
id
name
path
style
value
values
The hidden tag can be used in two ways:
  • If the name attribute is defined, then value is used.
  • If the path attribute is defined, then get the fieldname. If it exists, then use values[fieldname] as value of use default when the value is None.
Note: Either name or path can be defined.
The XHTML is identical to self.input(type='hidden', ...)
Python example
self.hidden(path='address@id', selectedrecords)
self.hidden(name='myhidden', value=1234)


hoverpopup _hoverpopup href
id
offsetx
offsety
params
target
The hoverpopup tag builds a link to sideways to the mouse hovering local window that shows information about the link.
The use of the hoverpopup tag needs the page header to include javascripts /_root/_lib2/javascripts/hoverpopup.js and /_root/_lib2/javascripts/globalbehaviours.js.
Additionally the content of a named hoverpopupcontent is cumulated in an e['variable_' + name] output stream. Just before the _body closing tag this variable needs to be emptied. This is done with the following code: self.valueof(name) If the href is omitted or None then the tag will simply behave as a trigger for the popup, not as a link.
The two offsetx and offsety attributes define the top-left position of the popup window, relative to the mouse.
The default values are (10, 10). The positive x goes to the right, where the positive y goes down.
A total hover has two parts. The hoverpopup defines the linking position of the hover popup. The content of the tag content defines the visible area that triggers the popup. The hoverpopupcontent defined the content of the popping yp window. It is an independent div. The id value needs to be the same to bind the tags-pair together.

Python example
self.head()
self.script(src='/_root/_lib2/javascripts/globalbehaviors.js')
self.script(src='/_root/_lib2/javascripts/hoverpopup.js')
...
self._head()
self.body()
...
self.myhovers = []
...
id = 'icon%d' % project.id
self.hoverpopup(id=id, offsetx=20, offsety=-10)
self.text('My visible link')
self._hoverpopup()

self.hoverpopupcontent(id=id)
self.div(style='background-color:white;width:200px;padding: 6px 6px 6px 6px;')
self.text(project.description or 'No description')
self._div()
self._hoverpopupcontent()

self.myhovers.append(id)
...
for hover in self.myhovers:
  self.valueof(hover)
self._body()


hoverpopupcontent _hoverpopupcontent id
The hoverpopupcontent tag builds the content of a hover popup window. For further description see hoverpopup.
ifauthorized block
role
If the current user as defined in e.session['xierpa_user'] is authorized for role then export the block content. The valid roles must be available as list under e.session['xierpa_user_roles'].
Note: This tag is mainly used to switch on role content when parsing XML code. In Python the authorization choice can simply me made by if role in e.session['xierpa_user_roles'].
Note: In order to get the content, is can easily be collected by an XSL variable.
See also: ifnotauthorized

Python example
self.ifauthorized('admin', block='Any rendered content here.')

Then the collecting XSL could be something like this
XML example
<xsl:template match="ifauthorized">
	<xsl:variable name="block">
		<xsl:apply-templates/>
	</xsl:variable>
	<xsl:copy>
		<xsl:attribute name="role">
			<xsl:value-of select="@role"/>
		</xsl:attribute>
		<xsl:attribute name="block">
			<xsl:value-of select="$block"/>
		</xsl:attribute>
	</xsl:copy>
</xsl:template>

The template above is available by adding the following line to your template.xsl document:
XSL example
<xsl:include href="xierpa/authorization.xsl"/>

To initialize the roles, a typical Python source could be
Python example
# Get roles of this user if not already in session
if not e.session['xierpa_user_roles']:
users = getselection(agent, 'address', where="studentid = '%s'" % (e.session['xierpa_user'] or 'guest') )
if users:
e.session['xierpa_user_roles'] = users[0].authorize_many._list('name')
else:
e.session['xierpa_user_roles'] = []

where there are related tables address and authorize
ifloggedin block
If there is a current user available under e.session['xierpa_user'] and there are valid roles in e.session['xierpa_user_roles'] then export the block.

Python example
self.ifloggedin('Any rendered content here')


ifnotauthorized block
role
If the current user as defined in e.session['xierpa_user'] is not authorized for role then export the block content. The valid roles must be available as list under e.session['xierpa_user_roles'].
Note: This tag is mainly used to switch on role content when parsing XML code. In Python the authorization choice can simply me made by if role in e.session['xierpa_user_roles'].
Note: In order to get the content, is can easily be collected by an XSL variable.
See also: ifauthorized

Python example
self.ifnotauthorized('admin', block='Any rendered content here.')

Then the collecting XSL could be something like this
XML example
<xsl:template match="ifnotauthorized">
	<xsl:variable name="block">
		<xsl:apply-templates/>
	</xsl:variable>
	<xsl:copy>
		<xsl:attribute name="role">
			<xsl:value-of select="@role"/>
		</xsl:attribute>
		<xsl:attribute name="block">
			<xsl:value-of select="$block"/>
		</xsl:attribute>
	</xsl:copy>
</xsl:template>

The template above is available by adding the following line to your template.xsl document:
XSL example
<xsl:include href="xierpa/authorization.xsl"/>


ifnotloggedin block
If there not is a current user available under e.session['xierpa_user'] and there are not valid roles in e.session['xierpa_user_roles'] then export the block.

Python example
self.ifnotloggedin('Any rendered content here')


ignore _ignore
The ignore tag diverts all output of the block in a NULL write. Ignore blocks may me nested.
Warning: This method does change the output of the current builder, so on errors unpredictable result may be invisible when output stream is not restored properly.
See also: valueof

Python example
self.ignore()
self.text('This is a ignored text.')
self._ignore()


im _im
The im tag is a variant on the em tag that can render to an italic, expecting an .im CSS class definition.

Python example
self.im()
...
self._im()


image align
alt
border
caption
class_
height
href
hspace
iconpath
id
name
relation
src
style
target
title
usemap
vspace
width
The self.image() tag is calling the standard XhtmlBuilder self.img tag.
The difference is that it checks if the image has one of the extensions in jpg | png | gif.
If the extenstion is one of qt | mov | mp3 | mpg | mpeg then the self.movie() tag is called.
When the extension is pdf then an icon link is created to download the document. The optional target attribute defines if another window should be opened to view the PDF file. The iconpath defines where the icon should come from if the image can not be displayed (e.g. as is the case with PDF documents). The default value for icondpath is /_root/_lib2/images/icons/iconpdf.gif. The width and height attributes have no effect on the size of the icon.

Python example
self.image(src=self.PATH_IMAGESBASE + '/im1234.png', width=100)
self.image(src=self.PATH_IMAGESBASE + '/im1234.mov', width=100)
self.image(src=self.PATH_IMAGESBASE + '/im1234.pdf', iconpath=self.PATH_IMAGESBASE + '/icons/mypdficon.png')


imagecroppingform choices
choicesshow
debug
formaction
imagepath
label
maxsize
page
pagetitle
preset
previewpath
savelabel
savepath
savewidth
useajax
imagepath of the image If page is set (True|False) the full html page is build. Add optional pagetitle. The default page title is 'Xierpa: Image Cropping'.
If formaction a form is added to collecting data. Otherwise a form is expected to be there allready. The Javascript will give an error message, if no form is available.
If label submit button label.
If image is wider than maxsize image is scaled down in the form.
If savepath the cropped image is saved with the applied savewidth.
choicesshow makes the cropping data visible and editle. choices is the number of cropping data fields.
If self.IMAGECROPWITHAJAX = True, image crop corners coordinate are put into the js call sendImageCropData2AjaxHandler(event, x, y, w, h).
Otherwise coordinates are put in a visible form input field. If previewpath is set, the folder _ic_temp/ is created there, and temp image preview (width=200) is placed there.
preset is a commaseparated string with an initial crop set.
Todo: Make a cron job that deletes all _ic_temp/ folders (could run every hour). This starts xpyth.application.cleanupimagecrop and deletes all files older than 30 minutes in _ic_temp/ folders:
sudo python start.py -cleanupimagecrop -age 1800



Python example
Scripts needed:
self.script(src='/_root/_lib2/javascripts/gethtmlupdate.js')
self.script(src="/_root/_lib2/javascripts/globalbehaviors.js")
#
formaction="./patterns//-/p-xierpabuilder#1_imagecroppingform"
imagepath = './patterns/_images/200309_vancouver_093.jpg'
self.imagecroppingform(imagepath=imagepath, maxsize=480,choices=2,choicesshow=True)
previewpath='./_images'
savepath=self.PATH_IMAGESBASE + '/_thumbnails/200309_vancouver_093.jpg'
self.imagecroppingform(imagepath=imagepath, previewpath=previewpath, savepath=savepath, maxsize=480, savewidth=400,choices=2,choicesshow=True)


imageslides duration
height
id
images
position
transition
width
z
The imageslides tag builds slidehow fade in/out image transition.
images can be list or a comma separated string of image paths.
duration is the time in milliseconds between the transitions.
transition is the length of each step in the transition - use between 1 and 0.01, where 1 is very fast and 0.01 is pretty slow.
position defines the CSS position value. Default behaviour is to use 'inherit'.
These javascripts are needed: self.script(src='/_root/_lib2/javascripts/globalbehaviors.js') self.script(src='/_root/_lib2/javascripts/imageSlidesTransition.js')
Python example
self.imageslides(width=100,height=75,images=list_of_images,duration=1000,transition=0.01)
self.imageslides(width=100,height=75,images=list_of_images,duration=3000,transition=0.05)
self.imageslides(width=100,height=75,images=list_of_images,duration=5000,transition=0.2)


include raw
src
static
Call another Python application to render content into the result buffer.
The src attribute is an relative path.
If the static flag is True, then answer the cached (XHTML) result if it exists. The flag can e.g. be related to the DEBUGSERVER flag, so it will no cache on development servers.
If the raw attribute is False then just copy the file to the output without interpretation or rendering.
Todo: detect if this is a recursive call.
Todo: register if the file was changed. Then always update.

Python example
self.include(src='./_py/anotherapp.py', static=not DEBUGSERVER)


initcookie
Normally the session id is copied automatically into the local cookie by the httprequest. But apart from that it is also possible to initialize and modifie cookie values from within the page. In that case the appropriate Javascript module needs to be included.
The initcookie tag inserts the cookie Javascript in the page. Use this tag inside the head block.
See also: setcookie

Python example
self.head()
...
self.initcookie()
self._head()


labelbutton accesskey
class_
enabled
id
label
mode
name
onclick
path
submit
The labelbutton tag builds a button with 2 hidden fields that enables the application to respond to a language indepedent label. The tag is used by special button tags such as savebutton, deletebutton and others.
The hidden field creates a connection between the label of the button and the value that we want to trigger on in the called page.
So in the called page we can check on self.getcommand() == 'Save' to know that e.g. a Bewaar button was clicked. If the label attribute is omitted, then the name is used. The path attribute holds the path name that this command applies to. The label attribute holds that label of the button. If the submit attribute is True then the button will respond to the [Enter] key.
Likewise the “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.
The path attribute holds the path name that this command applies to. The label attribute holds the label of the button.
The root of the command is derived from the class constant self.getcommandname(), optionally overwritten by the inheriting application class.
If the submit attribute is True then the button will respond to the [Enter] key.

Python example
self.labelbutton(path='mypath', label='My own label on a button', submit=True)


language block
code
The language tag will write the block content to output if the code does match with the current language code as available in e.session['xierpa_language'].
Note: The language tag is mainly used to switch on language when parsing XML code. In Python the language choice can simply me made by if mylanguage == e.session['xierpa_language'].

Python example
self.language('nl', block='Any rendered content here.')

Since we need the to collect the block in XSL, the following template could be used:
XSL example
<xsl:template match="nl">
	<xsl:variable name="block">
		<xsl:apply-templates/>
	</xsl:variable>
	<xsl:element name="language">
		<xsl:attribute name="code">
			<xsl:value-of select="name()"/>
		</xsl:attribute>
		<xsl:attribute name="block">
			<xsl:value-of select="$block"/>
		</xsl:attribute>
	</xsl:copy>
</xsl:template>

Now the following XML can be translated:
XML example
<nl>...</nl> <en>...</en>

Try to select the language here: English
languagenavigation flags
params
sid
The languagenavigation method builds a navigation on the current languages.
If the flags is set to False then the language names are shown.
leftarrow size
The leftarrow tag shows a standard left arrow, to be used in editors.
The size can be used to change the size of the icon. Standard is 10 pixels.
See also: uparrow, rightarrow and downarrow

Python example
self.leftarrow()
self.leftarrow(20)


letterproof backgroundcolor
color
content
font
fontsize
h
w
The letterproof tag generates a letterproof of the specified font (if font is defined) or all available fonts in the server.
If the content is not defined, then display fontname + ' Hamburgefonstiv'.
The w and h defined the size of the images in pixes. Default is respectively 500, 36.
The default of fontsize is 36. The default of color is black and the default of backgroundcolor is white.

Python example
self.letterproof(w=400, h=36, font='Salmiak-Italic', color='white', backgroundcolor='black')
self.letterproof(w=400, h=36, font='Productus-Medium', color='yellow', backgroundcolor='green')

Cannot display font Salmiak-Italic

Cannot display font Productus-Medium

link _link accesskey
alt
class_
currentcss
forcecurrent
href
id
iscurrent
javascript
name
onclick
ondblclick
onfocus
onmousedown
onmouseout
onmouseover
onmouseup
page
params
rel
rev
style
target
title
The link tag builds standard XHTML a tag if href does not refer to the current page e['path']. If the href attribute is None, then the content of the current e['path'] is used. If href is the char #, then the content is untouched, since this is the HTML marker that the href is not touched.
If the page attribute is defined, then add a parameter to the URL where the name is in self.PARAM_PAGE (default is 'page') and the value is the content of the attribute.
If one of the params values is 1 then just show the parameter identifier in the URL Todo: More examples
@@@@@@@@@ forcecurrent working Todo: Add missing attributes

linksid _linksid accesskey
alt
class_
currentcss
forcecurrent
href
id
iscurrent
name
onclick
ondblclick
onfocus
onmouseout
onmouseover
page
params
rel
rev
style
target
title
Similar to the link tag, the linksid tag builds a XHTML a link.
The difference is that always a /-/_sid- parameter with the current session id, but only then if the session really exists and it was not read from a cookie. The tag is checking this from the e.iscookisession.
If the URL refers to the current page, then only the plain text is send to the output.

list _list class_
id
start
style
title
type
Equivalent to the XHTML ul tag. It defines an unordered list.
The type attribate takes the values disc | square | circle Todo: make it work with ul and start too (currently that is an end tag problem)
See also: http://www.w3schools.com/tags/tag_ul.asp

Python example
self.ul(type='disc')
...
self._ul()


loginbutton accesskey
class_
enabled
label
mode
path
submit
Show a login button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.loginbutton(path='address')



mailto bcc
cc
ishtml
mailfrom
mailserver
mailto
message
password
port
replyto
subject
user
The mailto tag instantly sends an email to the specified address.
The tag is mostly used for monitoring the behaviour of pages or server in general.
And it can be used to send a message as response on a form entry to one or a few email addresses.
The subject and message attributes must both be unicode or else an error is raised.
The optional user and password allow to login into an external mail server if the mailserver is set to another IP number that LOCALHOSTS.
Warning: The tag should not be used for large quantities of addresses, since the sending is done while generating the page. While the generation of pages by Xierpa is not (yet) multi-threading this will block the execution of any other page request in the server.

Python example
self.mailto(u'This is the subject', u'This is the string to mail', mailto='buro@petr.com')


matrix class_
cols
formats
hook
length
mode
rows
width
The matrix method builds a matrix as table with the defined proportions. At least one of cols and rows attributes must be defined. If the length attribute is defined, then the number of rows is infinite and the method runs until the number of length cells is processed. Rows will always be finished if the length is less than a whole division of columns on the last row.
For every cell the hook method is called with the following attributes hook(self, col, row, i, mode) where col is the current column number, the row is the current row number and index is the running index on the elements and format.
The optional format attribute is a list of tuples defining the width and alignment of the columns as format = [(200,'left'), (100,'right')].
If the length of format is less that the amount of columns, then the last format values are used for the rest of the columns.
The mode attribute is unchanged transferred into the hook and can be used for custom purposes. The width attribute defines the width of the matrix table. Default value is '100%'.
Python example
def hook(self, col, row, mode):
    self.text('Cell (%s,%s)' % (col, row))
...

self.matrix(self.hook, 3)


mouseover alt
class_
forcecurrent
height
href
image
imageclick
imagecurrent
imageover
iscurrent
iscurrentbool
onclick
params
rel
rev
target
title
width
The mouseover implements a link with roll-over images. There are 4 image path attributes possible:
  • image Unbased path to the main image;
  • imageover Unbased path to the image that is visible during roll-over (default is the value of image);
  • imageclick Unbased path to the image that is visible when the mouse is down (default is the value of imageover);
  • imagecurrent Unbased path to the image that is visible when href links to the current page (default is the value of image);
The forcecurrent attribute is depriocated. Use iscurrent and iscurrentbool instead. When the iscurrent attribute is set and the expression iscurrent in e['path'] of if the iscurrentbool is True then the plain image imagecurrent is showed with no link./ Todo: Make a more robust comparison between the href attribute and the current path e['path']
Todo: Make more attributes of link available in mouseover

Python example
self.mouseover(href='#', image=self.PATH_IMAGESBASE + '/mouseover1.png', imageover=self.PATH_IMAGESBASE + '/mouseover2.png', imageclick=self.PATH_IMAGESBASE + '/mouseover3.png', forcecurrent=True, width=60, height=60)

   
mouseoversid alt
class_
forcecurrent
height
href
image
imageclick
imagecurrent
imageover
iscurrent
iscurrentbool
onclick
params
rel
rev
target
width
Similar to the mouseover tag, the mouseoversid tag implements a link with roll-over images. The current session id is always added to the URL parameters named _sid. There are 4 image path attributes possible:
  • image Unbased path to the main image;
  • imageover Unbased path to the image that is visible during roll-over (default is the value of image);
  • imageclick Unbased path to the image that is visible when the mouse is down (default is the value of imageover);
  • imagecurrent Unbased path to the image that is visible when href links to the current page (default is the value of image);
The forcecurrent attribute is depriocated. Use iscurrent and iscurrentbool instead. When the iscurrent attribute is set and the expression iscurrent in e['path'] of if the iscurrentbool is True then the plain image imagecurrent is showed with no link./ Todo: Make a more robust comparison between the href attribute and the current path e['path']
Todo: Make more attributes of link available in mouseover

Python example
self.mouseover(href='#', image=self.PATH_IMAGESBASE + '/mouseover1.png', imageover=self.PATH_IMAGESBASE + '/mouseover2.png', imageclick=self.PATH_IMAGESBASE + '/mouseover3.png', forcecurrent=True, width=60, height=60)

   
movie
Does not seem to be defined in w3schools??
Python example
self.embed(src='./_images/amovie.qt')


mp3 _mp3 length
src
text
Use self.mp3player() before first to load the needed js libraries and build the player container.

Python example
self.mp3(src="/_root/_lib2/players/_examples/Tre_gule_kort_og_to_rode.mp3")


mp3player _mp3player autoplay
class_
color
length
loadprogresscolor
player
playerid
progresscolor
src
style
width
@@@@: More manual to come.

Python example
self.mp3player(width=200, style="margin-top:8px;margin-bottom:4px")
self.text('Test sound:')
self.mp3(src="/_root/_lib2/players/_examples/Tre_gule_kort_og_to_rode.mp3")
self.text('Tre gule kort og to røde')

Test sound:Tre gule kort og to røde
nbsp count
The nbsp tag generates an XHTML non-breaking space.
The count attribute is the repeat count. Default value is 1.

Python example
self.nbsp(2)


newbutton accesskey
class_
enabled
label
mode
path
submit
Show a new button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.newbutton(path='address')



newelementicon size
The newelementicon tag shows a standard icon create a new element.
The size can be used to change the size of the icon. Standard is 10 pixels.

Python example
self.newelementicon()
self.newelementicon(20)


newline
nlist _nlist class_
id
start
style
title
type
Equivalent to the XHTML ol tag. It defines a numbered list.
See also: http://www.w3schools.com/tags/tag_ocdl.asp

Python example
self.ol()
...
self._ol()


notifyerror mailto
message
mode
subject
The notifyerror method is called to make a switch between handling an error with raising the error, show it in the page with self.error, or sending an email to mailto (default value is self.NOTIFYERROR_DEFAULTMAIL, depending on the value of the mode attribute, respectively self.NOTIFYERROR_RAISE, self.NOTIFYERROR_ERROR and self.NOTIFYERROR_MAIL. Default value for mode is self.NOTIFYERROR_RAISE if the server is DEBUGSERVER and self.NOTIFYERROR_MAIL if the server is not DEBUGSERVER. If the subject attribute is omitted then '[Xierpa Error]' is used. The message is used as message for all modes.

openediticon size
The openediticon tag shows a standard icon to open an editor.
The size can be used to change the size of the icon. Standard is 10 pixels.

Python example
self.openediticon()
self.openediticon(20)


openwindow _openwindow class_
directories
height
href
id
location
menubar
params
resizable
scrollbars
status
title
toolbar
width
Open a new window with using the attributes as parameters.

Python example
self.openwindow(href='./anotherpage', title='Another window', width=200, height=200)


pagewrapper _pagewrapper backgroundcolor
border
class_
width
z
The pagewrapper tag builds a centering “page” on the body background. The default value for the z attribute is 10.

Python example
self.body() self.pagewrapper(width=900, z=20, backgroundcolor='white') ...
self._pagewrapper() self._body()


para class_
count
id
style
title
The paragraph tag is identical to the XHTML br tag.
The count attribute is the repeat count of breaks. Default value is 1.
The class_ can define the amount of leading in px of the break.

Python example
self.para(2)
self.para()


pastebutton accesskey
class_
enabled
label
mode
path
submit
Show a paste button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.pastebutton(path='address')



pdfinfo page
path
unit
Note: pyPdf library must be installed.
The library needs python version 2.4 or above
See also: pyPdf source: pybrary.net/pyPdf/

Returns a PyPdf object, that has various methods, each of them return info from within the pdf file:
title(),
subject(),
length(),
trimbox()
mediabox()
bleedbox()
cropbox()
artbox()
path is the relative path of the pdf.
Default unit is mm, but mm, pc, px, in and pt can be used.
mm and px return values as int ... pc, in and pt returns float.
trimbox(unit='px', type='float')
page is the page number of the pdf. Default is 0
See also: Example edit.kost.dk/test/pdfinfo


Python example
pdf = b.pdfinfo('/200803ann_bauta.pdf')
if pdf:
   self.text(pdf.title())
   b.br()
   b.text(pdf.trimbox('px'))
   b.br()
   b.text(pdf.mediabox())


play name
The play tag does run the recorded instructions of the e['record_' + name] Recorder insance.
See also: recorder

popup checkedvalue
class_
default
disabled
format
id
onchange
optionfield
options
path
submit
values
Create a standard popup. There are two possible types of option lists:
  • A plain list as in 'A,B,C,D,E,F,G' (a comma separated string) or e.g. [1,2,3,4,5,6] and ['a','b','c','d','e'] (examples of a list of objects), where the displayed value is identical to the answered value
  • A list or tuple with the construction [keys, dict] the keys define the order of the dict.
    The dict can be either a plain string of a language dictionary.
  • A dictionary as e.g. [{'id':1, 'value':'aaa'}, {'id':2, 'value':'bbb'}, {'id':3, 'value':'ccc'}] e.g. when reading with optionslist, optionsdict = agent.getnormalized(table) directly. Here the value is the name for the field to use. This can be changed by defining the optionfield attribute, which then holds the name or names of the fields to display in the list. The optionfield attribute may hold one fieldname, a comma separated string of fieldnames or a list of strings with fieldnames.
    If the format attribute is defined, then use that as Python format string instead of the comma separation.
The latter construction comes from reading a normalized table content is specific order.
Also the list can contain objects, such as Record instances, that have 'id' and 'value' available as attributes.
Checking of the current option is done by comparing the option id (converted to a string by unicodify()) with the optional dictionary values. If omitted an empty dictionary is used instead. The code evaluated is selected = unicodify(values.get(path) or values.get(fieldname)) == unicodify(id), where fieldname is derived from the attribute part of path. This double check is done for usage of both e.g. values.get('address@name') (as in e.session items) or values.get('name') as in records. In most situations the values attribute can simply be set by values=e.session.
The default attribute has 3 possible modes None (No initial value in the popup), '-' (Initial '-' with id = 0, this is default of the default attribute) 'xyx' (Another initial value with id = 0) The optional checkedvalue attribute can be used to overwrite the value on which the popop should initially be checked.
The format attribute is a standard Python format string, used for display only. It is not used for comparing the selected value.
If the options attribute is not set and there is a values dictionary (as e.g. the result of an optionslist, optionsdict = agent.getnormalized(table) query), then use that set as key/option values.
If the submit is set to True then the form is submited upon change. This is equivalent to onchange='javascript:submit().
Todo: Make checking work more robust and intuitive. Avoid building new dictionaries for values. Add name attribute? Use id attribute?


Python example
self.popup(path='address@type', options=[1,2,3,4,5], values=selectedrecords, format='%000d')


preloadimage src
The preloadimage tag does preload an image in the page. This is mostly used in situations where it is critical to have the image available immediately, such as in a mouseover tag or other JavaScript manipulated page content. The src is an relative path.
printbutton accesskey
class_
enabled
label
Show a button to print the current web page. Note that the printbutton tag must be used inside form.
The optional label can be used to define the button label. Default value is Print.

Python example



pythonpowered animated
small
The pythonpowered tag shows a standard “Python Powered” icon.
If the small attribute is True then the icon has a size of 55 x 22 pixels.
If the attribute is omitted (default) or False the icon has a size of 110 x 44 pixels.
If the animated is True (default) then the icon shows a short animation.
The icon is made by Just van Rossum.
See also: http://www.python.org/community/logos.html

Python example
self.pythonpowered(small=True)
self.pythonpowered(small=True, animated=False)
self.pythonpowered()
self.pythonpowered(animated=False)


pythonpowerednew small
trans
wide
The pythonpowerednew tag shows the new standard “Python Powered” icon (2007?).
If the wide is omitted (default) the attribute is True:
  • If the small attribute is True then the wide version of the icon has a size of 70 x 28 pixels.
  • If the attribute is omitted (default) or False the icon has a size of 200 x 80 pixels.
If the wide is False the high version or the logo is chosen:
  • If the small attribute is True then the high version of the icon has a size of 50 x 65 pixels.
  • if the attribute is omitted (default) or False the icon has a size of 140 x 182 pixels.
See also: http://www.python.org/community/logos

Python example
self.pythonpowerednew(small=True)
self.pythonpowerednew()
self.pythonpowerednew(small=True,wide=False)
self.pythonpowerednew(wide=False)

pythonpowered pythonpowered
pythonpowered pythonpowered

recorder _recorder name
The recorder tag does divert all output of the block in a variable at e['recorder_' + name] by creating a Record instance. The recorded instructions are accumulated and not yet sent to the builder.
The code can be run multiple times by the play tag, maybe with different setting of e and e.session variables.
See also: run
See also: valueof

rellink charset
class_
dir
href
hreflang
id
lang
media
rel
rev
sizes
style
target
title
type
The rellink is identical to the XHTML link.
The rellink tag defines the relationship between two linked documents.
If the href attribute is defined, then convert it to a based path.
Note that this tag is defined by XierpaBuilder. When using an inheriting class from XierpaBuilder then use the rellink tag name instead.
See also: http://www.w3schools.com/tags/tag_link.asp
See also: favicon

Python example
self.head()
...
self.rellink(href=self.PATH_IMAGESBASE + '/favicon.ico', rel='shortcut icon')
...
self._head()


reloadpage delay
params
If the reloadpage tag is added inside the head tag of the page, then the page will reload after delay number of seconds. The default delay is 4 seconds.
Optional a dictionary parameters param can be added to the URL, so it is possible e.g. to implement a counter or another value that has a function in the input of the reloaded page.
Todo: Make the params work in the URL and make the transfer tag call the reloadpage.

Python example
self.reloadpage()
self.reloadpage(12, {'marker': 1234})


rightarrow size
The rightarrow tag shows a standard right arrow, to be used in editors.
The size can be used to change the size of the icon. Standard is 10 pixels.
See also: uparrow, downarrow and leftarrow

Python example
self.rightarrow()
self.rightarrow(20)


row _row id
relation
style
Equivalent to the XHTML tr tag.

Python example
self.row()
...
self._row()


ruler align
class_
color
noshade
size
style
width
Equivalent to the XHTML hr tag.

Python example
self.ruler(size=15, noshade=True)




savebutton accesskey
class_
enabled
label
mode
path
submit
Show a save button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.savebutton(path='address')





sendbutton accesskey
class_
enabled
label
mode
path
submit
Show a send button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.sendbutton(path='address')



sep _sep class_
id
style
Equivalent to the XHTML li tag. The sep tag defines the start of a list item. The sep tag is used in both ordered (ol) and unordered lists (ul>).

Python example
self.ul(type='disc')
self.sep()
...
self._sep()
self._ul()


session backtrack
keep
lifetime
name
protected
user
The session tag creates a new session in environment e, but only if it does not exist already. The lifetime attrbute defines the expiration time of the session in seconds.
The default is 3600 seconds (1 hour). The user attribute defines the user of this session. Default value is e['user'] If the protected attribute is set to True (default value is False), then the content of the e.form parameters is not copied into e.session. This gives much more protection since the content of e.session cannot be overwritten from URL parameters. The application needs to copy (and modify) the values into session, e.g. in the setup() method. This should be the strategy for all future applications. However this give problems with backward compatibility for applications that assume all parameters available in the session. That is why the attribute is default set to False.
e[self.XIERPA_SID] holds the unique number of the session.
All pages using formsid or include should call this tag in the beginning of the page.

Python example
self.session()


sessionvalue name
The sessionvalue tag shows the name current value of name in e.session.
This tag is mainly used to access the session values from an XML text. It is equivalent to e.session[name].
setcookie expire
name
value
The setcookie tag builds javascript to set a name named cookie to value value with the domain domain. If the domain attribute is not set, then the current domain name is used.
The optional expire attribute sets the amount of seconds before the cookie expires.
Default is 1 year. 60 * 60 *24 * 365 = 31536000. In the xpythserver.py automatic setting of the session id, the expire time of the session is used.
See also: initcookie
to initialize the cookie Javascript in a page.

Python example
self.setcookie('mycookie', 'ValueOfTheCookie')
self.setcookie('sid', self.e.sidversion())

But cookies can also be set from other controls as in

Python example
self.input(type='button', value='Set Cookie', onclick='setCookie("data", prompt("Enter some data:"))')


showdebug
showform truncate
Show the content of the e.form in a table with keys and values.
All data string > TRUNCATELENGTH characters are trunctated as default.
(e.g. content of read tables as countries and languages are long).

Python example
self.showform(truncate=100)


showquery agent
class_
The showquery tag shows the last query of agent in as class_.
Default class is error.

Python example
self.showquery(myagent)


showsession truncate
Show the content of the e.session in a table with keys and values. All data string > TRUNCATELENGTH characters are trunctated as default (e.g. content of read tables as countries and languages are long).

Python example
self.showsession(truncate=100)


showtags xml
The showtags tag show the xml string with all tags escaped to show in XHTML.
showtime message
t
The showtime method builds the showing of the time between the optional t and the current time, with the content of the message attribute.
If the t is omitted, then the just the message is shown. The current time answered so this method can be used to open and close the timing in a chunk of code by feeding the answered time of the initial call into as t attribute into the final call of the same method. Then the time difference is visible.
The method only shows the message if either self.e.form['time'] or self.SHOWTIME evaluate to True
shy
The shy tag generates an XHTML “soft-hyphen”. The hyphen is no visible inside words, but does indicate the position in a word where a line can be hyphenated. In HTML shy; is generated. In GalleyBuilder the character chr(0x00AD) is used.
http://www.fileformat.info/info/unicode/char/00ad/index.htm
Not all browsers in the past support this function, but an increasingly number does.
simpleheadimage backgroundcolor
cachepath
color
content
font
fontsize
format
h
leading
offsetx
offsety
padding
underline
underlinecolor
underlineposition
unique
visible
w
simplesite bgcolor
font
fontsize
path
template
title
The simplesite is a tiny, tiny example of the next generation of page builders. 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 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.

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


singlecheckbox checked
name
onchange
The singlecheckbox tag implements a special checkbox that adds a hidden field, so we know for sure that it is cleared when submitting directly with an onchange.
If the checked attribute is not None then use the value of e.session[name] instead.

Python example
self.singlecheckbox(name='mybox', onchange=True)
self.text('Example of the single checkbox')

Example of the single checkbox
space count
The space tag generates an single text space, equivalent to self.text(' ').
tag _tag
For typing XML as example in an XML document (e.g. for manuals as this one) the tag tag generates XHTML escaped code for “<” and “>”.

Python example
self.tag()
self.text('aaa')
self._tag()
...
self.tag()
self.text('aaa')
self._tag()

to generate: <aaa>...</aaa> Note: The tag will probably never be used directly from a Python method, because then there is not need to escape the symbols of XHTML.
But when the methods are called from XSL/XML, it is useful. In that case the line above would be generated by
Python example
<tag>aaa</tag>...<tag>/aaa</tag>

(now think about how the XML code looks like to generate the line above in the manual source code).
text class_
s
style
Show the content of the s string attribute as plain text. When the class_ or the style attributes are defined, then put the string as block inside a span tag.

Python example
self.text('Hello world', class_='shout')


textlabel class_
label
params
style
The textlabel method show the label in the current language. If the attribute is a dictionary then get the current language of the default language from it. If the label attribute is a string, then show answer the plain string. If the current language does not exist in the label dictionary, then show the plain label attribute. The optional params attribute can be used as parameters if label is a Python format string or a language dictionary containing Python format strings.

textlabeltext label
params
thumbnail cachename
class_
height
href
imageheight
imagewidth
maxheight
maxwidth
proportional
specimen
src
style
target
unique
width
DEPRECATED Using S3 store for all sites from now on. The thumbnail tag draws an image in a smaller scale and creates a thumbnail image file in the local directory ./_images/_thumbnails/. A unique filename is calculated with MD5 from the combination of the image basedpath, width, height and optional speciment.
Either the w or the h can be set. The other value is calculated from the w/h ratio of the source image. If both are defined, then the proportions of the projected image are distorted to match the requested w/h ratio of the thumbnail, depending on the value of proportional. If the attribute is False then keep the proportions of the image and make a best fit in the defined width and height.
If neither of the width and height is defined, then use the original size of the source image.
If one of both of the optional maxwidth and maxheight attributes are defined, these defined the maximum size of the image. If the real image measures are smaller, then no sizing is applied. These values only have effect if the extension of the image is one of ('jpg', 'png', 'gif').
The optional cachename attribute defines the cache name of the thunbnail.
If the href is defined, then creates a self.linksid around the thumbnail with target as target.
The imagewidth and imageheight attributes allow to overrule that actual display size of the HTML image. If omitted then the values of respectively the width and height attributes are used.
Todo: Make the specimen writing work with right fontsize, opacity, rotation and positioning
Todo: Make testing on existing cached file work

today class_
The today shows the current date.
Todo: Add some formatting options

Python example
self.today(class_='myclass')


transfer href
params
The transfer tag builds meta transfer tag. Put inside a head to force a transfer to another page. The href attribute can be an relative path. The params is an optional dictionary of parameters to add to the URL.

Python example
self.transfer('./anotherpage')


transfersid href
params
The transfersid tag is equivalent to transfer except that it adds the session id.
Put this tag inside a head to force a transfer to another page. The href attribute can be an relative path. The params is an optional dictionary of parameters to add to the URL.

Python example
self.transfer('./anotherpage')


uparrow size
The uparrow tag shows a standard up arrow, to be used in editors.
The size can be used to change the size of the icon. Standard is 10 pixels.
See also: rightarrow, downarrow and leftarrow

Python example
self.uparrow()
self.uparrow(20)


updatebutton accesskey
class_
enabled
label
mode
path
submit
Show a update button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.updatebutton(path='address')



upload accesskey
contentkey
filenamekey
width
The upload tag allows the local user to upload a file to the server.
Since the HTML of the tag is a type of input the actual appearance of the tag is very much dependent on the browser used. Unfortunately there is not way around that.
The width attribute has a default of 36px.
The attributes contentkey and filenamekey define the name in which the binary content of the uploaded file and the original file name of the file are stored. If not defined then the result of the upload is always in e.form['upload.filename'] and e.form['upload.content'].
Note: Make sure that both contentkey and filenamekey both start with upload. or else the server will try to UTF-8 the binary content.
Note: Don’t forget to set the form or formsid attribute as enctype="multipart/form-data" or else the document is not uploaded.
Note: This function required the script /_root/_lib2/javascripts/globalbehaviours.js to be loaded.
.
Note: If multitple uploads entries are defined on the same page, then the checkupload javascript function is defined only once.


Python example
self.upload()
self.upload(contentkey='upload.myupload.content', filenamekey='upload.myupload.filename')


uploadbutton accesskey
class_
enabled
label
mode
path
submit
Show an upload button with a default or defined label. When the submit is set to True then this button will respond to the [Enter] key.
The “mode” of a button, as defined by the optional mode attribute can be obtained by self.getcommandmode() to differentiate buttons with the same label.

Python example
self.uploadbutton(path='address')





valueof name
The valueof tag sends diverted output to the result output.
Note that the block is immediately executed. The diverted output needs to exist when the call is done.
It is not allowed to nest diversions, attempts will result in an error.
See also: variable
See also: getvalueofvariable
See also: record

Python example
self.variable('aaaa')
self.text('This is a diverted text.
self._variable()
...
self.h1()
self.valueof('aaaa')
self._h1()

...

This is a diverted text.


variable _variable name
The variable tag diverts all output of the block in a variable at e['variable_' + name] by creating a new temporary output stream. The output is later in the page available as plain XHTML code, so it can be pasted into the output stream on another position of the page by valueof.
Note that the block is immediately executed. The diverted output needs to exist when the call is done.
Diversions may me nested.
Warning: This method does change the output of the current builder, so on errors unpredictable result may be invisible when output stream is not restored properly.
See also: valueof

Python example
self.variable('aaaa')
self.text('This is a diverted text.')
self._variable()
...
self.h1()
self.valueof('aaaa')
self._h1()

...

This is a diverted text.


visualverify format
height
label
path
pattern
width
The visualverify method builds an image with distorted text to verify that the sender of the form is a human being. It is assumed that the distortion is enough so automatic image processing is not able to recognize the text pattern displayed.
If the optional text pattern pattern is not defined, then the method will generate a pattern. The minumum value for width and height is resptectively (200, 50).
The generated pattern is also stored as the e.session[self.XIERPABUILDER_VISUALVERIFY_PATTERN], so it is invisble in the XHTML code of the page. The called page should check if e.session[self.XIERPABUILDER_VISUALVERIFY_PATTERN] == e.form[mypath] the mypath is identical to the defined path attribute.
The optional label is used to mark that where to type the code. If omitted then the default string 'Verify the code ' is used.

Python example

AB24823726E1A4DF0CEC0850AD214C0E.png
Verify the code



warning class_
s
style
The warning tag can be used with a single string attribute s. To use it as an XML tag, include the xierpa/unknown.xsl template library. It generates a standard XHTML span with class attribute warning unless the class_ is defined instead. This allows the appearance of warnings be defined in CSS.

Python example
self.warning('This is an warning')


XML example
<warning>This is an warning </warning>

This is a warning
wikipedia target
word
Make a link to Wikipedia to find information about a certain word.

Python example
self.wikipedia('Python', target='example')

python
www href
target
The www creates a link using the URL as linking text. Url’s both with and without the http:// can be used.

Python example
self.www('www.petr.com')
self.www('http://www.xierpa.com', target='external')

Since we need the to collect the block in XSL, the following template could be used:
XSL example
<xsl:template match="www">
		<xsl:variable name="block">
		<xsl:apply-templates/>
		</xsl:variable>
		<xsl:copy>
		<xsl:attribute name="href">
			<xsl:value-of select="$block"/>
		</xsl:attribute>
		<xsl:for-each select="@*">
			<xsl:copy/>
		</xsl:for-each>
		</xsl:copy>
		</xsl:template>

The XSL code above is available as standard Xierpa library. Add the following line to your template.xsl:
XSL example
<xsl:include href="xierpa/link.xsl"/>

Now the following XML can be translated as www.petr.com.

XML example
<www target="external">www.petr.com"</www>
		<www>http://www.xierpa.com</www>


xierpalogo delay
glyphs
width
The xierpalogo method builds an animation from the Xierpa logo, the X filling with liquid.
There are several attributes that influence the appearence of the animated logo. The animated logo is built from frames. Each frame contains 3 glyphs (e.g. 'ABf') from the font 'XierpaLogo'. The 'AB' shows the “X” and the third letters defined the level of the liquid.
The optional width attribute defines the width of the (square) logo. If omitted the default value self.XIERPAVALUE_LOGOWIDTH is used.
The glyphs are located in the following character positions:
Python example






Mismatch in closing tag "table", expected "tr" in tree "['html', 'body', 'div', 'div', 'div', 'component', 'div', 'table']".
Mismatch in closing tag "component", expected "table" in tree "['html', 'body', 'div', 'div', 'div', 'component', 'div']".
Mismatch in closing tag "div", expected "component" in tree "['html', 'body', 'div', 'div', 'div']".
Mismatch in closing tag "body", expected "div" in tree "['html', 'body', 'div']".
Mismatch in closing tag "html", expected "div" in tree "['html', 'body']".