# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
-import logging
-import hashlib
+from xml.dom import minidom
from django.conf import settings
from django.http import HttpResponse
from django.utils import simplejson as json
from django.utils.http import parse_etags
from django.utils.encoding import smart_str
-from xml.dom import minidom
from pithos.lib.filter import parse_filters
SaveToBackendHandler, object_data_response, put_object_block, hashmap_md5, simple_list_response, api_method)
from pithos.backends.base import NotAllowedError, QuotaError
+import logging
+import hashlib
+
logger = logging.getLogger(__name__)
--- /dev/null
+from django.conf import settings
+from os.path import abspath, dirname, join
+
+PROJECT_PATH = getattr(settings, 'PROJECT_PATH', dirname(dirname(abspath(__file__))))
+
+# SQLAlchemy (choose SQLite/MySQL/PostgreSQL).
+BACKEND_DB_MODULE = getattr(settings, 'PITHOS_BACKEND_DB_MODULE', 'pithos.backends.lib.sqlalchemy')
+BACKEND_DB_CONNECTION = getattr(settings, 'PITHOS_BACKEND_DB_CONNECTION', 'sqlite:///' + join(PROJECT_PATH, 'backend.db'))
+
+# Block storage.
+BACKEND_BLOCK_MODULE = getattr(settings, 'PITHOS_BACKEND_BLOCK_MODULE', 'pithos.backends.lib.hashfiler')
+BACKEND_BLOCK_PATH = getattr(settings, 'PITHOS_BACKEND_BLOCK_PATH', join(PROJECT_PATH, 'data/'))
+
+# Queue for billing.
+BACKEND_QUEUE_MODULE = getattr(settings, 'PITHOS_BACKEND_QUEUE_MODULE', None) # Example: 'pithos.backends.lib.rabbitmq'
+BACKEND_QUEUE_CONNECTION = getattr(settings, 'PITHOS_BACKEND_QUEUE_CONNECTION', None) # Example: 'rabbitmq://guest:guest@localhost:5672/pithos'
+
+# Default setting for new accounts.
+BACKEND_QUOTA = getattr(settings, 'PITHOS_BACKEND_QUOTA', 50 * 1024 * 1024 * 1024)
+BACKEND_VERSIONING = getattr(settings, 'PITHOS_BACKEND_VERSIONING', 'auto')
+
Conflict, LengthRequired, PreconditionFailed, RequestEntityTooLarge,
RangeNotSatisfiable, InternalServerError, NotImplemented)
from pithos.api.short_url import encode_url
+from pithos.api.settings import (BACKEND_DB_MODULE, BACKEND_DB_CONNECTION,
+ BACKEND_BLOCK_MODULE, BACKEND_BLOCK_PATH,
+ BACKEND_QUEUE_MODULE, BACKEND_QUEUE_CONNECTION,
+ BACKEND_QUOTA, BACKEND_VERSIONING)
from pithos.backends import connect_backend
from pithos.backends.base import NotAllowedError, QuotaError
return json.dumps(l)
def get_backend():
- backend = connect_backend(db_module=settings.BACKEND_DB_MODULE,
- db_connection=settings.BACKEND_DB_CONNECTION,
- block_module=settings.BACKEND_BLOCK_MODULE,
- block_path=settings.BACKEND_BLOCK_PATH,
- queue_module=settings.BACKEND_QUEUE_MODULE,
- queue_connection=settings.BACKEND_QUEUE_CONNECTION)
- backend.default_policy['quota'] = settings.BACKEND_QUOTA
- backend.default_policy['versioning'] = settings.BACKEND_VERSIONING
+ backend = connect_backend(db_module=BACKEND_DB_MODULE,
+ db_connection=BACKEND_DB_CONNECTION,
+ block_module=BACKEND_BLOCK_MODULE,
+ block_path=BACKEND_BLOCK_PATH,
+ queue_module=BACKEND_QUEUE_MODULE,
+ queue_connection=BACKEND_QUEUE_CONNECTION)
+ backend.default_policy['quota'] = BACKEND_QUOTA
+ backend.default_policy['versioning'] = BACKEND_VERSIONING
return backend
def update_request_headers(request):
k.startswith('X-Object-') or k.startswith('Content-')):
del(response[k])
response[quote(k)] = quote(v, safe='/=,:@; ')
-
- if settings.TEST:
- response['Date'] = format_date_time(time())
def render_fault(request, fault):
- if isinstance(fault, InternalServerError) and (settings.DEBUG or settings.TEST):
+ if isinstance(fault, InternalServerError) and settings.DEBUG:
fault.details = format_exc(fault)
request.serialization = 'text'
+++ /dev/null
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
- 'django.template.loaders.filesystem.Loader',
- 'django.template.loaders.app_directories.Loader',
-)
-
-MIDDLEWARE_CLASSES = (
- 'django.middleware.common.CommonMiddleware',
- 'pithos.middleware.LoggingConfigMiddleware',
- 'pithos.middleware.SecureMiddleware',
- 'pithos.middleware.UserMiddleware'
-)
-
-ROOT_URLCONF = 'pithos.urls'
-
-TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates".
- # Always use forward slashes, even on Windows.
- # Don't forget to use absolute paths, not relative paths.
-)
-
-INSTALLED_APPS = (
- 'pithos.api',
-)
+++ /dev/null
-DEBUG = True
-TEMPLATE_DEBUG = DEBUG
-
-TEST = False
-
-ADMINS = (
- # ('Your Name', 'your_email@domain.com'),
-)
-
-MANAGERS = ADMINS
-
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = '$j0cdrfm*0sc2j+e@@2f-&3-_@2=^!z#+b-8o4_i10@2%ev7si'
-
-# Use to log to a file.
-LOGFILE = None
-
-# The server is behind a proxy (apache and gunicorn setup).
-USE_X_FORWARDED_HOST = False
-
-# Set umask (needed for gunicorn setup).
-#umask(0077)
+++ /dev/null
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be available on all operating systems.
-# On Unix systems, a value of None will cause Django to use the same
-# timezone as the operating system.
-# If running in a Windows environment this must be set to the same as your
-# system time zone.
-TIME_ZONE = 'UTC'
-
-# Language code for this installation. All choices can be found here:
-# http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'en-us'
-
-SITE_ID = 1
-
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
-USE_I18N = True
-
-# If you set this to False, Django will not format dates, numbers and
-# calendars according to the current locale
-USE_L10N = True
-
-# Absolute filesystem path to the directory that will hold user-uploaded files.
-# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = ''
-
-# URL that handles the media served from MEDIA_ROOT. Make sure to use a
-# trailing slash if there is a path component (optional in other cases).
-# Examples: "http://media.lawrence.com", "http://example.com/media/"
-MEDIA_URL = ''
-
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
-# trailing slash.
-# Examples: "http://foo.com/media/", "/media/".
-ADMIN_MEDIA_PREFIX = '/media/'
+++ /dev/null
-# The backend modules to use and their initilization options.
-
-# SQLite.
-#BACKEND_DB_MODULE = 'pithos.backends.lib.sqlite'
-#BACKEND_DB_CONNECTION = join(PROJECT_PATH, 'backend.db')
-
-# SQLAlchemy (choose SQLite/MySQL/PostgreSQL).
-BACKEND_DB_MODULE = 'pithos.backends.lib.sqlalchemy'
-BACKEND_DB_CONNECTION = 'sqlite:///' + join(PROJECT_PATH, 'backend.db')
-#BACKEND_DB_CONNECTION = 'mysql://user:pass@host/db'
-#BACKEND_DB_CONNECTION = 'postgresql://user:pass@host/db'
-
-# Block storage.
-BACKEND_BLOCK_MODULE = 'pithos.backends.lib.hashfiler'
-BACKEND_BLOCK_PATH = join(PROJECT_PATH, 'data/')
-
-# Queue for billing.
-#BACKEND_QUEUE_MODULE = 'pithos.backends.lib.rabbitmq'
-#BACKEND_QUEUE_CONNECTION = 'rabbitmq://guest:guest@localhost:5672/pithos'
-BACKEND_QUEUE_MODULE = None
-BACKEND_QUEUE_CONNECTION = None
-
-# Default setting for new accounts.
-BACKEND_QUOTA = 50 * 1024 * 1024 * 1024
-BACKEND_VERSIONING = 'auto'
+++ /dev/null
-DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': join(PROJECT_PATH, 'pithos.db')
- }
-}
+++ /dev/null
-#coding=utf8
-
-# Either set local users here, or a remote host.
-# To disable local users set to None.
-AUTHENTICATION_USERS = {
- '0000': 'test',
- '0001': 'verigak',
- '0002': 'chazapis',
- '0003': 'gtsouk',
- '0004': 'papagian',
- '0005': 'louridas',
- '0006': 'chstath',
- '0007': 'pkanavos',
- '0008': 'mvasilak',
- '0009': 'διογένης'
-}
-
-# Where astakos is hosted.
-AUTHENTICATION_HOST = '127.0.0.1:10000'
-# Copyright 2011-2012 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# 1. Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-
-from glob import glob
-from os import umask
-from os.path import abspath, dirname, exists, join
+#coding=utf8
+# Django settings for pithos project.
+from os.path import abspath, dirname, exists, join
PROJECT_PATH = dirname(abspath(__file__))
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
-conffiles = glob(join(PROJECT_PATH, 'settings.d', '*.conf'))
+ADMINS = (
+ # ('Your Name', 'your_email@domain.com'),
+)
-for conf in sorted(conffiles):
- execfile(conf)
+MANAGERS = ADMINS
-conf = join(PROJECT_PATH, 'settings.local')
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': join(PROJECT_PATH, 'pithos.db')
+ }
+}
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'UTC'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale
+USE_L10N = True
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = ''
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
+MEDIA_URL = ''
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/'
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '$j0cdrfm*0sc2j+e@@2f-&3-_@2=^!z#+b-8o4_i10@2%ev7si'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ #'django.middleware.csrf.CsrfViewMiddleware',
+ #'django.contrib.sessions.middleware.SessionMiddleware',
+ #'django.contrib.auth.middleware.AuthenticationMiddleware',
+ #'django.contrib.messages.middleware.MessageMiddleware',
+ 'pithos.middleware.LoggingConfigMiddleware',
+ 'pithos.middleware.SecureMiddleware',
+ 'pithos.middleware.UserMiddleware'
+)
+
+ROOT_URLCONF = 'pithos.urls'
+
+TEMPLATE_DIRS = (
+ # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+)
+
+# Use to log to a file.
+LOGFILE = None
+
+# The server is behind a proxy (apache and gunicorn setup).
+USE_X_FORWARDED_HOST = False
+
+# Set umask (needed for gunicorn setup).
+#umask(0077)
+
+# Either set local users here, or a remote host.
+# To disable local users set to None.
+AUTHENTICATION_USERS = {
+ '0000': 'test',
+ '0001': 'verigak',
+ '0002': 'chazapis',
+ '0003': 'gtsouk',
+ '0004': 'papagian',
+ '0005': 'louridas',
+ '0006': 'chstath',
+ '0007': 'pkanavos',
+ '0008': 'mvasilak',
+ '0009': 'διογένης'
+}
+
+# Where astakos is hosted.
+AUTHENTICATION_HOST = '127.0.0.1:10000'
+
+conf = join(PROJECT_PATH, 'settings.local')
if exists(conf):
execfile(conf)
elif exists('/etc/pithos/settings.local'):
execfile('/etc/pithos/settings.local')
+
+INSTALLED_APPS = (
+ 'pithos.api',
+)