From a20ff434501a099b259da903d88b47bb77e07469 Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Tue, 1 Feb 2011 09:07:22 +0100 Subject: import --- meetingtools/__init__.py | 0 meetingtools/ac/__init__.py | 0 meetingtools/ac/api.py | 66 +++++++++++++++++++++++++ meetingtools/apps/__init__.py | 0 meetingtools/apps/room/__init__.py | 0 meetingtools/apps/room/admin.py | 10 ++++ meetingtools/apps/room/models.py | 14 ++++++ meetingtools/apps/room/views.py | 0 meetingtools/extensions/__init__.py | 0 meetingtools/manage.py | 11 +++++ meetingtools/settings.py | 96 +++++++++++++++++++++++++++++++++++++ meetingtools/site_logging.py | 10 ++++ meetingtools/urls.py | 16 +++++++ 13 files changed, 223 insertions(+) create mode 100644 meetingtools/__init__.py create mode 100644 meetingtools/ac/__init__.py create mode 100644 meetingtools/ac/api.py create mode 100644 meetingtools/apps/__init__.py create mode 100644 meetingtools/apps/room/__init__.py create mode 100644 meetingtools/apps/room/admin.py create mode 100644 meetingtools/apps/room/models.py create mode 100644 meetingtools/apps/room/views.py create mode 100644 meetingtools/extensions/__init__.py create mode 100644 meetingtools/manage.py create mode 100644 meetingtools/settings.py create mode 100644 meetingtools/site_logging.py create mode 100644 meetingtools/urls.py (limited to 'meetingtools') diff --git a/meetingtools/__init__.py b/meetingtools/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/meetingtools/ac/__init__.py b/meetingtools/ac/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/meetingtools/ac/api.py b/meetingtools/ac/api.py new file mode 100644 index 0000000..2631987 --- /dev/null +++ b/meetingtools/ac/api.py @@ -0,0 +1,66 @@ +''' +Created on Jan 31, 2011 + +@author: leifj +''' + +from lxml import etree +import httplib2 +from urllib import urlencode + +class ACPException(Exception): + def __init__(self, value): + self.value = value + + def __str__(self): + return repr(self.value) + +class ACPResult(): + + def __init__(self,content): + self.et = etree.parse(content) + self.status = self.et.find('status') + + def is_error(self): + return self.status.get('code') != 'ok' + + def exception(self): + raise ACPException,self.status + + def get_principal(self): + return self.et.find('principal') + +class ACPClient(): + + def __init__(self,url,username=None,password=None): + self.url = url + self.session = None + if username and password: + self.login(username,password) + + def request(self,method,p={}): + url = self.url+"?"+"action=%s" % method + if self.session: + url = url + "&session=%s" % self.session + urlencode(dict([k,v.encode("iso-8859-1")] for (k,v) in p.items())) + + h = httplib2.Http(".cache"); + resp, content = h.request(url, "GET") + if resp.status != 200: + raise ACPException,resp.reason + + if resp.has_key('set-cookie'): + cookie = resp['set-cookie'] + if cookie: + avp = cookie.split(";") + if avp.len > 0: + av = avp[0].split('=') + self.session = av[1] + + return ACPResult(content) + + def login(self,username,password): + result = self.request('login',{'login':username,'password':password}) + if result.is_error(): + raise result.exception() + \ No newline at end of file diff --git a/meetingtools/apps/__init__.py b/meetingtools/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/meetingtools/apps/room/__init__.py b/meetingtools/apps/room/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/meetingtools/apps/room/admin.py b/meetingtools/apps/room/admin.py new file mode 100644 index 0000000..13d80a8 --- /dev/null +++ b/meetingtools/apps/room/admin.py @@ -0,0 +1,10 @@ +''' +Created on Jan 31, 2011 + +@author: leifj +''' + +from django.contrib import admin +from meetingtools.apps.room.models import Room + +admin.site.register(Room) \ No newline at end of file diff --git a/meetingtools/apps/room/models.py b/meetingtools/apps/room/models.py new file mode 100644 index 0000000..f75478e --- /dev/null +++ b/meetingtools/apps/room/models.py @@ -0,0 +1,14 @@ +''' +Created on Jan 31, 2011 + +@author: leifj +''' + +from django.db import models +from django.db.models.fields import CharField, BooleanField, URLField + +class Room(models.Model): + name = CharField(max_length=128) + group = CharField(max_length=128) # populate from entitlement held by creator + resetWhenEmpty = BooleanField() + meetingRoomUrl = URLField() \ No newline at end of file diff --git a/meetingtools/apps/room/views.py b/meetingtools/apps/room/views.py new file mode 100644 index 0000000..e69de29 diff --git a/meetingtools/extensions/__init__.py b/meetingtools/extensions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/meetingtools/manage.py b/meetingtools/manage.py new file mode 100644 index 0000000..5e78ea9 --- /dev/null +++ b/meetingtools/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +try: + import settings # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + execute_manager(settings) diff --git a/meetingtools/settings.py b/meetingtools/settings.py new file mode 100644 index 0000000..3c43a57 --- /dev/null +++ b/meetingtools/settings.py @@ -0,0 +1,96 @@ +# Django settings for meetingtools project. + +import meetingtools.site_logging + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) + +BASE_DIR = '..' + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': '%s/sqlite.db' % BASE_DIR, # Or path to database file if using sqlite3. + 'USER': '', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} + + +# 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 = 'Europe/Stockholm' + +# 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 + +MEDIA_ROOT = "%s/site-media" % BASE_DIR +ADMIN_MEDIA_ROOT = "/usr/lib/pymodules/python2.5/django/contrib/admin/media" +MEDIA_URL = '/site-media/' +ADMIN_MEDIA_PREFIX = '/admin-media/' + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 'tz78l!c=cl2=jic5$2#(bq)7-4s1ivtm*a+q0w1yi0$)hrmc7l' + +# 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', +# 'django.template.loaders.eggs.Loader', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'coip.middleware.UserMappingMiddleware', + 'django.contrib.auth.middleware.RemoteUserMiddleware' +) + +AUTHENTICATION_BACKENDS = ( + 'django.contrib.auth.backends.RemoteUserBackend', + 'django.contrib.auth.backends.ModelBackend', +) + +ROOT_URLCONF = 'meetingtools.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. + "%s/templates" % BASE_DIR +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.admin', + 'django.contrib.humanize', + 'django_extensions' +) diff --git a/meetingtools/site_logging.py b/meetingtools/site_logging.py new file mode 100644 index 0000000..cdbe3c2 --- /dev/null +++ b/meetingtools/site_logging.py @@ -0,0 +1,10 @@ +import logging +import sys + +logger = logging.getLogger('') +logger.setLevel(logging.DEBUG) +handler = logging.StreamHandler(sys.stderr) +handler.setLevel(logging.DEBUG) +formatter = logging.Formatter('%(levelname)-8s %(message)s') +handler.setFormatter(formatter) +logger.addHandler(handler) diff --git a/meetingtools/urls.py b/meetingtools/urls.py new file mode 100644 index 0000000..69b4bf0 --- /dev/null +++ b/meetingtools/urls.py @@ -0,0 +1,16 @@ +from django.conf.urls.defaults import * + +# Uncomment the next two lines to enable the admin: +# from django.contrib import admin +# admin.autodiscover() + +urlpatterns = patterns('', + # Example: + # (r'^meetingtools/', include('meetingtools.foo.urls')), + + # Uncomment the admin/doc line below to enable admin documentation: + # (r'^admin/doc/', include('django.contrib.admindocs.urls')), + + # Uncomment the next line to enable the admin: + # (r'^admin/', include(admin.site.urls)), +) -- cgit v1.1