Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get(self, request,app=None):
pycsw_settings = build_pycsw_settings(app)
server = Csw(rtconfig=pycsw_settings, env=request.META.copy())
if not app:
app = "all"
#request by named app, use app related view
record_table = Application.get_view_name(app)
try:
if not self.application_records.get(app,None):
base = declarative_base(bind=server.repository.engine,mapper=Mapper)
self.application_records[app] = type('dataset', (base,),
dict(__tablename__=record_table,__table_args__={'autoload': True,'schema': None},__mapper_args__={"primary_key":["id"]}))
server.repository.dataset = self.application_records[app]
except:
pass
server.request = "http://{}{}".format(get_current_site(request),
reverse("csw_endpoint"))
def handle(self, *args, **options):
log_level = {
0: logging.ERROR,
1: logging.WARNING,
2: logging.INFO,
3: logging.DEBUG
}.get(options["verbosity"])
logger.setLevel(log_level)
pycsw_logger = logging.getLogger("pycsw")
pycsw_logger.setLevel(log_level)
pycsw_config = build_pycsw_settings()
context = StaticContext()
self.pycsw_admin_handler.parse_configuration(pycsw_config, context)
ArgsObject = namedtuple("ArgsObject", options.keys())
the_args = ArgsObject(**options)
result = the_args.func(the_args)
if result is not None:
self.stdout.write(result)
self.stdout.write("Done!")
def post(self, request,app=None):
pycsw_settings = build_pycsw_settings()
server = Csw(rtconfig=pycsw_settings, env=request.META.copy(),
version=self._get_post_version(request.body))
logger.info(request.body)
server.request = request.body
server.requesttype = request.method
status_code, response = server.dispatch()
return HttpResponse(response, status=status_code,
content_type="application/xml")