Glashammer with Google App Engine - add_shared(...) method.

7 views
Skip to first unread message

Ritesh Nadhani

unread,
Apr 28, 2009, 10:02:37 PM4/28/09
to glash...@googlegroups.com
Hi

So I am trying out Glashammer with Google App Engine and it seems to
be working great. Though I am having one issue with
app.add_shared(...) method.

My project folder structure is:

project/
wekzeug/
glashammer/
jinja2/
...
main.py
static
shared/css/style.css

In my app setup, I am doing:

app.add_shared('static', 'static')

and in my template, I do:

{{ h.link('stylesheet', url_for('shared/static', filename='css/bauer.css')) }}

which gives me

<link href="/_shared/static/css/bauer.css" rel="stylesheet" />

and it does not work. Changing it to:

<link href="//static/css/bauer.css" rel="stylesheet" />

correctly references my stylesheet.

Looking deeper, I see in application.py/add_shared(...) method:

url = sep.join(['/_shared', name])
ep = sep.join(['shared', name])

Why is this being added?

Running the app as standalone app using gh-admin works correct.

The only part of code that seemed relevant was:

# now add the middleware for static file serving
self.add_shared('glashammer', sibpath(__file__, 'shared'))
self.add_middleware(SharedDataMiddleware, self._shared_exports)

What am I doing wrong?

--
Ritesh
http://www.riteshn.com

Ali Afshar

unread,
May 5, 2009, 5:15:21 PM5/5/09
to glashammer
Hi, (sorry for the delay, I seem to not be getting notification from
google sometimes)

Glashammer serves the default shared stuff under /_shared. Now when
using AppEngine, you really really don't want to use the Glashammer
static file serving. You would rather use AppEngine's static file
serving as referenced in app.yaml. So I would make a rule in app.yaml
to serve your shared directory at /_shared. This way you can use your
app with gh-admin, or AppEngine and it would work in both.

Ali

Ritesh Nadhani

unread,
May 6, 2009, 5:57:10 PM5/6/09
to glash...@googlegroups.com
Hello

On Tue, May 5, 2009 at 2:15 PM, Ali Afshar <aaf...@gmail.com> wrote:
>
> Hi, (sorry for the delay, I seem to not be getting notification from
> google sometimes)

No problem.

>
> Glashammer serves the default shared stuff under /_shared. Now when
> using AppEngine, you really really don't want to use the Glashammer
> static file serving. You would rather use AppEngine's static file
> serving as referenced in app.yaml. So I would make a rule in app.yaml
> to serve your shared directory at /_shared. This way you can use your
> app with gh-admin, or AppEngine and it would work in both.

Alright. Thus I have to always expose my static files from _static as
a standard. That should not be a problem.

Maybe we can document this issue?
--
Ritesh
http://www.riteshn.com

Ritesh Nadhani

unread,
Feb 13, 2010, 12:38:07 AM2/13/10
to glash...@googlegroups.com
Well, the issue is now that I want to move all my static files to S3,
the shared URL does not work as I do want to allias /_shared.

Thus, a command like:

app.add_shared('static', 'http://static.beamto.us')

{{ url_for('shared/static', filename='c.css') }}

becomes: /_shared/static/c.css

Can this be easily solved? Then it will be much easier to move your
static files to different storage services with one change. In
application.py/add_shared, the shared link is generated in an
hardcoded manner.

>> --~--~---------~--~----~------------~-------~--~----~
>> You received this message because you are subscribed to the Google Groups "glashammer" group.
>> To post to this group, send email to glash...@googlegroups.com
>> To unsubscribe from this group, send email to glashammer+...@googlegroups.com
>> For more options, visit this group at http://groups.google.com/group/glashammer?hl=en
>> -~----------~----~----~----~------~----~------~--~---
>>
>>
>
>
>
> --
> Ritesh

Ali Afshar

unread,
Feb 13, 2010, 12:50:42 AM2/13/10
to glash...@googlegroups.com
I usually keep a copy for development, and url_for then use some kind
of alias/redirect at the server level in production.

Ali

> --


> You received this message because you are subscribed to the Google Groups "glashammer" group.

> To post to this group, send email to glash...@googlegroups.com.
> To unsubscribe from this group, send email to glashammer+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/glashammer?hl=en.
>
>

Ritesh Nadhani

unread,
Feb 14, 2010, 12:46:16 AM2/14/10
to glash...@googlegroups.com
Well, I really do not have that option with GAE. I can only alias a
URL in GAE to respond static files but with _shared being added
automagically, I cannot effectively use the S3 static file hosting.

Maybe an API to do such thing would be nice? I can help you write up a
patch for the same.

--
Ritesh
http://www.riteshn.com

Ali Afshar

unread,
Feb 14, 2010, 4:37:21 AM2/14/10
to glash...@googlegroups.com
Sure, that would be useful, thanks.

Ritesh Nadhani

unread,
Feb 16, 2010, 1:40:45 PM2/16/10
to glash...@googlegroups.com
So would a new API like:

add_shared() e.g. add_static() would be better.

or we can extend add_shared to have additional conditional parameters.

Ali Afshar

unread,
Feb 16, 2010, 1:47:38 PM2/16/10
to glash...@googlegroups.com
I think something like add_shared_external() and then use some clever
trick in the werkzeug rule to make it translate automatically

Ritesh Nadhani

unread,
Feb 24, 2010, 5:56:41 PM2/24/10
to glash...@googlegroups.com
Hi,

First of all, the download page: http://glashammer.org/downloads.html
seems to be really outdated. Its showing 0.1 while I have 0.2 and the
trunk is 0.3.

Anyway, before I start working on add_shared_ext(), I have a patch
that checks out WTForms currently when using gh-admin. Let me know if
that works for you.

I will start working on the other patch soon.

Ritesh Nadhani

unread,
Feb 24, 2010, 5:57:29 PM2/24/10
to glash...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages