Permalink
Browse files

Merge pull request #19 from tomkralidis/master

simplify settings.py and pycsw view
  • Loading branch information...
2 parents dfa9a4a + dca0a74 commit 0ccdc71f28773508c337875fd32478dd4324a50c @ahinz ahinz committed Oct 18, 2012
Showing with 28 additions and 39 deletions.
  1. +28 −19 OpenDataCatalog/catalog/views.py
  2. +0 −20 OpenDataCatalog/settings.py
@@ -7,40 +7,49 @@
from pycsw import server
+CONFIGURATION = {
+ 'server': {
+ 'home': '.',
+ 'mimetype': 'application/xml; charset=UTF-8',
+ 'encoding': 'UTF-8',
+ 'language': 'en-US',
+ 'maxrecords': '10',
+ # 'pretty_print': 'true',
+ 'profiles': 'apiso,dif,fgdc,atom,ebrim',
+ },
+ 'repository': {
+ 'source': 'odc',
+ 'mappings': os.path.join(os.path.dirname(__file__), 'mappings.py')
+ }
+}
+
@csrf_exempt
def csw(request):
-
- app_root = os.path.dirname(__file__)
-
+ """CSW WSGI wrapper"""
# serialize settings.CSW into SafeConfigParser
# object for interaction with pycsw
+ mdict = dict(settings.CSW, **CONFIGURATION)
+
+ # TODO: pass just dict when pycsw supports it
config = SafeConfigParser()
- for section, options in settings.CSW.iteritems():
+ for section, options in mdict.iteritems():
config.add_section(section)
for k, v in options.iteritems():
config.set(section, k, v)
- scheme = "http"
- if request.is_secure():
- scheme = "https"
-
-
# update server.url
- server_url = '%s://%s/catalog/csw' %(scheme, request.META['HTTP_HOST'])
+ server_url = '%s://%s%s' % \
+ (request.META['wsgi.url_scheme'],
+ request.META['HTTP_HOST'],
+ request.META['PATH_INFO'])
+
config.set('server', 'url', server_url)
- # request.meta has:
- # QUERY_STRING, REMOTE_ADDR, CONTENT_LENGTH, SERVER_NAME
- # SERVER_PORT
env = request.META.copy()
+
env.update({
- 'local.app_root': app_root,
+ 'local.app_root': os.path.dirname(__file__),
'REQUEST_URI': request.build_absolute_uri(),
- 'REQUEST_METHOD': request.method,
- 'wsgi.url_scheme': scheme,
- 'SCRIPT_NAME': '', ##### IS THIS CORRECT?!?!?!
- 'PATH_INFO': request.path_info,
- 'wsgi.input': request # this is being a bit sneaky but w/e
})
csw = server.Csw(config, env)
@@ -163,22 +163,6 @@
# pycsw configuration
CSW = {
- 'server': {
- 'home': '.',
- 'mimetype': 'application/xml; charset=UTF-8',
- 'encoding': 'UTF-8',
- 'language': 'en-US',
- 'maxrecords': '10',
-# 'loglevel': 'DEBUG',
-# 'logfile': '/tmp/pycsw.log',
-# 'ogc_schemas_base': 'http://foo',
-# 'federatedcatalogues': 'http://geo.data.gov/geoportal/csw/discovery',
-# 'pretty_print': 'true',
-# 'gzip_compresslevel': '8',
-# 'domainquerytype': 'range',
-# 'domaincounts': 'true',
- 'profiles': 'apiso,dif,fgdc,atom,ebrim',
- },
'metadata:main': {
'identification_title': 'Open Data Catalog CSW',
'identification_abstract': 'Open Data Catalog is an open data catalog based on Django, Python and PostgreSQL. It was originally developed for OpenDataPhilly.org, a portal that provides access to open data sets, applications, and APIs related to the Philadelphia region. The Open Data Catalog is a generalized version of the original source code with a simple skin. It is intended to display information and links to publicly available data in an easily searchable format. The code also includes options for data owners to submit data for consideration and for registered public users to nominate a type of data they would like to see openly available to the public.',
@@ -203,10 +187,6 @@
'contact_instructions': 'During hours of service. Off on weekends.',
'contact_role': 'pointOfContact',
},
- 'repository': {
- 'source': 'odc',
- 'mappings': 'catalog/mappings.py',
- },
'metadata:inspire': {
'enabled': 'false',
'languages_supported': 'eng',

0 comments on commit 0ccdc71

Please sign in to comment.