Exemplo n.º 1
0
 def __init__(self, fields, validator=None, multiplicity=(0,1), default=None,
              show=True, page='main', group=None, layouts=None, move=0,
              indexed=False, searchable=False, specificReadPermission=False,
              specificWritePermission=False, width='', height=None,
              maxChars=None, colspan=1, master=None, masterValue=None,
              focus=False, historized=False, mapping=None, label=None,
              subLayouts=Table('frv', width=None), widths=None):
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, False,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, None, None, None, None, True)
     self.validable = True
     # Tuples of (names, Field instances) determining the format of every
     # element in the list.
     self.fields = fields
     # Force some layouting for sub-fields, if subLayouts are given. So the
     # one who wants freedom on tuning layouts at the field level must
     # specify subLayouts=None.
     if subLayouts:
         for name, field in self.fields:
             field.layouts = field.formatLayouts(subLayouts)
     # One may specify the width of every column in the list. Indeed, using
     # widths and layouts of sub-fields may not be sufficient.
     if not widths:
         self.widths = [''] * len(self.fields)
     else:
         self.widths = widths
Exemplo n.º 2
0
 def __init__(self, validator=None, multiplicity=(0,1), default=None,
              show='view', page='main', group=None, layouts=None, move=0,
              indexed=False, searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=None, height=None,
              maxChars=None, colspan=1, method=None, plainText=True,
              master=None, masterValue=None, focus=False, historized=False,
              sync=True, mapping=None, label=None, sdefault='', scolspan=1,
              swidth=None, sheight=None, context={}):
     # The Python method used for computing the field value
     self.method = method
     # Does field computation produce plain text or XHTML?
     self.plainText = plainText
     if isinstance(method, basestring):
         # When field computation is done with a macro, we know the result
         # will be HTML.
         self.plainText = False
     # The context is a dict (or method returning a dict) that will be given
     # to the macro specified in self.method. If the dict contains key
     # "someKey", it will be available to the macro as "options/someKey".
     self.context = context
     Field.__init__(self, None, multiplicity, default, show, page, group,
                    layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, sync, mapping, label, sdefault, scolspan,
                    swidth, sheight)
     self.validable = False
Exemplo n.º 3
0
 def __init__(self,
              validator=None,
              multiplicity=(0, 1),
              default=None,
              show=True,
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              sdefault=False,
              scolspan=1,
              swidth=None,
              sheight=None,
              persist=True):
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, persist)
     self.pythonType = bool
Exemplo n.º 4
0
 def __init__(
     self,
     validator=None,
     multiplicity=(0, 1),
     default=None,
     show=True,
     page="main",
     group=None,
     layouts=None,
     move=0,
     indexed=False,
     searchable=False,
     specificReadPermission=False,
     specificWritePermission=False,
     width=5,
     height=None,
     maxChars=13,
     colspan=1,
     master=None,
     masterValue=None,
     focus=False,
     historized=False,
     mapping=None,
     label=None,
     sdefault=("", ""),
     scolspan=1,
     swidth=None,
     sheight=None,
 ):
     Field.__init__(
         self,
         validator,
         multiplicity,
         default,
         show,
         page,
         group,
         layouts,
         move,
         indexed,
         searchable,
         specificReadPermission,
         specificWritePermission,
         width,
         height,
         maxChars,
         colspan,
         master,
         masterValue,
         focus,
         historized,
         True,
         mapping,
         label,
         sdefault,
         scolspan,
         swidth,
         sheight,
     )
     self.pythonType = long
Exemplo n.º 5
0
 def __init__(self, validator=None, multiplicity=(0,1), default=None,
              format=WITH_HOUR, dateFormat=None, hourFormat=None,
              calendar=True, startYear=time.localtime()[0]-10,
              endYear=time.localtime()[0]+10, reverseYears=False,
              show=True, page='main', group=None, layouts=None, move=0,
              indexed=False, mustIndex=True, searchable=False,
              specificReadPermission=False, specificWritePermission=False,
              width=None, height=None, maxChars=None, colspan=1, master=None,
              masterValue=None, focus=False, historized=False, mapping=None,
              label=None, sdefault=None, scolspan=1, swidth=None,
              sheight=None, persist=True, view=None, xml=None, showDay=True):
     self.format = format
     self.calendar = calendar
     self.startYear = startYear
     self.endYear = endYear
     # If reverseYears is True, in the selection box, available years, from
     # self.startYear to self.endYear will be listed in reverse order.
     self.reverseYears = reverseYears
     # If p_showDay is False, the list for choosing a day will be hidden.
     self.showDay = showDay
     # If no p_dateFormat/p_hourFormat is specified, the application-wide
     # tool.dateFormat/tool.hourFormat instead.
     self.dateFormat = dateFormat
     self.hourFormat = hourFormat
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, mustIndex, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, persist, False, view, xml)
Exemplo n.º 6
0
 def __init__(self, validator=None, multiplicity=(0,1), default=None,
              show=('view', 'result'), page='main', group=None,
              layouts=None, move=0, indexed=False, searchable=False,
              specificReadPermission=False, specificWritePermission=False,
              width=None, height=None, maxChars=None, colspan=1, method=None,
              formatMethod=None, plainText=False, master=None,
              masterValue=None, focus=False, historized=False, mapping=None,
              label=None, sdefault='', scolspan=1, swidth=None, sheight=None,
              context=None):
     # The Python method used for computing the field value, or a PX.
     self.method = method
     # A specific method for producing the formatted value of this field.
     # This way, if, for example, the value is a DateTime instance which is
     # indexed, you can specify in m_formatMethod the way to format it in
     # the user interface while m_method computes the value stored in the
     # catalog.
     self.formatMethod = formatMethod
     if isinstance(self.method, basestring):
         # A legacy macro identifier. Raise an exception
         raise Exception(self.WRONG_METHOD % self.method)
     # Does field computation produce plain text or XHTML?
     self.plainText = plainText
     if isinstance(method, Px):
         # When field computation is done with a PX, the result is XHTML.
         self.plainText = False
     # If method is a PX, its context can be given in p_context.
     self.context = context
     Field.__init__(self, None, multiplicity, default, show, page, group,
                    layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, False)
     self.validable = False
Exemplo n.º 7
0
 def __init__(self,
              validator=None,
              multiplicity=(1, 1),
              default=None,
              show='view',
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None):
     Field.__init__(self, None, (0, 1), default, show, page, group, layouts,
                    move, indexed, False, specificReadPermission,
                    specificWritePermission, width, height, None, colspan,
                    master, masterValue, focus, historized, False, mapping,
                    label, None, None, None, None)
     self.validable = False
Exemplo n.º 8
0
 def __init__(self, validator=None, multiplicity=(1,1), default=None,
              show=True, page='main', group=None, layouts=None, move=0,
              indexed=False, searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=None, height=None,
              maxChars=None, colspan=1, action=None, result='computation',
              confirm=False, master=None, masterValue=None, focus=False,
              historized=False, mapping=None, label=None):
     # Can be a single method or a list/tuple of methods
     self.action = action
     # For the 'result' param:
     #  * value 'computation' means that the action will simply compute
     #    things and redirect the user to the same page, with some status
     #    message about execution of the action;
     #  * 'file' means that the result is the binary content of a file that
     #    the user will download.
     #  * 'redirect' means that the action will lead to the user being
     #    redirected to some other page.
     self.result = result
     # If following field "confirm" is True, a popup will ask the user if
     # she is really sure about triggering this action.
     self.confirm = confirm
     Field.__init__(self, None, (0,1), default, show, page, group, layouts,
                    move, indexed, False, specificReadPermission,
                    specificWritePermission, width, height, None, colspan,
                    master, masterValue, focus, historized, mapping, label,
                    None, None, None, None, False)
     self.validable = False
     self.renderLabel = False # Label is rendered directly within the button.
Exemplo n.º 9
0
 def __init__(self, validator=None, default=None, show=('view', 'result'),
              page='main', group=None, layouts=None, move=0, indexed=False,
              searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=None, height=None,
              maxChars=None, colspan=1, master=None, masterValue=None,
              focus=False, historized=False, mapping=None, label=None,
              template=None, context=None, action=None, askAction=False,
              stylesMapping={}, freezeFormat='pdf'):
     # The following param stores the path to a POD template
     self.template = template
     # The context is a dict containing a specific pod context, or a method
     # that returns such a dict.
     self.context = context
     # Next one is a method that will be triggered after the document has
     # been generated.
     self.action = action
     # If askAction is True, the action will be triggered only if the user
     # checks a checkbox, which, by default, will be unchecked.
     self.askAction = askAction
     # A global styles mapping that would apply to the whole template
     self.stylesMapping = stylesMapping
     # Freeze format is by PDF by default
     self.freezeFormat = freezeFormat
     Field.__init__(self, None, (0,1), default, show, page, group, layouts,
                    move, indexed, searchable, specificReadPermission,
                    specificWritePermission, width, height, None, colspan,
                    master, masterValue, focus, historized, False, mapping,
                    label, None, None, None, None)
     self.validable = False
