本文整理汇总了Python中mediacore.model.DBSession.rollback方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.rollback方法的具体用法?Python DBSession.rollback怎么用?Python DBSession.rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediacore.model.DBSession
的用法示例。
在下文中一共展示了DBSession.rollback方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_audiodesc_video_url_media
# 需要导入模块: from mediacore.model import DBSession [as 别名]
# 或者: from mediacore.model.DBSession import rollback [as 别名]
def test_audiodesc_video_url_media(self):
"""Media with both Audio files and Video files attatched should be
Video type."""
try:
# Create the media object
media = self._new_publishable_media(u'description-video',
u'(Audio Description + Video)')
DBSession.add(media)
# Add an audio description
media_file = add_new_media_file(media, None,
u'http://fakesite.com/fakefile.mp3')
media_file.type = AUDIO_DESC
media.update_status()
# Add a video file
media_file = add_new_media_file(media, None,
u'http://fakesite.com/fakefile.m4v')
media.update_status()
# Commit + test
DBSession.commit()
assert media.type == VIDEO, \
"A Media object with a .m4v file and an Audio Description " \
"was not labelled as a video type; it was labelled %s" % \
(t, media.type)
except SQLAlchemyError, e:
DBSession.rollback()
raise e
示例2: view
# 需要导入模块: from mediacore.model import DBSession [as 别名]
# 或者: from mediacore.model.DBSession import rollback [as 别名]
def view(self, slug, podcast_slug=None, **kwargs):
"""Display the media player, info and comments.
:param slug: The :attr:`~mediacore.models.media.Media.slug` to lookup
:param podcast_slug: The :attr:`~mediacore.models.podcasts.Podcast.slug`
for podcast this media belongs to. Although not necessary for
looking up the media, it tells us that the podcast slug was
specified in the URL and therefore we reached this action by the
preferred route.
:rtype dict:
:returns:
media
The :class:`~mediacore.model.media.Media` instance for display.
related_media
A list of :class:`~mediacore.model.media.Media` instances that
rank as topically related to the given media item.
comments
A list of :class:`~mediacore.model.comments.Comment` instances
associated with the selected media item.
comment_form_action
``str`` comment form action
comment_form_values
``dict`` form values
next_episode
The next episode in the podcast series, if this media belongs to
a podcast, another :class:`~mediacore.model.media.Media`
instance.
"""
media = fetch_row(Media, slug=slug)
request.perm.assert_permission(u'view', media.resource)
if media.podcast_id is not None:
# Always view podcast media from a URL that shows the context of the podcast
if url_for() != url_for(podcast_slug=media.podcast.slug):
redirect(podcast_slug=media.podcast.slug)
try:
media.increment_views()
DBSession.commit()
except OperationalError:
DBSession.rollback()
if request.settings['comments_engine'] == 'facebook':
response.facebook = Facebook(request.settings['facebook_appid'])
related_media = viewable_media(Media.query.related(media))[:6]
# TODO: finish implementation of different 'likes' buttons
# e.g. the default one, plus a setting to use facebook.
return dict(
media = media,
related_media = related_media,
comments = media.comments.published().all(),
comment_form_action = url_for(action='comment'),
comment_form_values = kwargs,
)
示例3: test_add_file_url
# 需要导入模块: from mediacore.model import DBSession [as 别名]
# 或者: from mediacore.model.DBSession import rollback [as 别名]
def test_add_file_url(self):
slug = u'test-add-file-url'
title = u'Test Adding File by URL on Media Edit Page.'
try:
media = self._new_publishable_media(slug, title)
media.publishable = False
media.reviewed = False
DBSession.add(media)
DBSession.commit()
media_id = media.id
except SQLAlchemyError, e:
DBSession.rollback()
raise e
示例4: _get_media
# 需要导入模块: from mediacore.model import DBSession [as 别名]
# 或者: from mediacore.model.DBSession import rollback [as 别名]
def _get_media(self, unique):
"""Return the media/mediafiles required for the Helpers tests"""
try:
media = self._new_publishable_media(u'media-selection-%s' % unique,
u'Media Selection Test (%s)' % unique)
DBSession.add(media)
media_files = {}
for t in ['oga', 'ogv', 'm4a', 'm4v', 'flv', 'mp3', 'xml']:
media_files[t] = add_new_media_file(media, None,
u'http://fakesite.com/fakefile.%s' % t)
media_files['youtube'] = add_new_media_file(media, None,
u'http://www.youtube.com/watch?v=3RsbmjNLQkc')
media.update_status()
DBSession.commit()
except SQLAlchemyError, e:
DBSession.rollback()
raise e
示例5: test_captioned_url_media
# 需要导入模块: from mediacore.model import DBSession [as 别名]
# 或者: from mediacore.model.DBSession import rollback [as 别名]
def test_captioned_url_media(self):
"""Media with only subtitles attatched should be None type."""
try:
for t in self.caption_types:
media = self._new_publishable_media(u'caption-%s' % t,
u'%s (Captioned)' % t.upper())
DBSession.add(media)
media_file = add_new_media_file(media, None,
u'http://fakesite.com/fakefile.%s' % t)
media.update_status()
DBSession.commit()
assert media.type == None, \
"A Media object with only an .%s file associated was " \
"not labelled as a 'None' type; it was labelled %s" % \
(t, media.type)
except SQLAlchemyError, e:
DBSession.rollback()
raise e
示例6: test_audio_description_url_media
# 需要导入模块: from mediacore.model import DBSession [as 别名]
# 或者: from mediacore.model.DBSession import rollback [as 别名]
def test_audio_description_url_media(self):
"""Media with only Audio Descriptions attatched should be None type."""
try:
for t in self.audio_types:
media = self._new_publishable_media(u'description-%s' % t,
u'%s (Audio Description)' % t.upper())
DBSession.add(media)
media_file = add_new_media_file(media, None,
u'http://fakesite.com/fakefile.%s' % t)
media_file.type = AUDIO_DESC
media.update_status()
DBSession.commit()
assert media.type == None, \
"A Media object with only an Audio Description file " \
"associated was not labelled as a None type; it " \
"was labelled %s" % (t, media.type)
except SQLAlchemyError, e:
DBSession.rollback()
raise e
示例7: test_edit_media
# 需要导入模块: from mediacore.model import DBSession [as 别名]
# 或者: from mediacore.model.DBSession import rollback [as 别名]
def test_edit_media(self):
title = u'Edit Existing Media Test'
slug = u'edit-existing-media-test' # this should be unique
# Values that we will change during the edit process
name = u'Frederick Awesomeson'
email = u'[email protected]'
description = u'This media item was created to test the "admin/media/edit/someID" method'
htmlized_description = '<p>This media item was created to test the "admin/media/edit/someID" method</p>'
notes = u'Some Notes!'
try:
media = self._new_publishable_media(slug, title)
media.publishable = False
media.reviewed = False
DBSession.add(media)
DBSession.commit()
media_id = media.id
except SQLAlchemyError, e:
DBSession.rollback()
raise e