Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Hamza Faran
    @hfaran
    I guess the easiest way would be to make this an argument of the get_module_routes function
    And then have a sane kwarg default for it
    which IMO would be the exisitng one but with the hyphen added in
    Hamza Faran
    @hfaran
    Actually, I'm not too sure what the best solution for this is. It's kind of why this is still hardcoded because I wasn't sure how best to make it configurable.
    It could use tornado.options
    It could be a constant that you could monkeypatch
    or it could be passed all the way through from get_routes
    I'll see what your PR brings though :)
    Konrad Talik
    @ktalik
    I would say tornado.options < constant < kwarg value ;) or something like that
    But for start kwarg value will be fine
    Then you can expand it to take a default from constant or tornado.options
    Konrad Talik
    @ktalik
    Hi there. I have a question. I want to use schema validation but in the same time need to provide exceptions with {"status": "error", "code": error_code} instead of {"status": "success"}. How to do that without JSend wrapper OR how to validate JSend responses?
    Hamza Faran
    @hfaran
    I don't think I quite follow what you mean
    Could you give an example?
    Konrad Talik
    @ktalik

    Sure, here it is:

        @schema.validate(
            input_schema=INPUT_SCHEMA,
            output_schema=OUTPUT_SCHEMA,
            output_example=OUTPUT_EXAMPLE
        )
        def get(self):
            exception = EXCEPTION_XXX
            self.error(**exception)

    with constants:

    OUTPUT_SCHEMA = {
        "type" : "object",
        "properties" : {
            "elements" : {
                "type" : "array",
            }
        }
    }
    
    EXCEPTION_XXX = {
        "code" : 2,
        "message" : "Please provide more device properties.",
        "data" : {
            "elements" : [],
        }
    }

    When providing a valid JSON (like OUTPUT_EXAMPLE), there is no problem. But for self.error() server raises following exception (with a proper error response with no issue):

    TypeError: None is not of type 'object'
    
    Failed validating 'type' in schema['properties']['result']:
    (structure omitted)
    
    On instance['result']:
        None
    (structure has been omitted by me)
    Konrad Talik
    @ktalik
    There is no way to use schema validation with jsend methods. Do you think this is an issue or it's how it should be or am I doing something wrong?
    Hamza Faran
    @hfaran
    Hey
    Just got around to reading this
    Konrad Talik
    @ktalik
    Hi there
    Hamza Faran
    @hfaran
    So, from what I understand, you're trying to return a specific error from within a RequestHandler, correct?
    Konrad Talik
    @ktalik
    Yeah, from APIHandler. Forgot to mention that.
    Hamza Faran
    @hfaran
    Okay, you should be using APIError for this. This is how the API is designed for Tornado-JSON. The JSend methods aren't meant to be called directly! :)
    Somewhat relevant comment from an earlier issue: https://github.com/hfaran/Tornado-JSON/issues/76#issuecomment-118563408
    Konrad Talik
    @ktalik
    Wut, much thanks, I'll try with it! I'm somewhat new to Tornado :)
    Thx for the link
    Hamza Faran
    @hfaran
    Ah, well, APIError is a Tornado-JSON specific thing :P
    That is one of the example projects linked in the README
    If you ever want to raise an exception with error code and messages to propogate to the user, you should raise an APIError or use api_assert
    Konrad Talik
    @ktalik
    Brilliant
    Hamza Faran
    @hfaran
    No problem
    Konrad Talik
    @ktalik
    tornado_json.exceptions doc is missing. I think that confused me days ago ;) thanks for the examples
    Hamza Faran
    @hfaran
    Oh... so it is. How odd...
    I'll make an issue for that haha
    Konrad Talik
    @ktalik
    :+1:
    Konrad Talik
    @ktalik
    Hi Hamza. What would you recommend to imply a constant value on url, when implementing a handler? In other words I would like to have "/spam/<spamid>/eggs", where spamid is a parameter (also in python function of the handler) but "eggs" is always the same string.
    Konrad Talik
    @ktalik
    Hi @hfaran, still looking for the solution :(
    Hamza Faran
    @hfaran
    Hi @ktalik would love to help you out with this ASAP, but I am unfortunately busy with exams (amongst a number of other things) at the moment. I can hopefully look into this for you more in the last week of December. Please send me a ping around the 22nd if you haven't found a good solution by that time.
    dpopcorn
    @dpopcorn
    hi @hfaran, i have try tornado-json, an compile my application with pyinstaller. But when i start my exe file, tornado success open port. when i try to access RequestHandler from tornado this returning normal, but when i try to access API url returned 404, can you help me please...
    Hamza Faran
    @hfaran
    @dpopcorn this only happens on the exe and not when running normally?
    Have you been doing all of your development on Windows?
    dpopcorn
    @dpopcorn
    i developing in windows
    when i run from py file this running normal
    this error only at exefile
    after i try to compile from pyinstaller
    dpopcorn
    @dpopcorn
    tornado_json.routes get_routes returning an empty array after I compile to exe