本文整理汇总了Python中models.user.User.get_by_slug方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_slug方法的具体用法?Python User.get_by_slug怎么用?Python User.get_by_slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.get_by_slug方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_slug [as 别名]
def get(self, profile_slug, data_source_slug, data_view_ext):
try:
user = User.get_by_slug(profile_slug)
if not user:
raise ValueError("No user exists called %s" % profile_slug)
data_source = DataSource.get_by_slug(user, data_source_slug)
if not data_source:
raise ValueError("No data source exists with the slug %s" % data_source_slug)
data_view = DataView.get_by_extension(data_source, data_view_ext)
if not data_view:
raise ValueError("No data view exists with the extension %s" % data_view_ext)
self.response.headers.add('Access-Control-Allow-Origin','*')
self.response.content_type = str(data_view.mimetype)
self.response.write(data_view.render())
# TODO Consider context specific error messages (xml, json &c.) issue#31
except ValueError as e:
error_404(self.request, self.response, e)
except Exception as e:
error_500(self.request, self.response, e)
示例2: test_user_method_get_by_slug
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_slug [as 别名]
def test_user_method_get_by_slug(self):
user = self.make_user()
self.assertEqual(user.key(), User.get_by_slug(dummy.user['profile_slug']).key())