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.

Starting in Xierpa

One step more complex

Now we will build a bit more complex page. The original build method is divided by calling two other methods that we created: buildhead and buildbody.
# -*- coding: UTF-8 -*-
from xpyth.xierpa.builders.xierpabuilder import XierpaBuilder

def px(value):
	return str(value) + 'px'
	
class Home(XierpaBuilder):
	
	def buildhead(self):
		self.head()
		self.title()
		self.text('Title of "Hello world" page')
		self._title()
		
		self.style()
		self.css(ids='body', fontfamily='Verdana', fontsize=px(11))
		self._style()
		
		self.calendarpopupinit()
		self.script(src='/_root/_lib2/javascripts/globalbehaviors.js', 
			type='text/javascript', charset='UTF-8')
		self._head()
	
	def buildbody(self):
		self.body()	

		self.table(border=1)
		self.row()
		self.col()
		self.text('Hello world top left')
		self._col()
		self.col()
		self.text('Hello world top right')
		self._col()
		self._row()
		
		self.row()
		self.col()
		self.text('Hello world bottom left')
		self._col()
		self.col()
		self.text('Hello world bottom right')
		self.br()
		self.calendarpopup(path='activity@when')
		self._col()
		self._row()
		self._table()
		
		self._body()

	def build(self):
		self.doctype('xhtml-transitional')
		self.html()
		self.buildhead()
		self.buildbody()
		self._html()

Home(e, result).build()
Example 3


(click on the image to see the page in the browser)

The two methods are called by
		self.buildhead()
		self.buildbody()
In the header the css style for body is defined by
		self.style()
		self.css(ids='body', fontfamily='Verdana', fontsize=px(11))
		self._style()
The attributes for the css tag are identical to the standard css parameters with al hyphens (-) removed.

In the buildbody a table is defined with the following
		self.table()
		...
		self._table()
and the two columns are defined by
		self.row()
		...
		self._row()
		
		self.row()
		...
		self._row()
The cells of the table are defined by
		self.col()
		self.text(...)
		self._col()
Note that, unlike XML, the indenting of the code is determined by the Python syntax. Therefor it is not possible to use the block indent as is common practice with XML.

Go to the next step of complexity