Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    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.
    Mustain
    @kang-mus
    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?
    Mustain
    @kang-mus
    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
    Mustain
    @kang-mus
    tornado_json.routes get_routes returning an empty array after I compile to exe