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

Python sphutils.get_sph_setting函数代码示例

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

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



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

示例1: _get_markup_choices

def _get_markup_choices():
    choices = []
    classes = {}

    enabled_markup = get_sph_setting('board_markup_enabled', ('bbcode',))
    custom_markup = get_sph_setting('board_custom_markup', {})

    for en in enabled_markup:
        try:
            renderclass = AVAILABLE_MARKUP[en]
        except KeyError:
            try:
                renderer = custom_markup[en]
            except KeyError:
                raise exceptions.ImproperlyConfigured(
                    _(u"Custom renderer '%(renderer)s' needs a matching Render \
Class entry in your sphene settings 'board_custom_markup'") \
                    % {'renderer': en})
            renderclass = get_method_by_name(renderer)

        classes[en] = renderclass

        choices.append((en, renderclass.label))

    return tuple(choices), classes
开发者ID:hpoul,项目名称:sct-communitytools,代码行数:25,代码来源:renderers.py


示例2: sph_markdown

def sph_markdown(value, arg='', oldmd=None, extra_macros={}):
    try:
        from sphene.contrib.libs.markdown import markdown
    except ImportError:
        if settings.DEBUG:
            raise template.TemplateSyntaxError, "Error in {% markdown %} filter: The Python markdown library isn't installed."
        return value
    else:
        safe_mode = arg == 'safe'
        macros = { 'helloWorld': SimpleHelloWorldMacro(),
                   'news': NewsMacro(),
                   'newsrss': NewsRSSLinkMacro(),
                   'include': IncludeMacro(),
                   'includetemplate': IncludeTemplateMacro(),
                   }
        macros.update(extra_macros),
        md = markdown.Markdown(value,
                               extensions = [ 'footnotes', 'wikilink', 'macros', 'toc' ],
                               extension_configs = { 'wikilink': [ ],
                                                     'macros': [ ( 'macros', macros
                                                                 )
                                                               ],
                                                     'toc': { 'include_header_one_in_toc': True, },
                                                     },
                               safe_mode = safe_mode,
                                 )
        md.number_headings = get_sph_setting('markdown_number_headings', True)
        md.top_heading_level = get_sph_setting('markdown_top_heading_level', 1)
        if oldmd and hasattr(oldmd,'header_numbers'): md.header_numbers = oldmd.header_numbers
        ret = md.toString()
        if hasattr(md, 'tocDiv'):
            sphdata = get_current_sphdata()
            sphdata['toc'] = mark_safe( md.tocDiv.toxml() )
        return ret
开发者ID:pigletto,项目名称:sct-communitytools,代码行数:34,代码来源:sph_extras.py


示例3: clean_community_advprofile_avatar

def clean_community_advprofile_avatar(self):
    f = self.cleaned_data['community_advprofile_avatar']
    if f is None:
        return f

    # Verify file size ..
    size = len(self.cleaned_data['community_advprofile_avatar'])
    max_size = get_sph_setting( 'community_avatar_max_size' )
    if size > max_size:
        raise djangoforms.ValidationError( _(u"Max upload filesize of %(max_size)d bytes exceeded. (Your file had %(size)d bytes)") % {'max_size':max_size, 'size':size} )

    from PIL import Image
    from cStringIO import StringIO

    try:
        # Verify image dimensions ..
        image = Image.open(f)
        width = image.size[0]
        height = image.size[1]

        f.seek(-f.tell())

        max_width = get_sph_setting( 'community_avatar_max_width' )
        max_height = get_sph_setting( 'community_avatar_max_height' )

        if width > max_width or height > max_height:
            raise djangoforms.ValidationError( "Max size of %dx%d exceeded (Your upload was %dx%d)" % (max_width, max_height, width, height) )
        
    except IOError:
        raise ValidationError( _(u"Uploaded an invalid image.") )
    
    return f
开发者ID:sunilpatelmca,项目名称:dishnine,代码行数:32,代码来源:__init__.py


