• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python parameters.get_user函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

    def __init__(self, mbox, mailid, request, dformat="DISPLAYMODE", addrfull=False, links=0):
        mformat = parameters.get_user(request.user, "DISPLAYMODE")
        self.dformat = parameters.get_user(request.user, dformat)

        self.headers = []
        self.attachments = {}
        self.imapc = get_imapconnector(request)
        msg = self.imapc.fetchmail(mbox, mailid, readonly=False, headers=self.headers_as_list)
        self.mbox = mbox
        self.mailid = mailid
        headers = msg["BODY[HEADER.FIELDS (%s)]" % self.headers_as_text]
        fallback_fmt = "html" if self.dformat == "plain" else "plain"

        self.bs = BodyStructure(msg["BODYSTRUCTURE"])
        data = None

        mformat = self.dformat if self.bs.contents.has_key(self.dformat) else fallback_fmt

        if len(self.bs.contents):
            bodyc = u""
            for part in self.bs.contents[mformat]:
                pnum = part["pnum"]
                data = self.imapc._cmd("FETCH", mailid, "(BODY.PEEK[%s])" % pnum)
                content = decode_payload(part["encoding"], data[int(mailid)]["BODY[%s]" % pnum])
                charset = self._find_content_charset(part)
                if charset is not None:
                    try:
                        content = content.decode(charset)
                    except (UnicodeDecodeError, LookupError):
                        result = chardet.detect(content)
                        content = content.decode(result["encoding"])
                bodyc += content

            self._fetch_inlines()
            self.body = getattr(self, "viewmail_%s" % mformat)(bodyc, links=links)
        else:
            self.body = None

        self._find_attachments()

        msg = email.message_from_string(headers)
        for hdr in self.headernames:
            label = hdr[0]
            name = hdr[0]
            if not name in msg.keys():
                name = name.upper()
                if not name in msg.keys():
                    continue
            try:
                key = re.sub("-", "_", name).lower()
                value = getattr(IMAPheader, "parse_%s" % key)(msg[name], full=addrfull)
            except AttributeError:
                value = msg[name]
            if hdr[1]:
                self.headers += [{"name": label, "value": value}]
            try:
                label = re.sub("-", "_", label)
                setattr(self, label, value)
            except:
                pass
开发者ID:juju2013,项目名称:modoboa,代码行数:60,代码来源:lib.py


示例2: send_mail

def send_mail(request, form, posturl=None):
    """Email verification and sending.

    If the form does not present any error, a new MIME message is
    constructed. Then, a connection is established with the defined
    SMTP server and the message is finally sent.

    :param request: a Request object
    :param posturl: the url to post the message form to
    :return: a 2-uple (True|False, HttpResponse)
    """
    if not form.is_valid():
        editormode = parameters.get_user(request.user, "EDITOR")
        listing = _render_to_string(
            request, "webmail/compose.html",
            {"form": form, "noerrors": True,
             "body": form.cleaned_data.get("body", "").strip(),
             "posturl": posturl}
        )
        return False, dict(status="ko", listing=listing, editor=editormode)

    msg = form.to_msg(request)
    rcpts = prepare_addresses(form.cleaned_data["to"], "envelope")
    for hdr in ["cc", "cci"]:
        if form.cleaned_data[hdr]:
            msg[hdr.capitalize()] = prepare_addresses(form.cleaned_data[hdr])
            rcpts += prepare_addresses(form.cleaned_data[hdr], "envelope")
    try:
        secmode = parameters.get_admin("SMTP_SECURED_MODE")
        if secmode == "ssl":
            s = smtplib.SMTP_SSL(parameters.get_admin("SMTP_SERVER"),
                                 int(parameters.get_admin("SMTP_PORT")))
        else:
            s = smtplib.SMTP(parameters.get_admin("SMTP_SERVER"),
                             int(parameters.get_admin("SMTP_PORT")))
            if secmode == "starttls":
                s.starttls()
    except Exception as text:
        raise WebmailInternalError(str(text))

    if parameters.get_admin("SMTP_AUTHENTICATION") == "yes":
        try:
            s.login(request.user.username, get_password(request))
        except smtplib.SMTPException as err:
            raise WebmailInternalError(str(err))
    try:
        s.sendmail(request.user.email, rcpts, msg.as_string())
        s.quit()
    except smtplib.SMTPException as err:
        raise WebmailInternalError(str(err))

    sentfolder = parameters.get_user(request.user, "SENT_FOLDER")
    get_imapconnector(request).push_mail(sentfolder, msg)
    clean_attachments(request.session["compose_mail"]["attachments"])
    del request.session["compose_mail"]
    return True, {}
