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()
(click on the image to see the page in the browser)
The two methods are called by
self.buildhead() self.buildbody()
self.style() self.css(ids='body', fontfamily='Verdana', fontsize=px(11)) self._style()
In the buildbody a table is defined with the following
self.table() ... self._table()
self.row() ... self._row() self.row() ... self._row()
self.col() self.text(...) self._col()
Go to the next step of complexity
