Comments (2)
Do you have a specific need to use your actual implementation,
instead of simply concatenating path segments ?
Yes.
The wraps in my implementation are programmed to overload settings
from their parents. So, when a request is executed, the information
will flow from top to bottom. Every wrap can add their default config
if it's not there.
Now, this could also be implemented by going from bottom to top.
However, wraps are made to be saved for later use. This means that a
bottom to top solution could behave weirdly. For example:
example = tortilla.wrap('https://api.example.org')
# worst case scenario of endpoint
users = example('get').users('for', 'each', params={'this': 'that'})
# we've logged in and set the authorization header
example.headers.authorization = 'secret key'
# this won't send the authorization header because the `example` parent
# can't modify the request information
users.get('someone')
If we use a top to bottom method, the request will fall through our
example
wrap which can add the headers and other config.
URLs are created seperately from the request in the url()
method.
This method concatenates URL parts from top to bottom and could be
done in the request method. But, because the __repr__
method also
uses the URL, I chose to abstract the URL creation in a different
function to keep things DRY.
I'm completely open to modifications to improve performance, but I
don't want it to impact the flexibility of using the library. :)
from tortilla.
OK I understand better your point of view, my basic implementation clearly can't handle this, but I never though about storing intermediates values, nor modifing them and expecting it to still work ;-)
from tortilla.
Related Issues (20)
- How can I POST json data? HOT 2
- Does tortilla support authentication cookies? HOT 1
- Link to the docs. HOT 1
- Recurring params HOT 1
- adding delay between each request? HOT 1
- Missing Dependency: lunch HOT 2
- Client.request format impose same conversion for requests load and response HOT 1
- GETting a response which has a key called 'self' raises an exception HOT 1
- Documentation about headers is wrong HOT 2
- Docs are outdated HOT 1
- dependency on colorclass HOT 4
- Any way to access response headers? HOT 6
- How to set parameters of the API? HOT 1
- Add support for BasicAuth HOT 3
- PyPI release HOT 1
- Add path formatting flags
- Logo proposal HOT 7
- Formatting flags are not working for single endpoints HOT 1
- Can't open a PR
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tortilla.