Exemplo n.º 10
0
 def __init__(self, validator=None, multiplicity=(0,1), default=None,
              show=True, page='main', group=None, layouts=None, move=0,
              indexed=False, searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=5, height=None,
              maxChars=13, colspan=1, master=None, masterValue=None,
              focus=False, historized=False, mapping=None, label=None,
              sdefault=('',''), scolspan=1, swidth=None, sheight=None,
              persist=True, precision=None, sep=(',', '.'), tsep=' '):
     # The precision is the number of decimal digits. This number is used
     # for rendering the float, but the internal float representation is not
     # rounded.
     self.precision = precision
     # The decimal separator can be a tuple if several are allowed, ie
     # ('.', ',')
     if type(sep) not in sutils.sequenceTypes:
         self.sep = (sep,)
     else:
         self.sep = sep
     # Check that the separator(s) are among allowed decimal separators
     for sep in self.sep:
         if sep not in Float.allowedDecimalSeps:
             raise Exception('Char "%s" is not allowed as decimal ' \
                             'separator.' % sep)
     self.tsep = tsep
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, False,
                    specificReadPermission, specificWritePermission, width,
                    height, maxChars, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, persist)
     self.pythonType = float
Exemplo n.º 11
0
 def __init__(self, validator=None, multiplicity=(0,1), default=None,
              format=LINE, show=True, page='main', group=None, layouts=None,
              move=0, indexed=False, searchable=False,
              specificReadPermission=False, specificWritePermission=False,
              width=None, height=None, maxChars=None, colspan=1, master=None,
              masterValue=None, focus=False, historized=False, mapping=None,
              label=None, sdefault='', scolspan=1, swidth=None, sheight=None,
              transform='none', styles=('p','h1','h2','h3','h4'),
              allowImageUpload=True, inlineEdit=False):
     # According to format, the widget will be different: input field,
     # textarea, inline editor... Note that there can be only one String
     # field of format CAPTCHA by page, because the captcha challenge is
     # stored in the session at some global key.
     self.format = format
     self.isUrl = validator == String.URL
     # When format is XHTML, the list of styles that the user will be able to
     # select in the styles dropdown is defined hereafter.
     self.styles = styles
     # When format is XHTML, do we allow the user to upload images in it ?
     self.allowImageUpload = allowImageUpload
     # When format in XHTML, can the field be inline-edited (ckeditor)?
     self.inlineEdit = inlineEdit
     # The following field has a direct impact on the text entered by the
     # user. It applies a transformation on it, exactly as does the CSS
     # "text-transform" property. Allowed values are those allowed for the
     # CSS property: "none" (default), "uppercase", "capitalize" or
     # "lowercase".
     self.transform = transform
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, maxChars, colspan, master, masterValue, focus,
                    historized, True, mapping, label, sdefault, scolspan,
                    swidth, sheight)
     self.isSelect = self.isSelection()
     # If self.isSelect, self.sdefault must be a list of value(s).
     if self.isSelect and not sdefault:
         self.sdefault = []
     # Default width, height and maxChars vary according to String format
     if width == None:
         if format == String.TEXT:  self.width  = 60
         # This width corresponds to the standard width of an Appy page.
         if format == String.XHTML: self.width  = None
         else:                      self.width  = 30
     if height == None:
         if format == String.TEXT: self.height = 5
         elif self.isSelect:       self.height = 4
         else:                     self.height = 1
     if maxChars == None:
         if self.isSelect: pass
         elif format == String.LINE: self.maxChars = 256
         elif format == String.TEXT: self.maxChars = 9999
         elif format == String.XHTML: self.maxChars = 99999
         elif format == String.PASSWORD: self.maxChars = 20
     self.filterable = self.indexed and (self.format == String.LINE) and \
                       not self.isSelect
     self.swidth = self.swidth or self.width
     self.sheight = self.sheight or self.height
Exemplo n.º 12
0
 def __init__(self,
              validator=None,
              multiplicity=(0, 1),
              default=None,
              show=('view', 'result'),
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              method=None,
              formatMethod=None,
              plainText=False,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              sdefault='',
              scolspan=1,
              swidth=None,
              sheight=None,
              context=None):
     # The Python method used for computing the field value, or a PX.
     self.method = method
     # A specific method for producing the formatted value of this field.
     # This way, if, for example, the value is a DateTime instance which is
     # indexed, you can specify in m_formatMethod the way to format it in
     # the user interface while m_method computes the value stored in the
     # catalog.
     self.formatMethod = formatMethod
     if isinstance(self.method, basestring):
         # A legacy macro identifier. Raise an exception
         raise Exception(self.WRONG_METHOD % self.method)
     # Does field computation produce plain text or XHTML?
     self.plainText = plainText
     if isinstance(method, Px):
         # When field computation is done with a PX, the result is XHTML.
         self.plainText = False
     # If method is a PX, its context can be given in p_context.
     self.context = context
     Field.__init__(self, None, multiplicity, default, show, page, group,
                    layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, False)
     self.validable = False
Exemplo n.º 13
0
 def __init__(self, multiplicity=(0,1), default=None, show=None, page='main',
   group=None, layouts=None, move=0, indexed=False, mustIndex=True,
   searchable=False, specificReadPermission=False,
   specificWritePermission=False, width=None, height=None, maxChars=None,
   colspan=1, method=None, formatMethod=None, plainText=False, master=None,
   masterValue=None, focus=False, historized=False, mapping=None, label=None,
   sdefault='', scolspan=1, swidth=None, sheight=None, context=None,
   view=None, xml=None, unfreezable=False, validable=False):
     # The Python method used for computing the field value, or a PX
     self.method = method
     # A specific method for producing the formatted value of this field.
     # This way, if, for example, the value is a DateTime instance which is
     # indexed, you can specify in m_formatMethod the way to format it in
     # the user interface while m_method computes the value stored in the
     # catalog.
     self.formatMethod = formatMethod
     if isinstance(self.method, basestring):
         # A legacy macro identifier. Raise an exception
         raise Exception(self.WRONG_METHOD % self.method)
     # Does field computation produce plain text or XHTML?
     self.plainText = plainText
     if isinstance(method, Px):
         # When field computation is done with a PX, the result is XHTML
         self.plainText = False
     # Determine default value for "show"
     if show == None:
         # XHTML content in a Computed field generally corresponds to some
         # custom XHTML widget. This is why, by default, we do not render it
         # in the xml layout.
         show = self.plainText and ('view', 'result', 'xml') or \
                                   ('view', 'result')
     # If method is a PX, its context can be given in p_context
     self.context = context
     Field.__init__(self, None, multiplicity, default, show, page, group,
                    layouts, move, indexed, mustIndex, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, False, False, view, xml)
     # When a custom widget is built from a computed field, its values are
     # potentially editable an validable, so "validable" must be True.
     self.validable = validable
     # One classic use case for a Computed field is to build a custom widget.
     # In this case, self.method stores a PX or method that produces, on
     # view or edit, the custom widget. Logically, you will need to store a
     # custom data structure on obj.o, in an attribute named according to
     # this field, ie self.name. Typically, you will set or update a value
     # for this attribute in obj.onEdit, by getting, on the obj.request
     # object, values encoded by the user in your custom widget (edit mode).
     # This "custom widget" use case is incompatible with "freezing". Indeed,
     # freezing a Computed field implies storing the computed value at
     # obj.o.[self.name] instead of recomputing it as usual. So if you want
     # to build a custom widget, specify the field as being unfreezable.
     self.unfreezable = unfreezable
Exemplo n.º 14
0
 def __init__(self, validator=None, multiplicity=(1,1), default=None,
              show='view', page='main', group=None, layouts=None, move=0,
              indexed=False, searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=None, height=None,
              maxChars=None, colspan=1, master=None, masterValue=None,
              focus=False, historized=False, mapping=None, label=None):
     Field.__init__(self, None, (0,1), default, show, page, group, layouts,
                    move, indexed, False, specificReadPermission,
                    specificWritePermission, width, height, None, colspan,
                    master, masterValue, focus, historized, mapping, label,
                    None, None, None, None, False)
     self.validable = False
