本文整理汇总了Python中task.models.Task.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python Task.serialize方法的具体用法?Python Task.serialize怎么用?Python Task.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类task.models.Task
的用法示例。
在下文中一共展示了Task.serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_taskdb
# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import serialize [as 别名]
def get_taskdb(request, filename):
if filename == 'pending.data':
taskstr = Task.serialize('pending')
elif filename == 'completed.data':
taskstr = Task.serialize('completed')
elif filename == 'undo.data':
taskstr = Undo.serialize()
else:
return HttpResponseNotFound()
response = HttpResponse(taskstr, mimetype='text/plain')
response['Content-Length'] = len(taskstr)
return response
示例2: test_taskdb_PUT_completed
# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import serialize [as 别名]
def test_taskdb_PUT_completed(self):
self._create_user_and_login()
data = open(os.path.join(TASK_DATA, 'completed.data'), 'r').read()
response = self.client.put('/taskdb/completed.data',
content_type='text/plain',
data=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(list(Undo.objects.all()), [])
self.assertEqual(Task.serialize('completed'), data)
示例3: test_taskdb_PUT_pending
# 需要导入模块: from task.models import Task [as 别名]
# 或者: from task.models.Task import serialize [as 别名]
def test_taskdb_PUT_pending(self):
self._create_user_and_login()
data = open(os.path.expanduser('~/.task/pending.data'), 'r').read()
response = self.client.put('/taskdb/pending.data',
content_type='text/plain',
data=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(list(Undo.objects.all()), [])
self.assertEqual(Task.serialize('pending'), data)