Skip to content
Snippets Groups Projects
Commit 73b707fe authored by Maël Méliani's avatar Maël Méliani
Browse files

Merge branch 'alternate' of https://github.com/neogeo-technologies/mra into develop

parents e7555e02 3cf3273d
No related branches found
No related tags found
No related merge requests found
......@@ -137,8 +137,6 @@ class Layer(MetadataMixin):
def add_style_sld(self, mf, s_name, new_sld):
# Because we do not want to apply the sld to real layers by mistake
# we need to rename it to something we are sure is not used.
sld_layer_name = "__mra_tmp_template"
......@@ -150,7 +148,8 @@ class Layer(MetadataMixin):
xmlsld = parseString(new_sld)
try:
xmlsld.firstChild.getElementsByTagName("NamedLayer")[0].getElementsByTagName("Name")[0].firstChild.data = sld_layer_name
xmlsld.firstChild.getElementsByTagName("NamedLayer")[0]\
.getElementsByTagName("Name")[0].firstChild.data = sld_layer_name
except:
raise ValueError("Bad sld (No NamedLayer/Name)")
......
src/mra.py 0 → 100644
This diff is collapsed.
storage:
mapfiles: "/path/to/your/mapfiles/directory"
resources: "/path/to/your/data/directory"
## All default storage paths are relative to mra's root which is described here:
root: "/my/full/path/to/mra/root"
## However, you can specify specific directories for any of those sub-directories.
## They will default to root/sub_directory_name
# services: ""
# available: ""
# resources: ""
## Folowing the same principle, the folowing two directories will
## default to resources/sub_directory_name
# styles: ""
# data: ""
mapserver:
url: "http://127.0.0.1/cgi-bin/mapserv?"
......@@ -9,31 +22,28 @@ mapserver:
wcs_version: "1.0.0"
debug:
# web_debug allows for easy debuging in the the browser, should be deactivated in production.
## web_debug allows for easy debuging in the the browser, should be deactivated in production.
web_debug: False
# Normaly some exceptions are transformed into web errors. (404, ...)
# This can be prevented by setting raise_all to True.
## Normaly some exceptions are transformed into web errors. (404, ...)
## This can be prevented by setting raise_all to True.
raise_all: False
logging:
format: "%(asctime)s %(levelname)7s: (%(funcName)s:%(lineno)s) %(message)s"
file: "./mra.log"
level: "DEBUG"
# Add the logs to the generated output of the webapp by setting web_logs.
web_logs: False
file: "/tmp/mra.log"
level: "INFO"
testing:
# Aditions to the API for testing, should ne deactivated in production.
active: False
# Which map file to use to create new test files.
model: model
## Add the logs to the generated output of the webapp by setting web_logs.
web_logs: False
plugins:
# The paths in this lists will be loaded as plugins.
# A plugin can be a python package, if that is the case it
# should define the __all__ attribute to indicate which modules
# should be handled as plugins. (An example can be found in /plugins)
## The paths in this lists will be loaded as plugins.
## A plugin can be a python package, if that is the case it
## should define the __all__ attribute to indicate which modules
## should be handled as plugins. (An example can be found in /plugins)
loadpaths: [
# "/path/to/your/plugins"
# "/my/full/path/to/plugins"
]
This diff is collapsed.
......@@ -22,7 +22,8 @@ $def with (base, path, links, code)
</div>
<ul class="breadcrumb">
$for name in path[:-1]: <li><a href="$base$('/'.join(path[:loop.index]))">$name</a><span class="divider">/</span></li>
<li><a href="$base">mra</a></li>
$for name in path[:-1]: <li><a href="$base$('/'.join(path[:loop.index]))">$name </a><span class="divider">/</span></li>
<li class="active">$path[-1]</li>
</ul>
......
......@@ -38,36 +38,36 @@ from osgeo import osr
__config = None
def get_config(key=None, mode='r'):
"""This reads the YAML configuration file."""
# def get_config(key=None, mode='r'):
# """This reads the YAML configuration file."""
global __config
if not __config:
try:
__config = yaml.load(open(os.path.join(sys.path[0], 'mra.yaml'), mode))
except yaml.YAMLError, exc:
exit('Error in configuration file: %s' % exc)
return __config if key == None else __config[key] if key in __config else {}
# global __config
# if not __config:
# try:
# __config = yaml.load(open(os.path.join(sys.path[0], 'mra.yaml'), mode))
# except yaml.YAMLError, exc:
# exit('Error in configuration file: %s' % exc)
# return __config if key == None else __config[key] if key in __config else {}
def get_mapfile_paths():
"""Generates a list of mapfile paths managed by Mapserver REST API."""
# def get_mapfile_paths():
# """Generates a list of mapfile paths managed by Mapserver REST API."""
for (root, subFolders, files) in os.walk(get_config('storage')['mapfiles']):
for f in files:
if f.endswith('.map') and not f.startswith('.'):
yield os.path.join(root, f)
# for (root, subFolders, files) in os.walk(get_config('storage')['mapfiles']):
# for f in files:
# if f.endswith('.map') and not f.startswith('.'):
# yield os.path.join(root, f)
def get_mapfile(name):
with webapp.mightNotFound(message="Could not find mapfile '%s'." % name, exceptions=(IOError, OSError, KeyError)):
mf = mapfile.Mapfile(name, get_config('storage')['mapfiles'])
return mf
# def get_mapfile(name):
# with webapp.mightNotFound(message="Could not find mapfile '%s'." % name, exceptions=(IOError, OSError, KeyError)):
# mf = mapfile.Mapfile(name, get_config('storage')['mapfiles'])
# return mf
def get_mapfile_workspace(mf_name, ws_name):
mf = get_mapfile(mf_name)
with webapp.mightNotFound("workspace", mapfile=mf_name):
ws = mf.get_workspace(ws_name)
return mf, ws
# def get_mapfile_workspace(mf_name, ws_name):
# mf = get_mapfile(mf_name)
# with webapp.mightNotFound("workspace", mapfile=mf_name):
# ws = mf.get_workspace(ws_name)
# return mf, ws
def assert_is_empty(generator, tname, iname):
try:
......@@ -77,7 +77,6 @@ def assert_is_empty(generator, tname, iname):
else:
raise webapp.Forbidden(message="Can't remove '%s' because it is an non-empty %s." % (iname, tname))
def href(url):
return pyxml.Entries({'href': url})
......@@ -87,78 +86,78 @@ def safe_path_join(root, *args):
raise webapp.Forbidden(message="path '%s' outside root directory." % (args))
return full_path
def get_mapfile_path(*args):
return safe_path_join(get_config('storage')['mapfiles'], *args)
# def get_mapfile_path(*args):
# return safe_path_join(get_config('storage')['mapfiles'], *args)
def get_resource_path(*args):
return safe_path_join(get_config('storage')['resources'], *args)
# def get_resource_path(*args):
# return safe_path_join(get_config('storage')['resources'], *args)
def get_st_data_path(ws_name, st_type, name, *args):
return get_resource_path("workspaces", ws_name, st_type, name, *args)
# def get_st_data_path(ws_name, st_type, name, *args):
# return get_resource_path("workspaces", ws_name, st_type, name, *args)
def get_ds_data_path(ws_name, name, *args):
return get_st_data_path(ws_name, "datastores", name, *args)
# def get_ds_data_path(ws_name, name, *args):
# return get_st_data_path(ws_name, "datastores", name, *args)
def get_cs_data_path(ws_name, name, *args):
return get_st_data_path(ws_name, "coveragestores", name, *args)
# def get_cs_data_path(ws_name, name, *args):
# return get_st_data_path(ws_name, "coveragestores", name, *args)
def get_style_path(name, *args):
return safe_path_join(get_config('storage')['resources'], "styles", name, *args)
# def get_style_path(name, *args):
# return safe_path_join(get_config('storage')['resources'], "styles", name, *args)
def iter_styles(mapfile=None):
"""Generates a list of style paths managed by Mapserver REST API."""
# def iter_styles(mapfile=None):
# """Generates a list of style paths managed by Mapserver REST API."""
used_styles = list(mapfile.iter_styles()) if mapfile else []
# used_styles = list(mapfile.iter_styles()) if mapfile else []
for s in used_styles:
yield s
# for s in used_styles:
# yield s
styles_dir = os.path.join(get_config('storage')['resources'], "styles")
if not os.path.isdir(styles_dir):
return
# styles_dir = os.path.join(get_config('storage')['resources'], "styles")
# if not os.path.isdir(styles_dir):
# return
for (root, subFolders, files) in os.walk(styles_dir):
for f in files:
if f not in used_styles:
yield f
# for (root, subFolders, files) in os.walk(styles_dir):
# for f in files:
# if f not in used_styles:
# yield f
def mk_path(path):
dirs = os.path.dirname(path)
if not os.path.isdir(dirs):
os.makedirs(dirs)
# def mk_path(path):
# dirs = os.path.dirname(path)
# if not os.path.isdir(dirs):
# os.makedirs(dirs)
def mk_mapfile_path(name, *args):
path = get_mapfile_path(name, *args)
mk_path(path)
return path
# def mk_mapfile_path(name, *args):
# path = get_mapfile_path(name, *args)
# mk_path(path)
# return path
def mk_ds_data_path(ws_name, name, *args):
path = get_ds_data_path(name, *args)
mk_path(path)
return path
# def mk_ds_data_path(ws_name, name, *args):
# path = get_ds_data_path(name, *args)
# mk_path(path)
# return path
def mk_cs_data_path(ws_name, name, *args):
path = get_cs_data_path(ws_name, name, *args)
mk_path(path)
return path
# def mk_cs_data_path(ws_name, name, *args):
# path = get_cs_data_path(ws_name, name, *args)
# mk_path(path)
# return path
def mk_st_data_path(ws_name, st_type, name, *args):
path = get_st_data_path(ws_name, st_type, name, *args)
mk_path(path)
return path
# def mk_st_data_path(ws_name, st_type, name, *args):
# path = get_st_data_path(ws_name, st_type, name, *args)
# mk_path(path)
# return path
def mk_style_path(name, *args):
path = get_style_path(name, *args)
mk_path(path)
return path
# def mk_style_path(name, *args):
# path = get_style_path(name, *args)
# mk_path(path)
# return path
def no_root(root, path):
path = os.path.abspath(path)
root = os.path.abspath(root)
return path[len(root):] if path.startswith(root) else path
# def no_root(root, path):
# path = os.path.abspath(path)
# root = os.path.abspath(root)
# return path[len(root):] if path.startswith(root) else path
def no_res_root(path):
return os.path.relpath(path, get_config('storage')['resources'])
# def no_res_root(path):
# return os.path.relpath(path, get_config('storage')['resources'])
def is_hidden(path):
# TODO Add a lot of checks, recursive option (to check folders)
......@@ -178,7 +177,7 @@ def proj4_to_wkt(proj4):
def wkt_to_authority(wkt):
srs = osr.SpatialReference()
srs.ImportFromWkt(wkt)
# Are there really no other with osgeo? Oo
if srs.GetAuthorityCode('PROJCS') != None:
......
......@@ -436,7 +436,7 @@ def get_data(name=None, mandatory=[], authorized=[], forbidden=[]):
data = web.data()
if not data:
raise web.badrequest('You must suply some data. (mandatory: %s, authorized: %s)' % (madatory, authorized))
raise web.badrequest('You must suply some data. (mandatory: %s, authorized: %s)' % (mandatory, authorized))
if not 'CONTENT_TYPE' in web.ctx.env:
raise web.badrequest('You must specify a Content-Type.')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment