Example #1
0
    def authentication_certificate(self, uid):
        """Return authentication certificate row of the given user.

        The return value is the corresponding 'pytis.data.Row' instance.  If
        the user doesn't have authentication certificate assigned, return
        'None'.

        This method considers only authentication certificates.  Certificates
        present for other purposes are ignored.

        Arguments:

          uid -- user id as an integer

        """
        data = self._data
        uid_value = pd.Value(data.find_column('uid').type(), uid)
        purpose_value = pd.Value(data.find_column('purpose').type(), self.Spec._PURPOSE_AUTHENTICATION)
        try:
            self._data.select(pd.AND(pd.EQ('uid', uid_value), pd.EQ('purpose', purpose_value)))
            row = self._data.fetchone()
        finally:
            try:
                self._data.close()
            except:
                pass
        return row
Example #2
0
def sfs_columns(fields, data, labelfunc=Field.label):
    """Return a list of 'SFSColumn' instances for SFS dialog constructor.

    (SFS = Search, Filter, Sort)

    Argumenty:

      fields -- sequence of 'Field' instances from specification
      data -- related data object
      labelfunc -- function of one argument ('Field' instance) returning the
        column label used in the dialog or None to exclude the field from the
        dialog.

    """
    columns = []
    for f in fields:
        id = f.id()
        label = labelfunc(f)
        column = data.find_column(id)
        if column is not None and label and data.permitted(
                id, pytis.data.Permission.VIEW):
            columns.append(SFSColumn(id, column.type(), label))
    import locale
    columns.sort(key=lambda c: locale.strxfrm(c.label()))
    return columns
Example #3
0
def sfs_columns(fields, data, labelfunc=Field.label):
    """Return a list of 'SFSColumn' instances for SFS dialog constructor.

    (SFS = Search, Filter, Sort)

    Argumenty:

      fields -- sequence of 'Field' instances from specification
      data -- related data object
      labelfunc -- function of one argument ('Field' instance) returning the
        column label used in the dialog or None to exclude the field from the
        dialog.

    """
    columns = []
    for f in fields:
        id = f.id()
        label = labelfunc(f)
        column = data.find_column(id)
        if column is not None and label and data.permitted(id, pytis.data.Permission.VIEW):
            columns.append(SFSColumn(id, column.type(), label))
    import locale
    columns.sort(key=lambda c: locale.strxfrm(c.label()))
    return columns