本文整理汇总了Python中mediacore.model.Media.description方法的典型用法代码示例。如果您正苦于以下问题:Python Media.description方法的具体用法?Python Media.description怎么用?Python Media.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediacore.model.Media
的用法示例。
在下文中一共展示了Media.description方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_media_obj
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import description [as 别名]
def save_media_obj(self, name, email, title, description, tags, uploaded_file, url):
# create our media object as a status-less placeholder initially
media_obj = Media()
media_obj.author = Author(name, email)
media_obj.title = title
media_obj.slug = get_available_slug(Media, title)
media_obj.description = description
if request.settings['wording_display_administrative_notes']:
media_obj.notes = request.settings['wording_administrative_notes']
media_obj.set_tags(tags)
# Give the Media object an ID.
DBSession.add(media_obj)
DBSession.flush()
# Create a MediaFile object, add it to the media_obj, and store the file permanently.
media_file = add_new_media_file(media_obj, file=uploaded_file, url=url)
# The thumbs may have been created already by add_new_media_file
if not has_thumbs(media_obj):
create_default_thumbs_for(media_obj)
media_obj.update_status()
DBSession.flush()
return media_obj
示例2: save_media_obj
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import description [as 别名]
def save_media_obj(author_name, author_email, title, description, tags, file, url):
media = Media()
media.author = Author(author_name, author_email)
media.title = title
media.description = description
media.tags = tags
add_new_media_file(media, file=file, url=url)
DBSession.add(media)
DBSession.commit()
return media
示例3: _new_publishable_media
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import description [as 别名]
def _new_publishable_media(self, slug, name):
from datetime import datetime
from mediacore.model import Author, Media
media = Media()
media.slug = slug
media.title = name
media.subtitle = None
media.description = u"""<p>Description</p>"""
media.description_plain = u"""Description"""
media.author = Author(u'fake name', u'[email protected]')
media.publish_on = datetime.now()
media.publishable = True
media.reviewed = True
media.encoded = False
media.type = None
return media
示例4: _save_media_obj
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import description [as 别名]
def _save_media_obj(self, name, email, title, description, tags, file, url):
# create our media object as a status-less placeholder initially
media_obj = Media()
media_obj.author = Author(name, email)
media_obj.title = title
media_obj.slug = get_available_slug(Media, title)
media_obj.description = description
media_obj.notes = fetch_setting('wording_additional_notes')
media_obj.set_tags(tags)
# Create a media object, add it to the media_obj, and store the file permanently.
if file is not None:
media_file = _add_new_media_file(media_obj, file.filename, file.file)
else:
media_file = MediaFile()
url = unicode(url)
embed = parse_embed_url(url)
if embed:
media_file.type = embed['type']
media_file.container = embed['container']
media_file.embed = embed['id']
media_file.display_name = '%s ID: %s' % \
(embed['container'].capitalize(), media_file.embed)
else:
# Check for types we can play ourselves
ext = os.path.splitext(url)[1].lower()[1:]
container = guess_container_format(ext)
if container in accepted_extensions():
media_file.type = guess_media_type(container)
media_file.container = container
media_file.url = url
media_file.display_name = os.path.basename(url)
else:
# Trigger a validation error on the whole form.
raise formencode.Invalid('Please specify a URL or upload a file below.', None, None)
media_obj.files.append(media_file)
# Add the final changes.
media_obj.update_status()
DBSession.add(media_obj)
DBSession.flush()
create_default_thumbs_for(media_obj)
return media_obj
示例5: _save_media_obj
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import description [as 别名]
def _save_media_obj(self, name, email, title, description, tags, file, url):
# create our media object as a status-less placeholder initially
media_obj = Media()
media_obj.author = Author(name, email)
media_obj.title = title
media_obj.slug = get_available_slug(Media, title)
media_obj.description = description
media_obj.notes = fetch_setting('wording_additional_notes')
media_obj.set_tags(tags)
# Create a media object, add it to the media_obj, and store the file permanently.
if file is not None:
media_file = _add_new_media_file(media_obj, file.filename, file.file)
else:
# FIXME: For some reason the media.type isn't ever set to video
# during this request. On subsequent requests, when
# media_obj.update_type() is called, it is set properly.
# This isn't too serious an issue right now because
# it is called the first time a moderator goes to review
# the new media_obj.
media_file = MediaFile()
url = unicode(url)
for type, info in external_embedded_containers.iteritems():
match = info['pattern'].match(url)
if match:
media_file.type = guess_media_type(type)
media_file.container = type
media_file.embed = match.group('id')
media_file.display_name = type.capitalize() + ' ID: ' + media_file.embed
break
else:
# Trigger a validation error on the whole form.
raise formencode.Invalid('Please specify a URL or upload a file below.', None, None)
media_obj.files.append(media_file)
# Add the final changes.
media_obj.update_type()
media_obj.update_status()
DBSession.add(media_obj)
DBSession.flush()
create_default_thumbs_for(media_obj)
return media_obj
示例6: _save_media_obj
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import description [as 别名]
def _save_media_obj(self, name, email, title, description, tags, file):
# cope with anonymous posters
if name is None:
name = 'Anonymous'
# create our media object as a status-less placeholder initially
media_obj = Media()
media_obj.author = Author(name, email)
media_obj.title = title
media_obj.slug = get_available_slug(Media, title)
media_obj.description = helpers.clean_xhtml(description)
media_obj.status = 'draft,unencoded,unreviewed'
media_obj.notes = helpers.fetch_setting('wording_additional_notes')
media_obj.set_tags(tags)
# Create a media object, add it to the media_obj, and store the file permanently.
media_file = _add_new_media_file(media_obj, file.filename, file.file)
# Add the final changes.
media_obj.update_type()
media_obj.update_status()
DBSession.add(media_obj)
return media_obj
示例7: add_default_data
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import description [as 别名]
def add_default_data():
log.info('Adding default data')
settings = [
(u'email_media_uploaded', None),
(u'email_comment_posted', None),
(u'email_support_requests', None),
(u'email_send_from', u'[email protected]'),
(u'wording_user_uploads', N_(u"Upload your media using the form below. We'll review it and get back to you.")),
(u'wording_administrative_notes', None),
(u'wording_display_administrative_notes', u''),
(u'popularity_decay_exponent', u'4'),
(u'popularity_decay_lifetime', u'36'),
(u'rich_text_editor', u'tinymce'),
(u'google_analytics_uacct', u''),
(u'featured_category', u'1'),
(u'max_upload_size', u'314572800'),
(u'ftp_storage', u'false'),
(u'ftp_server', u'ftp.someserver.com'),
(u'ftp_user', u'username'),
(u'ftp_password', u'password'),
(u'ftp_upload_directory', u'media'),
(u'ftp_download_url', u'http://www.someserver.com/web/accessible/media/'),
(u'ftp_upload_integrity_retries', u'10'),
(u'akismet_key', u''),
(u'akismet_url', u''),
(u'req_comment_approval', u''),
(u'use_embed_thumbnails', u'true'),
(u'api_secret_key_required', u'true'),
(u'api_secret_key', random_string(20)),
(u'api_media_max_results', u'50'),
(u'api_tree_max_depth', u'10'),
(u'general_site_name', u'MediaCore'),
(u'general_site_title_display_order', u'prepend'),
(u'sitemaps_display', u'True'),
(u'rss_display', u'True'),
(u'vulgarity_filtered_words', u''),
(u'primary_language', u'en'),
(u'advertising_banner_html', u''),
(u'advertising_sidebar_html', u''),
(u'comments_engine', u'mediacore'),
(u'facebook_appid', u''),
]
settings.extend(appearance_settings)
for key, value in settings:
s = Setting()
s.key = key
s.value = value
DBSession.add(s)
admin_user = User()
admin_user.user_name = u'admin'
admin_user.display_name = u'Admin'
admin_user.email_address = u'[email protected]'
admin_user.password = u'admin'
DBSession.add(admin_user)
admin_group = Group(name=u'admins', display_name=u'Admins')
admin_group.users.append(admin_user)
DBSession.add(admin_group)
editor_group = Group(name=u'editors', display_name=u'Editors')
DBSession.add(editor_group)
admin_perm = Permission(name=u'admin', groups=[admin_group],
description=u'Grants access to the admin panel')
DBSession.add(admin_perm)
edit_perm = Permission(name=u'edit', groups=[admin_group, editor_group],
description=u'Grants access to edit site content')
DBSession.add(edit_perm)
category = Category(name=u'Featured', slug=u'featured')
DBSession.add(category)
category2 = Category(name=u'Instructional', slug=u'instructional')
DBSession.add(category2)
podcast = Podcast()
podcast.slug = u'hello-world'
podcast.title = u'Hello World'
podcast.subtitle = u'My very first podcast!'
podcast.description = u"""<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"""
podcast.category = u'Technology'
podcast.author = Author(admin_user.display_name, admin_user.email_address)
podcast.explicit = None
podcast.copyright = u'Copyright 2009 Xyz'
podcast.itunes_url = None
podcast.feedburner_url = None
DBSession.add(podcast)
comment = Comment()
comment.subject = u'Re: New Media'
comment.author = AuthorWithIP(name=u'John Doe', ip=2130706433)
comment.body = u'<p>Hello to you too!</p>'
DBSession.add(comment)
media = Media()
media.type = None
#.........这里部分代码省略.........
示例8: media_from_entry
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import description [as 别名]
def media_from_entry(e, tags=False, save_files=False):
# Get tags as a list of unicode objects.
tags = [t['term'] for t in e['tags']]
# Assume not explicit.
explicit = 0
if 'itunes_explicit' in e:
explicit = e['itunes_explicit']
# Find the duration, if it exists
duration = u''
if 'itunes_duration' in e:
try:
duration = e['itunes_duration']
duration = duration_to_seconds(duration)
except ValueError:
duration = None
# Find the first <img> tag in the summary, if there is one
image = None
m = img_regex.match(e['summary'])
if m is not None:
image = m.group(1)[1:-1]
title = e['title']
slug = slugify(title)
author_name = u"PLACEHOLDER NAME"
author_email = u"[email protected]"
if 'author_detail' in e:
if 'name' in e['author_detail']:
author_name = e['author_detail']['name']
if 'email' in e['author_detail']:
author_email = e['author_detail']['email']
year, month, day, hour, minute, second = e['updated_parsed'][:6]
updated = datetime(year, month, day, hour, minute, second)
media = Media()
media.slug = get_available_slug(Media, slug, media)
media.title = e['title']
media.author = Author(author_name, author_email)
media.description = e['summary']
media.notes = u''
if tags:
media.set_tags(tags)
else:
media.set_categories(tags)
media.publish_on = updated
media.created_on = updated
media.publishable = True
media.reviewed = True
media.duration = duration
DBSession.add(media)
DBSession.flush()
# Create thumbs from image, or default thumbs
created_images = False
if image:
temp_imagefile = tempfile.TemporaryFile()
imagefile = urllib2.urlopen(image)
temp_imagefile.write(imagefile.read())
temp_imagefile.seek(0)
filename = urlparse.urlparse(image)[2]
create_thumbs_for(media, temp_imagefile, filename)
created_images = True
if not created_images:
create_default_thumbs_for(media)
print "Loaded episode:", media
# now add all of the files.
for enc in e['enclosures']:
mf = media_file_from_enclosure(enc, media, save_files)
print "Loaded media file:", mf
media.update_status()
return media
示例9: add_default_data
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import description [as 别名]
def add_default_data():
log.info("Adding default data")
settings = [
(u"email_media_uploaded", None),
(u"email_comment_posted", None),
(u"email_support_requests", None),
(u"email_send_from", u"[email protected]"),
(u"wording_user_uploads", N_(u"Upload your media using the form below. We'll review it and get back to you.")),
(u"wording_administrative_notes", None),
(u"wording_display_administrative_notes", u""),
(u"popularity_decay_exponent", u"4"),
(u"popularity_decay_lifetime", u"36"),
(u"rich_text_editor", u"tinymce"),
(u"google_analytics_uacct", u""),
(u"featured_category", u"1"),
(u"max_upload_size", u"314572800"),
(u"ftp_storage", u"false"),
(u"ftp_server", u"ftp.someserver.com"),
(u"ftp_user", u"username"),
(u"ftp_password", u"password"),
(u"ftp_upload_directory", u"media"),
(u"ftp_download_url", u"http://www.someserver.com/web/accessible/media/"),
(u"ftp_upload_integrity_retries", u"10"),
(u"akismet_key", u""),
(u"akismet_url", u""),
(u"req_comment_approval", u""),
(u"use_embed_thumbnails", u"true"),
(u"api_secret_key_required", u"true"),
(u"api_secret_key", random_string(20)),
(u"api_media_max_results", u"50"),
(u"api_tree_max_depth", u"10"),
(u"general_site_name", u"MediaCore"),
(u"general_site_title_display_order", u"prepend"),
(u"sitemaps_display", u"True"),
(u"rss_display", u"True"),
(u"vulgarity_filtered_words", u""),
(u"primary_language", u"en"),
(u"advertising_banner_html", u""),
(u"advertising_sidebar_html", u""),
(u"comments_engine", u"mediacore"),
(u"facebook_appid", u""),
]
settings.extend(appearance_settings)
for key, value in settings:
s = Setting()
s.key = key
s.value = value
DBSession.add(s)
admin_user = User()
admin_user.user_name = u"admin"
admin_user.display_name = u"Admin"
admin_user.email_address = u"[email protected]"
admin_user.password = u"admin"
DBSession.add(admin_user)
admin_group = Group(name=u"admins", display_name=u"Admins")
admin_group.users.append(admin_user)
DBSession.add(admin_group)
editor_group = Group(name=u"editors", display_name=u"Editors")
DBSession.add(editor_group)
anonymous_group = Group(name=u"anonymous", display_name=u"Everyone (including guests)")
DBSession.add(anonymous_group)
authenticated_group = Group(name=u"authenticated", display_name=u"Logged in users")
DBSession.add(authenticated_group)
admin_perm = Permission(name=u"admin", groups=[admin_group], description=u"Grants access to the admin panel")
DBSession.add(admin_perm)
edit_perm = Permission(
name=u"edit", groups=[admin_group, editor_group], description=u"Grants access to edit site content"
)
DBSession.add(edit_perm)
view_perm = Permission(
name=u"view", groups=[admin_group, anonymous_group, editor_group], description=u"View published media"
)
DBSession.add(view_perm)
upload_perm = Permission(
name=u"upload", groups=[admin_group, anonymous_group, editor_group], description=u"Can upload new media"
)
DBSession.add(upload_perm)
media_upload_perm = Permission()
media_upload_perm.permission_name = u"MEDIA_UPLOAD"
media_upload_perm.description = u"Grants the ability to upload new media"
media_upload_perm.groups.append(admin_group)
media_upload_perm.groups.append(editor_group)
media_upload_perm.groups.append(anonymous_group)
DBSession.add(edit_perm)
category = Category(name=u"Featured", slug=u"featured")
DBSession.add(category)
category2 = Category(name=u"Instructional", slug=u"instructional")
#.........这里部分代码省略.........