Exemplo n.º 15
0
 def __init__(self,
              validator=None,
              multiplicity=(0, 1),
              default=None,
              show='view',
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              method=None,
              plainText=True,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              sync=True,
              mapping=None,
              label=None,
              sdefault='',
              scolspan=1,
              swidth=None,
              sheight=None,
              context={}):
     # The Python method used for computing the field value
     self.method = method
     # Does field computation produce plain text or XHTML?
     self.plainText = plainText
     if isinstance(method, basestring):
         # When field computation is done with a macro, we know the result
         # will be HTML.
         self.plainText = False
     # The context is a dict (or method returning a dict) that will be given
     # to the macro specified in self.method. If the dict contains key
     # "someKey", it will be available to the macro as "options/someKey".
     self.context = context
     Field.__init__(self, None, multiplicity, default, show, page, group,
                    layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, sync, mapping, label, sdefault, scolspan,
                    swidth, sheight)
     self.validable = False
Exemplo n.º 16
0
 def __init__(self,
              validator=None,
              default=None,
              show=('view', 'result'),
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              template=None,
              context=None,
              action=None,
              askAction=False,
              stylesMapping={},
              freezeFormat='pdf'):
     # The following param stores the path to a POD template
     self.template = template
     # The context is a dict containing a specific pod context, or a method
     # that returns such a dict.
     self.context = context
     # Next one is a method that will be triggered after the document has
     # been generated.
     self.action = action
     # If askAction is True, the action will be triggered only if the user
     # checks a checkbox, which, by default, will be unchecked.
     self.askAction = askAction
     # A global styles mapping that would apply to the whole template
     self.stylesMapping = stylesMapping
     # Freeze format is by PDF by default
     self.freezeFormat = freezeFormat
     Field.__init__(self, None, (0, 1), default, show, page, group, layouts,
                    move, indexed, searchable, specificReadPermission,
                    specificWritePermission, width, height, None, colspan,
                    master, masterValue, focus, historized, False, mapping,
                    label, None, None, None, None)
     self.validable = False
Exemplo n.º 17
0
 def __init__(self,
              fields,
              validator=None,
              multiplicity=(0, 1),
              default=None,
              show=True,
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width='',
              height=None,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              subLayouts=Table('frv', width=None),
              widths=None):
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, False,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, None, None, None, None,
                    True)
     self.validable = True
     # Tuples of (names, Field instances) determining the format of every
     # element in the list.
     self.fields = fields
     # Force some layouting for sub-fields, if subLayouts are given. So the
     # one who wants freedom on tuning layouts at the field level must
     # specify subLayouts=None.
     if subLayouts:
         for name, field in self.fields:
             field.layouts = field.formatLayouts(subLayouts)
     # One may specify the width of every column in the list. Indeed, using
     # widths and layouts of sub-fields may not be sufficient.
     if not widths:
         self.widths = [''] * len(self.fields)
     else:
         self.widths = widths
Exemplo n.º 18
0
 def __init__(self,
              validator=None,
              multiplicity=(0, 1),
              default=None,
              format=WITH_HOUR,
              calendar=True,
              startYear=time.localtime()[0] - 10,
              endYear=time.localtime()[0] + 10,
              reverseYears=False,
              show=True,
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              sdefault=None,
              scolspan=1,
              swidth=None,
              sheight=None,
              persist=True):
     self.format = format
     self.calendar = calendar
     self.startYear = startYear
     self.endYear = endYear
     # If reverseYears is True, in the selection box, available years, from
     # self.startYear to self.endYear will be listed in reverse order.
     self.reverseYears = reverseYears
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, persist)
Exemplo n.º 19
0
 def __init__(self, validator=None, multiplicity=(0,1), default=None,
              show=True, page='main', group=None, layouts = None, move=0,
              indexed=False, searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=None, height=None,
              maxChars=None, colspan=1, master=None, masterValue=None,
              focus=False, historized=False, mapping=None, label=None,
              sdefault=False, scolspan=1, swidth=None, sheight=None,
              persist=True, render='checkbox'):
     # By default, a boolean is edited via a checkbox. It can also be edited
     # via 2 radio buttons (p_render="radios").
     self.render = render
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, persist)
     self.pythonType = bool
Exemplo n.º 20
0
 def __init__(self,
              fields,
              validator=None,
              multiplicity=(0, 1),
              default=None,
              show=True,
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              subLayouts=Table('fv', width=None)):
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, False,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, True, mapping, label, None, None, None,
                    None)
     self.validable = True
     # Tuples of (names, Field instances) determining the format of every
     # element in the list.
     self.fields = fields
     self.fieldsd = [(n, f.__dict__) for (n, f) in self.fields]
     # Force some layouting for sub-fields, if subLayouts are given. So the
     # one who wants freedom on tuning layouts at the field level must
     # specify subLayouts=None.
     if subLayouts:
         for name, field in self.fields:
             field.layouts = field.formatLayouts(subLayouts)
Exemplo n.º 21
0
 def __init__(self,
              validator=None,
              multiplicity=(0, 1),
              default=None,
              show=True,
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              sdefault=False,
              scolspan=1,
              swidth=None,
              sheight=None,
              persist=True,
              render='checkbox'):
     # By default, a boolean is edited via a checkbox. It can also be edited
     # via 2 radio buttons (p_render="radios").
     self.render = render
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, persist)
     self.pythonType = bool
Exemplo n.º 22
0
 def __init__(self, validator=None, multiplicity=(0,1), default=None,
              format=WITH_HOUR, calendar=True,
              startYear=time.localtime()[0]-10,
              endYear=time.localtime()[0]+10, reverseYears=False,
              show=True, page='main', group=None, layouts=None, move=0,
              indexed=False, searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=None, height=None,
              maxChars=None, colspan=1, master=None, masterValue=None,
              focus=False, historized=False, mapping=None, label=None,
              sdefault=None, scolspan=1, swidth=None, sheight=None):
     self.format = format
     self.calendar = calendar
     self.startYear = startYear
     self.endYear = endYear
     # If reverseYears is True, in the selection box, available years, from
     # self.startYear to self.endYear will be listed in reverse order.
     self.reverseYears = reverseYears
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, True, mapping, label, sdefault, scolspan,
                    swidth, sheight)
Exemplo n.º 23
0
 def __init__(self, fields, validator=None, multiplicity=(0,1), default=None,
              show=True, page='main', group=None, layouts=None, move=0,
              indexed=False, searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=None, height=None,
              maxChars=None, colspan=1, master=None, masterValue=None,
              focus=False, historized=False, mapping=None, label=None,
              subLayouts=Table('fv', width=None)):
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, False,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, True, mapping, label, None, None, None, None)
     self.validable = True
     # Tuples of (names, Field instances) determining the format of every
     # element in the list.
     self.fields = fields
     self.fieldsd = [(n, f.__dict__) for (n,f) in self.fields]
     # Force some layouting for sub-fields, if subLayouts are given. So the
     # one who wants freedom on tuning layouts at the field level must
     # specify subLayouts=None.
     if subLayouts:
         for name, field in self.fields:
             field.layouts = field.formatLayouts(subLayouts)
