anselmorenato / threepress

Automatically exported from code.google.com/p/threepress
Other
0 stars 0 forks source link

Deploy bookworm to a non-root webserver location #155

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Deploy bookworm to a location that isn't the webserver document root (eg: 
/apps/bookworm/)
2. Click on a link on the homepage (actually it will be a 404); the link to 
'about' will be "/about", 
not "/apps/bookworm/about"

It would be nice to be able to deploy bookworm to a non-root location on a 
webserver 
sometimes. I'm not sure if this is possible using some django-fu of which I'm 
not aware. When 
deploying a ruby on rails application using mongrel_rails, you can specify a 
root url, making the 
application portable.

The same thing can be achieved cheaply by introducing a BASE_URL variable to 
the settings.py 
file, and referencing this BASE_URL in the urls.py routes/paths/patterns. 

Example:
-                       (r'^admin/(.*)',  admin.site.root),
+                       (r'^%sadmin/(.*)' % settings.BASE_URL,  
admin.site.root),

I've attached a diff made against today's trunk. My svn info output:
URL: http://threepress.googlecode.com/svn/trunk
Repository Root: http://threepress.googlecode.com/svn
Repository UUID: e08d0fb5-4147-0410-a205-bba44f1f51a3
Revision: 863
Node Kind: directory
Schedule: normal
Last Changed Author: liza31337
Last Changed Rev: 863
Last Changed Date: 2009-08-20 05:48:07 +1000 (Thu, 20 Aug 2009)
Properties Last Updated: 2009-08-21 10:17:02 +1000 (Fri, 21 Aug 2009)

Original issue reported on code.google.com by steven.m...@gmail.com on 21 Aug 2009 at 1:45

Attachments:

GoogleCodeExporter commented 9 years ago
FWIW, at least one other Django project I've seen has handled this with a config
variable like BASE_URL. I don't know if there's another way.

Original comment by liza31337@gmail.com on 21 Aug 2009 at 2:21

GoogleCodeExporter commented 9 years ago
I should probably attribute 
http://gnuvince.wordpress.com/2007/12/22/django-paths-and-urls/ as confirming 
my idea of using a settings variable to do this.

Original comment by steven.m...@gmail.com on 21 Aug 2009 at 2:26

GoogleCodeExporter commented 9 years ago
oh, and you'll also need to ammend settings.LOGIN_URL accordingly:

LOGIN_URL = '/%s%s%s' %  (BASE_URL, ugettext('account/'), ugettext('signin/'))

Original comment by steven.m...@gmail.com on 26 Aug 2009 at 4:15

GoogleCodeExporter commented 9 years ago
I committed a version of the patch that includes the variable in settings.py 
but sets
it to the empty string; there's a comment to explain what to do. 

Thanks!

Original comment by liza31337@gmail.com on 26 Aug 2009 at 10:11