-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some things I miss... #61
Comments
Thanks for posting. Note that Picoweb has one important goal - to be the minimalist and simple web nano-framework. It takes inspiration in the words "Perfection is achieved not when there is nothing more to add, but when there is nothing to take away." of one well-known author. Instead of trying to satisfy everyone, which is impossible, Picoweb aspires to find a core set of functionality which allows to write simple, but useful webapps. And be extensible, so more functionality can be added on top of (not inside) it. I envision over time various plugins, etc. appear for Picoweb, and welcome interested parties to do that. Bu the core should stay simple. With that in mind, let's look over your list:
I'm not sure what exactly you mean, can you elaborate to avoid guesswork?
That's the right way to deal with it.
If you mean a kind of catch-all handler, then ok, I see the point. Let me look into adding it. (Note that I would add extension point, not the handler itself.)
The whole purpose of Picoweb is to use StreamWriter directly. Of course, if you want to make it more complex than that - sure, you can.
Well, picoweb has facilities for that itself, it's in (pretty short!) source: https://github.com/pfalcon/picoweb/blob/master/picoweb/__init__.py#L39 . Let that be the illustration of my point: the more stuff you add, the more people will miss. If there're 10 methods, people will figure out 5 methods and miss 5. If there're 100 methods, people will figure out 5 and miss 95. The only way to stop this vicious circle is to keep project minimal, and invite people to actually read the code they're going to run. That's the mission of Picoweb (and entire Pycopy project, of which Picoweb just one part).
That's again how it's intended to be done. If you think that it would be useful to other people, package up this extension as a separate project, and publish/support it on your own.
Not needed, there's req.reader.read*() family of methods. It can't be an attribute, Picoweb can run on systems with some 50K of memory, while somebody may send you a few gigabytes of data.
Everything is there - please study the source, it's kept small specifically so it's not a problem for anybody, even beginners, to study it.
ujson.loads(string)
If a request has a body, it's view's responsibility to read it. |
Thank you for your answer and for the time it will have taken. First of all, Picoweb is an awesome project, and I would be struggling with myself without it. Precisely, the fact that it is so minimalist helps a lot when using and extending it. I understand the limited resources this library have to deal with, although it's true that I may have not considered it enough. I will try to take it more into account from now on. With that in mind, my three last points are against minimalism and performance, and I get that anyone (like me) could make a custom implementation for it, but it should not be part of the main project. Also, I didn't notice the With respect to the other points:
I mean that it would be nice to be able to filter the HTTP request methods allowed for a certain view (GET, POST, PUT...). However, thinking about it, it may has more sense to just create a custom decorator in order to be able to send a custom 405 response. Anyway, and as many of my other points, this is only a high-level feature that it could be useful but not really required.
Yup, a catch-all handler is what I meant. Again, it can be solved with a simple decorator, but I let you value if this is really needed in the core. This issue was about "what do you think about all these things", since you are the author of this library (and Pycopy) and should have a deep understanding of working with minimal hardware resources. Anyway, if it's worth adding some of these points to Picoweb, great. I will keep doing the rest of my high-level things outside the main code :) Thank you so much! |
Thanks for clarification! Just as a quick update (short of time now), I've pushed ability to override "global" exception handling, but mind that it might not work exactly as you might wish, see comments in the code: 35bf48b . |
Also posted an example on the above: https://github.com/pfalcon/picoweb/blob/master/examples/example_global_exc.py |
Hi!
I'm using Picoweb and it's great. However, I'm feeling that it lacks of some minor features and convenience methods. I'm working on these features as I need them in my project, and I think my work or ideas might be useful to improve Picoweb. These are my thoughts so far:
route()
function for it. I've created a decorator function to handle this.methods
decorator that I created, although it is not an ideal solution.text/html
andapplication/json
responses. I've also created a subclass that format the response based on the JSend specification, although this is a very personal feature.body
attribute in the request object (or aread()
method), although there is aread_form_data()
method (only useful with web forms). Ajson()
method would also be great :)body
attribute could also help to empty and close the reader stream before the handler is called.I've solved all of these needs, and I can adapt my code into Picoweb and make a few pull requests. However, I wanted to know what do you think about these features and if it makes sense to include them into the library.
Thank you, and sorry if my English doesn't make sense sometimes...
The text was updated successfully, but these errors were encountered: