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


Python Entry.slug方法代码示例

本文整理汇总了Python中blog.models.Entry.slug方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.slug方法的具体用法?Python Entry.slug怎么用?Python Entry.slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在blog.models.Entry的用法示例。


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

示例1: create

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import slug [as 别名]
	def create(self, form):
		entry = Entry(parent=Service.to_key(form.category.data))
		entry.title = form.title.data
		entry.summary = form.summary.data
		entry.post = form.post.data
		entry.tags = [Key(urlsafe=tag) for tag in form.tags.data]
		entry.slug = Service.slugify(entry.title)
		# entry.user = users.get_current_user()
		return entry.put()
开发者ID:stretchhog,项目名称:stretchhog,代码行数:11,代码来源:entry_service.py

示例2: create_entry

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import slug [as 别名]
def create_entry(**kwargs):
    defaults = {
        "title": "Test entry1",
        "body": "Entry body",
        "keywords": "test, entry",
        # 'categories': self.create_category(),
    }
    defaults.update(kwargs)
    entry = Entry(**defaults)
    entry.slug = slugify(entry.title)
    entry.save()
    category = create_category()
    entry.categories.add(category)
    return entry
开发者ID:aleosd,项目名称:sw_mon,代码行数:16,代码来源:test_views.py

示例3: metaWeblog_newPost

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import slug [as 别名]
def metaWeblog_newPost(blogid, username, password, struct, publish):
    user = User.objects.get(username__exact=username)
    if struct.has_key('title') and struct.has_key('description'):
        post = Entry(title=struct['title'],content = struct['description'])
        post.author=user
        if struct.has_key('categories'):
            catename = struct['categories'][0]
            cate=Category.objects.get(name__exact=catename)
            post.category=cate
        else:
            post.category_id=1
        if struct.has_key('mt_keywords'):
            post.tags=struct['mt_keywords']
        if struct.has_key('wp_slug'):
            post.slug=struct['wp_slug']
        post.save(True)
    return ""
开发者ID:Spoylerman,项目名称:libaoyinblog,代码行数:19,代码来源:rpc.py

示例4: init_data

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import slug [as 别名]
def init_data(**kwargs):
    link=Link(text="dengmin's blog",href="http://www.iyouf.info")
    link.save()
    
    default_cate=Category(name=u'未分类',slug='default',desc=u'未分类')
    default_cate.save()
    
    entry=Entry(title='Hello World!',content='<b>Hello World, welcome to use youflog! thank you!</a>',tags='youflog')
    entry.allow_comment=True
    entry.slug='hello-world'
    entry.category=default_cate
    entry.author_id=1
    entry.save(True)
    
    comment=Comment(author='admin',email='[email protected]',weburl='http://iyouf.info',content=u'测试第一条评论')
    comment.content_object=entry
    comment.save()
开发者ID:Spoylerman,项目名称:libaoyinblog,代码行数:19,代码来源:management.py

示例5: load

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import slug [as 别名]
def load():
    """
    Load a series of markdown and yaml files from content folders. YAML is for
    blogpost metadata and markdown files are blogpost content.
    """
    # Clearout the old db
    # FIXME: this should check itself before it deletes things.
    old_entries = Entry.objects.all()
    old_entries.delete()

    # Recreate the content of the db
    years = ['02011'] # only one year of content for now, append later
    # TODO: use this in a blog-wide yaml config file, can generate 1996-2010(c)
    for year in years:
        folder = './content/blog/' + year + '/'
        files = set([os.path.splitext(f)[0] for f in os.listdir(folder)])
        for file in files:
            meta_file   = open(folder + file + '.yaml', 'r')
            metadata    = yaml.load(meta_file)
            meta_file.close()

            post_file   = open(folder + file + '.md', 'r')
            post        = post_file.read()
            post_file.close()

            e = Entry()
            # TODO: implement django-tagging here
            # Metadata
            e.title     = metadata['title']
            e.slug      = slugify(metadata['title'])
            e.pub_date  = metadata['pub_date']
            e.published = metadata['published']
            # Post
            e.body      = post
            e.snip      = post[:139]            # 140 characters of fun
            e.save()
    pass
开发者ID:sethwoodworth,项目名称:blogish,代码行数:39,代码来源:views.py

