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


Python Photo.slug方法代码示例

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


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

示例1: handle_uploaded_file

# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import slug [as 别名]
def handle_uploaded_file(f,title):
    """ """
    photo = Photo()
    photo.title = u'%s %s' % (time_slug_string(), title) 
    photo.slug = time_slug_string()
    photo.image = f
    photo.save()
    return photo    
开发者ID:codesyntax,项目名称:cssocialprofile,代码行数:10,代码来源:load_images.py

示例2: handle_uploaded_file

# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import slug [as 别名]
def handle_uploaded_file(f, author):
    photo = Photo()
    extra = PhotoExtended()
    photo.title = u"%s %s" % (author, time_slug_string())
    photo.slug = u"%s-%s" % (author, slugify(time_slug_string()))
    photo.image = f
    photo.save()
    extra.photo = photo
    extra.author = author
    extra.save()
    return photo
开发者ID:codesyntax,项目名称:bitakora,代码行数:13,代码来源:images.py

示例3: handle_url_file

# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import slug [as 别名]
def handle_url_file(url, author):
    photo = Photo()
    extra = PhotoExtended()
    photo.title = u"%s %s" % (author, time_slug_string())
    photo.slug = u"%s-%s" % (slugify(author), slugify(time_slug_string()))

    img_name = photo.slug + url[url.rfind(".") :]
    photo.image.save(img_name, ContentFile(urllib2.urlopen(url).read()))
    photo.save()
    extra.photo = photo
    extra.author = author
    extra.save()
    return photo
开发者ID:codesyntax,项目名称:bitakora,代码行数:15,代码来源:images.py

示例4: loadUrlImage

# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import slug [as 别名]
def loadUrlImage(url='', title='', tags='', format='jpg', slug=''):
    """ """
    if not url:
        url = 'http://irudiak.argazkiak.org/1d3023545b4051907e533648e66329f8_c.jpg'
        title = 'Kakalardoa'
        tags = 'test argazkiak'

    if not slug:
        slug = time_slug()

    if Photo.objects.filter(slug=slug):
        slug = time_slug_long()

    title = title[:99]
    if Photo.objects.filter(title=title):
        title = '%s %s' % (slug, title)[:90]
    
        
    image = _getUrlImage(url)

    if not image:
        return None

    photo = Photo()
    photo.title = title[:100]
    photo.tags = tags
    photo.slug = slug
    
    try:
        image_t = Image.open(ContentFile(image.read()))
        image_t = image_t.convert("RGB")
        f=StringIO()
        image_t.save(f,"JPEG")
        f.seek(0)    
    
        photo.image.save('%s.%s' % (slug,format), ContentFile(f.read()))

    except Exception, e:
        print 'Errorea irudi honekin RGB', photo.slug, e
        return photo      
开发者ID:aitzol,项目名称:gamerauntsia,代码行数:42,代码来源:images.py


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