The different functionalities of Gizmo(QP) make use of several
object types, each dedicated to specific task. Not all are formal
types, as some are no more than a working convention, e.g.
the crumb data tuple.
This sections demos a few of the these special object types.
eXportable
QP implements an export as an informal 4-tuple.
Gizmo formalizes the eXportable type, that is equivalent
to a QP export except for the fact that it
is only a QP export if it passes contextual access control.
See module: gz.fill.exportable
Dhi
The Dhi object for an export is contributed to by all
participants of a response, making complex DHTML pages easier
to build and debug, as well as simpler to render by the client.
See module: gz.fill.dhi
Crumb
A 5-tuple, that contains navigation-pertinent information
about an export.
See module: gz.fill.directory
Python source : gizmo(qp) directory, /specials/ | specials.py#code |
from gz.pub.common import page, get_dhi
from gz.fill.exportable import X
from gz.fill.dhi import Dhi
from gz.fill.directory import Directory
from gz.lib.design_patterns import bunch
class SpecialsDir(Directory):
exportables = [
# X(component, attribute, crumb, title, allow=None, dhi=None)
X(”, ‘index’, ‘Special Types’, ‘Special Types’),
X(‘x’, ‘x’, ‘X’, ‘eXportable’),
X(‘dhi’, ‘dhinfo’, ‘Dhi’, ‘Dhi’, None,
# Example of a pre-initialized Dhi
dhi=Dhi(
css_codes=[
‘.bb { border: 3px dotted blue; }’,
‘.bg { border: 2px dashed green; }’,
‘.by { border: 3px dashed yellow; }’,
‘.br { border: 2px dotted red; }’,
],
js_codes=[
‘var kount=0;’,
‘var initial_body_klass;’,
“var klasses = [‘bb’,’bg’,’by’,’br’];”,
“””
function get_body() { return document.getElementsByTagName(‘body’)[0]; }”””,
“””
function mod(divisee, base) {
return Math.round(divisee – (Math.floor(divisee/base)*base)); }”””,
“””
function set_body_klass() {
get_body().className = initial_body_klass+’ ‘+klasses[mod(kount, 4)];
kount += 1;
window.setTimeout(‘set_body_klass();’, 1000); }”””,
],
onload_actions=[
“initial_body_klass = get_body().className;”,
“set_body_klass();”,
],
meta=bunch(description=’dhtmlinfo object test page’),
http_equiv=bunch(refresh=”60;url=’.'”))),
X(‘crumb’, ‘crumb’, ‘Crumb’, ‘Crumb Tuple’),
]
def index(self):
return page(get_dhi().x.title, template=’specials.html’)
def dhinfo(self):
return page(get_dhi().x.title, template=’specials_dhi.html’)
def x(self):
return page(get_dhi().x.title, template=’specials_x.html’)
def crumb(self):
return page(get_dhi().x.title, template=’specials_crumb.html’,
get_crumbs=self.get_crumbs)