Skip to content
This repository was archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
Rename all settings with the old "polla" name, this is a breaking cha…
Browse files Browse the repository at this point in the history
…nge!
  • Loading branch information
fdemmer committed Jul 5, 2017
1 parent 6219333 commit fa2e343
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions airavata/settings.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os


POLLA_BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
AIRAVATA_BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

## Sites specific files base directory
POLLA_SITES_DIR = os.path.join(POLLA_BASE_DIR, 'sites')
AIRAVATA_SITES_DIR = os.path.join(AIRAVATA_BASE_DIR, 'sites')

## should dots from domain names be replaced by underscores for
## paths used in templates, staticfiles and urls loaders
POLLA_REPLACE_DOTS_IN_DOMAINS = False
AIRAVATA_REPLACE_DOTS_IN_DOMAINS = False
2 changes: 1 addition & 1 deletion airavata/staticfiles_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, app_name=None, *args, **kwargs):
self.storages = OrderedDict()
for site in Site.objects.all():
current = get_domain_path(site.domain)
root = os.path.join(settings.POLLA_SITES_DIR, current, 'static')
root = os.path.join(settings.AIRAVATA_SITES_DIR, current, 'static')
if os.path.exists(root) and (current, root) not in self.locations:
self.locations.append((current, root))

Expand Down
2 changes: 1 addition & 1 deletion airavata/template_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_template_sources(self, template_name, template_dirs=None):
return False

try:
return safe_join(settings.POLLA_SITES_DIR, current, 'templates', template_name)
return safe_join(settings.AIRAVATA_SITES_DIR, current, 'templates', template_name)
except SuspiciousFileOperation:
return False

Expand Down
2 changes: 1 addition & 1 deletion airavata/templatetags/sitestatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def static(path):
site_path = get_current_path()
if os.path.exists(os.path.join(settings.POLLA_SITES_DIR, site_path, 'static', path)):
if os.path.exists(os.path.join(settings.AIRAVATA_SITES_DIR, site_path, 'static', path)):
return staticfiles_storage.url(os.path.join(site_path, path))
return staticfiles_storage.url(path)

Expand Down
10 changes: 5 additions & 5 deletions airavata/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from django.conf import settings


POLLA_PATCHED_RESOLVER = False
AIRAVATA_PATCHED_RESOLVER = False

class UrlPatterns(object):

def __init__(self, defaults=[]):
if not settings.POLLA_REPLACE_DOTS_IN_DOMAINS:
raise ImproperlyConfigured("POLLA_REPLACE_DOTS_IN_DOMAINS needs to be set to True in order to use this functionality")
if not settings.AIRAVATA_REPLACE_DOTS_IN_DOMAINS:
raise ImproperlyConfigured("AIRAVATA_REPLACE_DOTS_IN_DOMAINS needs to be set to True in order to use this functionality")
self.defaults = defaults
self.extras = []

Expand Down Expand Up @@ -93,9 +93,9 @@ def __reversed__(self):
to_reverse = list(self.get_current_urls())
return reversed(to_reverse)

if not POLLA_PATCHED_RESOLVER:
if not AIRAVATA_PATCHED_RESOLVER:
from .utils import get_resolver, get_ns_resolver
from django.core import urlresolvers
urlresolvers.get_resolver = get_resolver
urlresolvers.get_ns_resolver = get_ns_resolver
POLLA_PATCHED_RESOLVER = True
AIRAVATA_PATCHED_RESOLVER = True
2 changes: 1 addition & 1 deletion airavata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_current_site(request=None):
## Loaders

def get_domain_path(domain):
if settings.POLLA_REPLACE_DOTS_IN_DOMAINS:
if settings.AIRAVATA_REPLACE_DOTS_IN_DOMAINS:
domain = domain.replace('.', '_')
return domain.lower()

