Actually, it's not out of scope; GeoNode doesn't cover nearly the depth and
breadth of the GeoServer admin interface so it is useful for the admin
interface to work.  So, thanks for the patch :)  In the future, though, it
would be nice to have diff files (http://en.wikipedia.org/wiki/Diff) instead
of English descriptions of the files to modify.  If you are using version
control it is usually easy to have your version control tool generate such a
file.

I should warn you that the proxy is not very efficient at the moment though;
it requires GeoServer to complete the response before it can forward the
results to the original client, and buffers that response entirely in memory
(so it would be problematic to, say, make a large WFS request via the proxy.
 In GeoNode we restrict its usage to REST API access only, so it is has not
caused us much trouble yet.  In the long term we'll probably need a better
solution, but it is not a pressing concern yet.)

As for the patch itself - there are many requests you can make to GeoServer
which use the POST method but do not include a Location: header in the
results, and similarly there are requests you can make using other HTTP
methods which will include a Location: header. I think a more robust
solution would be to check for Location: explicitly and rewrite the URL if
an absolute URL is detected.  I haven't tested this code, but I think
something like this would work fairly well:

    if resp.status != 404:
        if "content-type" in resp.keys():
            return
HttpResponse(content=content,status=resp.status,mimetype=resp["content-type"])
        else:
            if "location" in resp.keys():
                location = resp["location"]
                if location.find("http://";) == 0:
                    idx = location.find("/", len("http://";))
                    location = location[idx:]
                return HttpResponseRedirect(location)
            return HttpResponse(content = content, status = resp.status)
    else:
        return HttpResponse(content="Something went wrong",status=404)

Hope this helps.

--
David Winslow
OpenGeo - http://opengeo.org/

On Wed, Jan 26, 2011 at 12:58 AM, <[email protected]> wrote:

> This might be kind of out-of-scope for what you're doing with Geonode, but
> I just thought I'd ask... I'm working on another project where I want to
> play with providing access to Geoserver from behind Django. I essentially
> copied your view
> (
> https://github.com/GeoNode/geonode/blob/master/src/GeoNodePy/geonode/proxy/views.py
> -- Thanks!!), and with a couple of tweaks to my Django project's urls.py I
> was able to access the Geoserver pages. I ran into a problem, though, when
> the login POST wouldn't finish properly. I noticed exactly the same issue
> if I go to http://demo.geonode.org/geoserver/web/ and try some random
> login there -- you end up with a 302 that doesn't seem to resolve itself,
> and the browser just shows a blank page.
>
> I noticed that resp['content-location'] shows
>
> http://localhost:8080/geoserver/;jsessionid=6D614A678A2C0170FE5509443554A4E1
> after a post, so I hacked the view by including:
>
> if resp.status != 404:
>    if "content-type" in resp.keys():
>        return
>
> HttpResponse(content=content,status=resp.status,mimetype=resp["content-type"])
>    else:
>        if request.method in ("POST"):
>            cookie = resp['location'].split(';')[1]
>            return HttpResponseRedirect('/geoserver/web/;' + cookie)
>        return HttpResponse(content=content,status=resp.status)
> else:
>    return HttpResponse(content="<p>Something went wrong</p><p>I
> requested: " + url + "</p>",status=404)
>
> I think that what I'm doing is short-circuiting the javascript-based
> redirection that occurs from /geoserver/ to /geoserver/web/ after the
> POST. I also had to add a couple of extra patterns to urlconf in order to
> get everything to seem like it is working smoothly - I'm basically
> skipping the javascript redirection in a couple of other places:
>
> geoserver = patterns('',
>    (r'^/?$', 'django.views.generic.simple.redirect_to', {'url':
> '/geoserver/web/'}),
>    (r'^/j_acegi_logout$', 'django.views.generic.simple.redirect_to',
> {'url': '/geoserver/web/'}),
>    (r'^/', 'granite.views.geoserver'),
> )
>
> urlpatterns = patterns('',
>    (r'^admin/', include(admin.site.urls)),
>    (r'^geoserver', include(geoserver)),
>    ...,
> )
>
>  It all sort of feels like a hack - I'm not sure if something else will
> break somewhere else.
>
> As I understand the project, Geonode's UI manipulates Geoserver without
> you ever actually using the default Geoserver admin pages, but reading
> your view was really useful and I just thought I'd throw this out there in
> case you're interested. It also seemed like a good excuse to get
> subscribed to the mailing list.
>
> Thanks,
> Ryan
>
>
>

Reply via email to