Exemplo n.º 24
0
 def __init__(self,
              validator=None,
              multiplicity=(0, 1),
              default=None,
              format=LINE,
              show=True,
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              sdefault='',
              scolspan=1,
              swidth=None,
              sheight=None,
              persist=True,
              transform='none',
              placeholder=None,
              styles=('p', 'h1', 'h2', 'h3', 'h4'),
              allowImageUpload=True,
              spellcheck=False,
              contentLanguage=None,
              inlineEdit=False):
     # According to format, the widget will be different: input field,
     # textarea, inline editor... Note that there can be only one String
     # field of format CAPTCHA by page, because the captcha challenge is
     # stored in the session at some global key.
     self.format = format
     self.isUrl = validator == String.URL
     # When format is XHTML, the list of styles that the user will be able to
     # select in the styles dropdown is defined hereafter.
     self.styles = styles
     # When format is XHTML, do we allow the user to upload images in it ?
     self.allowImageUpload = allowImageUpload
     # When format is XHTML, do we run the CK spellchecker ?
     self.spellcheck = spellcheck
     # What is the language of field content?
     self.contentLanguage = contentLanguage
     # When format in XHTML, can the field be inline-edited (ckeditor)?
     self.inlineEdit = inlineEdit
     # The following field has a direct impact on the text entered by the
     # user. It applies a transformation on it, exactly as does the CSS
     # "text-transform" property. Allowed values are those allowed for the
     # CSS property: "none" (default), "uppercase", "capitalize" or
     # "lowercase".
     self.transform = transform
     # "placeholder", similar to the HTML attribute of the same name, allows
     # to specify a short hint that describes the expected value of the input
     # field. It is shown inside the input field and disappears as soon as
     # the user encodes something in it. Works only for strings whose format
     # is LINE. Does not work with IE < 10. You can specify a method here,
     # that can, for example, return an internationalized value.
     self.placeholder = placeholder
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, maxChars, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, persist)
     self.isSelect = self.isSelection()
     # If self.isSelect, self.sdefault must be a list of value(s).
     if self.isSelect and not sdefault:
         self.sdefault = []
     # Default width, height and maxChars vary according to String format
     if width == None:
         if format == String.TEXT: self.width = 60
         # This width corresponds to the standard width of an Appy page.
         if format == String.XHTML: self.width = None
         else: self.width = 30
     if height == None:
         if format == String.TEXT: self.height = 5
         elif self.isSelect: self.height = 4
         else: self.height = 1
     if maxChars == None:
         if self.isSelect: pass
         elif format == String.LINE: self.maxChars = 256
         elif format == String.TEXT: self.maxChars = 9999
         elif format == String.XHTML: self.maxChars = 99999
         elif format == String.PASSWORD: self.maxChars = 20
     self.filterable = self.indexed and (self.format == String.LINE) and \
                       not self.isSelect
     self.swidth = self.swidth or self.width
     self.sheight = self.sheight or self.height
Exemplo n.º 25
0
 def __init__(self, validator=None, default=None, show=('view', 'result'),
              page='main', group=None, layouts=None, move=0, indexed=False,
              searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=None, height=None,
              maxChars=None, colspan=1, master=None, masterValue=None,
              focus=False, historized=False, mapping=None, label=None,
              template=None, templateName=None, showTemplate=None,
              freezeTemplate=None, context=None, stylesMapping={},
              formats=None):
     # Param "template" stores the path to the pod template(s).
     if not template: raise Exception(Pod.NO_TEMPLATE)
     if isinstance(template, basestring):
         self.template = [template]
     else:
         self.template = template
     # Param "templateName", if specified, is a method that will be called
     # with the current template (from self.template) as single arg and must
     # return the name of this template. If self.template stores a single
     # template, you have no need to use param "templateName". Simply use the
     # field label to name the template. But if you have a multi-pod field
     # (with several templates specified as a list or tuple in param
     # "template"), you will probably choose to hide the field label and use
     # param "templateName" to give a specific name to every template. If
     # "template" contains several templates and "templateName" is None, Appy
     # will produce names from template filenames.
     self.templateName = templateName
     # "showTemplate" determines if the current user may generate documents
     # based on this pod field. More precisely, "showTemplate", if specified,
     # must be a method that will be called with the current template as
     # single arg (one among self.template) and that must return the list or
     # tuple of formats that the current user may use as output formats for
     # generating a document. If the current user is not allowed at all to
     # generate documents based on the current template, "showTemplate" must
     # return an empty tuple/list. If "showTemplate" is not specified, the
     # user will be able to generate documents based on the current template,
     # in any format from self.formats (see below).
     # "showTemplate" comes in addition to self.show. self.show dictates the
     # visibility of the whole field (ie, all templates from self.template)
     # while "showTemplate" dictates the visiblity of a specific template
     # within self.template.
     self.showTemplate = showTemplate
     # "freezeTemplate" determines if the current user may freeze documents
     # normally generated dynamically from this pod field. More precisely,
     # "freezeTemplate", if specified, must be a method that will be called
     # with the current template as single arg and must return the (possibly
     # empty) list or tuple of formats the current user may freeze. The
     # "freezing-related actions" that are granted by "freezeTemplate" are
     # the following. When no document is frozen yet for a given
     # template/format, the user may:
     # - freeze the document: pod will be called to produce a document from
     #   the current database content and will store it in the database.
     #   Subsequent user requests for this pod field will return the frozen
     #   doc instead of generating on-the-fly documents;
     # - upload a document: the user will be able to upload a document that
     #   will be stored in the database. Subsequent user requests for this
     #   pod field will return this doc instead of generating on-the-fly
     #   documents.
     # When a document is already frozen or uploaded for a given
     # template/format, the user may:
     # - unfreeze the document: the frozen or uploaded document will be
     #   deleted from the database and subsequent user requests for the pod
     #   field will again generate on-the-fly documents;
     # - re-freeze the document: the frozen or uploaded document will be
     #   deleted, a new document will be generated from the current database
     #   content and will be frozen as a replacement to the deleted one;
     # - upload a document: the frozen or uploaded document will be replaced
     #   by a new document uploaded by the current user.
     self.freezeTemplate = freezeTemplate
     # The context is a dict containing a specific pod context, or a method
     # that returns such a dict.
     self.context = context
     # A global styles mapping that would apply to the whole template
     self.stylesMapping = stylesMapping
     # What are the output formats when generating documents from this pod ?
     self.formats = formats
     if not formats:
         # Compute default ones
         if self.template[0].endswith('.ods'):
             self.formats = ('xls', 'ods')
         else:
             self.formats = ('pdf', 'doc', 'odt')
     Field.__init__(self, None, (0,1), default, show, page, group, layouts,
                    move, indexed, searchable, specificReadPermission,
                    specificWritePermission, width, height, None, colspan,
                    master, masterValue, focus, historized, mapping, label,
                    None, None, None, None, True)
     # Param "persist" is set to True but actually, persistence for a pod
     # field is determined by freezing.
     self.validable = False
