当前位置: 首页>>代码示例>>Python>>正文


Python settings.get_var函数代码示例

本文整理汇总了Python中uliweb.settings.get_var函数的典型用法代码示例。如果您正苦于以下问题:Python get_var函数的具体用法?Python get_var怎么用?Python get_var使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_var函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_save

 def post_save(obj, data):
     from uliweb import functions
     from uliweb.utils.common import Serial
     from uliweb.mail import Mail
     
     Topic.filter(Topic.c.id==int(topic_id)).update(num_replies=Topic.c.num_replies+1, last_post_user=request.user.id, last_reply_on=date.now())
     Forum.filter(Forum.c.id==int(forum_id)).update(num_posts=Forum.c.num_posts+1, last_post_user=request.user.id, last_reply_on=date.now())
     self._clear_files(obj.slug, data['content'])
     
     #増加发送邮件的处理
     emails = []
     for u_id in Post.filter((Post.c.topic==int(topic_id)) & (Post.c.reply_email==True) & (Post.c.floor<obj.floor)).values(Post.c.posted_by):
         user = User.get(u_id[0])
         if user and user.email and (user.email not in emails) and (user.email!=request.user.email):
             emails.append(user.email)
     
     if not emails:
         return
     
     _type = settings.get_var('PARA/FORUM_REPLY_PROCESS', 'print')
     url = '%s/forum/%s/%s' % (settings.get_var('PARA/DOMAIN'), forum_id, topic_id)
     d = {'url':str(url)}
     mail = {'from_':settings.get_var('PARA/EMAIL_SENDER'), 'to_':emails,
         'subject':settings.get_var('FORUM_EMAIL/FORUM_EMAIL_TITLE'),
         'message':settings.get_var('FORUM_EMAIL/FORUM_EMAIL_TEXT') % d,
         'html':True}
     
     if _type == 'mail':
         Mail().send_mail(**mail)
     elif _type == 'print':
         print mail
     elif _type == 'redis':
         redis = functions.get_redis()
         _t = Serial.dump(mail)
         redis.lpush('send_mails', _t)
开发者ID:pyhunterpig,项目名称:plugs,代码行数:35,代码来源:views.py

示例2: __init__

    def __init__(self, application, settings):
        from datetime import timedelta
        self.options = dict(settings.get('SESSION_STORAGE', {}))
        self.options['data_dir'] = application_path(self.options['data_dir'])
        if 'url' not in self.options:
            _url = (settings.get_var('ORM/CONNECTION', '') or
            settings.get_var('ORM/CONNECTIONS', {}).get('default', {}).get('CONNECTION', ''))
            if _url:
                self.options['url'] = _url
        
        #process Session options
        self.remember_me_timeout = settings.SESSION.remember_me_timeout
        self.session_storage_type = settings.SESSION.type
        self.timeout = settings.SESSION.timeout
        Session.force = settings.SESSION.force
        
        #process Cookie options
        SessionCookie.default_domain = settings.SESSION_COOKIE.domain
        SessionCookie.default_path = settings.SESSION_COOKIE.path
        SessionCookie.default_secure = settings.SESSION_COOKIE.secure
        SessionCookie.default_cookie_id = settings.SESSION_COOKIE.cookie_id

        if isinstance(settings.SESSION_COOKIE.timeout, int):
            timeout = timedelta(seconds=settings.SESSION_COOKIE.timeout)
        else:
            timeout = settings.SESSION_COOKIE.timeout
        SessionCookie.default_expiry_time = timeout
开发者ID:28sui,项目名称:uliweb,代码行数:27,代码来源:middle_session.py

示例3: init_static_combine

def init_static_combine():

    from uliweb import settings
    from hashlib import md5
    import os

    PLUGINS = settings.get_var("TEMPLATE_GULP")

    d = {}


    if settings.get_var('STATIC_COMBINE_CONFIG/enable', False):
        # for k, v in settings.get('STATIC_COMBINE', {}).items():
        #     key = '_cmb_' + md5(''.join(v)).hexdigest() + os.path.splitext(v[0])[1]
        #     d[key] = v
        from uliweb.contrib.template.tags import find
        for k, v in PLUGINS.items():
            js_list = []
            css_list = []
            for x in v:
                s = find(x)
                m = s[0] + s[1]
                for i in m:
                    if not i.startswith('<!--'):
                        e = os.path.splitext(i)[1]
                        if e == ".css":
                            css_list.append(i)
                        elif e == ".js":
                            js_list.append(i)
            if js_list:
                d[k+".js"] = js_list
            if css_list:
                d[k + ".css"] = css_list
    return d
