def setCellValue(self,row,value): assert isinstance(row,self._owner._instanceClass) langs = row.getContext().getBabelLangs() #values = row.getFieldValue(self.name) values = row._values.get(self.name) if values is None: #if self._isMandatory: # raise DataVeto("may not be empty") values = [None] * len(row.getDatabase().getBabelLangs()) row._values[self.name] = values if len(langs) > 1: assert issequence(value), \ "%s is not a sequence" % repr(value) assert len(value) == len(langs), \ "%s expects %d values but got %s" % \ (self.name, len(langs), repr(value)) i = 0 for lang in langs: if lang.index != -1: values[lang.index] = value[i] i += 1 else: assert not issequence(value) index = langs[0].index if index != -1: values[index] = value
def setCellValue(self, row, value): assert isinstance(row, self._owner._instanceClass) langs = row.getContext().getBabelLangs() #values = row.getFieldValue(self.name) values = row._values.get(self.name) if values is None: #if self._isMandatory: # raise DataVeto("may not be empty") values = [None] * len(row.getDatabase().getBabelLangs()) row._values[self.name] = values if len(langs) > 1: assert issequence(value), \ "%s is not a sequence" % repr(value) assert len(value) == len(langs), \ "%s expects %d values but got %s" % \ (self.name, len(langs), repr(value)) i = 0 for lang in langs: if lang.index != -1: values[lang.index] = value[i] i += 1 else: assert not issequence(value) index = langs[0].index if index != -1: values[index] = value
def __init__(self, doc, parent, columns, model, width, flowStyle): # TODO : make a copy of model.columns here so that # TableInstance.addColumn does not modify the model (?) # Currently this is done by child()ing the model... # self.rows = [] self.currentRow = None self._rowIndex = -1 if width is None: width = parent.getTextWidth() assert isnumber(width), "%s is not a number" % repr(width) assert isinstance(model, TableModel) # child() the model because updates to the table instance should # not update the TableModel self.model = model.child() if flowStyle is None: flowStyle = model.flowStyle ChildEnvironment.__init__(self, doc, parent, width, flowStyle, self.model.paraStyle) if columns is not None: assert self.model.getColumnCount() is 0 self.model.isgrowing = False # self.columns = [] if issequence(columns): # it is a sequence of relative widths ## s = 0 ## for w in columns: ## s += w s = reduce(lambda x, y: x + y, columns) # print s for w in columns: self.addColumn(width=w * self.width / s) elif type(columns) is types.StringType: # string of colspecs characters for c in columns: s = self._paraStyle.child(alignment=colspecs[c]) s.setName("%s.defaultParaStyle" % \ c.__class__.__name__) self.addColumn(style=s) else: raise "%s : invalid colSpecs" % repr(columns) #else: # self.columns = list(self.model.columns) if self.model.getColumnCount() > 0: self.computeColWidths() #else: # print 'foo' # "beginTable() must specify the number of columns" """make a copy using list() so that adding cell formats won't
def buildURL(self, url, flds): sep = "?" for (k, v) in flds.items(): if issequence(v): for i in v: url += sep + k + "=" + str(i) sep = "&" elif v is not None: url += sep + k + "=" + str(v) sep = "&" return url
def buildURL(self,url,flds): sep = "?" for (k,v) in flds.items(): if issequence(v): for i in v: url += sep + k + "=" + str(i) sep = "&" elif v is not None: url += sep + k + "=" + str(v) sep = "&" return url
def buildURL(self, url, *args, **kw): if len(args): url += "/" + "/".join([str(v) for v in args]) sep = "?" for (k, v) in kw.items(): if issequence(v): for i in v: url += sep + k + "=" + str(i) sep = "&" elif v is not self.CLEAR: if v is None: url += sep + k + "=" else: url += sep + k + "=" + str(v) sep = "&" return url
def __init__(self, doc, parent, columns, model, width, flowStyle ): # TODO : make a copy of model.columns here so that # TableInstance.addColumn does not modify the model (?) # Currently this is done by child()ing the model... # self.rows = [] self.currentRow = None self._rowIndex = -1 if width is None: width = parent.getTextWidth() assert isnumber(width), "%s is not a number" % repr(width) assert isinstance(model,TableModel) # child() the model because updates to the table instance should # not update the TableModel self.model = model.child() if flowStyle is None: flowStyle = model.flowStyle ChildEnvironment.__init__(self, doc, parent,width, flowStyle, self.model.paraStyle) if columns is not None: assert self.model.getColumnCount() is 0 self.model.isgrowing = False # self.columns = [] if issequence(columns): # it is a sequence of relative widths ## s = 0 ## for w in columns: ## s += w s = reduce(lambda x, y: x+y, columns) # print s for w in columns: self.addColumn(width=w * self.width / s) elif type(columns) is types.StringType: # string of colspecs characters for c in columns: s = self._paraStyle.child(alignment=colspecs[c]) s.setName("%s.defaultParaStyle" % \ c.__class__.__name__) self.addColumn(style=s) else: raise "%s : invalid colSpecs" % repr(columns) #else: # self.columns = list(self.model.columns) if self.model.getColumnCount() > 0: self.computeColWidths() #else: # print 'foo' # "beginTable() must specify the number of columns" """make a copy using list() so that adding cell formats won't