Thoughts about including an alias function for static files to reduce typing?
from flask import static
static('css/mystyle.css')
static('a/means/to/an/end.png')
This would be just a wrapper of
url_for('.static', filename='....')
--
Thadeus
fre 2010-08-27 klockan 11:22 -0500 skrev Thadeus Burgess: > Thoughts about including an alias function for static files to reduce typing? > > from flask import static > > static('css/mystyle.css') > static('a/means/to/an/end.png') > > This would be just a wrapper of > > url_for('.static', filename='....') > > -- > Thadeus This would be easy for you to do yourself. I usually have a utils module in my application package for things like this. However of course there's still value in discussing what might be valuable to include in the framework. Personally I've considered a function for linking static assets including a unix timestamp of the modification date, to ensure caching does not fuck up when "static" files are updated. asset('styles.css') → /static/styles.css?9084210938
Oh yeah super easy to do.
static = lambda filename: url_for('.static', filename=filename)
I was just wondering why this should not be included in the framework?
Its just syntatic sugar sure, but then I always end up having this
gigantic utils module of code I usually need in every flask app I
write.
--
Thadeus
On Fri, Aug 27, 2010 at 3:13 PM, Dag Odenhall <dag.odenhall@gmail.com> wrote:
> wever of course there's still value in discussing what might be
> valuable to include in the frame
Hi, On 2010-08-27 11:05 PM, Thadeus Burgess wrote: > Oh yeah super easy to do. > > static = lambda filename: url_for('.static', filename=filename) > > I was just wondering why this should not be included in the framework? > Its just syntatic sugar sure, but then I always end up having this > gigantic utils module of code I usually need in every flask app I > write. -1 for Flask itself for the moment due to how static things work with modules. Your usage might not be the one everyone has. I see the advantage, but going builtin is a big step. Put that and other helpers into a Flask-Utils extension perhaps and if enough people use it we can move stuff from there into core. Such an extension should probably be a community project though with more than one release manager and person with access to the sourcecode. Regards, Armin
lör 2010-08-28 klockan 02:12 +0200 skrev Armin Ronacher: > Hi, > > On 2010-08-27 11:05 PM, Thadeus Burgess wrote: > > Oh yeah super easy to do. > > > > static = lambda filename: url_for('.static', filename=filename) > > > > I was just wondering why this should not be included in the framework? > > Its just syntatic sugar sure, but then I always end up having this > > gigantic utils module of code I usually need in every flask app I > > write. > -1 for Flask itself for the moment due to how static things work with > modules. Your usage might not be the one everyone has. I see the > advantage, but going builtin is a big step. > > Put that and other helpers into a Flask-Utils extension perhaps and if > enough people use it we can move stuff from there into core. Such an > extension should probably be a community project though with more than > one release manager and person with access to the sourcecode. > > > Regards, > Armin +1 for a community utility extension. Could include some of the snippets on the website and in the docs, and some Werkzeug helpers such as a decorator for basic ETags. Git or Mercurial; what is the community preference? Last I checked only Armin's extensions are on Git and the rest on Mercurial.
Hi, On 2010-08-28 11:51 AM, Dag Odenhall wrote: > Git or Mercurial; what is the community preference? Last I checked only > Armin's extensions are on Git and the rest on Mercurial. I'm currently playing with the idea of providing a service on pocoo.org that mirrors git to hg and the other way round. Unfortunately there is currently a bug in the dulwhich module I'm using for that so it will take a bit longer. Regards, Armin
lör 2010-08-28 klockan 12:20 +0200 skrev Armin Ronacher: > Hi, > > On 2010-08-28 11:51 AM, Dag Odenhall wrote: > > Git or Mercurial; what is the community preference? Last I checked only > > Armin's extensions are on Git and the rest on Mercurial. > I'm currently playing with the idea of providing a service on pocoo.org > that mirrors git to hg and the other way round. Unfortunately there is > currently a bug in the dulwhich module I'm using for that so it will > take a bit longer. > > > Regards, > Armin > Would it be able to sync repositories between GitHub and Bitbucket? How real-time would it be?
On Fri, Aug 27, 2010 at 11:05 PM, Thadeus Burgess <thadeusb@thadeusb.com> wrote: > I was just wondering why this should not be included in the framework? > Its just syntatic sugar sure, but then I always end up having this > gigantic utils module of code I usually need in every flask app I > write. What about a Flask-Utils extension? Alex
I'm about to =0 -- Thadeus On Fri, Aug 27, 2010 at 5:13 PM, Alex <thinkpragmatic@gmail.com> wrote: > On Fri, Aug 27, 2010 at 11:05 PM, Thadeus Burgess <thadeusb@thadeusb.com> wrote: >> I was just wondering why this should not be included in the framework? >> Its just syntatic sugar sure, but then I always end up having this >> gigantic utils module of code I usually need in every flask app I >> write. > > What about a Flask-Utils extension? > > Alex >