示例4: community_advprofile_display

def community_advprofile_display(sender, signal, request, user, **kwargs):
    try:
        profile = CommunityUserProfile.objects.get(user=user)
    except CommunityUserProfile.DoesNotExist:
        return None

    avatar = None
    avatar_width = None
    avatar_height = None
    if not profile.avatar:
        default_avatar = get_sph_setting("community_avatar_default")
        if not default_avatar:
            return None
        avatar = default_avatar
        avatar_width = get_sph_setting("community_avatar_default_width")
        avatar_height = get_sph_setting("community_avatar_default_height")
    else:
        avatar = profile.avatar.url
        avatar_width = profile.avatar_width
        avatar_height = profile.avatar_height

    ret = ""

    ret = '<tr><th>%s</th><td><img src="%s" width="%dpx" height="%dpx" alt="%s"></img></td></tr>' % (
        _(u"Avatar"),
        avatar,
        avatar_width,
        avatar_height,
        _(u"Users avatar"),
    )

    return ret
开发者ID:eviljoel,项目名称:BARcamp-Chicago-Website,代码行数:32,代码来源:__init__.py


示例5: sph_showavatar

def sph_showavatar(user, maxwidth = None):
    profile = None
    try:
        profile = CommunityUserProfile.objects.get( user = user, )
    except CommunityUserProfile.DoesNotExist:
        pass
    
    avatar = None
    avatar_width = None
    avatar_height = None
    if not profile or not profile.avatar:
        avatar = get_sph_setting( 'community_avatar_default' )
        log.error("got default avatar: %s", avatar)
        if not avatar:
            return ''
        avatar_width = get_sph_setting( 'community_avatar_default_width' )
        avatar_height = get_sph_setting( 'community_avatar_default_height' )
    else:
        avatar = profile.avatar.url
        avatar_width = profile.avatar_width
        avatar_height = profile.avatar_height
    
    if maxwidth is not None and maxwidth < avatar_width:
        avatar_height = round(float(avatar_height) * (float(maxwidth) / avatar_width))
        avatar_width = maxwidth
        
    log.info("avatar: %s", avatar)
    return '<img src="%s" width="%dpx" height="%dpx" alt="%s" class="sph_avatar"></img>' % (avatar, avatar_width, avatar_height, _(u'Users avatar'))
开发者ID:ShaastraWebops,项目名称:Shaastra-2011-Website,代码行数:28,代码来源:sph_extras.py


示例6: sph_publicemailaddress

def sph_publicemailaddress(value):
    if get_sph_setting('community_email_anonymous_require_captcha'):
        # as a security constraint we don't return the public email
        # address if the user is not logged in.
        if not get_current_user().is_authenticated:
            validated = get_current_request().session.get('sph_email_captcha_validated', 0)

            # if the timeout is reached or the captcha was never entered
            # provide a link for the user to enter the captcha.
            if validated < time() - get_sph_setting('community_email_anonymous_require_captcha_timeout'):
                return mark_safe('<a href="%s">%s</a>' % (
                sph_reverse('sph_reveal_emailaddress', kwargs={'user_id': value.id, }), _('Reveal this emailaddress')))

    if get_sph_setting('community_email_show_only_public'):
        try:
            return CommunityUserProfile.objects.get(user=value, ).public_emailaddress
        except CommunityUserProfile.DoesNotExist:
            pass
        return ''

    try:
        profile = CommunityUserProfile.objects.get(user=value, )
    except CommunityUserProfile.DoesNotExist:
        return "n/a"  # value.email
    return profile.public_emailaddress or value.email
开发者ID:hpoul,项目名称:sct-communitytools,代码行数:25,代码来源:sph_extras.py


示例7: attachmentEdit