示例6: post

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import slug [as 别名]
    def post(self):
        self.response.out.write('<html><body>You wrote:<pre>')
        key = self.request.get('id_key')
        title = self.request.get('title')
        slug = str(slugify(title))
        item_type = self.request.get('item_type')
        tag_list = None


        if item_type == "entry":
            content = self.request.get('content')
            genre = self.request.get('genre')
            enable_comments = self.request.get('enable_comments')
            country = self.request.get('country')
            core_topic = self.request.get('core_topic')
            tags = self.request.get('tags')
            private = self.request.get('private')
            publish_date = self.request.get('publish_date')
 
            if publish_date:
                publish_date = datetime.strptime(publish_date, '%Y-%m-%d').date()
            else:
                publish_date = datetime.today().date()
                
            if genre == "blog":
                country_obj = Country.get(country)
            else:
                country_obj = None

            if key:
                entry = Entry.get(key)
            else:
                entry = Entry()
            entry.title = title
            entry.slug = slug
            entry.content = content
            entry.genre = genre
            entry.country = country_obj
            entry.publish_date = publish_date
            if len(core_topic):
                entry.core_topic = core_topic
            if private == "on":
                b = bool("1")
            else:
                b = bool("")
            entry.private = b
            entry.put()

            if len(tags) > 0:
                tag_list = shlex.split(str(tags))
                if tag_list:
                  for tag in tag_list:
                      tag_obj = Tag.get_or_insert(str(tag))
                      if tag_obj.name == None:
                          tag_obj.name = str(tag)
                          tag_obj.put()
                      entry.tags.append(tag_obj.key())
                  entry.put()
        else:
            map_url = self.request.get('map_url')
            if key:
                country = Country.get(key)
            else:
                country = Country()
            country.title = title
            country.slug = slug
            country.map_url = map_url
            country.put()

        self.response.out.write(str("Key: %s<br />" % key))
        self.response.out.write(str("Title: %s<br />" % title))
        self.response.out.write(str("Slug: %s<br />" % slug))
        self.response.out.write(str("Type: %s<br />" % item_type))
        if tag_list:
          self.response.out.write(str("Tags: %s<br />" % tags))
       
        self.response.out.write('</pre></body></html>')
开发者ID:kelvinn,项目名称:gae-demo-blog,代码行数:79,代码来源:admin.py

示例7: POST

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import slug [as 别名]
    def POST(self,slug='post'):
        action=self.param("action")
        title=self.param("post_title")
        content=self.param('content')
        tags=self.param("tags")
        cats=self.request.get_all('cats')
        key=self.param('key')
        if self.param('publish')!='':
            published=True
        elif self.param('unpublish')!='':
            published=False
        else:
            published=self.param('published')=='True'

        allow_comment=self.parambool('allow_comment')
        allow_trackback=self.parambool('allow_trackback')
        entry_slug=self.param('slug')
        entry_parent=self.paramint('entry_parent')
        menu_order=self.paramint('menu_order')
        entry_excerpt=self.param('excerpt').replace('\n','<br />')
        password=self.param('password')
        sticky=self.parambool('sticky')

        is_external_page=self.parambool('is_external_page')
        target=self.param('target')
        external_page_address=self.param('external_page_address')

        def mapit(cat):
            return {'name':cat.name,'slug':cat.slug,'select':cat.slug in cats}

        vals={'action':action,'postback':True,'cats':Category.all(),'entrytype':slug,
              'cats':map(mapit,Category.all()),
              'entry':{ 'title':title,'content':content,'strtags':tags,'key':key,'published':published,
                         'allow_comment':allow_comment,
                         'allow_trackback':allow_trackback,
                        'slug':entry_slug,
                        'entry_parent':entry_parent,
                        'excerpt':entry_excerpt,
                        'menu_order':menu_order,
                        'is_external_page':is_external_page,
                        'target':target,
                        'external_page_address':external_page_address,
                        'password':password,
                        'sticky':sticky}
              }

        if not (title and (content or (is_external_page and external_page_address))):
            vals.update({'result':False, 'msg':_('Please input title and content.')})
            self.render2('views/admin/entry.html',vals)
        else:
            if action=='add':
                entry= Entry(title=title,content=content)
                entry.settags(tags)
                entry.entrytype=slug
                entry.slug=entry_slug.replace(" ","-")
                entry.entry_parent=entry_parent
                entry.menu_order=menu_order
                entry.excerpt=entry_excerpt
                entry.is_external_page=is_external_page
                entry.target=target
                entry.external_page_address=external_page_address
                newcates=[]
                entry.allow_comment=allow_comment
                entry.allow_trackback=allow_trackback
                entry.author=self.author.user
                entry.author_name=self.author.dispname
                entry.password=password
                entry.sticky=sticky
                if cats:

                    for cate in cats:
                        c=Category.all().filter('slug =',cate)
                        if c:
                            newcates.append(c[0].key())
                entry.categorie_keys=newcates;

                entry.save(published)
                if published:
                    smsg=_('Saved ok. <a href="/blog/%(link)s" target="_blank">View it now!</a>')
                else:
                    smsg=_('Saved ok.')

                vals.update({'action':'edit','result':True,'msg':smsg%{'link':str(entry.link)},'entry':entry})
                self.render2('views/admin/entry.html',vals)
                if published and entry.allow_trackback and self.blog.allow_pingback:
                    try:
                        autoPingback(str(entry.fullurl),HTML=content)
                    except:
                        pass
            elif action=='edit':
                #try:
                if 1:
                    entry=Entry.get(key)
                    entry.title=title
                    entry.content=content
                    entry.slug=entry_slug.replace(' ','-')
                    entry.entry_parent=entry_parent
                    entry.menu_order=menu_order
                    entry.excerpt=entry_excerpt
                    entry.is_external_page=is_external_page
