Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom urlpath to be specified #205

Merged
merged 1 commit into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/test_config.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[WOF]
Network: TEST
Vocabulary: TESTVocab
URLPATH: TESTURL
Menu_Group_Name: TEST OBSERVATIONS
Service_WSDL: http://not.a.real.url/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you're not changing Service_WSDL here, but it seems like this would not be needed anymore, right? It can be constructed automatically from URLPATH, like this (assumes WOF 1.1): URLPATH/soap/cuahsi_1_1/.wsdl

If that's true, it should be removed from here and handled automatically. But this could be done in a follow up PR if you'd like, so that this PR is not delayed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emiliom Yea, I think that's possible to do, Service_WSDL can be auto-generated. I can work on that next. Thanks.

Timezone:00:00
Expand Down
6 changes: 5 additions & 1 deletion wof/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def __init__(self, file_name, templates=None):
self.vocabulary = config.get('WOF_1_1', 'Vocabulary')
else:
self.vocabulary = config.get('WOF', 'Vocabulary')
if config.has_option('WOF_1_1', 'URLPATH'):
self.urlpath = config.get('WOF_1_1', 'URLPATH')
else:
self.urlpath = config.get('WOF', 'URLPATH')
if config.has_option('WOF_1_1', 'Menu_Group_Name'):
self.menu_group_name = config.get('WOF_1_1', 'Menu_Group_Name')
else:
Expand Down Expand Up @@ -263,7 +267,7 @@ def getSpyneApplications(wof_obj_1_0, wof_obj_1_1, templates=None):
# wof_obj_1_0 = wof_1_0.WOF(dao, config_file)
# wof_obj_1_1 = wof_1_1.WOF_1_1(dao,config_file)

sensorNetwork = wof_obj_1_0.network.replace('/', '').lower()
sensorNetwork = wof_obj_1_0.urlpath.replace('/', '').lower()