def attachmentEdit(request, group, snipName, attachmentId = None):
    
    """Importing ModelForm"""
    from django.forms import ModelForm
    
    """ Class necessary for the Modelform """
    class AttachmentFormNew(ModelForm):
        class Meta:
            model = WikiAttachment
    
    attachment = None
    if attachmentId is None:
        AttachmentForm = AttachmentFormNew()
    else:
        attachment = WikiAttachment.objects.get(id=attachmentId)
        AttachmentForm = AttachmentFormNew(instance=attachment)

    if attachment:
        if not attachment.snip.has_edit_permission():
            raise PermissionDenied()
    if 'delete' in request.GET and request.GET['delete'] == '1':
        attachment.delete()
        messages.success(request,  message = ugettext("Successfully deleted attachment.") )
        return HttpResponseRedirect( attachment.snip.get_absolute_attachmenturl() )

    AttachmentForm.base_fields['fileupload'].widget = widgets.FileInput()

    if request.method == 'POST':
        if get_sph_setting( 'django096compatibility' ):
            reqdata = request.POST.copy()
            reqdata.update(request.FILES)
            form = AttachmentForm(reqdata)
        else:
            form = AttachmentFormNew(request.POST, request.FILES)
        if form.is_valid():
            attachment = form.save(commit=False)
            snip = WikiSnip.objects.get( name__exact = snipName, group = group )
            attachment.snip = snip
            attachment.uploader = request.user

            if get_sph_setting( 'django096compatibility' ):
                attachment.save_fileupload_file( reqdata['fileupload']['filename'], reqdata['fileupload']['content'] )
                
            attachment.save()
            return HttpResponseRedirect( snip.get_absolute_attachmenturl() )
    else:
        form = AttachmentFormNew(instance=attachment)

    return render_to_response( 'sphene/sphwiki/editAttachment.html',
                               { 'form': form,
                                 'snipName' : snipName,
                                 },
                               context_instance = RequestContext(request) )
开发者ID:hmm,项目名称:sct-communitytools,代码行数:53,代码来源:views.py


示例8: community_advprofile_edit_init_form

def community_advprofile_edit_init_form(sender, instance, signal, *args, **kwargs):
    user = instance.user
    try:
        profile = CommunityUserProfile.objects.get( user = user, )
    except CommunityUserProfile.DoesNotExist:
        profile = CommunityUserProfile( user = user, )

    if profile.avatar:
        instance.fields['community_advprofile_avatar_remove'] = djangoforms.BooleanField( label = _(u'Delete avatar'), required = False )

    max_width = get_sph_setting( 'community_avatar_max_width' )
    max_height = get_sph_setting( 'community_avatar_max_height' )
    instance.fields['community_advprofile_avatar'] = djangoforms.ImageField( label = _(u'Avatar'), help_text = _(u'Avatar with maximum size of %(max_width)sx%(max_height)s' % { 'max_width': max_width, 'max_height': max_height }), required = False, )
    instance.clean_community_advprofile_avatar = lambda : clean_community_advprofile_avatar(instance)
开发者ID:pigletto,项目名称:sct-communitytools,代码行数:14,代码来源:__init__.py


示例9: pdf_get_cachefile

    def pdf_get_cachefile(self):
        """ Returns the pathname to the cache file for this wiki snip. """
        if not get_sph_setting("wiki_pdf_generation", False) or not self.pdf_enabled():
            raise Exception("PDF Generation not enabled by configuration.")

        cachedir = get_sph_setting("wiki_pdf_generation_cachedir", "/tmp/sct_pdf")

        if not os.path.isdir(cachedir):
            os.mkdir(cachedir)

        filename = re.sub("[^A-Za-z0-9]", "_", self.name)
        cachefile = os.path.join(cachedir, "%s_%d.pdf" % (filename, self.id))

        return cachefile
开发者ID:eviljoel,项目名称:BARcamp-Chicago-Website,代码行数:14,代码来源:models.py


示例10: is_spammer

