Skip to content

Model

Models are used in Flask to conveniently handle interactions with databases using ORM (Object Relational Mapping).

Define a table and a class to hold saved searches the class has a get method that returns a list of saved search there is also a mapper to map relationships

SavedSearches

SavedSearches(**kw)

Bases: StatefulObjectMixin, DomainObject

SavedSearches model.

Source code in ckanext/saeoss/model/saved_search.py
def __init__(self, **kw):
    super(SavedSearches, self).__init__(**kw)
    self.owner_id = kw.get("owner_user")

get

get(**kw)

returns a list of saved searches based on user id.

Source code in ckanext/saeoss/model/saved_search.py
def get(cls, **kw):
    """
    returns a list of saved searches
    based on user id.
    """
    query = model.meta.Session.query(cls)
    return query.filter_by(**kw)

Define a table and a class to hold stac harvester the class has a get method that returns a list of stac harvester there is also a mapper to map relationships.

StacHarvester

StacHarvester(**kw)

Bases: StatefulObjectMixin, DomainObject

StacHarvester model.

Source code in ckanext/saeoss/model/stac_harvester.py
def __init__(self, **kw):
    super(StacHarvester, self).__init__(**kw)
    self.owner_id = kw.get("user")

get

get(**kw)

returns a list of saved searches based on user id.

Source code in ckanext/saeoss/model/stac_harvester.py
def get(cls, **kw):
    """
    returns a list of saved searches
    based on user id.
    """
    query = model.meta.Session.query(cls)
    return query.filter_by(**kw)

Additional fields for the user model for storing affiliation details.