66 lines
2.1 KiB
Python
Raw Normal View History

2012-12-02 00:03:21 +01:00
# -*- coding: utf-8 -*-
"""
***************************************************************************
2012-12-03 11:09:54 +01:00
workspace.py
2012-12-02 00:03:21 +01:00
---------------------
Date : November 2012
2012-12-03 09:07:13 +01:00
Copyright : (C) 2012 by David Winslow
Email : dwins at opengeo dot com
2012-12-02 00:03:21 +01:00
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
2012-12-03 09:07:13 +01:00
__author__ = 'David Winslow'
2012-12-02 00:03:21 +01:00
__date__ = 'November 2012'
2012-12-03 09:07:13 +01:00
__copyright__ = '(C) 2012, David Winslow'
2012-12-02 00:03:21 +01:00
# This will get replaced with a git SHA1 when you do a git archive
2012-12-02 00:03:21 +01:00
__revision__ = '$Format:%H$'
from processing.admintools.geoserver.support import xml_property, write_bool, \
ResourceInfo, url
def workspace_from_index(catalog, node):
name = node.find('name')
return Workspace(catalog, name.text)
2012-12-10 00:12:07 +01:00
class Workspace(ResourceInfo):
resource_type = 'workspace'
def __init__(self, catalog, name):
super(Workspace, self).__init__()
self.catalog = catalog
self.name = name
@property
def href(self):
return url(self.catalog.service_url, ['workspaces', self.name + '.xml'
])
@property
def coveragestore_url(self):
return url(self.catalog.service_url, ['workspaces', self.name,
'coveragestores.xml'])
@property
def datastore_url(self):
return url(self.catalog.service_url, ['workspaces', self.name,
'datastores.xml'])
enabled = xml_property('enabled', lambda x: x.lower() == 'true')
writers = dict(enabled=write_bool('enabled'))
def __repr__(self):
return '%s @ %s' % (self.name, self.href)