Exemplo n.º 26
0
 def __init__(self, validator=None, default=None, show=('view', 'result'),
              page='main', group=None, layouts=None, move=0,
              specificReadPermission=False, specificWritePermission=False,
              width=None, height=None, maxChars=None, colspan=1, master=None,
              masterValue=None, focus=False, historized=False, mapping=None,
              label=None, template=None, templateName=None,
              useTemplateName=None, showTemplate=None, freezeTemplate=None,
              maxPerRow=5, context=None, stylesMapping={}, formats=None,
              getChecked=None, mailing=None, mailingName=None,
              showMailing=None, mailingInfo=None, view=None, xml=None,
              downloadName=None, downloadDisposition='attachment',
              forceOoCall=False, confirm=False):
     # Param "template" stores the path to the pod template(s). If there is
     # a single template, a string is expected. Else, a list or tuple of
     # strings is expected. Every such path must be relative to your
     # application. A pod template name Test.odt that is stored at the root
     # of your app will be referred as "Test.odt" in self.template. If it is
     # stored within sub-folder "pod", it will be referred as "pod/Test.odt".
     if not template: raise Exception(NO_TEMPLATE)
     if isinstance(template, basestring):
         self.template = [template]
     elif isinstance(template, tuple):
         self.template = list(template)
     else:
         self.template = template
     # Param "templateName", if specified, is a method that will be called
     # with the current template (from self.template) as single arg and must
     # return the name of this template. If self.template stores a single
     # template, you have no need to use param "templateName". Simply use the
     # field label to name the template. But if you have a multi-pod field
     # (with several templates specified as a list or tuple in param
     # "template"), you will probably choose to hide the field label and use
     # param "templateName" to give a specific name to every template. If
     # "template" contains several templates and "templateName" is None, Appy
     # will produce names from template filenames.
     self.templateName = templateName
     # If you want to use "templateName" hereabove even if self.template
     # contains a single template, set "usetTemplateName" to True.
     if useTemplateName == None:
         self.useTemplateName = len(self.template) > 1
     else:
         self.useTemplateName = useTemplateName
     # "showTemplate" determines if the current user may generate documents
     # based on this pod field. More precisely, "showTemplate", if specified,
     # must be a method that will be called with the current template as
     # single arg (one among self.template) and that must return the list or
     # tuple of formats that the current user may use as output formats for
     # generating a document. If the current user is not allowed at all to
     # generate documents based on the current template, "showTemplate" must
     # return an empty tuple/list. If "showTemplate" is not specified, the
     # user will be able to generate documents based on the current template,
     # in any format from self.formats (see below).
     # "showTemplate" comes in addition to self.show. self.show dictates the
     # visibility of the whole field (ie, all templates from self.template)
     # while "showTemplate" dictates the visiblity of a specific template
     # within self.template.
     self.showTemplate = showTemplate
     # "freezeTemplate" determines if the current user may freeze documents
     # normally generated dynamically from this pod field. More precisely,
     # "freezeTemplate", if specified, must be a method that will be called
     # with the current template as single arg and must return the (possibly
     # empty) list or tuple of formats the current user may freeze. The
     # "freezing-related actions" that are granted by "freezeTemplate" are
     # the following. When no document is frozen yet for a given
     # template/format, the user may:
     # - freeze the document: pod will be called to produce a document from
     #   the current database content and will store it in the database.
     #   Subsequent user requests for this pod field will return the frozen
     #   doc instead of generating on-the-fly documents;
     # - upload a document: the user will be able to upload a document that
     #   will be stored in the database. Subsequent user requests for this
     #   pod field will return this doc instead of generating on-the-fly
     #   documents.
     # When a document is already frozen or uploaded for a given
     # template/format, the user may:
     # - unfreeze the document: the frozen or uploaded document will be
     #   deleted from the database and subsequent user requests for the pod
     #   field will again generate on-the-fly documents;
     # - re-freeze the document: the frozen or uploaded document will be
     #   deleted, a new document will be generated from the current database
     #   content and will be frozen as a replacement to the deleted one;
     # - upload a document: the frozen or uploaded document will be replaced
     #   by a new document uploaded by the current user.
     self.freezeTemplate = freezeTemplate
     # If p_template contains more than 1 template, "maxPerRow" tells how
     # much templates must appear side by side.
     self.maxPerRow = maxPerRow
     # The context is a dict containing a specific pod context, or a method
     # that returns such a dict.
     self.context = context
     # A global styles mapping that would apply to the whole template
     self.stylesMapping = stylesMapping
     # What are the output formats when generating documents from this pod ?
     self.formats = formats
     if not formats: # Compute default ones
         self.formats = self.getAllFormats(self.template[0])
     # Parameter "getChecked" can specify the name of a Ref field belonging
     # to the same gen class. If it is the case, the context of the pod
     # template will contain an additional object, name "_checked", and
     # "_checked.<name of the Ref field>" will contain the list of the
     # objects linked via the Ref field that are currently selected in the
     # user interface.
     self.getChecked = getChecked
     # Mailing lists can be defined for this pod field. For every visible
     # mailing list, a menu item will be available in the user interface and
     # will allow to send the pod result as attachment to the mailing list
     # recipients. Attribute p_mailing stores a mailing list's id
     # (as a string) or a list of ids.
     self.mailing = mailing
     if isinstance(mailing, basestring):
         self.mailing = [mailing]
     elif isinstance(mailing, tuple):
         self.mailing = list(mailing)
     # "mailingName" returns the name of the mailing as will be shown in the
     # user interface. It must be a method accepting the mailing list id
     # (from self.mailing) as single arg and returning the mailing list's
     # name.
     self.mailingName = mailingName
     # "showMailing" below determines when the mailing list(s) must be shown.
     # It may store a method accepting a mailing list's id (among
     # self.mailing) and a template (among self.template) and returning the
     # list or tuple of formats for which the pod result can be sent to the
     # mailing list. If no such method is defined, the mailing list will be
     # available for all visible templates and formats.
     self.showMailing = showMailing
     # When it it time to send an email, "mailingInfo" gives all the
     # necessary information for this email: recipients, subject, body. It
     # must be a method whose single arg is the mailing id (from
     # self.mailing) and that returns an instance of class Mailing (above).
     self.mailingInfo = mailingInfo
     # "downloadName", if specified, is a method that will be called with
     # the current template (from self.template) as single arg and must
     # return the name of the file as the user will get it once he will
     # download the pod result from its browser. This is for people that do
     # not like the default download name. Do not specify any extension: it
     # will be appended automatically. For example, if your method returns
     # "PodResultForSomeObject", and the pod result is a pdf file, the file
     # will be named "PodResultForSomeObject.pdf". If you specify such a
     # method, you have the responsibility to produce a valid,
     # any-OS-and-any-browser-proof file name. For inspiration, see the
     # default m_getDownloadName method hereafter. If you have several
     # templates in self.template, for some of them where you are satisfied
     # with the default download name, return None.
     self.downloadName = downloadName
     # The field below allow to determine the "disposition" when downloading
     # a pod result. "attachment" by default, it can be set to "inline". But
     # with disposition=inline, Google Chrome and IE may launch a PDF viewer
     # that triggers one or many additional crashing HTTP GET requests.
     self.downloadDisposition = downloadDisposition
     # Normally, when you generate a pod result that is in ODT/ODS format,
     # LibreOffice is not called. But if you want it to be called
     # nevertheless, for example to ensure that all the indexes are
     # up-to-date (including the table of contents), set "forceOoCall" to
     # True. When generating pod results in other formats (pdf, doc, xls...),
     # LibreOffice is always called and indexes are always refreshed.
     self.forceOoCall = forceOoCall
     # If "confirm" is True, a popup will be shown before generating the
     # pod result.
     self.confirm = confirm
     Field.__init__(self, None, (0,1), default, show, page, group, layouts,
                    move, False, True, False, specificReadPermission,
                    specificWritePermission, width, height, None, colspan,
                    master, masterValue, focus, historized, mapping, label,
                    None, None, None, None, False, False, view, xml)
     # Param "persist" is False, but actual persistence for this field is
     # determined by freezing.
     self.validable = False
