Пример #1
0
    def __ProcessDbd(self):
        # ordered dict of field_name -> arginfo
        self._FieldInfo = OrderedDict()
        valid_names = []
        status = mydbstatic.dbFirstField(self.dbEntry, 0)
        while status == 0:
            name = mydbstatic.dbGetFieldName(self.dbEntry)
            desc = mydbstatic.dbGetPrompt(self.dbEntry)
            typ = mydbstatic.dbGetFieldType(self.dbEntry)
            group = mydbstatic.dbGetPromptGroup(self.dbEntry)
            if typ in [DCT_STRING, DCT_INLINK, DCT_OUTLINK, DCT_FWDLINK]:
                ArgInfo = arginfo.Simple(desc, str)
            elif typ in [DCT_INTEGER]:
                ArgInfo = arginfo.Simple(desc, int)
            elif typ in [DCT_REAL]:
                ArgInfo = arginfo.Simple(desc, float)
            elif typ in [DCT_MENU, DCT_MENUFORM]:
                n_choices = mydbstatic.dbGetNMenuChoices(self.dbEntry)
                if n_choices > 0:
                    menu_void = mydbstatic.dbGetMenuChoices(self.dbEntry)
                    menu_p = ctypes.cast(
                        menu_void, ctypes.POINTER(ctypes.c_char_p * n_choices))
                    ArgInfo = arginfo.Choice(desc, list(menu_p[0]))
                else:
                    ArgInfo = arginfo.Simple(desc, str)
            else:
                # No access field.
                ArgInfo = None
            if name != "NAME":
                valid_names.append(name)
                if ArgInfo is not None:
                    self._FieldInfo[name] = ArgInfo
            status = mydbstatic.dbNextField(self.dbEntry, 0)

        self._ValidNamesSet = set(valid_names)
Пример #2
0
    def __ProcessDbd(self):
        # ordered dict of field_name -> arginfo
        self._FieldInfo = OrderedDict()
        valid_names = []
        status = mydbstatic.dbFirstField(self.dbEntry, 0)
        while status == 0:
            name = mydbstatic.dbGetFieldName(self.dbEntry)
            desc = mydbstatic.dbGetPrompt(self.dbEntry)
            typ = mydbstatic.dbGetFieldType(self.dbEntry)
            group = mydbstatic.dbGetPromptGroup(self.dbEntry)
            if typ in [DCT_STRING, DCT_INLINK, DCT_OUTLINK, DCT_FWDLINK]:
                ArgInfo = arginfo.Simple(desc, str)
            elif typ in [DCT_INTEGER]:
                ArgInfo = arginfo.Simple(desc, int)
            elif typ in [DCT_REAL]:
                ArgInfo = arginfo.Simple(desc, float)
            elif typ in [DCT_MENU, DCT_MENUFORM]:
                n_choices = mydbstatic.dbGetNMenuChoices(self.dbEntry)
                if n_choices > 0:
                    menu_void = mydbstatic.dbGetMenuChoices(self.dbEntry)
                    menu_p = ctypes.cast(menu_void,
                        ctypes.POINTER(ctypes.c_char_p * n_choices))
                    ArgInfo = arginfo.Choice(desc, list(menu_p[0]))
                else:
                    ArgInfo = arginfo.Simple(desc, str)
            else:
                # No access field.
                ArgInfo = None
            if name != "NAME":
                valid_names.append(name)
                if ArgInfo is not None:
                    self._FieldInfo[name] = ArgInfo
            status = mydbstatic.dbNextField(self.dbEntry, 0)

        self._ValidNamesSet = set(valid_names)
Пример #3
0
    def ValidFieldValue(self, name, value):
        # First check the field name is valid and set the cursor in focus.
        self.ValidFieldName(name)
        value = str(value)

        # Set the database cursor to the field
        status = mydbstatic.dbFirstField(self.dbEntry, 0)
        while status == 0:
            if mydbstatic.dbGetFieldName(self.dbEntry) == name:
                break
            status = mydbstatic.dbNextField(self.dbEntry, 0)

        # Now see if we can write the value to it
        message = mydbstatic.dbVerify(self.dbEntry, value)
        assert message == None, \
            'Can\'t write "%s" to field %s: %s' % (value, name, message)
Пример #4
0
    def ValidFieldValue(self, name, value):
        # First check the field name is valid and set the cursor in focus.
        self.ValidFieldName(name)
        value = str(value)

        # Set the database cursor to the field
        status = mydbstatic.dbFirstField(self.dbEntry, 0)
        while status == 0:
            if mydbstatic.dbGetFieldName(self.dbEntry) == name:
                break
            status = mydbstatic.dbNextField(self.dbEntry, 0)

        # Now see if we can write the value to it
        message = mydbstatic.dbVerify(self.dbEntry, value)
        assert message == None, \
            'Can\'t write "%s" to field %s: %s' % (value, name, message)