Exemple #1
0
 def on_text(self, event):
     event.Skip()
     s = event.GetString()
     if len(s) < self.minimum_input_length:
         return
     if self.url:
         base_url = self.url
     else:
         base_url = "/select2/fields/auto.json"
     url = base_url + "?term=%s&page=1&context=&field_id=%s" % (
         s,
         self.field_id,
     )
     http = wx.GetApp().get_http(self.combo)
     response = http.get(self, url)
     print(response.str())
     tab = schjson.loads(response.str())
     if not "err" in tab or ("err" in tab and
                             (tab["err"] != "nil" or tab["err"] != None)):
         self.list_ctrl.Clear()
         if len(tab["results"]) > 0:
             for pos in tab["results"]:
                 self.list_ctrl.Append(pos["text"], pos["id"])
             if s:
                 self.list_ctrl.SetSelection(0)
Exemple #2
0
 def GetRecAsStr(self, nrRec):
     response = self.http.post(
         self.parent,
         self.tabaddress,
         process_post_parm({"cmd": CMD_RECASSTR, "nr": nrRec}),
     )
     ret = schjson.loads(response.str())
     return ret["recasstr"]
Exemple #3
0
 def get_count(self):
     parm = {"cmd": CMD_COUNT}
     if "value" in self.parm:
         parm["value"] = self.parm["value"]
     response = self.http.post(self.parent, self.tabaddress, process_post_parm(parm))
     s = response.str()
     ret = schjson.loads(s)
     self.max_count = int(ret["count"])
     return self.max_count
Exemple #4
0
 def command(self, cmd_dict):
     if "cmd" in cmd_dict:
         cmd = cmd_dict["cmd"]
     else:
         cmd = CMD_PAGE
         cmd_dict = {}
         cmd_dict["nr"] = 0
     if cmd == CMD_INFO:
         return self._info()
     if cmd == CMD_PAGE:
         if "value" in cmd_dict:
             value = cmd_dict["value"]
         else:
             value = None
         if "sort" in cmd_dict:
             return self._page(int(cmd_dict["nr"]), cmd_dict["sort"], value=value)
         else:
             return self._page(int(cmd_dict["nr"]), value=value)
     if cmd == CMD_COUNT:
         if "value" in cmd_dict:
             value = cmd_dict["value"]
         else:
             value = None
         return self._count(value)
     if cmd == CMD_SYNC:
         return self._sync(
             schjson.loads(cmd_dict["update"]),
             schjson.loads(cmd_dict["insert"]),
             schjson.loads(cmd_dict["delete"]),
         )
     if cmd == CMD_AUTO:
         return self._auto(
             cmd_dict["col_name"], cmd_dict["col_names"], cmd_dict["rec"]
         )
     if cmd == CMD_RECASSTR:
         return self._rec_as_str(int(cmd_dict["nr"]))
     if cmd == CMD_EXEC:
         if "value" in cmd_dict:
             value = cmd_dict["value"]
         else:
             value = None
         return self._exec(value)
     return None
Exemple #5
0
 def filter(self, parent, f):
     http = wx.GetApp().get_http(parent)
     response = http.get(self, str(self.href), {'query': f.encode('utf-8')})
     s = response.str()
     try:
         self.tab = schjson.loads(s)
     except:
         self.tab = []
     self.tab2 = []
     for pos in self.tab:
         self.tab2.append((pos['value'], ))
     self.tab = self.tab2
Exemple #6
0
    def __init__(self, *args, **kwds):
        """Constructor"""
        if "style" in kwds:
            kwds["style"] |= wx.TE_PROCESS_ENTER
        else:
            kwds["style"] = wx.TE_PROCESS_ENTER

        if "dialog_with_value" in kwds:
            self.dialog_with_value = kwds["dialog_with_value"]
            del kwds["dialog_with_value"]
        else:
            self.dialog_with_value = True
        ComboCtrl.__init__(self, *args, **kwds)

        self.win = None
        self.html = None
        self.rec_value = []
        self.event_object = None
        self.page = None
        self.popup = None
        self.start_value = ""

        if self.defaultvalue:
            self.clear_str = self.defaultvalue
        else:
            self.clear_str = ""

        href = self.href.split(";")
        if len(href) > 1:
            self.href = href[0]
            self.href2 = href[1]
        else:
            self.href2 = None

        self.http = wx.GetApp().get_http(self)
        response = self.http.get(self, str(self.href) + "size/")
        self.size = schjson.loads(response.str())

        self.simpleDialog = True
        if self.GetTextCtrl():
            self.GetTextCtrl().SetForegroundColour(wx.Colour(0, 0, 0))

        self.UseAltPopupWindow(enable=True)

        popoup = self._create_popoup()
        self.SetPopupControl(popoup)