Exemplo n.º 27
0
 def __init__(self, validator=None, default=None, show=('view', 'result'),
              page='main', group=None, layouts=None, move=0, indexed=False,
              searchable=False, specificReadPermission=False,
              specificWritePermission=False, width=None, height=None,
              maxChars=None, colspan=1, master=None, masterValue=None,
              focus=False, historized=False, mapping=None, label=None,
              template=None, templateName=None, showTemplate=None,
              freezeTemplate=None, maxPerRow=5, context=None,
              stylesMapping={}, formats=None, getChecked=None, mailing=None,
              mailingName=None, showMailing=None, mailingInfo=None):
     # Param "template" stores the path to the pod template(s). If there is
     # a single template, a string is expected. Else, a list or tuple of
     # strings is expected. Every such path must be relative to your
     # application. A pod template name Test.odt that is stored at the root
     # of your app will be referred as "Test.odt" in self.template. If it is
     # stored within sub-folder "pod", it will be referred as "pod/Test.odt".
     if not template: raise Exception(Pod.NO_TEMPLATE)
     if isinstance(template, basestring):
         self.template = [template]
     elif isinstance(template, tuple):
         self.template = list(template)
     else:
         self.template = template
     # Param "templateName", if specified, is a method that will be called
     # with the current template (from self.template) as single arg and must
     # return the name of this template. If self.template stores a single
     # template, you have no need to use param "templateName". Simply use the
     # field label to name the template. But if you have a multi-pod field
     # (with several templates specified as a list or tuple in param
     # "template"), you will probably choose to hide the field label and use
     # param "templateName" to give a specific name to every template. If
     # "template" contains several templates and "templateName" is None, Appy
     # will produce names from template filenames.
     self.templateName = templateName
     # "showTemplate" determines if the current user may generate documents
     # based on this pod field. More precisely, "showTemplate", if specified,
     # must be a method that will be called with the current template as
     # single arg (one among self.template) and that must return the list or
     # tuple of formats that the current user may use as output formats for
     # generating a document. If the current user is not allowed at all to
     # generate documents based on the current template, "showTemplate" must
     # return an empty tuple/list. If "showTemplate" is not specified, the
     # user will be able to generate documents based on the current template,
     # in any format from self.formats (see below).
     # "showTemplate" comes in addition to self.show. self.show dictates the
     # visibility of the whole field (ie, all templates from self.template)
     # while "showTemplate" dictates the visiblity of a specific template
     # within self.template.
     self.showTemplate = showTemplate
     # "freezeTemplate" determines if the current user may freeze documents
     # normally generated dynamically from this pod field. More precisely,
     # "freezeTemplate", if specified, must be a method that will be called
     # with the current template as single arg and must return the (possibly
     # empty) list or tuple of formats the current user may freeze. The
     # "freezing-related actions" that are granted by "freezeTemplate" are
     # the following. When no document is frozen yet for a given
     # template/format, the user may:
     # - freeze the document: pod will be called to produce a document from
     #   the current database content and will store it in the database.
     #   Subsequent user requests for this pod field will return the frozen
     #   doc instead of generating on-the-fly documents;
     # - upload a document: the user will be able to upload a document that
     #   will be stored in the database. Subsequent user requests for this
     #   pod field will return this doc instead of generating on-the-fly
     #   documents.
     # When a document is already frozen or uploaded for a given
     # template/format, the user may:
     # - unfreeze the document: the frozen or uploaded document will be
     #   deleted from the database and subsequent user requests for the pod
     #   field will again generate on-the-fly documents;
     # - re-freeze the document: the frozen or uploaded document will be
     #   deleted, a new document will be generated from the current database
     #   content and will be frozen as a replacement to the deleted one;
     # - upload a document: the frozen or uploaded document will be replaced
     #   by a new document uploaded by the current user.
     self.freezeTemplate = freezeTemplate
     # If p_template contains more than 1 template, "maxPerRow" tells how
     # much templates must appear side by side.
     self.maxPerRow = maxPerRow
     # The context is a dict containing a specific pod context, or a method
     # that returns such a dict.
     self.context = context
     # A global styles mapping that would apply to the whole template
     self.stylesMapping = stylesMapping
     # What are the output formats when generating documents from this pod ?
     self.formats = formats
     if not formats: # Compute default ones
         self.formats = self.getAllFormats(self.template[0])
     # Parameter "getChecked" can specify the name of a Ref field belonging
     # to the same gen class. If it is the case, the context of the pod
     # template will contain an additional object, name "_checked", and
     # "_checked.<name of the Ref field>" will contain the list of the
     # objects linked via the Ref field that are currently selected in the
     # user interface.
     self.getChecked = getChecked
     # Mailing lists can be defined for this pod field. For every visible
     # mailing list, a menu item will be available in the user interface and
     # will allow to send the pod result as attachment to the mailing list
     # recipients. Attribute p_mailing stores a mailing list's id
     # (as a string) or a list of ids.
     self.mailing = mailing
     if isinstance(mailing, basestring):
         self.mailing = [mailing]
     elif isinstance(mailing, tuple):
         self.mailing = list(mailing)
     # "mailingName" returns the name of the mailing as will be shown in the
     # user interface. It must be a method accepting the mailing list id
     # (from self.mailing) as single arg and returning the mailing list's
     # name.
     self.mailingName = mailingName
     # "showMailing" below determines when the mailing list(s) must be shown.
     # It may store a method accepting a mailing list's id (among
     # self.mailing) and a template (among self.template) and returning the
     # list or tuple of formats for which the pod result can be sent to the
     # mailing list. If no such method is defined, the mailing list will be
     # available for all visible templates and formats.
     self.showMailing = showMailing
     # When it it time to send an email, "mailingInfo" gives all the
     # necessary information for this email: recipients, subject, body. It
     # must be a method whose single arg is the mailing id (from
     # self.mailing) and that returns an instance of class Mailing (above).
     self.mailingInfo = mailingInfo
     Field.__init__(self, None, (0,1), default, show, page, group, layouts,
                    move, indexed, searchable, specificReadPermission,
                    specificWritePermission, width, height, None, colspan,
                    master, masterValue, focus, historized, mapping, label,
                    None, None, None, None, True)
     # Param "persist" is set to True but actually, persistence for a pod
     # field is determined by freezing.
     self.validable = False
Exemplo n.º 28
0
 def __init__(self,
              klass=None,
              attribute=None,
              validator=None,
              multiplicity=(0, 1),
              default=None,
              add=False,
              addConfirm=False,
              delete=None,
              noForm=False,
              link=True,
              unlink=None,
              back=None,
              show=True,
              page='main',
              group=None,
              layouts=None,
              showHeaders=False,
              shownInfo=(),
              select=None,
              maxPerPage=30,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=5,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              queryable=False,
              queryFields=None,
              queryNbCols=1,
              navigable=False,
              searchSelect=None,
              changeOrder=True,
              sdefault='',
              scolspan=1,
              swidth=None,
              sheight=None):
     self.klass = klass
     self.attribute = attribute
     # May the user add new objects through this ref ?
     self.add = add
     # When the user adds a new object, must a confirmation popup be shown?
     self.addConfirm = addConfirm
     # May the user delete objects via this Ref?
     self.delete = delete
     if delete == None:
         # By default, one may delete objects via a Ref for which one can
         # add objects.
         self.delete = bool(self.add)
     # If noForm is True, when clicking to create an object through this ref,
     # the object will be created automatically, and no creation form will
     # be presented to the user.
     self.noForm = noForm
     # May the user link existing objects through this ref?
     self.link = link
     # May the user unlink existing objects?
     self.unlink = unlink
     if unlink == None:
         # By default, one may unlink objects via a Ref for which one can
         # link objects.
         self.unlink = bool(self.link)
     self.back = None
     if back:
         # It is a forward reference
         self.isBack = False
         # Initialise the backward reference
         self.back = back
         self.backd = back.__dict__
         back.isBack = True
         back.back = self
         back.backd = self.__dict__
         # klass may be None in the case we are defining an auto-Ref to the
         # same class as the class where this field is defined. In this case,
         # when defining the field within the class, write
         # myField = Ref(None, ...)
         # and, at the end of the class definition (name it K), write:
         # K.myField.klass = K
         # setattr(K, K.myField.back.attribute, K.myField.back)
         if klass: setattr(klass, back.attribute, back)
     # When displaying a tabular list of referenced objects, must we show
     # the table headers?
     self.showHeaders = showHeaders
     # When displaying referenced object(s), we will display its title + all
     # other fields whose names are listed in the following attribute.
     self.shownInfo = list(shownInfo)
     if not self.shownInfo: self.shownInfo.append('title')
     # If a method is defined in this field "select", it will be used to
     # filter the list of available tied objects.
     self.select = select
     # Maximum number of referenced objects shown at once.
     self.maxPerPage = maxPerPage
     # Specifies sync
     sync = {'view': False, 'edit': True}
     # If param p_queryable is True, the user will be able to perform queries
     # from the UI within referenced objects.
     self.queryable = queryable
     # Here is the list of fields that will appear on the search screen.
     # If None is specified, by default we take every indexed field
     # defined on referenced objects' class.
     self.queryFields = queryFields
     # The search screen will have this number of columns
     self.queryNbCols = queryNbCols
     # Within the portlet, will referred elements appear ?
     self.navigable = navigable
     # The search select method is used if self.indexed is True. In this
     # case, we need to know among which values we can search on this field,
     # in the search screen. Those values are returned by self.searchSelect,
     # which must be a static method accepting the tool as single arg.
     self.searchSelect = searchSelect
     # If changeOrder is False, it even if the user has the right to modify
     # the field, it will not be possible to move objects or sort them.
     self.changeOrder = changeOrder
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, False,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, sync, mapping, label, sdefault, scolspan,
                    swidth, sheight)
     self.validable = self.link