soap_app_1_0 = Application(
[wml10(wof_obj_1_0, Unicode, _SERVICE_PARAMS["s_type"])],
Expand Down
1 change: 1 addition & 0 deletions wof/core_1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def config_from_file(self, file_name):

self.network = config.network.lower()
self.vocabulary = config.vocabulary.lower()
self.urlpath = config.urlpath.lower()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the lower() enforcement cause a problem in servers / OS's that allow for case-sensitive url's (other than the domain name, which per HTTP rules can not be case sensitive)? Is there a reason to force it to lower case?

self.menu_group_name = config.menu_group_name
self.service_wsdl = config.service_wsdl
self.timezone = config.timezone
Expand Down
1 change: 1 addition & 0 deletions wof/core_1_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def config_from_file(self, file_name):

self.network = config.network.lower()
self.vocabulary = config.vocabulary.lower()
self.urlpath = config.urlpath.lower()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the lower() enforcement cause a problem in servers / OS's that allow for case-sensitive url's (other than the domain name, which per HTTP rules can not be case sensitive)? Is there a reason to force it to lower case?

self.menu_group_name = config.menu_group_name
self.service_wsdl = config.service_wsdl
self.timezone = config.timezone
Expand Down
9 changes: 5 additions & 4 deletions wof/examples/flask/odm2/timeseries/odm2_config_timeseries.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[WOF]
Network: ODM2Timeseries
Vocabulary: ODM2Timeseries
URLPATH: wofpysqlite
Menu_Group_Name: ODM2
# Change this to your configuration; assumes port 8080
# http://serverip:port/networkcode/soap/cuahsi_1_0/.wsdl
Service_WSDL: http://127.0.0.1:8080/odm2timeseries/soap/cuahsi_1_0/.wsdl
# http://serverip:port/urlpath/soap/cuahsi_1_0/.wsdl
Service_WSDL: http://127.0.0.1:8080/wofpysqlite/soap/cuahsi_1_0/.wsdl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment on test_config.cfg about Service_WSDL now being obsolete (and even worse, if it's inconsistent with URLPATH).

Timezone: 00:00
TimezoneAbbreviation: GMT

Expand All @@ -16,8 +17,8 @@ EndDate: 2007-09-01T02:30:00

[WOF_1_1]
# Change this to your configuration; assumes port 8080
# http://serverip:port/networkcode/soap/cuahsi_1_1/.wsdl
Service_WSDL: http://127.0.0.1:8080/odm2timeseries/soap/cuahsi_1_1/.wsdl
# http://serverip:port/urlpath/soap/cuahsi_1_1/.wsdl
Service_WSDL: http://127.0.0.1:8080/wofpysqlite/soap/cuahsi_1_1/.wsdl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment on test_config.cfg about Service_WSDL now being obsolete (and even worse, if it's inconsistent with URLPATH).


[Default_Params_1_1]
West: -114
Expand Down
23 changes: 11 additions & 12 deletions wof/flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def create_app(wof_inst, wof_inst_1_1, soap_service_url=None, soap_service_1_1_u
#
# app.config.from_object(config.Config)
app = create_simple_app()
path = wof_inst.network.lower()
servicesPath = '/'+wof_inst.network.lower()
path = wof_inst.urlpath.lower()
servicesPath = '/'+wof_inst.urlpath.lower()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment about url case sensitivity and forcing lowercase url.

add_flask_routes(app,path,servicesPath,wof_inst,
wof_inst_1_1,soap_service_url=soap_service_url, soap_service_1_1_url=soap_service_1_1_url )
return app
Expand All @@ -56,22 +56,22 @@ def index():
rest2=path+'/rest_2/',
soap10=path+'/soap/cuahsi_1_0/',
soap11=path+'/soap/cuahsi_1_1/',
p=wof_inst.network,
p=wof_inst.urlpath,
v=version)

app.add_url_rule(servicesPath+'/', wof_inst.network+'index', index)
app.add_url_rule(servicesPath+'/', wof_inst.urlpath+'index', index)

def index_2_0():
return render_template('index_2.html',
path= path + '/rest/2/',
p=wof_inst.network,
p=wof_inst.urlpath,
s=wof_inst.default_site,
v=wof_inst.default_variable,
sd=wof_inst.default_start_date,
ed=wof_inst.default_end_date,
u=wof_inst.default_unitid,
sm=wof_inst.default_samplemedium)
app.add_url_rule(servicesPath+'/rest_2/', wof_inst.network+'index_2_0', index_2_0)
app.add_url_rule(servicesPath+'/rest_2/', wof_inst.urlpath+'index_2_0', index_2_0)

if wof_inst is not None:
if not 'SOAP_SERVICE_URL' in app.config and soap_service_url:
Expand All @@ -81,14 +81,14 @@ def index_2_0():
def index_1_0():
return render_template('index_1_0.html',
path= path + '/rest/1_0/',
p=wof_inst.network,
p=wof_inst.urlpath,
s=wof_inst.default_site,
v=wof_inst.default_variable,
sd=wof_inst.default_start_date,
ed=wof_inst.default_end_date,
u=wof_inst.default_unitid,
sm=wof_inst.default_samplemedium)
app.add_url_rule(servicesPath+'/rest_1_0/',wof_inst.network+ 'index_1_0', index_1_0)
app.add_url_rule(servicesPath+'/rest_1_0/',wof_inst.urlpath+ 'index_1_0', index_1_0)



Expand Down Expand Up @@ -130,7 +130,7 @@ def index_1_1():
so=wof_inst_1_1.default_south,
n=wof_inst_1_1.default_north,
e=wof_inst_1_1.default_east)
app.add_url_rule(servicesPath+'/rest_1_1/', wof_inst.network+'index_1_1', index_1_1)
app.add_url_rule(servicesPath+'/rest_1_1/', wof_inst.urlpath+'index_1_1', index_1_1)

#@app.route('/soap/wateroneflow_1_1.wsdl')
# def get_wsdl_1_1():
Expand Down Expand Up @@ -210,9 +210,8 @@ def create_wof_flask_multiple(wofConfig=[], templates=None):
wof_obj_1_1 = wof_1_1.WOF_1_1(wConf.dao,wConf.config,templates)

spyneapps.update(getSpyneApplications(wof_obj_1_0,wof_obj_1_1,templates) )
path = wof_obj_1_0.network.lower()
servicesPath = '/'+wof_obj_1_0.network.lower()

path = wof_obj_1_0.urlpath.lower()
servicesPath = '/'+wof_obj_1_0.urlpath.lower()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment about url case sensitivity and forcing lowercase url.

wof.flask.add_flask_routes(app,path, servicesPath,
wof_obj_1_0,
wof_obj_1_1,
Expand Down