Expand Down
14 changes: 7 additions & 7 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ To use any of the following features, make sure you enable `LocalThreadMiddlewar
)


POLLA_SITES_DIR
AIRAVATA_SITES_DIR
~~~~~~~~~~~~~~~

Every site-specific feature (template, urls, static file) is hosted under a main directory (``BASE_DIR/sites`` by default), to override it, provide ``POLLA_SITES_DIR`` in your ``settings.py``
Every site-specific feature (template, urls, static file) is hosted under a main directory (``BASE_DIR/sites`` by default), to override it, provide ``AIRAVATA_SITES_DIR`` in your ``settings.py``

POLLA_REPLACE_DOTS_IN_DOMAINS
AIRAVATA_REPLACE_DOTS_IN_DOMAINS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This setting is set to ``False`` by default. For people wanting to use Airavata as a drop-in replacement for ``dynamicsites`` or who would like to use the **Urls** feature, you shoud set it to ``True``.

Setting ``POLLA_REPLACE_DOTS_IN_DOMAINS`` will change the default behaviour when it comes to looking for site specific features.
Setting ``AIRAVATA_REPLACE_DOTS_IN_DOMAINS`` will change the default behaviour when it comes to looking for site specific features.

e.g: you are trying to load a template named ``base.html`` for the site ``example.com``. having ``POLLA_REPLACE_DOTS_IN_DOMAINS`` set to ``True`` django will try looking for it under ``sites/example_com/templates/base.html`` instead of the default ``sites/example.com/templates/base.html``
e.g: you are trying to load a template named ``base.html`` for the site ``example.com``. having ``AIRAVATA_REPLACE_DOTS_IN_DOMAINS`` set to ``True`` django will try looking for it under ``sites/example_com/templates/base.html`` instead of the default ``sites/example.com/templates/base.html``

.. note::
In any case directory names are lower-case
Expand All @@ -48,7 +48,7 @@ e.g: you are trying to load a template named ``base.html`` for the site ``exampl
TemplateLoader
--------------

Airavata provides a TemplateLoader allowing you to load different templates according to the requested host. Specific templates should be placed under the directory configured in ``POLLA_SITES_DIR`` under a sub-directory corresponding to the main domain name (the domain name in ``Site``).
Airavata provides a TemplateLoader allowing you to load different templates according to the requested host. Specific templates should be placed under the directory configured in ``AIRAVATA_SITES_DIR`` under a sub-directory corresponding to the main domain name (the domain name in ``Site``).

To enable Airavata's template loader, you have to make the following changes to your settings.py:
::
Expand Down Expand Up @@ -121,7 +121,7 @@ UrlPatterns
-----------

.. note::
To use this feature, make sure you set ``POLLA_REPLACE_DOTS_IN_DOMAINS`` to ``True`` in your ``settings.py``
To use this feature, make sure you set ``AIRAVATA_REPLACE_DOTS_IN_DOMAINS`` to ``True`` in your ``settings.py``
On Python 2 also make sure to include ``__init__.py`` in both ``sites`` and it's sub_directory

Airavata allows you to define different urlpatterns for specific domains. To use this feature, update your main ``urls.py`` to look like this
Expand Down
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
)

POLLA_REPLACE_DOTS_IN_DOMAINS = True
AIRAVATA_REPLACE_DOTS_IN_DOMAINS = True
4 changes: 2 additions & 2 deletions test_app/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ def testModel(self):
class UtilsTest(TestCase):

def test_dont_replace_dots_get_domain_path(self):
with self.settings(POLLA_REPLACE_DOTS_IN_DOMAINS=False):
with self.settings(AIRAVATA_REPLACE_DOTS_IN_DOMAINS=False):
self.assertEqual(get_domain_path('exAmple.com'), 'example.com')

def test_replace_dots_get_domain_path(self):
with self.settings(POLLA_REPLACE_DOTS_IN_DOMAINS=True):
with self.settings(AIRAVATA_REPLACE_DOTS_IN_DOMAINS=True):
self.assertEqual(get_domain_path('exAmple.com'), 'example_com')


Expand Down

0 comments on commit fa2e343

Please sign in to comment.