Exemplo n.º 29
0
 def __init__(
     self,
     validator=None,
     default=None,
     show=("view", "result"),
     page="main",
     group=None,
     layouts=None,
     move=0,
     indexed=False,
     searchable=False,
     specificReadPermission=False,
     specificWritePermission=False,
     width=None,
     height=None,
     maxChars=None,
     colspan=1,
     master=None,
     masterValue=None,
     focus=False,
     historized=False,
     mapping=None,
     label=None,
     template=None,
     templateName=None,
     showTemplate=None,
     freezeTemplate=None,
     context=None,
     stylesMapping={},
     formats=None,
 ):
     # Param "template" stores the path to the pod template(s).
     if not template:
         raise Exception(Pod.NO_TEMPLATE)
     if isinstance(template, basestring):
         self.template = [template]
     else:
         self.template = template
     # Param "templateName", if specified, is a method that will be called
     # with the current template (from self.template) as single arg and must
     # return the name of this template. If self.template stores a single
     # template, you have no need to use param "templateName". Simply use the
     # field label to name the template. But if you have a multi-pod field
     # (with several templates specified as a list or tuple in param
     # "template"), you will probably choose to hide the field label and use
     # param "templateName" to give a specific name to every template. If
     # "template" contains several templates and "templateName" is None, Appy
     # will produce names from template filenames.
     self.templateName = templateName
     # "showTemplate" determines if the current user may generate documents
     # based on this pod field. More precisely, "showTemplate", if specified,
     # must be a method that will be called with the current template as
     # single arg (one among self.template) and that must return the list or
     # tuple of formats that the current user may use as output formats for
     # generating a document. If the current user is not allowed at all to
     # generate documents based on the current template, "showTemplate" must
     # return an empty tuple/list. If "showTemplate" is not specified, the
     # user will be able to generate documents based on the current template,
     # in any format from self.formats (see below).
     # "showTemplate" comes in addition to self.show. self.show dictates the
     # visibility of the whole field (ie, all templates from self.template)
     # while "showTemplate" dictates the visiblity of a specific template
     # within self.template.
     self.showTemplate = showTemplate
     # "freezeTemplate" determines if the current user may freeze documents
     # normally generated dynamically from this pod field. More precisely,
     # "freezeTemplate", if specified, must be a method that will be called
     # with the current template as single arg and must return the (possibly
     # empty) list or tuple of formats the current user may freeze. The
     # "freezing-related actions" that are granted by "freezeTemplate" are
     # the following. When no document is frozen yet for a given
     # template/format, the user may:
     # - freeze the document: pod will be called to produce a document from
     #   the current database content and will store it in the database.
     #   Subsequent user requests for this pod field will return the frozen
     #   doc instead of generating on-the-fly documents;
     # - upload a document: the user will be able to upload a document that
     #   will be stored in the database. Subsequent user requests for this
     #   pod field will return this doc instead of generating on-the-fly
     #   documents.
     # When a document is already frozen or uploaded for a given
     # template/format, the user may:
     # - unfreeze the document: the frozen or uploaded document will be
     #   deleted from the database and subsequent user requests for the pod
     #   field will again generate on-the-fly documents;
     # - re-freeze the document: the frozen or uploaded document will be
     #   deleted, a new document will be generated from the current database
     #   content and will be frozen as a replacement to the deleted one;
     # - upload a document: the frozen or uploaded document will be replaced
     #   by a new document uploaded by the current user.
     self.freezeTemplate = freezeTemplate
     # The context is a dict containing a specific pod context, or a method
     # that returns such a dict.
     self.context = context
     # A global styles mapping that would apply to the whole template
     self.stylesMapping = stylesMapping
     # What are the output formats when generating documents from this pod ?
     self.formats = formats
     if not formats:
         # Compute default ones
         if self.template[0].endswith(".ods"):
             self.formats = ("xls", "ods")
         else:
             self.formats = ("pdf", "doc", "odt")
     Field.__init__(
         self,
         None,
         (0, 1),
         default,
         show,
         page,
         group,
         layouts,
         move,
         indexed,
         searchable,
         specificReadPermission,
         specificWritePermission,
         width,
         height,
         None,
         colspan,
         master,
         masterValue,
         focus,
         historized,
         mapping,
         label,
         None,
         None,
         None,
         None,
         True,
     )
     # Param "persist" is set to True but actually, persistence for a pod
     # field is determined by freezing.
     self.validable = False
Exemplo n.º 30
0
 def __init__(self, validator=None, multiplicity=(0,1), default=None,
              format=LINE, show=True, page='main', group=None, layouts=None,
              move=0, indexed=False, searchable=False,
              specificReadPermission=False, specificWritePermission=False,
              width=None, height=None, maxChars=None, colspan=1, master=None,
              masterValue=None, focus=False, historized=False, mapping=None,
              label=None, sdefault='', scolspan=1, swidth=None, sheight=None,
              persist=True, transform='none', placeholder=None,
              styles=('p','h1','h2','h3','h4'), allowImageUpload=True,
              spellcheck=False, languages=('en',), languagesLayouts=None,
              inlineEdit=False):
     # According to format, the widget will be different: input field,
     # textarea, inline editor... Note that there can be only one String
     # field of format CAPTCHA by page, because the captcha challenge is
     # stored in the session at some global key.
     self.format = format
     self.isUrl = validator == String.URL
     # When format is XHTML, the list of styles that the user will be able to
     # select in the styles dropdown is defined hereafter.
     self.styles = styles
     # When format is XHTML, do we allow the user to upload images in it ?
     self.allowImageUpload = allowImageUpload
     # When format is XHTML, do we run the CK spellchecker ?
     self.spellcheck = spellcheck
     # If "languages" holds more than one language, the field will be
     # multi-lingual and several widgets will allow to edit/visualize the
     # field content in all the supported languages. The field is also used
     # by the CK spell checker.
     self.languages = languages
     # When content exists in several languages, how to render them? Either
     # horizontally (one below the other), or vertically (one besides the
     # other). Specify here a dict whose keys are layouts ("edit", "view")
     # and whose values are either "horizontal" or "vertical".
     self.languagesLayouts = languagesLayouts
     # When format in XHTML, can the field be inline-edited (ckeditor)?
     self.inlineEdit = inlineEdit
     # The following field has a direct impact on the text entered by the
     # user. It applies a transformation on it, exactly as does the CSS
     # "text-transform" property. Allowed values are those allowed for the
     # CSS property: "none" (default), "uppercase", "capitalize" or
     # "lowercase".
     self.transform = transform
     # "placeholder", similar to the HTML attribute of the same name, allows
     # to specify a short hint that describes the expected value of the input
     # field. It is shown inside the input field and disappears as soon as
     # the user encodes something in it. Works only for strings whose format
     # is LINE. Does not work with IE < 10. You can specify a method here,
     # that can, for example, return an internationalized value.
     self.placeholder = placeholder
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, searchable,
                    specificReadPermission, specificWritePermission, width,
                    height, maxChars, colspan, master, masterValue, focus,
                    historized, mapping, label, sdefault, scolspan, swidth,
                    sheight, persist)
     self.isSelect = self.isSelection()
     # If self.isSelect, self.sdefault must be a list of value(s).
     if self.isSelect and not sdefault:
         self.sdefault = []
     # Default width, height and maxChars vary according to String format
     if width == None:
         if format == String.TEXT:  self.width  = 60
         # This width corresponds to the standard width of an Appy page.
         if format == String.XHTML: self.width  = None
         else:                      self.width  = 30
     if height == None:
         if format == String.TEXT: self.height = 5
         elif self.isSelect:       self.height = 4
         else:                     self.height = 1
     if maxChars == None:
         if self.isSelect: pass
         elif format == String.LINE: self.maxChars = 256
         elif format == String.TEXT: self.maxChars = 9999
         elif format == String.XHTML: self.maxChars = 99999
         elif format == String.PASSWORD: self.maxChars = 20
     self.filterable = self.indexed and (self.format == String.LINE) and \
                       not self.isSelect
     self.swidth = self.swidth or self.width
     self.sheight = self.sheight or self.height
     self.checkParameters()
