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


Python sphutils.get_sph_setting函数代码示例

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


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


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