maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] [PATCH] Bypass the city_exists check when no GIS databa


From: Maxime Petazzoni
Subject: [Maposmatic-dev] [PATCH] Bypass the city_exists check when no GIS database is set
Date: Wed, 9 Sep 2009 14:18:08 +0200

This allows for MapOSMatic to be used without a GIS-capable database to
test the web interface without doing any rendering or calls to the GIS
database.
---
 www/maposmatic/views.py |    6 ++++++
 www/settings.py         |    3 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/www/maposmatic/views.py b/www/maposmatic/views.py
index 0af721f..1d4b5e2 100644
--- a/www/maposmatic/views.py
+++ b/www/maposmatic/views.py
@@ -42,6 +42,12 @@ from www.maposmatic.widgets import AreaField
 # OpenStreetMap database. We don't go through the Django ORM but
 # directly to the database for simplicity reasons.
 def city_exists(city):
+
+    # If not GIS database is configured, bypass the city_exists check by
+    # returning True.
+    if not www.settings.has_gis_database():
+        return True
+
     try:
         conn = psycopg2.connect("dbname='%s' user='%s' host='%s' 
password='%s'" %
                                 (www.settings.GIS_DATABASE_NAME,
diff --git a/www/settings.py b/www/settings.py
index e871133..a0bf30a 100644
--- a/www/settings.py
+++ b/www/settings.py
@@ -120,3 +120,6 @@ LOG.addHandler(_fh)
 LOG.info("log restarted.")
 
 ITEMS_PER_PAGE = 25
+
+def has_gis_database():
+    return GIS_DATABASE_NAME and GIS_DATABASE_NAME != ''
-- 
1.6.3.3.210.g29cb3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]