Comments (4)
Alternatively we could drop support for typecasting, it's seldom used AFAIK, and the current implementation is inefficient.
from aspen.py.
Without typecasting you have to do the typecasting manually in each simplate. This gets verbose and WET.
/foo/%bar_id.bar/baz.spt
/foo/%bar_id.bar/buz.spt
/foo/%bar_id.bar/biz.spt
Inside each simplate I want a bar
object without having to manually call a library function.
Option: typecasters only apply to directory parts, not file parts? Would that work?
from aspen.py.
In Liberapay we don't use typecasting to handle the /%username/
path segment, we import and call the get_participant
function in every simplate. Calling the function explicitly makes it easier to send extra arguments to it. The extra import is a little redundant, but it could be removed by attaching get_participant
to the website
object. This leads me to the conclusion that builtin support for typecasters is unnecessary.
I think the default typecasters (int
and float
) could be advantageously replaced by simple helper methods that would be available for both the path and the querystring:
bar_id = request.path.get_int('bar_id', minimum=1)
x = request.path.parse('x', float)
page = request.qs.get_int('page', default=1)
from aspen.py.
If you want to remove typecasting I won't object. If I ever get to build another Aspen/Pando site and I want typecasters I can bring it back locally as a state chain function.
from aspen.py.
Related Issues (20)
- Efficient file transfer isn't implemented HOT 1
- Configuration is still taken from the environment
- Pure-python alternative to simplates HOT 18
- No easy way to pass the output of a single simplate page through a filter
- Static resources are always cached in RAM
- Unexpected `output` in template HOT 7
- Repoint aspen.io to RtD HOT 5
- Broken test HOT 3
- What about a rc3 release to PyPI to finalize support for Python 3? HOT 3
- The dispatcher should not raise redirects
- Static.render doesn't check the request method HOT 2
- Not optimized for production use HOT 5
- Drop state chain? HOT 3
- Simplates are assumed to be ASCII even under python 3
- The number of system calls made by dispatchers could be reduced
- 3.9 dropped support for Aspen "magic directories" HOT 1
- Keeping static files open
- `mmap` for static files
- Compression of static files
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 aspen.py.