开发者ID:uliwebext,项目名称:uliweb-ui,代码行数:34,代码来源:__init__.py

示例4: list

    def list(self):
        from uliweb import request
        from uliweb.utils.generic import ListView
        from uliweb.utils.common import get_choice
        import math
        
        pageno = int(request.values.get('page', 1)) - 1
        rows_per_page=int(request.values.get('rows', settings.get_var('MESSAGES/PAGE_NUMS', 10)))

        read_flag = request.GET.get('read', '')
        type_flag = request.GET.get('type', '')
        
        condition = None
        condition = (self.model.c.user == request.user.id) & condition
        condition = (self.model.c.send_flag == 'r') & condition
        
        if read_flag:
            condition = (self.model.c.read_flag == bool(read_flag=='1')) & condition
            
        if type_flag:
            condition = (self.model.c.type == type_flag) & condition

        def create_date(value, obj):
            from uliweb.utils.timesince import timesince
            return timesince(value)
        
        def user_image(value, obj):
            return functions.get_user_image(obj.sender, size=20)
        
        def message(value, obj):
            return value
        
        fields_convert_map = {'create_date':create_date, 
            'user_image':user_image,
            'message':message}
        
        view = ListView(self.model, condition=condition, 
            order_by=[self.model.c.create_date.desc()],
            rows_per_page=rows_per_page, pageno=pageno,
            fields_convert_map=fields_convert_map)
        view.query()
        
        result = {}
        result['read_flag'] = read_flag
        result['type_flag'] = type_flag
        result['message_type_name'] = get_choice(settings.get_var('MESSAGES/MESSAGE_TYPE'), type_flag, '全部类型')
        
        pages = int(math.ceil(1.0*view.total/rows_per_page))
        
#        result['page'] = pageno+1
#        result['total'] = view.total
#        result['pages'] = pages
        result['pagination'] = functions.create_pagination(functions.request_url(), view.total, pageno+1, rows_per_page)
        result['objects'] = list(view.objects())
        ids = []
        for row in result['objects']:
            ids.append(row._obj_.id)
        self.model.filter(self.model.c.id.in_(ids)).update(read_flag=True)
        _del_key(request.user.id)
        return result
开发者ID:lypinggan,项目名称:plugs,代码行数:60,代码来源:views.py

示例5: _find_option

    def _find_option(self, global_options, option):
        from uliweb import settings
        from uliweb.core.SimpleFrame import collect_settings
        from uliweb.utils.pyini import Ini

        print "------ Combined value of [%s] ------" % option
        print settings.get_var(option)

        print "------ Detail   value of [%s] ------" % option
        sec_flag = "/" not in option
        if not sec_flag:
            section, key = option.split("/")

        for f in collect_settings(
            global_options.project,
            settings_file=global_options.settings,
            local_settings_file=global_options.local_settings,
        ):
            x = Ini(f, raw=True)
            if sec_flag:
                if option in x:
                    print x[option]
            else:
                if section in x:
                    if key in x[section]:
                        v = x[section][key]
                        print "%s %s%s" % (str(v), key, v.value())
开发者ID:08haozi,项目名称:uliweb,代码行数:27,代码来源:manage.py

