Did I find the right examples for you? yes no

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)

        def update_or_create(cls, data, protect_prm_tamp=True):

    try:
        session = cls.query.session
    except AttributeError:
        raise AttributeError("entity has no query_property()")

    pk_props = sa.orm.class_mapper(cls).primary_key
    # if all pk are present
    if [1 for p in pk_props if data.get(p.key)]:
        pk_tuple = tuple([data[prop.key] for prop in pk_props])
        record = cls.query.get(pk_tuple)
        if record is None:
            raise Exception("cannot create with pk")
    else:
        record = cls()
        session.add(record)

    record = from_dict(record, data, protect_prm_tamp)
    return record
        


src/t/w/tw2.sqla-2.1.0/tw2/sqla/widgets.py   tw2.sqla(Download)
    def validated_request(cls, req, data, protect_prm_tamp=True, do_commit=True):
        if 'id' not in data and 'id' in req.GET:
            # If the 'id' is in the query string, we get it
            data['id'] = req.GET['id']
        utils.update_or_create(cls.entity, data,

src/t/w/tw2.sqla-HEAD/tw2/sqla/widgets.py   tw2.sqla(Download)
    def validated_request(cls, req, data, protect_prm_tamp=True, do_commit=True):
        if 'id' not in data and 'id' in req.GET:
            # If the 'id' is in the query string, we get it
            data['id'] = req.GET['id']
        utils.update_or_create(cls.entity, data,