Skip to content

Commit

Permalink
Choose FileStorage od DbStorage
Browse files Browse the repository at this point in the history
Choose FileStorage od DbStorage based on configuration.
  • Loading branch information
janpisl committed Jun 3, 2018
1 parent 254b1e5 commit 7f00fa0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions pywps/inout/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from pywps._compat import text_type
from pywps import E, WPS, OWS, OGCTYPE, NAMESPACES
from pywps.inout import basic
from pywps.inout.storage import FileStorage
from pywps.inout.storage import FileStorage, DbStorage
from pywps.inout.formats import Format
from pywps import configuration as config
from pywps.validator.mode import MODE
import lxml.etree as etree
import six
Expand Down Expand Up @@ -212,7 +213,23 @@ def _execute_xml_reference(self):
doc = WPS.Reference()

# get_url will create the file and return the url for it
self.storage = FileStorage()
store_type = config.get_config_value('server', 'store_type')
self.storage = None
# chooses FileStorage or DbStorage based on a store_type value in cfg file
if store_type == 'db' and \
config.get_config_value('db', 'dbname'):
# TODO: more databases in config file
self.storage = DbStorage()

This comment has been minimized.

Copy link
@jachym

jachym Jun 8, 2018

I think, that the method DbStorage.get_db_type which you already have, should be defined as static method and shouldbe used here, like

    self.storage = DbStorage.get_db_type()

self.storage would already be instance of SQLte or Postgre storage

else:
self.storage = FileStorage()

"""
to be implemented:
elif store_type == 's3' and \
config.get_config_value('s3', 'bucket_name'):
self.storage = S3Storage()
"""

doc.attrib['{http://www.w3.org/1999/xlink}href'] = self.get_url()

if self.data_format:
Expand Down

0 comments on commit 7f00fa0

Please sign in to comment.