Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    NotImplementedError. I think I've gone full circle.
    Lars Schöning
    @lyschoening
    AwareDateTime() is a custom column type that Flask-Potion does not natively understand. You can try adding the following lines in your TaskResource to tell it this is a datetime:
    from flask_potion import ModelResource, fields
    
    class TaskResource(ModelResource):
        class Meta:
            model = Task
        class Schema:
            record_created_on = fields.DateTime()
    Duncan Betts
    @DuncanBetts
    Awesome :) I will try this now. Perhaps I've been looking for the problem in the wrong part of my codebase.
    Duncan Betts
    @DuncanBetts
    Could you tell me, do you think the way I'm initializing the extension looks OK? I know SQLAlchemy needs to be initialized first. I'm reading over http://flask.pocoo.org/docs/0.12/extensiondev/
    Lars Schöning
    @lyschoening
    Again, the NotImplementedError is related to that custom column type. Your initialization is fine (more complicated than people usually write these things, but fine).
    What does lib.util_sqlalchemy.ResourceMixin look like. Does it declare any additional columns?
    Lars Schöning
    @lyschoening
    If you have any columns that are not standard SQLAlchemy columns, such as AwareDateTime then you need to tell Flask-Potion manually what field type you expect for them by adding them in the schema like I showed with record_created_on. If ResourceMixinadds any more columns like this, you need to add them all to the schema with an appropriate field type
    I only see AwareDateTime, not ResourceMixin here.
    Lars Schöning
    @lyschoening
    Ok, so you can see there are two more columns in that mixin, created_on and updated_on. You need to add them both to Schema
    Duncan Betts
    @DuncanBetts
    I see it. AwareDateTime. I should've guessed... been trying to sort this out for a few hours, I should probably take a break! Thanks very much for helping me with this, I doubt I would've worked this out.
    Booting up, fingers crossed :)

    `[_:~/devel … /Deep_Learning_API/spatialdb/blueprints/v1] master(+76/-125)*
    ± http :8000/schema
    HTTP/1.1 200 OK
    Connection: close
    Content-Length: 159
    Content-Type: application/json
    Date: Mon, 23 Jan 2017 13:14:50 GMT
    Server: gunicorn/19.6.0

    {
    "$schema": "http://json-schema.org/draft-04/hyper-schema#",
    "properties": {
    "tasks": {
    "$ref": "/tasks/schema#"
    }
    }
    }`

    Duncan Betts
    @DuncanBetts
    Working :clap: thanks very much
    Lars Schöning
    @lyschoening
    Awesome!
    Duncan Betts
    @DuncanBetts
    I can crack on with reading your documentation now :), thanks again, I've been looking forward to using potion for this project, it sucked when I couldn't.
    Alain Scialoja
    @Alain1405
    @lyschoening any plan for the next release? I'm especially interested in biosustain/potion#111
    Lars Schöning
    @lyschoening
    @Alain1405 v0.13.0 has been released now!
    Everyone: If an issue has been resolved and you’d like to see it released, just let me know. My plan is usually to release within a few days of a change, but it clearly has taken much longer this time round.
    Alain Scialoja
    @Alain1405
    Thanks for the current release!
    Alain Scialoja
    @Alain1405

    Quick question: when handling psycopg2 Integrity Error in update and create methids in the SqlAlchemy manager, the SQL statement and the parameters are logged, but not the actual error message. For instance, if I don't have an autoincrement index in a table and I try to add a row, psycopg2 raises, using str(exception):

    (psycopg2.IntegrityError) null value in column "id" violates not-null constraint
    12:16:19 PM web.1 |  DETAIL:  Failing row contains (2017-01-27 11:16:17.273989, 2017-01-27 11:16:17.274532, null, asd, 6).
    12:16:19 PM web.1 |   [SQL: 'INSERT INTO role (created_at, updated_at, name, created_by_id) VALUES (%(created_at)s, %(updated_at)s, %(name)s, %(created_by_id)s) RETURNING role.id'] [parameters: {'created_by_id': 6, 'created_at': datetime.datetime(2017, 1, 27, 11, 16, 17, 273989), 'name': 'asd', 'updated_at': datetime.datetime(2017, 1, 27, 11, 16, 17, 274532)}]

    while potion only answers with:

    {
      "debug_info": {
        "params": {
          "created_at": "Fri, 27 Jan 2017 11:11:58 GMT", 
          "created_by_id": 6, 
          "name": "asd", 
          "updated_at": "Fri, 27 Jan 2017 11:11:58 GMT"
        }, 
        "statement": "INSERT INTO role (created_at, updated_at, name, created_by_id) VALUES (%(created_at)s, %(updated_at)s, %(name)s, %(created_by_id)s) RETURNING role.id"
      }, 
      "message": "Conflict", 
      "status": 409
    }

    Is this intended?

    Also, is there any reason why session rollback and integrity errors are not handled in the delete method?
    @lyschoening
    Lars Schöning
    @lyschoening
    @Alain1405 I guess the honest answer is I’ve never encountered that issue in the delete method during testing.
    As for the error message, I would be fine with adding it.
    Alain Scialoja
    @Alain1405
    I will find some time for it!
    Alain Scialoja
    @Alain1405

    @lyschoening how to define a Route with an optional parameter?

    ```

    @Route.POST('/route_url')
        def a_route(self, par1: ACustomField(), par2: fields.ToOne('resouce_name')):
    
            do_stuff
            return True

    returns

    {'errors': [{'path': [], 'message': "'par2' is a required property", 'validationOf': {'required': ['par1', 'par2']}}], 'message': 'Bad Request', 'status': 400}

    Any way without explicitly defining the schema?
    Alain Scialoja
    @Alain1405
    I forgot to say that I would like par2 to be optional (non required)
    Lars Schöning
    @lyschoening
    @Alain1405 You can make it nullable, which essentially means optional in this context.
    Jesse Gonzalez
    @jessegonzalez
    is anyone here coming from a migration to potion scenario?
    Alain Scialoja
    @Alain1405
    @lyschoening is a release possible?
    Lars Schöning
    @lyschoening
    @Alain1405 going to release this afternoon
    Alain Scialoja
    @Alain1405
    :thumbsup:
    Alain Scialoja
    @Alain1405
    Thanks @lyschoening for the release. I wanted to ask if there is any progress with WebSockets, as written in the readme
    Also, I have created my own EnumField compatible with Python 3 enum.Enum type. It serializes by using just using the enum name, the value is not passed.
    Could that be a feature for potion?
    Lars Schöning
    @lyschoening
    @Alain1405 Yes, a fields.Enum would be useful
    Lars Schöning
    @lyschoening
    I should update that part of the README. We are still considering web sockets, but probably not for flask. We’ve internally started a project that is essentially Potion and would allow for request/reply and streaming communication with different server implementations; an aiohttp implementation could support streaming through WebSockets. The flask implementation would not.
    Russ
    @rmilne
    Is there a way to do ORs and ANDs with filters? I apologize if this isn't a well thought out question.
    Lars Schöning
    @lyschoening
    @rmilne filters are ANDed. In principle it should be possible to make a custom “$or” filter
    It’s been left out because it is rarely needed and would potentially allow for quite complicated queries
    Russ
    @rmilne
    Okay, thanks for the answer.
    Alain Scialoja
    @Alain1405

    @lyschoening I thought I'd check with you before opening a bug.

    I have an endpoint which has a "value": fields.Number() in the schema. We had a bug which caused NaN values to be passed in the response. I suppose due to allow_nan as for http://stackoverflow.com/questions/6601812/sending-nan-in-json , Potions' responds with a non-valid NaN in the Json, which makes the client parsing fail.

    Shouldn't this be handled by Potion?
    Lars Schöning
    @lyschoening
    @Alain1405 sorry for missing this. Yes, I suppose this should be validated on the request side at least (on the response side, Potion assumes that the response is valid for performance reasons)
    Lohanna
    @lohxx
    Hi, can anyone help me put the field of a relative resource in the schema of another resource?