def is_spammer(user_id):
    from sphene.sphboard.models import UserPostCount
    user = User.objects.get(pk=user_id)
    if user.username in get_sph_setting('board_no_limits_users'):
        return False

    apply_spammer_limits = False
    try:
        upc = UserPostCount.objects.get_post_count(user, get_current_group())
    except User.DoesNotExist:
        upc = 0
    if upc < get_sph_setting('board_signature_required_post_count'):
        apply_spammer_limits = True
    return apply_spammer_limits
开发者ID:hpoul,项目名称:sct-communitytools,代码行数:14,代码来源:utils.py


示例11: showThread

def showThread(request, thread_id, group = None):
    thread = get_object_or_404(Post.objects, pk = thread_id )
    if not thread.category.has_view_permission(request.user):
        raise PermissionDenied()
    thread.viewed( request.session, request.user )

    sphdata = get_current_sphdata()
    if sphdata != None: sphdata['subtitle'] = thread.subject

    category_type = thread.category.get_category_type()
    template_name = category_type.get_show_thread_template()
    
    res =  object_list( request = request,
                        #queryset = Post.objects.filter( Q( pk = thread_id ) | Q( thread = thread ) ).order_by('postdate'),
                        queryset = thread.get_all_posts().order_by('postdate'),
                        allow_empty = True,
                        template_name = template_name,
                        extra_context = { 'thread': thread,
                                          'allowPosting': thread.allowPosting( request.user ),
                                          'postSubject': 'Re: ' + thread.subject,
                                          'category_type': category_type,
                                          },
                        template_object_name = 'post',
                        paginate_by = get_sph_setting( 'board_post_paging' ),
                        )

    res.sph_lastmodified = thread.get_latest_post().postdate
    return res
开发者ID:sunilpatelmca,项目名称:dishnine,代码行数:28,代码来源:views.py


示例12: sphboard_default_notify_me

def sphboard_default_notify_me(user):
    try:
        profile = BoardUserProfile.objects.get(user = user)
        if profile.default_notifyme_value is False:
            return False
    except BoardUserProfile.DoesNotExist:
        pass
    return get_sph_setting( 'board_default_notifyme' )
开发者ID:pigletto,项目名称:sct-communitytools,代码行数:8,代码来源:sphboard_extras.py


示例13: clean_community_advprofile_avatar

def clean_community_advprofile_avatar(self):
    f = self.cleaned_data['community_advprofile_avatar']
    if f is None:
        return f

    # Verify file size ..
    size = len(self.cleaned_data['community_advprofile_avatar'])
    max_size = get_sph_setting('community_avatar_max_size')
    if size > max_size:
        raise djangoforms.ValidationError(
            _(u"Max upload filesize of %(max_size)d bytes exceeded. (Your file had %(size)d bytes)") % {
                'max_size': max_size, 'size': size})

    try:
        from PIL import Image
    except ImportError:
        import Image

    try:
        # Verify image dimensions ..
        image = Image.open(f)
        format = image.format
        width = image.size[0]
        height = image.size[1]

        f.seek(-f.tell())

        max_width = get_sph_setting('community_avatar_max_width')
        max_height = get_sph_setting('community_avatar_max_height')

        if width > max_width or height > max_height:
            # Instead of creating a validation error, simply resize the image.
            image.thumbnail((max_width, max_height), Image.ANTIALIAS)
            from tempfile import NamedTemporaryFile
            from django.core.files.base import File
            import os
            tmpfile = NamedTemporaryFile()
            image.save(tmpfile, format=format)
            f = File(tmpfile, f.name)
            # raise djangoforms.ValidationError( "Max size of %dx%d exceeded (Your upload was %dx%d)" % (max_width, max_height, width, height) )

    except IOError as e:
        print(e)
        raise djangoforms.ValidationError(_(u"Uploaded an invalid image."))

    return f
开发者ID:hpoul,项目名称:sct-communitytools,代码行数:46,代码来源:handlers.py


示例14: sph_showavatar