示例6: process_exception

    def process_exception(self, request, e):
        from uliweb import settings
        import traceback
        from uliweb.mail import Mail
        from uliweb.utils.common import Serial
        from uliweb.core.SimpleFrame import HTTPError, HTTPException, NotFound

        if isinstance(e, (HTTPError, NotFound, HTTPException)):
            return

        type, value, tb = sys.exc_info()
        txt = "".join(traceback.format_exception(type, value, tb))

        if settings.GLOBAL.EXCEPTION_PROCESS_TYPE == "mail":
            Mail().send_mail(
                settings.get_var("PARA/EMAIL_SENDER"), settings.get_var("PARA/DEV_TEAM"), u"程序运行出错:" + request.path, txt
            )
        elif settings.GLOBAL.EXCEPTION_PROCESS_TYPE == "print":
            print txt
        elif settings.GLOBAL.EXCEPTION_PROCESS_TYPE == "redis":
            mail = {
                "from": settings.get_var("PARA/EMAIL_SENDER"),
                "to": settings.get_var("PARA/DEV_TEAM"),
                "title": u"程序运行出错" + request.url,
                "message": txt,
            }
            _t = Serial.dump(mail)
            self.redis.lpush("send_mails", _t)
开发者ID:jeellee,项目名称:plugs,代码行数:28,代码来源:middle_traceback.py

示例7: get_sequence

def get_sequence(key, default=1, step=1, retry_times=None, retry_waittime=None):
    from uliweb.orm import SaveError
    from uliweb import settings
    
    assert step > 0 and default > 0

    Sequence = functions.get_model('sequence')
    i = 0
    waittime = retry_waittime or settings.get_var('SEQUENCE/retry_waittime', 0.05)
    retry_times = retry_times or settings.get_var('SEQUENCE/retry_times', 3)
    while 1:
        try:
            row = Sequence.get(Sequence.c.key==key)
            if row:
                row.value = row.value + step
                row.save(version=True)
            else:
                row = Sequence(key=key, value=(default+step-1))
                row.save()
            break
        except SaveError:
            i += 1
            if i == retry_times:
                raise
            else:
                sleep(waittime)

    return row.value
开发者ID:28sui,项目名称:uliweb,代码行数:28,代码来源:__init__.py

示例8: process_response

    def process_response(self, request, response):
        from uliweb import settings, functions, json_dumps
        import base64
        
        #if not debug status it'll quit
        if not settings.get_var('GLOBAL/DEBUG'):
            return response
        
        S = functions.get_model('uliwebrecorderstatus')
        s = S.all().one()
        if not s or s.status == 'E':
            return response
        
        if settings.get_var('ULIWEBRECORDER/response_text'):
            try:
                text = response.data
            except Exception as e:
                text = str(e)
        else:
            text = ''
        
        #test if post_data need to convert base64
        if not request.content_type:
            post_data_is_text = True
        else:
            post_data_is_text = self.test_text(request.content_type)
        if not post_data_is_text:
            post_data = base64.encodestring(request.data)
        else:
            post_data = json_dumps(request.POST.to_dict())

        #test if response.data need to convert base64
        response_data_is_text = self.test_text(response.content_type)
        if not response_data_is_text:
            response_data = base64.encodestring(text)
        else:
            response_data = text

        R = functions.get_model('uliwebrecorder')
        if request.user:
            user_id = request.user.id
        else:
            user_id = None
        max_content_length = settings.get_var('ULIWEBRECORDER/max_content_length')
        if len(response_data) > max_content_length:
            msg = "Content length is great than %d so it will be omitted." % max_content_length
            log.info(msg)
            response_data = msg
            response_data_is_text = True
        recorder = R(method=request.method,
            url=request_url(request),
            post_data_is_text=post_data_is_text,
            post_data=post_data, user=user_id,
            response_data=response_data,
            response_data_is_text=response_data_is_text,
            status_code=response.status_code,
            )
        recorder.save()
        return response
开发者ID:28sui,项目名称:uliweb,代码行数:59,代码来源:middle_recorder.py

