コード例 #1
0
ファイル: model.py プロジェクト: MarsStirner/webmis
class Group(ModelClass):
    # In a ModelClass we need to declare attributes in the following list.
    _appy_attributes = ['title', 'login', 'roles', 'users']
    # All methods defined below are fake. Real versions are in the wrapper.
    m = {'group': 'main', 'width': 25, 'indexed': True}
    title = gen.String(multiplicity=(1, 1), **m)

    def showLogin(self):
        pass

    def validateLogin(self):
        pass

    login = gen.String(show=showLogin,
                       validator=validateLogin,
                       multiplicity=(1, 1),
                       **m)
    roles = gen.String(validator=gen.Selection('getGrantableRoles'),
                       multiplicity=(0, None),
                       **m)
    users = gen.Ref(User,
                    multiplicity=(0, None),
                    add=False,
                    link=True,
                    back=gen.Ref(attribute='groups', show=True),
                    showHeaders=True,
                    shownInfo=('title', 'login'))
コード例 #2
0
ファイル: model.py プロジェクト: dpineiden/gestion_docs
class Group(ModelClass):
    _appy_attributes = ['title', 'login', 'roles', 'users', 'toTool2']
    # All methods defined below are fake. Real versions are in the wrapper.
    m = {'group': 'main', 'width': 25, 'indexed': True}
    title = gen.String(multiplicity=(1, 1), **m)

    def showLogin(self):
        pass

    def validateLogin(self):
        pass

    login = gen.String(show=showLogin,
                       validator=validateLogin,
                       multiplicity=(1, 1),
                       **m)
    roles = gen.String(validator=gen.Selection('getGrantableRoles'),
                       multiplicity=(0, None),
                       **m)

    def getSelectableUsers(self):
        pass

    users = gen.Ref(User,
                    multiplicity=(0, None),
                    add=False,
                    link=True,
                    back=gen.Ref(attribute='groups',
                                 show=User.showRoles,
                                 multiplicity=(0, None)),
                    select=getSelectableUsers,
                    height=15,
                    showHeaders=True,
                    shownInfo=('title', 'login'))
コード例 #3
0
class Page(ModelClass):
    _appy_attributes = ['title', 'content', 'pages', 'parent', 'toTool3']
    folder = True
    title = gen.String(show='edit', multiplicity=(1, 1), indexed=True)
    content = gen.String(format=gen.String.XHTML, layouts='f', richText=True)

    # Pages can contain other pages.
    def showSubPages(self):
        pass

    pages = gen.Ref(None,
                    multiplicity=(0, None),
                    add=True,
                    link=False,
                    back=gen.Ref(attribute='parent', show=False),
                    show=showSubPages,
                    navigable=True)
コード例 #4
0
ファイル: model.py プロジェクト: MarsStirner/webmis
class Tool(ModelClass):
    # In a ModelClass we need to declare attributes in the following list.
    _appy_attributes = list(defaultToolFields)

    # Tool attributes
    def validPythonWithUno(self, value):
        pass  # Real method in the wrapper

    unoEnabledPython = gen.String(group="connectionToOpenOffice",
                                  validator=validPythonWithUno)
    openOfficePort = gen.Integer(default=2002, group="connectionToOpenOffice")
    numberOfResultsPerPage = gen.Integer(default=30, show=False)
    listBoxesMaximumWidth = gen.Integer(default=100, show=False)
    appyVersion = gen.String(show=False, layouts='f')

    def refreshSecurity(self):
        pass  # Real method in the wrapper

    refreshSecurity = gen.Action(action=refreshSecurity, confirm=True)
    # Ref(User) will maybe be transformed into Ref(CustomUserClass).
    users = gen.Ref(User,
                    multiplicity=(0, None),
                    add=True,
                    link=False,
                    back=gen.Ref(attribute='toTool', show=False),
                    page=gen.Page('users', show='view'),
                    queryable=True,
                    queryFields=('title', 'login'),
                    showHeaders=True,
                    shownInfo=('title', 'login', 'roles'))
    groups = gen.Ref(Group,
                     multiplicity=(0, None),
                     add=True,
                     link=False,
                     back=gen.Ref(attribute='toTool2', show=False),
                     page=gen.Page('groups', show='view'),
                     queryable=True,
                     queryFields=('title', 'login'),
                     showHeaders=True,
                     shownInfo=('title', 'login', 'roles'))
    translations = gen.Ref(Translation,
                           multiplicity=(0, None),
                           add=False,
                           link=False,
                           show='view',
                           back=gen.Ref(attribute='trToTool', show=False),
                           page=gen.Page('translations', show='view'))
    enableNotifications = gen.Boolean(default=True,
                                      page=gen.Page('notifications',
                                                    show=False))

    @classmethod
    def _appy_clean(klass):
        toClean = []
        for k, v in klass.__dict__.iteritems():
            if not k.startswith('__') and (not k.startswith('_appy_')):
                if k not in defaultToolFields:
                    toClean.append(k)
        for k in toClean:
            exec 'del klass.%s' % k
        klass._appy_attributes = list(defaultToolFields)