def sph_showavatar(user, maxwidth=None):
    profile = None
    try:
        profile = CommunityUserProfile.objects.get(user=user, )
    except CommunityUserProfile.DoesNotExist:
        pass

    avatar = None
    avatar_width = None
    avatar_height = None

    get_avatar = get_sph_setting('community_user_get_avatar')
    if get_avatar is not None:
        avatarinfo = get_avatar(user)
        if avatarinfo is not None:
            avatar = avatarinfo['url']
            avatar_width = avatarinfo['width']
            avatar_height = avatarinfo['height']

    if avatar is None:
        if not profile or not profile.avatar:
            avatar = get_sph_setting('community_avatar_default')
            log.debug("got default avatar: %s", avatar)
            if not avatar:
                return ''
            avatar_width = get_sph_setting('community_avatar_default_width')
            avatar_height = get_sph_setting('community_avatar_default_height')
        else:
            avatar = profile.avatar.url
            avatar_width = profile.avatar_width
            avatar_height = profile.avatar_height

        if maxwidth is not None and maxwidth < avatar_width:
            avatar_height = round(float(avatar_height) * (float(maxwidth) / avatar_width))
            avatar_width = maxwidth

    log.info("avatar: %s", avatar)
    return format_html(
        '<img src="{}" width="{}px" height="{}px" alt="{}" class="sph_avatar"></img>',
        avatar, avatar_width, avatar_height, _(u'Users avatar'))
开发者ID:hpoul,项目名称:sct-communitytools,代码行数:40,代码来源:sph_extras.py


示例15: render_node_xhtml

 def render_node_xhtml(self, node):
     if len(node.children) == 0:
         return ''
     if not node.parameter is None:
         url = node.parameter.strip()
     else:
         url = node.children[0].text.strip()
     linktext = node.render_children_xhtml() #node.children[0].text.strip()
     if len(url) == 0:
         return ''
     else:
         post_link = get_sph_setting('board_post_link')
         return post_link % {'url':escape(url), 'text':linktext}
开发者ID:pigletto,项目名称:sct-communitytools,代码行数:13,代码来源:bbcode.py


示例16: get_paged_objects

def get_paged_objects(objects, page):
    paginator = Paginator(objects, get_sph_setting('blog_post_paging'))
    try:
        page = int(page)
    except ValueError:
        page = 1

    try:
        paged_objects = paginator.page(page)
    except (EmptyPage, InvalidPage):
        paged_objects = paginator.page(paginator.num_pages)

    return paged_objects
开发者ID:hmm,项目名称:sct-communitytools,代码行数:13,代码来源:views.py


示例17: pdf_generate

    def pdf_generate(self):
        """ Generates the PDF for this snip and stores it into cachedir. """
        cachefile = self.pdf_get_cachefile()
        xmlfile = cachefile + ".xhtml"

        snip_rendered_body = str(self.render())  # TODO do this in the model ? like the board post body ?
        sctpath = hasattr(settings, "LIB_PATH") and settings.LIB_PATH or "."
        # static_filepath = get_sph_setting( 'wiki_pdf_generation_static_filepath', os.path.join(sctpath, '..', 'static', 'sphene') )
        static_filepath = settings.MEDIA_ROOT
        snip_rendered_body = snip_rendered_body.replace(
            '<img src="%(media_url)s' % {"media_url": settings.STATIC_URL}, '<img src="%s/' % static_filepath
        )
        import codecs

        xmlout = codecs.open(xmlfile, mode="w", encoding="utf-8")

        xmlout.write(
            """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>%(title)s</title>
  </head>
  <body>
  <div id="header" class="pdf">
    <div class="label">%(title)s</div>
  </div>
  <div id="footer" class="pdf">
    Page
       <pdf:pagenumber />
  </div>

  """
            % {"title": self.title or self.name}
        )
        xmlout.write(snip_rendered_body)
        xmlout.write(
            """
  </body>
</html>
"""
        )

        xmlout.close()

        command = get_sph_setting("wiki_pdf_generation_command")
        os.system(command % {"srcfile": xmlfile, "destfile": cachefile})
        if not os.path.isfile(cachefile):
            raise Exception("Error while generating PDF.")