开发者ID:JHei,项目名称:modoboa,代码行数:56,代码来源:sendmail.py


示例3: getfs

def getfs(request, name):
    sc = SieveClient(user=request.user.username,
                     password=request.session["password"])
    editormode = parameters.get_user(request.user, "EDITOR_MODE")
    error = None
    try:
        content = sc.getscript(name, format=editormode)
    except SieveClientError as e:
        error = str(e)
    else:
        if content is None:
            error = _("Failed to retrieve filters set")

    if error is not None:
        return ajax_response(request, "ko", respmsg=error)

    if editormode == "raw":
        htmlcontent = render_to_string("modoboa_sievefilters/rawfilter.html", dict(
            name=name, scriptcontent=content
        ))
    else:
        htmlcontent = render_to_string("modoboa_sievefilters/guieditor.html", dict(
            fs=content
        ))

    menu = '<ul id="fsetmenu" class="nav nav-sidebar"><li class="nav-header">%s</li>%s</ul>' % \
        (_("Actions"), fset_menu(editormode, name))
    resp = dict(menu=menu, content=htmlcontent)
    return render_to_json_response(resp)
开发者ID:bearstech,项目名称:modoboa-sievefilters,代码行数:29,代码来源:views.py


示例4: _listing

def _listing(request):
    if not request.user.is_superuser and request.user.group != 'SimpleUsers':
        if not Domain.objects.get_for_admin(request.user).count():
            return empty_quarantine(request)

    navparams = QuarantineNavigationParameters(request)
    navparams.store()

    lst = SQLlisting(
        request.user,
        navparams=navparams,
        elems_per_page=int(
            parameters.get_user(request.user, "MESSAGES_PER_PAGE")
        )
    )
    page = lst.paginator.getpage(navparams.get('page'))
    if not page:
        return empty_quarantine(request)

    content = lst.fetch(request, page.id_start, page.id_stop)
    ctx = getctx(
        "ok", listing=content, paginbar=pagination_bar(page), page=page.number
    )
    if request.session.get('location', 'listing') != 'listing':
        ctx['menu'] = quar_menu()
    request.session['location'] = 'listing'
    return render_to_json_response(ctx)
开发者ID:SonRiab,项目名称:modoboa,代码行数:27,代码来源:views.py


示例5: empty

def empty(request, name):
    if name != parameters.get_user(request.user, "TRASH_FOLDER"):
        raise WebmailError(_("Invalid request"))
    get_imapconnector(request).empty(name)
    content = "<div class='alert alert-info'>%s</div>" % _("Empty mailbox")
    return ajax_simple_response(dict(
            status="ok", listing=content, mailbox=name
            ))
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:8,代码来源:views.py


示例6: extra_js

def extra_js(user):
    return [
        """function autoreply_cb() {
    $('#id_untildate').datepicker({format: 'yyyy-mm-dd', language: '%s'});
}
"""
        % parameters.get_user(user, "LANG", app="core")
    ]
开发者ID:simonkern,项目名称:modoboa,代码行数:8,代码来源:__init__.py


