Fix setup.py, fix _404 response and cleaning config file

* mandaye/__init__.py: add mandaye version
* mandaye/config.py: remove Vincennes configuration from the main config
* mandaye/response.py: fix _404 logging
* mandaye/server.py: fix _404 call
* setup.py: rename find_packages
This commit is contained in:
Jérôme Schneider 2011-09-12 19:04:36 +02:00
parent 516df263c4
commit 6d64b0d2f9
5 changed files with 26 additions and 63 deletions

View File

@ -0,0 +1 @@
VERSION=0.1

View File

@ -1,5 +1,5 @@
# Mandaye configuration
# Mandaye configuration
host = "127.0.0.1"
port = 8088
@ -18,69 +18,30 @@ template_directory = "mandaye/templates"
# Follow the rfc 1738 http://rfc.net/rfc1738.html
db_url = 'sqlite:///test.db'
from filters.vincennes import biblio_html_login_page
from filters.vincennes import biblio_html
from filters.default import MandayeFilter
biblio_mapping = {
r'/': {
'on_response_filters': [{
'type': 'data',
'filter': biblio_html
}]
},
r'/mandaye/login$': {
'method': 'GET',
'response': {
'dispatcher_method': 'login',
'values': {
'form_action': '/sezhame/page/connexion-abonne',
'from_headers': { 'Content-Type': 'application/x-www-form-urlencoded' },
'form_values': { 'user': '',
'password': '',
'op': 'Se connecter',
'form_id': 'dk_opac15_login_form' },
'username_field': 'user',
'password_field': 'password'
}
}
},
r'/mandaye/connection$': {
'method': 'GET',
'response': {
'dispatcher_method': 'connection',
'values': {
'destination': 'https://test.vincennes.fr/comptecitoyen/auth',
'next_url': 'http://biblio.local:8088/mandaye/login',
'service_name': 'biblio'
}
}
},
r'/sezhame/page/connexion-abonne$': {
'method': 'GET',
'on_response_filters': [{
'type': 'data',
'filter': biblio_html_login_page
},]
},
}
#example_mapping = {
# r'/': {
# 'on_response_filters': [{
# 'type': 'data',
# 'filter': my_filter
# }]
# },
# r'/test$': {
# 'method': 'GET',
# 'response': {
# 'dispatcher_method': 'my_test',
# 'values': {
# 'toto': 'titi',
# }
# }
# },
#}
from dispatchers.default import Dispatcher
from dispatchers.vincennes import VincennesDispatcher
# hosts = {'lamereasyl42': r'/': {'dispatcher': MyDispatcherBiatch, 'mapping': dick}}
hosts = {
'sfd.local:8088': [
(r'/', Dispatcher('http://www.sfdiabete.org')),
],
'linuxfr.local:8088': [
(r'/', Dispatcher('http://linuxfr.org')),
],
'biblio.local:8088': [
(r'/', VincennesDispatcher('http://biblio.vincennes.fr', biblio_mapping)),
],
'localhost:8088': [
(r'/', Dispatcher('http://localhost')),
(r'/', Dispatcher('http://perdu.com/')),
],
}

View File

@ -36,7 +36,7 @@ def _401(msg):
serve_template("response.html", title=title, body=msg))
def _404(path):
logging.waring("[404]: %s not found" % path)
logging.warning("[404]: %s not found" % path)
title = "Not Found"
body = "The requested URL %s was not found on this server." % path
headers = HTTPHeader({'Content-Type': ['text/html']})

View File

@ -40,7 +40,7 @@ class MandayeApp(object):
self.dispatcher.init(env)
return self.on_request(start_response)
else:
return self.on_response(start_response, _404)
return self.on_response(start_response, _404(env['PATH_INFO']))
def _get_dispatcher(self, local_host, path_info):
""" return the right dispatcher

View File

@ -6,7 +6,7 @@
import mandaye
from setuptools import setup, find_pacakges
from setuptools import setup, find_packages
setup(name="mandaye",
version=mandaye.VERSION,
@ -18,13 +18,14 @@ setup(name="mandaye",
maintainer="Jerome Schneider",
maintainer_email="jschneider@entrouvert.com",
scripts=['mandayectl'],
packages=find_pacakges(),
packages=find_packages(),
package_data={},
install_requires=[
'beaker>=1.5',
'gevent>=0.13',
'mako>=0.3',
'poster>=0.8',
'sqlachemy>=0.6'
'pycrypto>=2.0',
'sqlalchemy>=0.6',
],
)