Ejemplo n.º 1
0
 def __init__(self,
              text,
              input=None,
              inputs=None,
              help=None,
              disabled=False,
              trigger_mode=None,
              triggers=None):
     self.text = text
     if help:
         self.help = help
     if disabled:
         self.disabled = disabled
     if input and inputs:
         raise common.FormDefError('specify "input" or "inputs", not both')
     if input:
         inputs = [input]
     if inputs is None:
         inputs = []
     for input in inputs:
         if not isinstance(input, inputbase.InputBase):
             raise common.FormDefError('question inputs must be '
                                       'InputBase subclasses')
     self.inputs = inputs
     if trigger_mode is not None:
         self.trigger_mode = trigger_mode
     if triggers is not None:
         self.triggers = triggers
     self.columns = []
Ejemplo n.º 2
0
 def __init__(self, column, **kwargs):
     inputbase.ChoicesBase.__init__(self, column, **kwargs)
     for value, label in self.choices:
         if (len(self.column) + len(value)) > common.max_identifier_len:
             raise common.FormDefError(
                 'column %r choice %r combined are too long (max %d)' %
                 (self.column, value, common.max_identifier_len))
Ejemplo n.º 3
0
 def __init__(self,
              text,
              table=None,
              name=None,
              form_type=None,
              allow_multiple=False,
              update_time=None,
              author=None,
              username=None):
     _ElementContainer.__init__(self, text)
     if table:
         self.table = table
     if name:
         self.name = name
     if form_type:
         self.form_type = form_type
     if allow_multiple:
         self.allow_multiple = allow_multiple
     if update_time:
         if isinstance(update_time, basestring):
             try:
                 update_time = datetime.mx_parse_datetime(update_time)
             except datetime.Error, e:
                 raise common.FormDefError('update_time: %s' % e)
         self.update_time = update_time
Ejemplo n.º 4
0
 def __init__(self, column, **kwargs):
     ChoicesBase.__init__(self, column, **kwargs)
     if self.maxsize:
         for value, label in self.choices:
             if len(value) > self.maxsize:
                 raise common.FormDefError(
                     'Length of %r choice exceeds maximum field size (%s)' %
                     (value, self.maxsize))
Ejemplo n.º 5
0
 def __init__(self, column, **kwargs):
     if len(column) > common.max_identifier_len:
         raise common.FormDefError('%s input column name %r too long (%d, max %d)' %\
                     (self.__class__.__name__, column,
                      len(column), common.max_identifier_len))
     if self.locked_column:
         column = self.locked_column
     self.column = column
     if 'label' not in kwargs and 'summary' in kwargs:
         kwargs['label'] = kwargs.pop('summary')
     self.__dict__.update(kwargs)
     for skip in self.skips:
         if not isinstance(skip, Skip):
             raise common.FormDefError(
                 '%s input %r, skips must be a Skip instance, not %r' %
                 (self.__class__.__name__, self.column, skip))
         skip.input = self
Ejemplo n.º 6
0
 def add_column(self, input, col_name, col_type, **col_kwargs):
     self.input_by_name[input.column.lower()] = input
     col_name = col_name.lower()
     if col_name in self.col_dict:
         raise common.FormDefError('column "%s" is used more than once' %
                                   (col_name,))
     column = _Column(input, col_name, col_type, col_kwargs)
     self.col_dict[col_name] = column
     self.columns.append(column)
Ejemplo n.º 7
0
 def add_condition(self, skip, question):
     if skip.name in self.conditions_by_name:
         raise common.FormDefError('skip name "%s" is used more than once' %
                                   (skip.name,))
     self.conditions_by_name[skip.name] = skip, question
     try:
         xlinks_pending = self.xlinks_pending.pop(skip.name)
     except KeyError:
         pass
     else:
         for xlink in xlinks_pending:
             xlink.skip = skip