javascript proxy issue

22 views
Skip to first unread message

Timmie

unread,
Apr 23, 2009, 9:41:23 AM4/23/09
to web2py Web Framework
Hello,
after successfully creating my KML [1] I would like to load that as a
layer in a openlayers script.

According to the Openlayers homepage [2], javascript has a problem
fetching external urls.
They created a proxy.cgi script [3].

How can I include this in my web2py application in order to enable my
openlayers javascript code to load an arbitrary file (GeoRSS, GeoJSON,
KML, etc.) from any URL?

Would I need to put this into an apache cgi-bin?

Or does web2py provide another procedure for such a case?

Thanks in advance,
Timmie

[1] templating a non-html file (in view) - http://groups.google.com/group/web2py/t/b59bd3a9c40086f0
[2] ProxyHost - http://faq.openlayers.org/proxyhost/
[3] http://trac.openlayers.org/browser/trunk/openlayers/examples/proxy.cgi

Fran

unread,
Apr 23, 2009, 2:18:59 PM4/23/09
to web2py Web Framework
On Apr 23, 2:41 pm, Timmie <timmichel...@gmx-topmail.de> wrote:
> javascript has a problem fetching external urls.
> They created a proxy.cgi script [3].

Yup, I have the same issue :)

> How can I include this in my web2py application in order to enable my
> openlayers javascript code to load an arbitrary file (GeoRSS, GeoJSON,
> KML, etc.) from any URL?
> Would I need to put this into an apache cgi-bin?

I /think/ we need to rewrite the CGI script as a Web2Py
controller...well, I do at least, as I don't want to depend on Apache
as my app is going to be deployed in many scenarios...if you just have
a single instance & have Apache ready, then a simple CGI bin will sort
you out ;)

F

Tim Michelsen

unread,
Apr 23, 2009, 3:03:43 PM4/23/09
to web...@googlegroups.com
Hello!

>> javascript has a problem fetching external urls.
>> They created a proxy.cgi script [3].
>
> Yup, I have the same issue :)
Thanks for confirming this. Such a short time I am working with
Openlayers (OL)...

What I think is strange that the OL states that load from localhost
shouldn't be a problem...

I wonder how this is solved within other javascript frameworks. Do they
never load external pages?
Saving to a temporary file is not an option when the kml is generated
dynamically from queries.

> I /think/ we need to rewrite the CGI script as a Web2Py
> controller...well, I do at least, as I don't want to depend on Apache
> as my app is going to be deployed in many scenarios...

Did you already start with this?
I do not yet know how to write this as native web2py controller since I
do not understand the underlaying JS & proxy issues.
I will brach out you code and see what you have done so far.

What about looking at geo.turbogears & django?

>if you just have
> a single instance & have Apache ready, then a simple CGI bin will sort
> you out ;)

I think OL is just not enough to justify running apache among cherrypy
(web2py).


Please let's get this dicussion going on.

Regards,
Timmie

Fran

unread,
Apr 24, 2009, 3:00:33 AM4/24/09
to web2py Web Framework
On Apr 23, 8:03 pm, Tim Michelsen <timmichel...@gmx-topmail.de> wrote:
> Hello!>> javascript has a problem fetching external urls.
> >> They created a proxy.cgi script [3].
> > Yup, I have the same issue :)
> Thanks for confirming this. Such a short time I am working with
> Openlayers (OL)...

This is the bit that I'm more comfortable with :)

> What I think is strange that the OL states that load from localhost
> shouldn't be a problem...

It should be fine from the *same* host as the originating query.

> I wonder how this is solved within other javascript frameworks. Do they
> never load external pages?

They use a Proxy too.
jQuery now supports using JSONP callbacks which avoid the issue
outside of OL:
http://docs.jquery.com/Ajax/jQuery.ajax#options
Need to ask on OL list if this same technique can be used for OL...

> Saving to a temporary file is not an option when the kml is generated
> dynamically from queries.

Why not?
How often are you updating the queries?

> > I /think/ we need to rewrite the CGI script as a Web2Py
> > controller...well, I do at least, as I don't want to depend on Apache
> > as my app is going to be deployed in many scenarios...
> Did you already start with this?

Not seriously...

> I do not yet know how to write this as native web2py controller since I
> do not understand the underlaying JS & proxy issues.

'Just' a question of porting the existing Python CGI to Web2Py I
think.
Ignore the JS issue - what you need is a simple, dumb HTTP Proxy.
(Need to provide for authentication somewhere, but that part's easy in
Web2Py)

> I will brach out you code and see what you have done so far.

:)

> What about looking at geo.turbogears & django?

Definitely a good idea.
Ill see if the TG geo author can help us with this too...he's
interested in helping Sahana :)

> >if you just have
> > a single instance & have Apache ready, then a simple CGI bin will sort
> > you out ;)
> I think OL is just not enough to justify running apache among cherrypy
> (web2py).

Great - glad you have the same idea here :)

F

Fran

unread,
Apr 27, 2009, 5:26:47 PM4/27/09
to web2py Web Framework
On Apr 23, 8:03 pm, Tim Michelsen <timmichel...@gmx-topmail.de> wrote:
> I think OL is just not enough to justify running apache among cherrypy
> (web2py).

I got given a suggestion for a possible proxy to port into Web2Py:
http://trac.pythonpaste.org/pythonpaste/browser/Paste/trunk/paste/proxy.py

Maybe easier than starting from the CGI...

F

Tim Michelsen

unread,
May 3, 2009, 2:40:48 PM5/3/09
to web...@googlegroups.com
Hey, Fran,
here is something what I wanna get with web2py:
http://www.whitehouse.gov/change/

Cheers,
Timmie

Yarko Tymciurak

unread,
May 3, 2009, 4:10:33 PM5/3/09
to web...@googlegroups.com
This is great stuff, whitehouse.gov --

I know that google moderator (or a modification of) has been used for nationwide townhalls also - Guido vonRossum's team was involved in helping set that up.

I would like to see moderator-like app on web2py.

Note: I have yet to see anything that looks as good as the survey app that Massimo built for web2py anywhere.... so this can / should be a 2 way street.

Should we have a list (like a bug list, only an appliance wish-list) for web2py apps desired?  We could show examples, slowly evolve function lists, and people interested (and who had time) could pick up an develop.
Reply all
Reply to author
Forward
0 new messages