Exemple #7
0
    def get_page(self, nrPage):
        c = {"cmd": CMD_PAGE, "nr": nrPage}
        if self.parm:
            for (key, value) in list(self.parm.items()):
                c[key] = value
        response = self.http.post(self.parent, self.tabaddress, process_post_parm(c))

        try:
            page = schjson.loads(response.str())
            retpage = page["page"]
        except:
            retpage = None
            # from pytigon_lib.schhttptools.httperror import http_error
            # http_error(wx.GetApp().GetTopWindow(), self.http.str())
            self.http.show(wx.GetApp().GetTopWindow())
            retpage = []
        return retpage
Exemple #8
0
    def __init__(self, http, tabaddress):
        self.max_count = 1000000
        self.var_count = -1
        self.tabaddress = tabaddress
        self.tabaddress0 = self.tabaddress
        self.parm = ""
        self.parent = None
        self.http = http
        self.col_types2 = []
        self.parm = dict()
        self.is_valid = True

        response = self.http.post(
            self.parent,
            self.tabaddress,
            process_post_parm(
                {
                    "cmd": CMD_INFO,
                }
            ),
        )
        ret = schjson.loads(response.str())

        self.col_names = ret["col_names"]
        self.col_types = ret["col_types"]
        self.default_rec = ret["default_rec"]
        self.col_size = ret["col_length"]

        for i in range(0, len(self.col_size)):
            if (self.col_size)[i] > 32:
                (self.col_size)[i] = 32

        self.auto_cols = ret["auto_cols"]

        for col in self.col_types:
            self.col_types2.append(col.split(":")[0])

        self.tab_conw = {
            "long": self.conw_long,
            "string": self.conw_none,
            "double": self.conw_float,
            "bool": self.conw_bool,
            "choice": self.conw_none,
            "x": self.conw_none,
        }
Exemple #9
0
    def focus_out(self, value):
        if str(value) != self.start_value:
            if not str(value) == "":
                self.http = wx.GetApp().get_http(self)
                x = bencode(value)
                response = self.http.post(self,
                                          str(self.href) + "test/",
                                          {"value": x})
                tab = schjson.loads(self.response.str())
                ret = tab[0]

                if ret != 1:
                    if ret == 2:
                        self.OnButtonClick()
                    else:
                        self.clear_rec()
                else:
                    self.set_rec(tab[1], tab[2], False)
Exemple #10
0
def vfstable_view(request, folder, value=None):
    if request.POST:
        p = request.POST.copy()
        d = {}
        for (key, val) in list(p.items()):
            if key != "csrfmiddlewaretoken":
                d[str(key)] = schjson.loads(val)
    else:
        d = {}
    if value and value != "" and value != "_":
        d["value"] = bdecode(value)
    if folder and folder != "" and folder != "_":
        folder2 = bdecode(folder)
    else:
        folder2 = "/"
    # folder2 = replace_dot(folder2)
    folder2 = norm_path(folder2)
    tabview = VfsTable(folder2)
    retstr = tabview.command(d)
    return HttpResponse(retstr)
Exemple #11
0
    def auto_update(self, col_name, col_names, rec):
        """Return transformed row after current row is changed"""

        col_name2 = schjson.dumps(col_name)
        col_names2 = schjson.dumps(col_names)
        rec2 = schjson.dumps(rec)

        c = {
            "cmd": CMD_AUTO,
            "col_name": col_name2,
            "col_names": col_names2,
            "rec": rec2,
        }

        response = self.http.post(self.parent, self.tabaddress, process_post_parm(c))
        ret = schjson.loads(response.str())
        if ret == None:
            return rec
        else:
            return ret["rec"]
Exemple #12
0
def tbl(request, app, tab, value=None, template_name=None):
    """View to show table

    Args:
        app - application name
        tab - table name
        value
        template_name - template name
    """
    if request.POST:
        p = request.POST.copy()
        d = {}
        for (key, val) in list(p.items()):
            if key == 'csrfmiddlewaretoken':
                d[str(key)] = val
            else:
                d[str(key)] = schjson.loads(val)
    else:
        d = {}
    if value and value != '':
        d['value'] = b32decode(value.encode('ascii'))
    dbtab = DbTable(app, tab)
    retstr = dbtab.command(d)
    return HttpResponse(retstr)
Exemple #13
0
 def exec(self, parm):
     c = {"cmd": CMD_EXEC, "value": parm}
     response = self.http.post(self.parent, self.tabaddress, process_post_parm(c))
     ret = schjson.loads(response.str())
     return ret
Exemple #14
0
 def BeginEdit(self, row, col, grid):
     typ = grid.GetTable().GetTypeName(row, col)
     id = typ.find(":")
     self.choices = schjson.loads(typ[id + 1:])
     PopupDataCellEditor.BeginEdit(self, row, col, grid)