示例7: getmboxes

    def getmboxes(
            self, user, topmailbox='', until_mailbox=None,
            unseen_messages=True):
        """Returns a list of mailboxes for a particular user

        By default, only the first level of mailboxes under
        ``topmailbox`` is returned. If ``until_mailbox`` is specified,
        all levels needed to access this mailbox will be returned.

        :param user: a ``User`` instance
        :param topmailbox: the mailbox where to start in the tree
        :param until_mailbox: the deepest needed mailbox
        :param unseen_messages: include unseen messages counters or not
        :return: a list
        """
        if topmailbox:
            md_mailboxes = []
        else:
            md_mailboxes = [
                {"name": "INBOX", "class": "fa fa-inbox"},
                {"name": parameters.get_user(user, "DRAFTS_FOLDER"),
                 "class": "fa fa-file"},
                {"name": 'Junk', "class": "fa fa-fire"},
                {"name": parameters.get_user(user, "SENT_FOLDER"),
                 "class": "fa fa-envelope"},
                {"name": parameters.get_user(user, "TRASH_FOLDER"),
                 "class": "fa fa-trash"}
            ]
        if until_mailbox:
            name, parent = separate_mailbox(until_mailbox, self.hdelimiter)
            if parent:
                until_mailbox = parent
        self._listmboxes(topmailbox, md_mailboxes, until_mailbox)

        if unseen_messages:
            for mb in md_mailboxes:
                if "send_status" not in mb:
                    continue
                del mb["send_status"]
                key = "path" if "path" in mb else "name"
                if not mb.get("removed", False):
                    count = self.unseen_messages(mb[key])
                if count == 0:
                    continue
                mb["unseen"] = count
        return md_mailboxes
开发者ID:digideskio,项目名称:modoboa-webmail,代码行数:46,代码来源:imaputils.py


示例8: empty

def empty(request, name):
    if name != parameters.get_user(request.user, "TRASH_FOLDER"):
        raise BadRequest(_("Invalid request"))
    get_imapconnector(request).empty(name)
    content = "<div class='alert alert-info'>%s</div>" % _("Empty mailbox")
    return render_to_json_response({
        'listing': content, 'mailbox': name
    })
开发者ID:eignatov,项目名称:modoboa,代码行数:8,代码来源:views.py


示例9: getfs

def getfs(request, name):
    sc = SieveClient(user=request.user.username, password=request.session["password"])
    editormode = parameters.get_user(request.user, "EDITOR_MODE")
    error = None
    try:
        content = sc.getscript(name, format=editormode)
    except SieveClientError, e:
        error = str(e)
开发者ID:JHei,项目名称:modoboa,代码行数:8,代码来源:views.py


示例10: extra_js

def extra_js(user):
    return ["""function autoreply_cb() {
    $('.datefield').datetimepicker({
        format: 'YYYY-MM-DD hh:mm:ss',
        language: '%(lang)s'
    });
}
""" % {'lang': parameters.get_user(user, "LANG", app="core")}
    ]
开发者ID:kaxdev,项目名称:modoboa,代码行数:9,代码来源:general_callbacks.py


示例11: delete

def delete(request):
    mbox = request.GET.get("mbox", None)
    mailid = request.GET.get("mailid", None)
    if mbox is None or mailid is None:
        raise WebmailError(_("Invalid request"))
    mbc = get_imapconnector(request)
    mbc.move(mailid, mbox, parameters.get_user(request.user, "TRASH_FOLDER"))
    resp = dict(status="ok")
    return ajax_simple_response(resp)
开发者ID:juju2013,项目名称:modoboa,代码行数:9,代码来源:views.py


示例12: empty

def empty(request):
    """Empty the trash folder."""
    name = request.GET.get("name", None)
    if name != parameters.get_user(request.user, "TRASH_FOLDER"):
        raise BadRequest(_("Invalid request"))
    get_imapconnector(request).empty(name)
    content = "<div class='alert alert-info'>%s</div>" % _("Empty mailbox")
    return render_to_json_response({
        'listing': content, 'mailbox': name, 'pages': [1]
    })
开发者ID:kaxdev,项目名称:modoboa,代码行数:10,代码来源:views.py


示例13: _listing

