terranodo / landscapeportal

landscape portal geonode_project
0 stars 1 forks source link

Settings files #1

Closed matthewhanson closed 9 years ago

matthewhanson commented 9 years ago

The geonode project has this as individual settings:

import os
from geonode.settings import *
#
# General Django development settings
#

SITENAME = 'landscapeportal'

# Defines the directory that contains the settings file as the LOCAL_ROOT
# It is used for relative settings elsewhere.
LOCAL_ROOT = os.path.abspath(os.path.dirname(__file__))

WSGI_APPLICATION = "landscapeportal.wsgi.application"

# Load more settings from a file called local_settings.py if it exists
try:
    from local_settings import *
except ImportError:
    pass

# Additional directories which hold static files
STATICFILES_DIRS.append(
    os.path.join(LOCAL_ROOT, "static"),
)

# Note that Django automatically includes the "templates" dir in all the
# INSTALLED_APPS, se there is no need to add maps/templates or admin/templates
TEMPLATE_DIRS = (
    os.path.join(LOCAL_ROOT, "templates"),
) + TEMPLATE_DIRS

# Location of url mappings
ROOT_URLCONF = 'landscapeportal.urls'

# Location of locale files
LOCALE_PATHS = (
    os.path.join(LOCAL_ROOT, 'locale'),
    ) + LOCALE_PATHS

Now I haven't tried this in a while, but when I had a multi-tenancy GeoNode running I did this:

SITE_ID = 5
SITE_NAME = 'Conservation Design'
SITEURL = 'http://cdesign.ags.io/'
ROOT_URLCONF = 'geosolution.urls'

SITE_VECTOR = 'geo:cdesign_site'

SITE_APPS = (
    'geosites.cdesign.rpccr',
)

REGISTRATION_OPEN = False

###############################################
# Usually not edited
###############################################
import os
import mastersite

# SHORTNAME = SITE_NAME.lower()
SHORT_NAME = "cdesign"

MASTERSITE_ROOT = os.path.dirname(mastersite.__file__)
execfile(os.path.join(GEOSOLUTION_ROOT, 'settings_global.py'))

PROXY_ALLOWED_HOSTS = ('.ags.io','.conservationdesign.org')
ALLOWED_HOSTS = PROXY_ALLOWED_HOSTS
ALLOWED_HOSTS = ('*')
#PROXY_ALLOWED_HOSTS = (u'cdesign.ags.io',)
#ALLOWED_HOSTS = (u'.ags.io',)

TEMPLATE_DIRS = (
     os.path.join(SITE_ROOT, 'templates/'),
     os.path.join(MASTER_ROOT, 'templates/'),
     os.path.join(GEONODE_ROOT, 'templates/')
)

#DEBUG_STATIC = False
DEBUG_TOOLBAR = False

Notice the execfile statement. This allows another site file to be included into the current settings as if it were there to begin with. Then, individual keys of dictionaries can be overridden without having to respecify the entire block. I'll add an example of a master_settings file and a site settings file.

The master settings file in turn starts with the base geonode settings file. Once I get some examples we can talk about which things should be able to be changed per site.

As an aside, what is the WSGI_APPLICATION setting used for? Since that has to be set after setting the settings file itself, I'm not sure why it would be needed.

simod commented 9 years ago

Ok, this was just a default generated settings file from the geonode_project, I haven't changed it.

matthewhanson commented 9 years ago

Any idea how, or even if, the WSGI_APPLICATION setting is used?

simod commented 9 years ago

I think it's used when running the Geonode project in production somehow.

Il giovedì 18 giugno 2015, Matthew Hanson notifications@github.com ha scritto:

Any idea how, or even if, the WSGI_APPLICATION setting is used?

— Reply to this email directly or view it on GitHub https://github.com/terranodo/landscapeportal/issues/1#issuecomment-113136313 .

Simone

matthewhanson commented 9 years ago

Settings files added, for master site and a template for a GeoSite.

There is pre_settings and post_settings. Each site first loads pre_settings, then sets site specific variables (e.g., SITE_ID, SITE_NAME), then loads post_settings.