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