This is not finished yet. More work than what I expected but the main part is done.
It will need a lot of testing... There is still a bug when activating a new extension
in development mode (ie. with python web server), I think it does not occur behind
a real web server.
This commit is contained in:
tonio
2010-05-04 17:25:23 +02:00
parent af8c33e659
commit 7480e479e7
15 changed files with 171 additions and 52 deletions
+7
View File
@@ -27,6 +27,13 @@ def register(event, callback):
callbacks[event].append(callback)
return 1
def unregister(event, callback):
if not event in events:
return False
if not callbacks.has_key(event):
return False
callbacks[event].remove(callback)
def raiseEvent(event, **kwargs):
if not event in events or not event in callbacks.keys():
return 0
+6
View File
@@ -35,6 +35,12 @@ def register(app, name, type="string", deflt=None, help=None, **kwargs):
for k, v in kwargs.iteritems():
_params[app][name][k] = v
def unregister_app(app):
if not _params.has_key(app):
return False
del _params[app]
return True
def save(app, name, value):
if not app in _params.keys() or not name in _params[app].keys():
raise NotDefined(app, name)
+20 -24
View File
@@ -19,13 +19,14 @@ class Column:
label = getattr(self, "name")
return label
class SelectionColumn(Column):
def __str__(self):
return "<input type='checkbox' name='selectall' id='selectall' />"
def render(self, value):
return "<input type='checkbox' name='%s' value='%s' />" \
% (self.name, value)
def render(self, value, selection):
return "<input type='checkbox' id='%s' name='select_%s' value='%s' %s/>" \
% (self.name, value, value, selection and "checked" or "")
class ImgColumn(Column):
sortable = False
@@ -56,33 +57,28 @@ class Table(object):
nrow = {"id" : row[self.idkey], "cols" : []}
for c in self.columns:
newcol = {"name" : c.name}
try:
newcol["width"] = getattr(c, "width")
except AttributeError:
pass
try:
newcol["align"] = getattr(c, "align")
except:
pass
for key in ["width", "align", "cssclass"]:
try:
newcol[key] = getattr(c, key)
except AttributeError:
newcol[key] = ""
if isinstance(c, SelectionColumn):
newcol["value"] = c.render(row[self.idkey])
newcol["safe"] = True
if isinstance(c, ImgColumn):
selection = row.has_key(c.name) and row[c.name] or False
newcol["value"] = c.render(row[self.idkey], selection)
newcol["safe"] = True
elif isinstance(c, ImgColumn):
key = "img_%s" % c.name
if key in row.keys():
newcol["value"] = c.render(row[key])
newcol["safe"] = True
if row.has_key(c.name):
try:
cssclass = getattr(c, "cssclass")
except AttributeError:
cssclass = ""
elif row.has_key(c.name):
if "class" in row.keys():
cssclass += (cssclass != "") and ", %s" % row["class"] or row["class"]
newcol["value"] = self.parse(c.name, row[c.name])
newcol["class"] = cssclass
newcol["cssclass"] += newcol["cssclass"] != "" \
and ", %s" % row["class"] or row["class"]
try:
newcol["value"] = self.parse(c.name, row[c.name])
except AttributeError:
newcol["value"] = row[c.name]
nrow["cols"] += [newcol]
self.rows += [nrow]