示例9: sended_list

    def sended_list(self):
        from uliweb import request
        from uliweb.utils.generic import ListView
        from uliweb.utils.common import get_choice
        import math

        pageno = int(request.values.get("page", 1)) - 1
        rows_per_page = int(request.values.get("rows", settings.get_var("MESSAGES/PAGE_NUMS", 10)))

        read_flag = request.GET.get("read", "")
        type_flag = request.GET.get("type", "")

        condition = None
        condition = (self.model.c.sender == request.user.id) & condition
        condition = (self.model.c.send_flag == "s") & condition

        if read_flag:
            condition = (self.model.c.read_flag == bool(read_flag == "1")) & condition

        if type_flag:
            condition = (self.model.c.type == type_flag) & condition

        def create_date(value, obj):
            from uliweb.utils.timesince import timesince

            return timesince(value)

        def user_image(value, obj):
            return functions.get_user_image(obj.user, size=20)

        def message(value, obj):
            return value

        fields_convert_map = {"create_date": create_date, "user_image": user_image, "message": message}

        view = ListView(
            self.model,
            condition=condition,
            order_by=[self.model.c.create_date.desc()],
            rows_per_page=rows_per_page,
            pageno=pageno,
            fields_convert_map=fields_convert_map,
        )
        view.query()

        result = {}
        result["read_flag"] = read_flag
        result["type_flag"] = type_flag
        result["message_type_name"] = get_choice(settings.get_var("MESSAGES/MESSAGE_TYPE"), type_flag, "全部类型")

        pages = int(math.ceil(1.0 * view.total / rows_per_page))

        #        result['page'] = pageno+1
        #        result['total'] = view.total
        #        result['pages'] = pages
        result["pagination"] = functions.create_pagination(request.url, view.total, pageno + 1, rows_per_page)
        result["objects"] = view.objects()
        return result
开发者ID:woerwin,项目名称:uliwebzone,代码行数:58,代码来源:views.py

示例10: install_template_loader

    def install_template_loader(self, dirs):
        Loader = import_attr(settings.get_var('TEMPLATE_PROCESSOR/loader'))
        args = settings.get_var('TEMPLATE')

        if self.debug:
            args['check_modified_time'] = True
            args['log'] = log
            args['debug'] = settings.get_var('GLOBAL/DEBUG_TEMPLATE', False)
        return Loader(dirs, **args)
开发者ID:bluesky4485,项目名称:uliweb,代码行数:9,代码来源:SimpleFrame.py

示例11: get_id

def get_id(engine, tablename, id=0, table_prefix=False):
    from uliweb import settings
    
    table = functions.get_table(tablename)
    d = {'engine':engine, 'tableid':table.id, 'id':str(id), 'tablename':tablename}
    if table_prefix:
        format = settings.get_var('OBJCACHE/table_format', 'OC:%(engine)s:%(tableid)d:')
    else:
        format = settings.get_var('OBJCACHE/key_format', 'OC:%(engine)s:%(tableid)d:%(id)s')
    return format % d
开发者ID:chenke91,项目名称:uliweb,代码行数:10,代码来源:__init__.py

示例12: post_save

        def post_save(obj, data):
            from uliweb import functions
            from uliweb.utils.common import Serial
            from uliweb.mail import Mail

            Post.filter(Post.c.id == int(parent_id)).update(
                num_replies=Post.c.num_replies + 1, last_post_user=request.user.id, last_reply_on=date.now()
            )
            self._clear_files(obj.slug, data["content"])

            Topic.filter(Topic.c.id == int(topic_id)).update(
                num_replies=Topic.c.num_replies + 1,
                last_post_user=request.user.id,
                last_reply_on=date.now(),
                last_post=obj.id,
            )
            Forum.filter(Forum.c.id == int(forum_id)).update(
                num_posts=Forum.c.num_posts + 1,
                last_post_user=request.user.id,
                last_reply_on=date.now(),
                last_post=obj.id,
            )

            # 増加发送邮件的处理
            emails = []
            for u_id in Post.filter(
                (Post.c.topic == int(topic_id)) & (Post.c.reply_email == True) & (Post.c.id == parent_id)
            ).values(Post.c.posted_by):
                user = User.get(u_id[0])
                if user and user.email and (user.email not in emails) and (user.email != request.user.email):
                    emails.append(user.email)

            if not emails:
                return

            _type = settings.get_var("PARA/FORUM_REPLY_PROCESS", "print")
            url = "%s/forum/%s/%s" % (settings.get_var("PARA/DOMAIN"), forum_id, topic_id)
            d = {"url": str(url)}
            mail = {
                "from_": settings.get_var("PARA/EMAIL_SENDER"),
                "to_": emails,
                "subject": settings.get_var("FORUM_EMAIL/FORUM_EMAIL_TITLE"),
                "message": settings.get_var("FORUM_EMAIL/FORUM_EMAIL_TEXT") % d,
                "html": True,
            }

            if _type == "mail":
                Mail().send_mail(**mail)
            elif _type == "print":
                print mail
            elif _type == "redis":
                redis = functions.get_redis()
                _t = Serial.dump(mail)
                redis.lpush("send_mails", _t)
