Esempio n. 1
0
 def __init__(self, field, getrecords=True, *args, **kwargs):
     BaseFieldEditor.__init__(self, field, *args, **kwargs)
     self.reprfunc = kwargs.get("reprfunc", lambda r: r._astxt)
     if getrecords:
         self.records = RecordList(self.field.reference)
         self.records.reload()
     else:
         self.records = None
Esempio n. 2
0
class BaseReferenceEditor(BaseFieldEditor):
    """
    Base class for editors of fields which reference other records. 
    A reference field, by assumption, holds the 'objectid' of the record it references.
    Since reference editors are usually widgets similar to combo boxes, the base reference editor
    may retrieve a list of records from the referenced table, if the 'getrecords' keyword variable
    is passed to the constructor.
    """
    def __init__(self, field, getrecords=True, *args, **kwargs):
        BaseFieldEditor.__init__ (self, field, *args, **kwargs)
        self.reprfunc = kwargs.get ( "reprfunc", lambda r: r._astxt )        
        if getrecords:
            self.records = RecordList ( self.field.reference )
            self.records.reload()
        else:
            self.records = None
Esempio n. 3
0
class BaseReferenceEditor(BaseFieldEditor):
    """
    Base class for editors of fields which reference other records. 
    A reference field, by assumption, holds the 'objectid' of the record it references.
    Since reference editors are usually widgets similar to combo boxes, the base reference editor
    may retrieve a list of records from the referenced table, if the 'getrecords' keyword variable
    is passed to the constructor.
    """
    def __init__(self, field, getrecords=True, *args, **kwargs):
        BaseFieldEditor.__init__(self, field, *args, **kwargs)
        self.reprfunc = kwargs.get("reprfunc", lambda r: r._astxt)
        if getrecords:
            self.records = RecordList(self.field.reference)
            self.records.reload()
        else:
            self.records = None
Esempio n. 4
0
 def __init__(self, field, getrecords=True, *args, **kwargs):
     BaseFieldEditor.__init__ (self, field, *args, **kwargs)
     self.reprfunc = kwargs.get ( "reprfunc", lambda r: r._astxt )        
     if getrecords:
         self.records = RecordList ( self.field.reference )
         self.records.reload()
     else:
         self.records = None
Esempio n. 5
0
    def _create_default_field_editor(self, field, parent=None, **kwargs):
        from app import APP
        editor_class_name = field.editor_class
        default_class = EntryWidgets.Text
        options = {}
        prefix = ''
        suffix = ''

        if self.form.is_field_fixed(field.name):
            editor_class_name = 'Static'

        if field.isarray:
            if field.arrayof:
                editor_class_name = "List"
                prefix = "Array"
                options['recordlist'] = RecordList(field.arrayof).reload()
                default_class = EntryWidgets.ArrayCombo
            else:
                prefix = 'Array'
                default_class = EntryWidgets.ArrayText
        elif field.reference:
            suffix = 'Reference'
            default_class = EntryWidgets.ListReference

        wanted_class_name = prefix + editor_class_name + suffix
        print field, field.editor_class, wanted_class_name

        if hasattr(EntryWidgets, wanted_class_name):
            editor_class = getattr(EntryWidgets, wanted_class_name)
        elif APP.getExtraDataEditor(wanted_class_name):
            editor_class = APP.getExtraDataEditor(wanted_class_name)
        else:
            editor_class = default_class

        editor = editor_class(field,
                              parent,
                              variable=self.form.getvar(field.name),
                              **options)
        return editor