On Mon, Sep 21, 2009 at 00:28, Thadeus Burgess <[email protected]> wrote:
> In production, you would never rely on wsgi to serve static content. You
> would use apache, preferably on a subdomain, to serve static content (unless
> it is content that requires authentication)
>
> I propose a function, that works like the URL function, but you could have a
> global variable that defines your static url.
>
> For example, in db.py (or perhaps settings.py in the models folder?)
>
> static_server = "http://static.thadeusb.com/"
> # or static_server = "localhost"
>
> def S(filename):
> if static_server == "localhost":
> return URL(r=request, c='static', f=filename)
> else:
> return static_server + filename
>
>
> And you can use it in your controllers/views like so
>
> {{=S("images/spiffyimage.jpg")}}
>
> This way will increase the ability for one-click deployment to production,
> you only have to change one line!
>
> -Thadeus
You can do it with routes.py!
Example:
routes_out = (
('/myapp/static/(?P<filename>[A-Za-z_.-]+)',
'http://static.justen.eng.br/images/\g<filename>'),
)
When I use URL(a='myapp', c='static', f='blablabla.jpg') or something
like that (that should correspond to '/myapp/static/blablabla.jpg')
web2py uses routes_out regexes and turn it into
'http://static.justen.eng.br/images/blablabla.jpg'. Cool, isn't it?
:-)
--
Álvaro Justen
Peta5 - Telecomunicações e Software Livre
21 3021-6001 / 9898-0141
http://www.peta5.com.br/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---