-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmr.py
56 lines (56 loc) · 1.61 KB
/
mr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# import os
#
# from flask import Flask, request
# from flask.ext.mongoengine import MongoEngine
# from flask.ext.mongorest import MongoRest
# from flask.ext.mongorest.views import ResourceView
# from flask.ext.mongorest.resources import Resource
# from flask.ext.mongorest import operators as ops
# from flask.ext.mongorest.methods import *
# from flask.ext.mongorest.authentication import AuthenticationBase
#
#
# app = Flask(__name__)
#
# # Create dummy secrey key so we can use sessions
# app.config['SECRET_KEY'] = '123456790'
# app.config['MONGODB_SETTINGS'] = {'DB': 'testing11'}
#
# # Create models
# db = MongoEngine()
# db.init_app(app)
#
# db = MongoEngine(app)
# api = MongoRest(app)
#
# class User(db.Document):
# email = db.EmailField(unique=True, required=True)
#
# class Content(db.EmbeddedDocument):
# text = db.StringField()
#
# class ContentResource(Resource):
# document = Content
#
# class Post(db.Document):
# title = db.StringField(max_length=120, required=True)
# author = db.ReferenceField(User)
# content = db.EmbeddedDocumentField(Content)
#
# class PostResource(Resource):
# document = Post
# related_resources = {
# 'content': ContentResource,
# }
# filters = {
# 'title': [ops.Exact, ops.Startswith],
# 'author_id': [ops.Exact],
# }
# rename_fields = {
# 'author': 'author_id',
# }
#
# @api.register(name='posts', url='/posts/')
# class PostView(ResourceView):
# resource = PostResource
# methods = [methods.Create, methods.Update, methods.Fetch, methods.List]