-
Notifications
You must be signed in to change notification settings - Fork 79
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
path to image in url #16
Conversation
I've generally tried to take the approach of just do one thing and that's it to avoid all the complexity that inherently goes along with having a bunch of different ways to call/use an application. And from my perspective, passing options/data to an application naturally lends itself to passing via query parameters. I do recognize though that callers of pilbox might have very different requirements for how they would need to call it. But just as the application doesn't have caching or storage, which are also needed, I did not build in any url rewriting. I did not do this for a couple of reasons: I think the job can be done in the web server (e.g. nginx or apache) and I doubted I would be able to cover everything that everyone would need. So I typically recommend, as you mentioned, doing the url rewriting in nginx (or apache, or whatever) to pass the appropriate parameters to pilbox when pilbox's url format is inappropriate for your needs. That said, you don't need to run pilbox directly as an application; you can use it as a library and extend from PilboxApplication to override get_handlers and ImageHandler to override the get method. In which case, you pretty much get what you're asking for: pilbox understanding your particular url format. If you need me to refactor the internals of ImageHandler.get to make it easier to reuse, just let me know and I'd be happy to do it. Anyway, that's the short of my thinking: do as a little as possible to avoid complexity and promote clarity and extension. |
What I am thinking of, to make the app more extensible (and a bit more decoupled):
|
I'd have to see how it turned out, but gut reaction would be not super thrilled about introducing two more files and an extra class. Also, and I'm not sure your changes imply this, but I definitely would not want to require that the application run with a config file to work. I think there's probably happy medium where we can avoid the additional assets and still achieve the flexibility you need. |
The application would use it's internal |
I'm just not entirely sure what that would look like. I could very well be misunderstanding what you're describing, but if I'm importing Right now,
That said, if you want to implement what you're suggesting and send me a pull request, I'm definitely willing to be proven wrong. |
yep, this is what I meant, otherwise the app will use the default I think it is easy to avoid extending
But that is all a matter of taste I guess. I can start with making a pull request for granulating the |
Yeah, I agree the I'm not too worried about locking
|
I have only 3 days worth experience with Tornado, so tips would be appreciated. Btw, is there a reason for overriding?
|
Yeah, you'd want to make the internals of Are you asking me why I overrode |
Also, when you push your changes it will get sent to travis-ci, where it will get run against pep8, pyflakes and coverage. You can run all those things locally if you are running via the provided vagrant setup. I'd recommend running them yourself as relying on travis-ci to do it will be kind of a slow, tedious check and fix cycle. |
I wanted you to look at a first try and hear your comments on the commit. |
OK, will run it and look at it more closely tonight, but here's some quick comments. First, take a look at this fork. Basically, he's doing as a fork what you'd want to make possible without forking. So with that in mind:
Re: testing. Yeah, I don't think I made it super clear on how to write new tests. The case logic is pretty clunky. If there's something you'd want me to add or look at, let me know and I can help with that. |
Yes, I am actually thinking about doing the same thing, as 90% of the features will not be used in our app it seems like an overhead, plus I have concerns with when I expose the API to other clients, a malicious client might go about jamming the cache with random images. That is why I am considering leaving just resizing and having only 10 image resize steps clients can use. Breaking up even more makes sense. |
Yeah, I like that you're using I think the overhead of including those additional operations is minor, but exposing operations you don't want is actually an issue. I think the code can be modified rather simply to make it so the extending class can override the I agree with you about a malicious caller of the service, that's why I provided
Don't know if you're doing it, but I'd encourage you to extend from your fork and see if you can do the things you want to do with it. Because that will be the real test to know if you're making the right changes. And when we review it, we can just determine if the changes to pilbox are too specific to your app and go from there. |
I would say |
@@ -19,3 +19,6 @@ build | |||
/bin | |||
/include | |||
/lib | |||
|
|||
# PyCharm | |||
.idea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like editor specific ignores should be in the developer's global git ignore file.
This is all merged in, thanks for contributing. |
There is a setting
--implicit_base_url
that allows the following url format:Which is great, but what I want is the following:
Is it possible to add an optional flag to pass the image path in the url? Would you accept a pull request and how would you see it done?
P.S. I understand that I can rewrite the urls internally with something like nginx, but more of interested of why it was chosen to set the image path only as a url param.