Esempio n. 1
0
    def index(self, id_system=None):
        u"Отрисовует сведения о классе метрик и его методах"

        from app import mappings

        BasePage.index(self)
        root = mappings.find_map_obj(cherrypy.request.path_info)
        system = self.get_system(root)
        methods = get_methods(system)

        return self.drawTemplate(templ=metrics_metric,
                                 data=[{
                                     'system': system,
                                     'methods': methods
                                 }])
Esempio n. 2
0
def find_id_system_by_full_ref_name(fullhref, use_cache=True, conEngine=None):
    "Получить id_system для системы по полной ссылке. Если не найдено - None."
    if not use_cache:
        import db
        d = db.dbExec(sql='select ID_SYSTEM from ENGINE_FIND_SYSTEM_BY_FULL_REF(?)',
            params=[fullhref], fetch='one', id_system= -1, con=conEngine)
        if d is None:
            return None
        return d['ID_SYSTEM']
    else:
        from app import mappings

        obj = mappings.find_map_obj(fullhref)
        id_system = getattr(obj, 'id_system', None)
        return id_system
Esempio n. 3
0
    def ajaxBarcodeHTML(self, **kwargs):
        "Печать ШК или QR-кода"

        from app import mappings

        is_qr = self.cInt(kwargs['is_qr'])
        passwdBC = pu.convToWin(kwargs['passwdBC'])

        # проверка заполненности пароля
        if not passwdBC:
            return self.pyDumps(
                data={
                    'RES':
                    'error',
                    'ERROR_MSG':
                    _('Это поле должно быть заполнено.'
                      ),
                    'HTML':
                    '',
                    'BC':
                    '',
                    'LASTDATE':
                    ''
                })

        # валидация логина и пароля
        usr = verify_user(self.getUserVar('login'), passwdBC)
        if usr['ERROR_CODE']:
            return self.pyDumps(
                data={
                    'RES': 'error',
                    'ERROR_MSG': usr['ERROR_MSG'],
                    'HTML': '',
                    'BC': '',
                    'LASTDATE': ''
                })

        adminPanel = mappings.find_map_obj(ADMIN_PANEL_FULLREF)
        return adminPanel.ajaxBarcodeHTML(id_user=self.getUserVar('uid'),
                                          id_type=0,
                                          is_qr=is_qr)
Esempio n. 4
0
def get_methods(system):
    u"Получает методы-метрики по системе, имеющей класс метрик"
    import py_utils as pu
    from app import mappings

    methods = []
    obj = mappings.find_map_obj(system['FULL_REF_NAME'])
    id_system = getattr(obj, 'id_system', None)

    #для систем Profile, Account
    if id_system is not None and isinstance(obj, BaseMainMetric):
        for meth_name in dir(obj):
            meth = getattr(obj, meth_name)
            if callable(meth) and 'metric' in dir(meth):
                methods.append({
                    'NAME':
                    meth.__name__,
                    'FULL_REF_NAME':
                    system['FULL_REF_NAME'] + '/' + meth.__name__,
                    'DOCSTRING':
                    pu.format(meth.__doc__)
                })

    return methods