@@ -136,7 +136,7 @@ def __getitem__(self, name):
136
136
raise KeyError ("No content named %s" % name )
137
137
138
138
def __init__ (self , url , version = '1.0.0' , xml = None , username = None , password = None ,
139
- parse_remote_metadata = False , vendor_kwargs = None , headers = None , auth = None ,
139
+ parse_remote_metadata = False , vendor_kwargs = None , headers = None , auth = None , cookies = None ,
140
140
timeout = 30 ):
141
141
"""Initialize.
142
142
@@ -174,12 +174,13 @@ def __init__(self, url, version='1.0.0', xml=None, username=None, password=None,
174
174
self .vendor_kwargs = vendor_kwargs
175
175
self ._capabilities = None
176
176
self .headers = headers
177
+ self .cookies = cookies
177
178
self .auth = auth or Authentication (username , password )
178
179
self .timeout = timeout or 30
179
180
180
181
# Authentication handled by Reader
181
182
reader = WMTSCapabilitiesReader (
182
- self .version , url = self .url , headers = self .headers , auth = self .auth )
183
+ self .version , url = self .url , headers = self .headers , auth = self .auth , cookies = self . cookies )
183
184
if xml is not None : # read from stored xml
184
185
self ._capabilities = reader .readString (xml )
185
186
else : # read from server
@@ -456,7 +457,7 @@ def gettile(self, base_url=None, layer=None, style=None, format=None,
456
457
resurl = self .buildTileResource (
457
458
layer , style , format , tilematrixset , tilematrix ,
458
459
row , column , ** vendor_kwargs )
459
- u = openURL (resurl , headers = self .headers , auth = self .auth , timeout = self .timeout )
460
+ u = openURL (resurl , headers = self .headers , cookies = self . cookies , auth = self .auth , timeout = self .timeout )
460
461
return u
461
462
462
463
# KVP implemetation
@@ -482,7 +483,7 @@ def gettile(self, base_url=None, layer=None, style=None, format=None,
482
483
base_url = get_verbs [0 ].get ('url' )
483
484
except StopIteration :
484
485
pass
485
- u = openURL (base_url , data , headers = self .headers , auth = self .auth , timeout = self .timeout )
486
+ u = openURL (base_url , data , headers = self .headers , cookies = self . cookies , auth = self .auth , timeout = self .timeout )
486
487
487
488
# check for service exceptions, and return
488
489
if u .info ()['Content-Type' ] == 'application/vnd.ogc.se_xml' :
@@ -887,7 +888,7 @@ class WMTSCapabilitiesReader:
887
888
"""Read and parse capabilities document into a lxml.etree infoset
888
889
"""
889
890
890
- def __init__ (self , version = '1.0.0' , url = None , un = None , pw = None , headers = None , auth = None ):
891
+ def __init__ (self , version = '1.0.0' , url = None , un = None , pw = None , headers = None , auth = None , cookies = None ):
891
892
"""Initialize"""
892
893
self .version = version
893
894
self ._infoset = None
@@ -899,6 +900,7 @@ def __init__(self, version='1.0.0', url=None, un=None, pw=None, headers=None, au
899
900
auth .password = pw
900
901
self .auth = auth or Authentication (un , pw )
901
902
self .headers = headers
903
+ self .cookies = cookies
902
904
903
905
def capabilities_url (self , service_url , vendor_kwargs = None ):
904
906
"""Return a capabilities url
@@ -933,7 +935,7 @@ def read(self, service_url, vendor_kwargs=None):
933
935
934
936
# now split it up again to use the generic openURL function...
935
937
spliturl = getcaprequest .split ('?' )
936
- u = openURL (spliturl [0 ], spliturl [1 ], method = 'Get' , headers = self .headers , auth = self .auth )
938
+ u = openURL (spliturl [0 ], spliturl [1 ], method = 'Get' , cookies = self . cookies , headers = self .headers , auth = self .auth )
937
939
return getXMLTree (u )
938
940
939
941
def readString (self , st ):
0 commit comments