开发者ID:snavien,项目名称:sct-communitytools,代码行数:51,代码来源:models.py


示例18: handle_wikilinks_match

def handle_wikilinks_match(matchgroups):
    if matchgroups.get('urls'):
        # We matched a HTML link .. simply return the whole html code.
        return { 'label': matchgroups.get('urls') }
    if matchgroups.get('escape'):
        # CamelCase expresion was escaped ...
        return { 'label': matchgroups.get('wholeexpression') }
    snipname = matchgroups.get('camelcase') or matchgroups.get('snipname')
    label = matchgroups.get('sniplabel') or snipname.replace('_', ' ')

    cssclass = 'sph_wikilink'

    try:
        snip = WikiSnip.objects.get( group = get_current_group(),
                                     name = snipname, )
        href = snip.get_absolute_url()
    except WikiSnip.DoesNotExist:

        try:
            snip = WikiSnip( group = get_current_group(),
                            name = snipname, )
        except TypeError:
            log.error('No group found when getting wikilinks. Ignoring.')
            return { 'label' : label}

        if not snip.has_edit_permission() \
                and get_sph_setting('wiki_links_nonexistent_show_only_privileged'):
            return { 'label': label, }

        href = snip.get_absolute_editurl()
        cssclass += ' sph_nonexistent'
        if get_sph_setting( 'wiki_links_nonexistent_prefix' ):
            label = "create:"+label
    
    return { 'href': href,
             'label': label,
             'class': cssclass,
             }
开发者ID:ShaastraWebops,项目名称:Shaastra-2011-Website,代码行数:38,代码来源:wikilink_utils.py


示例19: ready

    def ready(self):
        from sphene.community.sphutils import get_sph_setting
        from sphene.community import sphsettings
        jsincludes = get_sph_setting( 'community_jsincludes', [])
        # jquery is already added by the community application.
        #jsincludes.append(settings.STATIC_URL + 'sphene/community/jquery-1.2.3.min.js')
        jsincludes.append(settings.STATIC_URL + 'sphene/community/jquery.dimensions.js')
        jsincludes.append(settings.STATIC_URL + 'sphene/community/ui.mouse.js')
        #jsincludes.append(settings.STATIC_URL + 'sphene/community/ui.draggable.js')
        jsincludes.append(settings.STATIC_URL + 'sphene/community/ui.droppable.js')
        jsincludes.append(settings.STATIC_URL + 'sphene/community/ui.sortable.js')
        jsincludes.append(settings.STATIC_URL + 'sphene/sphblockframework/blocksorting.js')

        sphsettings.set_sph_setting( 'community_jsincludes', jsincludes )
开发者ID:hpoul,项目名称:sct-communitytools,代码行数:14,代码来源:apps.py


示例20: pdf_enabled

    def pdf_enabled(self):
        """
        Checks if PDF generation is 1. enabled and 2. the current user has
        permission. (E.g. setting 'wiki_pdf_generation' to 'loggedin' would
        only allow loggedin users to view PDF versions.)
        This method is ment to be used in templates.
        """
        setting = get_sph_setting("wiki_pdf_generation")
        if setting == True:
            return True
        if setting == "loggedin":
            return get_current_user() and get_current_user().is_authenticated()
        if setting == "staff":
            return get_current_user() and get_current_user().is_authenticated() and get_current_user().is_staff

        return False
开发者ID:eviljoel,项目名称:BARcamp-Chicago-Website,代码行数:16,代码来源:models.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sphutils.sph_reverse函数代码示例发布时间:2022-05-27
下一篇:
Python middleware.get_current_group函数代码示例发布时间: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