コード例 #5
0
class Tool(ModelClass):
    # In a ModelClass we need to declare attributes in the following list.
    _appy_attributes = list(defaultToolFields)
    folder = True

    # Tool attributes
    def isManager(self):
        pass

    def isManagerEdit(self):
        pass

    lf = {'layouts': 'f'}
    title = gen.String(show=False,
                       page=gen.Page('main', show=False),
                       default='Configuration',
                       **lf)
    mailHost = gen.String(default='localhost:25', **lf)
    mailEnabled = gen.Boolean(default=False, **lf)
    mailFrom = gen.String(default='*****@*****.**', **lf)
    appyVersion = gen.String(**lf)
    dateFormat = gen.String(default='%d/%m/%Y', **lf)
    hourFormat = gen.String(default='%H:%M', **lf)

    # Ref(User) will maybe be transformed into Ref(CustomUserClass).
    userPage = gen.Page('users', show=isManager)
    users = gen.Ref(User,
                    multiplicity=(0, None),
                    add=True,
                    link=False,
                    back=gen.Ref(attribute='toTool', show=False),
                    page=userPage,
                    queryable=True,
                    queryFields=('title', 'login'),
                    show=isManager,
                    showHeaders=True,
                    shownInfo=('title', 'login', 'roles'))

    def computeConnectedUsers(self):
        pass

    connectedUsers = gen.Computed(method=computeConnectedUsers,
                                  page=userPage,
                                  plainText=False,
                                  show=isManager)
    groups = gen.Ref(Group,
                     multiplicity=(0, None),
                     add=True,
                     link=False,
                     back=gen.Ref(attribute='toTool2', show=False),
                     page=gen.Page('groups', show=isManager),
                     show=isManager,
                     queryable=True,
                     queryFields=('title', 'login'),
                     showHeaders=True,
                     shownInfo=('title', 'login', 'roles'))
    pt = gen.Page('translations', show=isManager)
    translations = gen.Ref(Translation,
                           multiplicity=(0, None),
                           add=False,
                           link=False,
                           show='view',
                           page=pt,
                           back=gen.Ref(attribute='trToTool', show=False))
    loadTranslationsAtStartup = gen.Boolean(default=True,
                                            show=False,
                                            page=pt,
                                            layouts='f')
    pages = gen.Ref(Page,
                    multiplicity=(0, None),
                    add=True,
                    link=False,
                    show='view',
                    back=gen.Ref(attribute='toTool3', show=False),
                    page=gen.Page('pages', show=isManager))

    # Document generation page
    dgp = {'page': gen.Page('documents', show=isManagerEdit)}

    def validPythonWithUno(self, value):
        pass  # Real method in the wrapper

    unoEnabledPython = gen.String(default='/usr/bin/python',
                                  show=False,
                                  validator=validPythonWithUno,
                                  **dgp)
    openOfficePort = gen.Integer(default=2002, show=False, **dgp)
    # User interface page
    numberOfResultsPerPage = gen.Integer(default=30,
                                         page=gen.Page('userInterface',
                                                       show=False))

    @classmethod
    def _appy_clean(klass):
        toClean = []
        for k, v in klass.__dict__.iteritems():
            if not k.startswith('__') and (not k.startswith('_appy_')):
                if k not in defaultToolFields:
                    toClean.append(k)
        for k in toClean:
            exec 'del klass.%s' % k
        klass._appy_attributes = list(defaultToolFields)
        klass.folder = True