def _listing(request):
    flt = None
    rcptfilter = None
    msgs = None

    if not request.user.is_superuser and request.user.group != 'SimpleUsers':
        if not Domain.objects.get_for_admin(request.user).count():
            return empty_quarantine(request)

    order = request.GET.get("order", "-date")
    if not "navparams" in request.session:
        request.session["navparams"] = {}
    request.session["navparams"]["order"] = order

    parse_search_parameters(request)
    if "pattern" in request.session:
        criteria = request.session["criteria"]
        if criteria == "both":
            criteria = "from_addr,subject,to"
        for c in criteria.split(","):
            if c == "from_addr":
                nfilter = Q(mail__from_addr__contains=request.session["pattern"])
            elif c == "subject":
                nfilter = Q(mail__subject__contains=request.session["pattern"])
            elif c == "to":
                rcptfilter = request.session["pattern"]
                continue
            else:
                raise Exception("unsupported search criteria %s" % c)
            flt = nfilter if flt is None else flt | nfilter

    msgs = get_wrapper().get_mails(request, rcptfilter)

    if "page" in request.GET:
        request.session["page"] = request.GET["page"]
        pageid = int(request.session["page"])
    else:
        if "page" in request.session:
            del request.session["page"]
        pageid = 1

    lst = SQLlisting(
        request.user, msgs, flt,
        navparams=request.session["navparams"],
        elems_per_page=int(parameters.get_user(request.user, "MESSAGES_PER_PAGE"))
    )
    page = lst.paginator.getpage(pageid)
    if not page:
        return empty_quarantine(request)

    content = lst.fetch(request, page.id_start, page.id_stop)
    navbar = lst.render_navbar(page, "listing/?")
    ctx = getctx("ok", listing=content, navbar=navbar,
                 menu=quar_menu(request.user))
    return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
开发者ID:schiiz1,项目名称:modoboa,代码行数:55,代码来源:views.py


示例14: delete

def delete(request):
    mbox = request.GET.get("mbox", None)
    selection = request.GET.getlist("selection[]", None)
    if mbox is None or selection is None:
        raise BadRequest(_("Invalid request"))
    selection = [item for item in selection if item.isdigit()]
    mbc = get_imapconnector(request)
    mbc.move(",".join(selection), mbox, parameters.get_user(request.user, "TRASH_FOLDER"))
    count = len(selection)
    message = ungettext("%(count)d message deleted", "%(count)d messages deleted", count) % {"count": count}
    return render_to_json_response(message)
开发者ID:jmfield2,项目名称:modoboa,代码行数:11,代码来源:views.py


示例15: msg

 def msg(self):
     """
     """
     if self._msg is None:
         self._msg = self.imapc.fetchmail(self.mbox, self.mailid, readonly=False, headers=self.headers_as_list)
         self.bs = BodyStructure(self._msg["BODYSTRUCTURE"])
         self._find_attachments()
         if not self.dformat in ["plain", "html"]:
             self.dformat = parameters.get_user(self.request.user, self.dformat)
         fallback_fmt = "html" if self.dformat == "plain" else "plain"
         self.mformat = self.dformat if self.dformat in self.bs.contents else fallback_fmt
     return self._msg
开发者ID:JHei,项目名称:modoboa,代码行数:12,代码来源:imapemail.py


示例16: extra_js

def extra_js(user):
    return ["""function autoreply_cb() {
    $('.datefield').datetimepicker({
        format: 'yyyy-mm-dd hh:ii:ss',
        language: '%(lang)s',
        autoclose: true,
        todayHighlight: true,
        todayBtn: 'linked'
    });
}
""" % {'lang': parameters.get_user(user, "LANG", app="core")}
    ]
开发者ID:JHei,项目名称:modoboa,代码行数:12,代码来源:general_callbacks.py


示例17: dologin

def dologin(request):
    error = None
    if request.method == "POST":
        form = LoginForm(request.POST)
        if form.is_valid():
            logger = logging.getLogger("modoboa.auth")
            user = authenticate(username=form.cleaned_data["username"], password=form.cleaned_data["password"])
            if user and user.is_active:
                login(request, user)
                if not form.cleaned_data["rememberme"]:
                    request.session.set_expiry(0)
                if request.user.has_mailbox:
                    request.session["password"] = encrypt(form.cleaned_data["password"])

                request.session["django_language"] = parameters.get_user(request.user, "LANG", app="general")

                logger.info(_("User '%s' successfully logged in" % user.username))
                events.raiseEvent("UserLogin", request, form.cleaned_data["username"], form.cleaned_data["password"])

                nextlocation = request.POST.get("next", None)
                if nextlocation is None or nextlocation == "None":
                    if user.group == "SimpleUsers":
                        nextlocation = reverse("modoboa.lib.webutils.topredirection")
                    else:
                        nextlocation = reverse("domains")
                return HttpResponseRedirect(nextlocation)
            error = _("Your username and password didn't match. Please try again.")
            logger.warning(
                "Failed connection attempt from '%(addr)s' as user '%(user)s'"
                % {"addr": request.META["REMOTE_ADDR"], "user": form.cleaned_data["username"]}
            )

        nextlocation = request.POST.get("next", None)
        httpcode = 401
    else:
        form = LoginForm()
        nextlocation = request.GET.get("next", None)
        httpcode = 200

    return HttpResponse(
        _render_to_string(
            request,
            "registration/login.html",
            {
                "form": form,
                "error": error,
                "next": nextlocation,
                "annoucements": events.raiseQueryEvent("GetAnnouncement", "loginpage"),
            },
        ),
        status=httpcode,
    )
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:52,代码来源:views.py