Exemplo n.º 31
0
 def __init__(self, klass=None, attribute=None, validator=None,
              multiplicity=(0,1), default=None, add=False, addConfirm=False,
              delete=None, noForm=False, link=True, unlink=None, back=None,
              show=True, page='main', group=None, layouts=None,
              showHeaders=False, shownInfo=(), select=None, maxPerPage=30,
              move=0, indexed=False, searchable=False,
              specificReadPermission=False, specificWritePermission=False,
              width=None, height=5, maxChars=None, colspan=1, master=None,
              masterValue=None, focus=False, historized=False, mapping=None,
              label=None, queryable=False, queryFields=None, queryNbCols=1,
              navigable=False, searchSelect=None, changeOrder=True,
              sdefault='', scolspan=1, swidth=None, sheight=None):
     self.klass = klass
     self.attribute = attribute
     # May the user add new objects through this ref ?
     self.add = add
     # When the user adds a new object, must a confirmation popup be shown?
     self.addConfirm = addConfirm
     # May the user delete objects via this Ref?
     self.delete = delete
     if delete == None:
         # By default, one may delete objects via a Ref for which one can
         # add objects.
         self.delete = bool(self.add)
     # If noForm is True, when clicking to create an object through this ref,
     # the object will be created automatically, and no creation form will
     # be presented to the user.
     self.noForm = noForm
     # May the user link existing objects through this ref?
     self.link = link
     # May the user unlink existing objects?
     self.unlink = unlink
     if unlink == None:
         # By default, one may unlink objects via a Ref for which one can
         # link objects.
         self.unlink = bool(self.link)
     self.back = None
     if back:
         # It is a forward reference
         self.isBack = False
         # Initialise the backward reference
         self.back = back
         self.backd = back.__dict__
         back.isBack = True
         back.back = self
         back.backd = self.__dict__
         # klass may be None in the case we are defining an auto-Ref to the
         # same class as the class where this field is defined. In this case,
         # when defining the field within the class, write
         # myField = Ref(None, ...)
         # and, at the end of the class definition (name it K), write:
         # K.myField.klass = K
         # setattr(K, K.myField.back.attribute, K.myField.back)
         if klass: setattr(klass, back.attribute, back)
     # When displaying a tabular list of referenced objects, must we show
     # the table headers?
     self.showHeaders = showHeaders
     # When displaying referenced object(s), we will display its title + all
     # other fields whose names are listed in the following attribute.
     self.shownInfo = list(shownInfo)
     if not self.shownInfo: self.shownInfo.append('title')
     # If a method is defined in this field "select", it will be used to
     # filter the list of available tied objects.
     self.select = select
     # Maximum number of referenced objects shown at once.
     self.maxPerPage = maxPerPage
     # Specifies sync
     sync = {'view': False, 'edit':True}
     # If param p_queryable is True, the user will be able to perform queries
     # from the UI within referenced objects.
     self.queryable = queryable
     # Here is the list of fields that will appear on the search screen.
     # If None is specified, by default we take every indexed field
     # defined on referenced objects' class.
     self.queryFields = queryFields
     # The search screen will have this number of columns
     self.queryNbCols = queryNbCols
     # Within the portlet, will referred elements appear ?
     self.navigable = navigable
     # The search select method is used if self.indexed is True. In this
     # case, we need to know among which values we can search on this field,
     # in the search screen. Those values are returned by self.searchSelect,
     # which must be a static method accepting the tool as single arg.
     self.searchSelect = searchSelect
     # If changeOrder is False, it even if the user has the right to modify
     # the field, it will not be possible to move objects or sort them.
     self.changeOrder = changeOrder
     Field.__init__(self, validator, multiplicity, default, show, page,
                    group, layouts, move, indexed, False,
                    specificReadPermission, specificWritePermission, width,
                    height, None, colspan, master, masterValue, focus,
                    historized, sync, mapping, label, sdefault, scolspan,
                    swidth, sheight)
     self.validable = self.link
Exemplo n.º 32
0
 def __init__(self,
              validator=None,
              default=None,
              show=('view', 'result'),
              page='main',
              group=None,
              layouts=None,
              move=0,
              indexed=False,
              searchable=False,
              specificReadPermission=False,
              specificWritePermission=False,
              width=None,
              height=None,
              maxChars=None,
              colspan=1,
              master=None,
              masterValue=None,
              focus=False,
              historized=False,
              mapping=None,
              label=None,
              template=None,
              templateName=None,
              showTemplate=None,
              freezeTemplate=None,
              maxPerRow=5,
              context=None,
              stylesMapping={},
              formats=None,
              getChecked=None,
              mailing=None,
              mailingName=None,
              showMailing=None,
              mailingInfo=None):
     # Param "template" stores the path to the pod template(s). If there is
     # a single template, a string is expected. Else, a list or tuple of
     # strings is expected. Every such path must be relative to your
     # application. A pod template name Test.odt that is stored at the root
     # of your app will be referred as "Test.odt" in self.template. If it is
     # stored within sub-folder "pod", it will be referred as "pod/Test.odt".
     if not template: raise Exception(Pod.NO_TEMPLATE)
     if isinstance(template, basestring):
         self.template = [template]
     elif isinstance(template, tuple):
         self.template = list(template)
     else:
         self.template = template
     # Param "templateName", if specified, is a method that will be called
     # with the current template (from self.template) as single arg and must
     # return the name of this template. If self.template stores a single
     # template, you have no need to use param "templateName". Simply use the
     # field label to name the template. But if you have a multi-pod field
     # (with several templates specified as a list or tuple in param
     # "template"), you will probably choose to hide the field label and use
     # param "templateName" to give a specific name to every template. If
     # "template" contains several templates and "templateName" is None, Appy
     # will produce names from template filenames.
     self.templateName = templateName
     # "showTemplate" determines if the current user may generate documents
     # based on this pod field. More precisely, "showTemplate", if specified,
     # must be a method that will be called with the current template as
     # single arg (one among self.template) and that must return the list or
     # tuple of formats that the current user may use as output formats for
     # generating a document. If the current user is not allowed at all to
     # generate documents based on the current template, "showTemplate" must
     # return an empty tuple/list. If "showTemplate" is not specified, the
     # user will be able to generate documents based on the current template,
     # in any format from self.formats (see below).
     # "showTemplate" comes in addition to self.show. self.show dictates the
     # visibility of the whole field (ie, all templates from self.template)
     # while "showTemplate" dictates the visiblity of a specific template
     # within self.template.
     self.showTemplate = showTemplate
     # "freezeTemplate" determines if the current user may freeze documents
     # normally generated dynamically from this pod field. More precisely,
     # "freezeTemplate", if specified, must be a method that will be called
     # with the current template as single arg and must return the (possibly
     # empty) list or tuple of formats the current user may freeze. The
     # "freezing-related actions" that are granted by "freezeTemplate" are
     # the following. When no document is frozen yet for a given
     # template/format, the user may:
     # - freeze the document: pod will be called to produce a document from
     #   the current database content and will store it in the database.
     #   Subsequent user requests for this pod field will return the frozen
     #   doc instead of generating on-the-fly documents;
     # - upload a document: the user will be able to upload a document that
     #   will be stored in the database. Subsequent user requests for this
     #   pod field will return this doc instead of generating on-the-fly
     #   documents.
     # When a document is already frozen or uploaded for a given
     # template/format, the user may:
     # - unfreeze the document: the frozen or uploaded document will be
     #   deleted from the database and subsequent user requests for the pod
     #   field will again generate on-the-fly documents;
     # - re-freeze the document: the frozen or uploaded document will be
     #   deleted, a new document will be generated from the current database
     #   content and will be frozen as a replacement to the deleted one;
     # - upload a document: the frozen or uploaded document will be replaced
     #   by a new document uploaded by the current user.
     self.freezeTemplate = freezeTemplate
     # If p_template contains more than 1 template, "maxPerRow" tells how
     # much templates must appear side by side.
     self.maxPerRow = maxPerRow
     # The context is a dict containing a specific pod context, or a method
     # that returns such a dict.
     self.context = context
     # A global styles mapping that would apply to the whole template
     self.stylesMapping = stylesMapping
     # What are the output formats when generating documents from this pod ?
     self.formats = formats
     if not formats:  # Compute default ones
         self.formats = self.getAllFormats(self.template[0])
     # Parameter "getChecked" can specify the name of a Ref field belonging
     # to the same gen class. If it is the case, the context of the pod
     # template will contain an additional object, name "_checked", and
     # "_checked.<name of the Ref field>" will contain the list of the
     # objects linked via the Ref field that are currently selected in the
     # user interface.
     self.getChecked = getChecked
     # Mailing lists can be defined for this pod field. For every visible
     # mailing list, a menu item will be available in the user interface and
     # will allow to send the pod result as attachment to the mailing list
     # recipients. Attribute p_mailing stores a mailing list's id
     # (as a string) or a list of ids.
     self.mailing = mailing
     if isinstance(mailing, basestring):
         self.mailing = [mailing]
     elif isinstance(mailing, tuple):
         self.mailing = list(mailing)
     # "mailingName" returns the name of the mailing as will be shown in the
     # user interface. It must be a method accepting the mailing list id
     # (from self.mailing) as single arg and returning the mailing list's
     # name.
     self.mailingName = mailingName
     # "showMailing" below determines when the mailing list(s) must be shown.
     # It may store a method accepting a mailing list's id (among
     # self.mailing) and a template (among self.template) and returning the
     # list or tuple of formats for which the pod result can be sent to the
     # mailing list. If no such method is defined, the mailing list will be
     # available for all visible templates and formats.
     self.showMailing = showMailing
     # When it it time to send an email, "mailingInfo" gives all the
     # necessary information for this email: recipients, subject, body. It
     # must be a method whose single arg is the mailing id (from
     # self.mailing) and that returns an instance of class Mailing (above).
     self.mailingInfo = mailingInfo
     Field.__init__(self, None, (0, 1), default, show, page, group, layouts,
                    move, indexed, searchable, specificReadPermission,
                    specificWritePermission, width, height, None, colspan,
                    master, masterValue, focus, historized, mapping, label,
                    None, None, None, None, True)
     # Param "persist" is set to True but actually, persistence for a pod
     # field is determined by freezing.
     self.validable = False