def delete(self, identifier): try: instance = self.query.filter_by(id=identifier).one_or_none() if not instance: raise NotFound('The process does not exist') if instance.chains: raise Conflict( 'The process belongs to a chain, so it cannot be deleted') # Delete related objects session.query(ProcessMetadata).filter_by( process_id=identifier).delete() session.query(Output).filter_by(process_id=identifier).delete() session.query(Input).filter_by(process_id=identifier).delete() # Delete object session.delete(instance) # Delete process file ProcessSerializer.delete_file(instance.identifier) session.commit() except: session.rollback() raise
def delete(self, identifier): try: self._delete(identifier) session.commit() except: session.rollback() raise
def update(self, identifier, data): try: instance = self._get_instance(identifier) self.validate(data, instance=instance) self.deserialize(data, instance) session.flush() serialized = self.serialize(instance) session.commit() return serialized except: session.rollback() raise
def create(self, data): try: instance = self.model() self.validate(data) self.deserialize(data, instance) session.add(instance) session.flush() serialized = self.serialize(instance) session.commit() return serialized except: session.rollback() raise
def list(self, filtering): try: filters = Filter(self.model, filtering) query = self.query.join(*filters.joins).filter( *self._list_filters()).filter( filters.orm_filters).order_by(*filters.order_by) return dict(results=[ self.serialize(m) for m in query.limit(filters.limit).offset( filters.offset).all() ], count=query.count()) except: session.rollback() raise
Format(name='WFS', mime_type='application/x-ogc-wfs', extension='.xml'), Format(name='WFS100', mime_type='application/x-ogc-wfs; version=1.0.0', extension='.xml'), Format(name='WFS110', mime_type='application/x-ogc-wfs; version=1.1.0', extension='.xml'), Format(name='WFS20', mime_type='application/x-ogc-wfs; version=2.0', extension='.xml'), Format(name='WMS', mime_type='application/x-ogc-wms', extension='.xml'), Format(name='WMS130', mime_type='application/x-ogc-wms; version=1.3.0', extension='.xml'), Format(name='WMS110', mime_type='application/x-ogc-wms; version=1.1.0', extension='.xml'), Format(name='WMS100', mime_type='application/x-ogc-wms; version=1.0.0', extension='.xml'), Format(name='TEXT', mime_type='text/plain', extension='.txt'), Format(name='NETCDF', mime_type='application/x-netcdf', extension='.nc'), ] if __name__ == '__main__': try: session.add_all(objects) session.commit() except: session.rollback()
def read(self, identifier): try: return self.serialize(self._get_instance(identifier)) except: session.rollback() raise