flask-restless

How to use the keyword arguments in Flask-RESTless

自作多情 提交于 2019-12-24 10:48:49
问题 Me and a buddy have been reading through the docs for Flask-RESTless and it says: The arguments to the preprocessor and postprocessor functions will be provided as keyword arguments, so you should always add **kw as the final argument when defining a preprocessor or postprocessor function. but it doesn't specify how we can use these keyword argument to pass info to the pre- or postprocessor. Can anyone tell us how to do this? Our create_api looks like this right now: create_api(Foo, methods=[

How to search a model by date with Flask-Restless

*爱你&永不变心* 提交于 2019-12-24 04:23:24
问题 According to the documentation, a search query should look like: GET /api/person?q={"filters":[{"name":"age","op":"ge","val":10}]} How do I compare a date? I tried: GET /api/person?q={"filters":[{"name":"date","op":"<=","val":"1/20/2015"}]} That gets no results, even though there are some which have dates prior to 1/20/2015. I tried: GET /api/person?q={"filters":[{"name":"date","op":">=","val":"1/20/2015"}]} That gets all results back, even ones that are from before 1/20/2015. This is the

GAE app.yaml routing with Flask-Restless

大城市里の小女人 提交于 2019-12-13 02:31:41
问题 I am developing an app with AngularJS frontend + GAE backend (Python and Flask). I am having troubles to setting app.yaml for routing my API endpoints created with Flask-Restless extention. My app.yaml file looks like this: application: myAppID version: 1 runtime: python27 threadsafe: true api_version: 1 handlers: # handler 1 - url: /favicon\.ico static_files: favicon.ico upload: favicon\.ico # handler 2 - url: /api/.* script: main.app # handler 3 - url: /test script: main.app # handler 4 -

PATCHing resources with nested objects with Flask/SQLAlchemy

感情迁移 提交于 2019-12-12 20:45:50
问题 I have the following setup: # models class Author(BaseModel): id = Column(Integer, primary_key=True) first_name = Column(String(64)) last_name = Column(String(64)) class Book(db.Model): id = Column(Integer, primary_key=True) title = Column(String(64)) author_id = Column(Integer, ForeignKey("author.id"), nullable=True) author = relationship(Author, backref=backref('books')) # schema class AuthorSchema(BaseSchema): first_name = fields.Str() last_name = fields.Str() class Meta(BaseSchema.Meta):

Python / Flask - Using flask_restless with flask_httpauth

二次信任 提交于 2019-12-11 07:54:25
问题 my objective in this question is to secure my API. in my application, I'm using Flask and flask_restless 's APIManager to provide CRUD API to my Person object. code sample: manager = APIManager(app, flask_sqlalchemy_db=db) manager.create_api(Person, methods=['GET', 'POST', 'PATCH', 'DELETE']) and also using flask_httpauth to protect my other routes like this: @app.route('/auth/get-token') @auth.login_required def get_auth_token(): token = g.user.generate_auth_token() return jsonify({'token':

How to return “already exists” error in Flask-restless?

拜拜、爱过 提交于 2019-12-06 01:31:23
问题 I would like to do some handler for exception. I'm using a combination of Flask-restless and SQLAlchemy in python. My problem: When I send request to api with object that already exists in DB, SQLAlchemy shows exception: IntegrityError: (IntegrityError) column <column_name> is not unique u'INSERT INTO ... So I have tried to add attribute validation_exceptions into create_api method: manager.create_api( ... , validation_exceptions=[IntegrityError]) But response json contains: { "validation

Flask-SQLAlchemy and Flask-Restless not fetching grandchildren

久未见 提交于 2019-12-05 01:39:13
问题 Problem I am building an app on Flask, Flask-SQLAlchemy, and Flask-Restless. I have used restless to generate an API for a parent-child-grandchild relationship*. A GET on my child will correctly fetch the grandchild, but a GET on the parent will not fetch the grandchild for each child. *In fact, the parent-child relationship is a many-to-many, but same premise. Models class Grandchild(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, nullable=False) parent =

How to return “already exists” error in Flask-restless?

﹥>﹥吖頭↗ 提交于 2019-12-04 05:40:50
I would like to do some handler for exception. I'm using a combination of Flask-restless and SQLAlchemy in python. My problem: When I send request to api with object that already exists in DB, SQLAlchemy shows exception: IntegrityError: (IntegrityError) column <column_name> is not unique u'INSERT INTO ... So I have tried to add attribute validation_exceptions into create_api method: manager.create_api( ... , validation_exceptions=[IntegrityError]) But response json contains: { "validation_errors": "Could not determine specific validation errors" } and server api shows exception : Traceback

Flask-SQLAlchemy and Flask-Restless not fetching grandchildren

淺唱寂寞╮ 提交于 2019-12-03 16:13:22
Problem I am building an app on Flask, Flask-SQLAlchemy, and Flask-Restless. I have used restless to generate an API for a parent-child-grandchild relationship*. A GET on my child will correctly fetch the grandchild, but a GET on the parent will not fetch the grandchild for each child. *In fact, the parent-child relationship is a many-to-many, but same premise. Models class Grandchild(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, nullable=False) parent = db.relationship('Child', backref='grandchild') parent_child = db.Table('parent_child', db.Column(

flask-RESTful vs flask-RESTless, which should be used, and when [closed]

房东的猫 提交于 2019-12-03 15:12:31
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . What are the key differences of these two libraries.In terms of usability, and features If you already have a huge number of model classes, using flask-restLESS makes perfect sense, right?. What are the features it would lack, if it would done with flask-restful. Or, what are