#.........这里部分代码省略.........
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:103,代码来源:views.py

示例8: submit_post

# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import slug [as 别名]
def submit_post(request):
    published=False
    if request.method == 'POST':
        title = request.POST['title']
        content=request.POST.get('content','')
        excerpt = request.POST.get('excerpt','')
        category_id = request.POST.get("category",1)
        tags = request.POST.get('tags','')
        slug=request.POST.get('slug','')
        allow_comment = request.POST.get('allow_comment',False)
        allow_pingback = request.POST.get('allow_pingback',False)
        action=request.POST.get('action','')
        posttype=request.POST.get('posttype','post')
        sticky=request.POST.get('sticky',False)
        
        sticky= True and sticky=='sticky'
        allow_comment= True and allow_comment == 'open'
        allow_pingback= True and allow_pingback == 'open'
        
        if request.POST.get('publish'):
            published = True
        elif request.POST.get('unpublish'):
            published = False
        else:
            published = request.POST.get('published')=='True'
        
        
        category=Category.objects.get(id=int(category_id))
        
        ctx={'action':action}
        
        if not (title and content):
            ctx.update({'msg':'Please input title and content.'})
            return render_response(request,"admin/post.html",ctx)
        
        if action== 'add':
            entry = Entry(title=title,content=content,excerpt=excerpt,\
                          category=category,slug=slug.replace(" ","-"))
            entry.tags=tags
            entry.allow_comment=allow_comment
            entry.allow_pingback=allow_pingback
            entry.entrytype=posttype
            entry.sticky=sticky
            entry.author=request.user
            if posttype and posttype =='page':
                menu_order=request.POST.get('order',0)
                if menu_order:
                    entry.menu_order=menu_order 
            
            entry.date=datetime.now()
            entry.save(published)
            
            def mapcategoy(cat):
                return  {"id":cat.id,"name":cat.name,\
                         "slug":cat.slug,"select":cat.id == int(category_id)}
            
            ctx.update({'action':'edit','entry':entry,\
                        'entrytype':posttype,'cats':map(mapcategoy,Category.objects.all())})
            
        elif action== 'edit':
            postid = request.POST.get('postid','')
            if postid:
                entry = Entry.objects.get(id=postid)
                entry.tags=tags
                entry.title=title
                entry.content=content
                entry.excerpt=excerpt
                entry.slug=slug.replace(" ","-")
                entry.entrytype=posttype
                entry.sticky=sticky
                entry.category=category
                entry.allow_pingback=allow_pingback
                if posttype and posttype =='page':
                    menu_order=request.POST.get('order',0)
                    entry.menu_order=menu_order
                entry.allow_comment=allow_comment
                entry.save(published)
                def mapcategoy(cat):
                    return  {"id":cat.id,"name":cat.name,"slug":cat.slug,"select":cat.id == entry.category.id}
    
                ctx.update({'action':'edit','entry':entry,\
                    'entrytype':posttype,'cats':map(mapcategoy,Category.objects.all())})
        else:
            pass
        
    return render_response(request,"admin/post.html",ctx)
开发者ID:zhigoo,项目名称:youflog,代码行数:88,代码来源:admin.py


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