예제 #1
0
파일: main.py 프로젝트: bk2204/newfol
    def callback(self, type_, obj):
        dbd = DatabaseData()
        if self.is_callback_type(type_, "select"):
            fields = self._get_fields()
            fieldres = []
            for f in fields:
                try:
                    fieldres.append(re.compile(f, re.IGNORECASE))
                except:
                    msg = _("'%s' is not a valid regular expression")
                    mb = MessageBox(msg % f)
                    mb.render(self.loop)
                    return

            def filter_(rec):
                if fieldres[0].search(rec.table) is None:
                    return False
                for field, reobj in zip(rec.fields, fieldres[1:]):
                    if reobj.search(field) is None:
                        return False
                return True
            recs = dbd.database().records(filter_)
            self.session.render_view(DisplayTemplateRecordView(fields[0],
                                                               recs))
        elif type_ == "change":
            self._set_titles_for_grid(obj[1])
        else:
            return super().callback(type_, obj)
예제 #2
0
파일: main.py 프로젝트: bk2204/newfol
 def callback(self, type_, obj):
     if self.is_callback_type(type_, "simple-select"):
         dbd = DatabaseData()
         newrec = self._build_record()
         recs = []
         inserted = False
         for r in dbd.database().records():
             if r is self.rec:
                 r.fields[:] = newrec.fields[:]
                 r.table = newrec.table
                 inserted = True
             recs.append(r)
         if not inserted:
             recs.append(newrec)
         dbd.database().records()[:] = recs
         render_previous_view(self.loop)
     elif type_ == "change":
         self._set_titles_for_grid(obj[1])
         if not any(self.rec.fields) and not self.rec.table:
             self._autofill(obj[1])
     else:
         return super().callback(type_, obj)
예제 #3
0
파일: main.py 프로젝트: bk2204/newfol
 def _render_in_editor_ro(self, title, recs, content, selected):
     dbd = DatabaseData()
     items = []
     for rec in recs:
         recvals = []
         for field in selected:
             if field == "table":
                 recvals.append(rec.table)
             else:
                 recvals.append(rec.fields[field])
         items.append(filemanip.Record(recvals))
         if dbd.database().schema().options("editor", "blank-lines"):
             items.append(filemanip.Record([]))
     self._display_in_editor(items, True)
예제 #4
0
파일: main.py 프로젝트: bk2204/newfol
 def _render_standard(self, loop):
     dbd = DatabaseData()
     recs = dbd.database().records(lambda rec: rec.table == self.table)
     title = _("List of records by key field for %s") % self.table
     return self._render_records(loop, title, recs,
                                 dbd.schema().key_fields())