How to use the catalogue.models.Application.get_view_name function in catalogue

To help you get started, we’ve selected a few catalogue examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dbca-wa / oim-cms / catalogue / views.py View on Github external
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"))
        server.requesttype = request.method
        server.kvp = self._normalize_params(request.GET)
        response = server.dispatch()
        return HttpResponse(response, content_type="application/xml")