示例18: _listing

def _listing(request):
    flt = None
    rcptfilter = None
    msgs = None

    if not request.user.is_superuser and request.user.group != 'SimpleUsers':
        if not Domain.objects.get_for_admin(request.user).count():
            return empty_quarantine(request)

    navparams = QuarantineNavigationParameters(request)
    navparams.store()
    pattern = navparams.get('pattern', '')
    if pattern:
        criteria = navparams.get('criteria')
        if criteria == "both":
            criteria = "from_addr,subject,to"
        for c in criteria.split(","):
            if c == "from_addr":
                nfilter = Q(mail__from_addr__contains=pattern)
            elif c == "subject":
                nfilter = Q(mail__subject__contains=pattern)
            elif c == "to":
                rcptfilter = pattern
                continue
            else:
                raise BadRequest("unsupported search criteria %s" % c)
            flt = nfilter if flt is None else flt | nfilter

    msgtype = navparams.get('msgtype', None)
    if msgtype is not None:
        nfilter = Q(mail__msgrcpt__content=msgtype)
        flt = flt | nfilter if flt is not None else nfilter

    msgs = get_wrapper().get_mails(request, rcptfilter)
    page = navparams.get('page')
    lst = SQLlisting(
        request.user, msgs, flt,
        navparams=request.session["quarantine_navparams"],
        elems_per_page=int(parameters.get_user(request.user, "MESSAGES_PER_PAGE"))
    )
    page = lst.paginator.getpage(page)
    if not page:
        return empty_quarantine(request)

    content = lst.fetch(request, page.id_start, page.id_stop)
    ctx = getctx(
        "ok", listing=content, paginbar=pagination_bar(page), page=page.number
    )
    if request.session.get('location', 'listing') != 'listing':
        ctx['menu'] = quar_menu()
    request.session['location'] = 'listing'
    return render_to_json_response(ctx)
开发者ID:Marx86,项目名称:modoboa,代码行数:52,代码来源:views.py


示例19: _build_msg

    def _build_msg(self, request):
        """Convert form's content to a MIME message.
        """
        editormode = parameters.get_user(request.user, "EDITOR")
        msg = getattr(self, "_%s_msg" % editormode)()

        if request.session["compose_mail"]["attachments"]:
            wrapper = MIMEMultipart(_subtype="mixed")
            wrapper.attach(msg)
            for attdef in request.session["compose_mail"]["attachments"]:
                wrapper.attach(create_mail_attachment(attdef))
            msg = wrapper
        return msg
开发者ID:JHei,项目名称:modoboa,代码行数:13,代码来源:forms.py


示例20: delete

def delete(request):
    mbox = request.GET.get("mbox", None)
    selection = request.GET.getlist("selection[]", None)
    if mbox is None or selection is None:
        raise WebmailError(_("Invalid request"))
    selection = [item for item in selection if item.isdigit()]
    mbc = get_imapconnector(request)
    mbc.move(",".join(selection), mbox, parameters.get_user(request.user, "TRASH_FOLDER"))
    count = len(selection)
    message = ungettext("%(count)d message deleted",
                        "%(count)d messages deleted",
                        count) % {"count": count}
    resp = dict(status="ok", respmsg=message)
    return ajax_simple_response(resp)
开发者ID:ricardopadilha,项目名称:modoboa,代码行数:14,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python parameters.register函数代码示例发布时间:2022-05-27
下一篇:
Python parameters.get_admin函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap