Re: Pyramid - Including diffrent version of static files in development and production mode

218 views
Skip to first unread message

Chris McDonough

unread,
Jul 21, 2012, 5:36:21 PM7/21/12
to pylons-...@googlegroups.com
On 07/21/2012 04:29 PM, psychowico wrote:
> Hi all.
> I am quite new in Pyramid and still learning. Now I looking for best
> way to manage static resources in project. I found nice package
> "Fanstatic <http://www.fanstatic.org/en/latest/index.html>" and
> "pyramid_fanstatic <http://pypi.python.org/pypi/pyramid_fanstatic/>"
> plugin, but it looks that this not working with pyramid 1.3 and Python 3.2.
> Main things that I want achieve is automatically replace develop
> libraries version in develop mode by packed in production - /jquery.js/
> and /jquery.min.js /for example.
> I see some ways to manage this, but I looking for elegant way, I guess
> this task is popular and some good way exists to do this.

If you've used a scaffold to set up your Pyramid application. You know
where you do:

config.add_static_view(..)

to add a static view?

That's python of course. Conditionalize it with an "if". Add a
different static directory based on a value passed in to "settings" in
your main().

- C

Jonathan Vanasco

unread,
Jul 21, 2012, 5:58:06 PM7/21/12
to pylons-discuss
i have a deploy script written in Fabric ( fabfile )

it handles a bunch of things like:

- minify js and css
- create symlinks for directories as needed
- etc

generally i do one - or both - of the following:
1) instead of static, i have /-static-source /static-production
2) a symlink in 'develop' mode links /static to /-static-source ; in
'production' mode, it works on 'source' files and exports them to
'production' - which is them symlinked to static
3) i also set a 'is_production' flag on the request object, and alter
templates like that

I opted for a flag and template logic, because on production systems I
want to concatenate as many of the CSS and JS files as possible to
minimize server requests. switching between a.js and a.min.js is a
step in the right direction, but i want my production to have a+b+c+d+e
+f.min.js

that being said == it's very rare that you should ever need to use a
non-minified version of jquery or most plugins. the production
versions have all the same debug capabilities, the non-minified
versions are really there for people to hack on the core.

psychowico

unread,
Jul 23, 2012, 4:18:47 AM7/23/12
to pylons-...@googlegroups.com
Thanks for all you advices. WebDeps looking very promising, I will look at it.
Reply all
Reply to author
Forward
0 new messages