开发者ID:tangjn,项目名称:plugs,代码行数:54,代码来源:views.py

示例13: __init__

 def __init__(self, host=None, port=None, user=None, password=None, backend=None):
     from uliweb import settings
     from uliweb.utils.common import import_attr
     
     self.host = host or (settings and settings.get_var('MAIL/HOST'))
     self.port = port or (settings and settings.get_var('MAIL/PORT', 25))
     self.user = user or (settings and settings.get_var('MAIL/USER'))
     self.password = password or (settings and settings.get_var('MAIL/PASSWORD'))
     self.backend = backend or (settings and settings.get_var('MAIL/BACKEND', 'uliweb.mail.backends.smtp'))
     cls = import_attr(self.backend + '.MailConnection')
     self.con = cls(self)
开发者ID:biluo1989,项目名称:uliweb,代码行数:11,代码来源:__init__.py

示例14: get_staticize

def get_staticize(backend=None, **kwargs):
    from uliweb import settings
    
    type = settings.get_var('STATICIZE/backend', 'file')
    _cls = _types.get(type)
    if not _cls:
        raise UliwebError("Can't found staticize type %s, please check the spell." % type)
    kw = settings.get_var('STATICIZE_BACKENDS/%s' % type, {})
    kw.update(kwargs)
    handler = _cls(**kw)
    return handler
开发者ID:chyhutu,项目名称:plugs,代码行数:11,代码来源:__init__.py

示例15: use

    def use(vars, env, plugin, *args, **kwargs):
        from uliweb.core.SimpleFrame import get_app_dir
        from uliweb import application as app, settings
        from uliweb.utils.common import is_pyfile_exist

        if plugin in UseNode.__saved_template_plugins_modules__:
            mod = UseNode.__saved_template_plugins_modules__[plugin]
        else:
            #add settings support, only support simple situation
            #so for complex cases you should still write module
            #format just like:
            #
            #[TEMPLATE_USE]
            #name = {
            #   'toplinks':[
            #       'myapp/jquery.myapp.{version}.min.js',
            #   ], 
            #   'depends':[xxxx], 
            #   'config':{'version':'UI_CONFIG/test'},
            #   'default':{'version':'1.2.0'},
            #}
            #
            mod = None
            c = settings.get_var('TEMPLATE_USE/'+plugin)
            if c:
                config = c.pop('config', {})
                default = c.pop('default', {})
                #evaluate config value
                config = dict([(k, settings.get_var(v, default.get(k, ''))) for k, v in config.items()])
                #merge passed arguments
                config.update(kwargs)
                for t in ['toplinks', 'bottomlinks']:
                    if t in c:
                        c[t] = [x.format(**config) for x in c[t]]
                mod = c
            else:
                for p in app.apps:
                    if not is_pyfile_exist(os.path.join(get_app_dir(p), 'template_plugins'), plugin):
                        continue
                    module = '.'.join([p, 'template_plugins', plugin])
                    try:
                        mod = __import__(module, {}, {}, [''])
                    except ImportError, e:
                        log.exception(e)
                        mod = None
            if mod:
                UseNode.__saved_template_plugins_modules__[plugin] = mod
            else:
                log.error("Can't find the [%s] template plugin, please check if you've installed special app already" % plugin)
                if settings.get_var('TEMPLATE/RAISE_USE_EXCEPTION'):
                    raise UseModuleNotFound("Can't find the %s template plugin, check if you've installed special app already" % plugin)
开发者ID:biluo1989,项目名称:uliweb,代码行数:51,代码来源:tags.py


注:本文中的uliweb.settings.get_var函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。