Giter Site home page Giter Site logo

Is OPLOG supported? about eve-sqlalchemy HOT 5 OPEN

tallesl avatar tallesl commented on August 17, 2024
Is OPLOG supported?

from eve-sqlalchemy.

Comments (5)

dkellner avatar dkellner commented on August 17, 2024

I've never tried it. But I've skimmed through the code in Eve and it seems it is independent of the datalayer anyway.

So you could try to manually configure an appropriate model and setting the OPLOG_* settings accordingly. If this works, we can add an example to the docs or think about including that oplog model in our codebase.

from eve-sqlalchemy.

opensorceror avatar opensorceror commented on August 17, 2024

@tallesl Did you happen to get this to work? If I simply enable OPLOG in the Eve settings, it doesn't seem to work (no error messages either).

from eve-sqlalchemy.

opensorceror avatar opensorceror commented on August 17, 2024

Update: Looks like I'm hitting this bug, which seems to have been fixed in eve 0.8.

@dkellner The latest release of eve-sqlalchemy requires eve < 0.8, which was released in 2018. Any plans to support a newer version of eve?

from eve-sqlalchemy.

opensorceror avatar opensorceror commented on August 17, 2024

Got this to work. Posting it here, in case it helps anyone. Had to do the following:

  1. Had to fork Eve 0.7.10 (the latest version supported by eve-sqlalchemy) and and integrate this fix into my fork.
  2. Unfortunately, eve hardcodes the oplog schema, so even after defining the model using sqlalchemy, eve would simply overwrite the schema and consequently fail. I had to add a on_oplog_push hook to re-overwrite the schema.

My final configs look as follows:

Sqlalchemy model:

class CommonColumns(Base):
    """Common columns"""

    __abstract__ = True
    _created = Column(TIMESTAMP, default=func.now())
    _updated = Column(TIMESTAMP, default=func.now(), onupdate=func.now())

class Oplog(CommonColumns):
    """Model that stores operational logs"""

    __tablename__ = "oplog"
    o = Column(String(10))
    r = Column(String(100))
    i = Column(String(36), primary_key=True)
    c = Column(JSON)
    ip = Column(String(50))
    u = Column(String(50))

App settings:

DOMAIN = DomainConfig({"oplog": ResourceConfig(Oplog)}).render()
IF_MATCH = False
HATEOAS = False

# Oplog
OPLOG = True
OPLOG_CHANGE_METHODS = ['PATCH', 'PUT', 'DELETE', 'POST']
OPLOG_AUDIT = True
OPLOG_NAME = "oplog"

Oplog push hook:

def oplog_extras(resource, entries):
    schema = DOMAIN['oplog']['schema']

    app.config["DOMAIN"]['oplog']["schema"] = schema

app.on_oplog_push += oplog_extras

from eve-sqlalchemy.

dkellner avatar dkellner commented on August 17, 2024

@dkellner The latest release of eve-sqlalchemy requires eve < 0.8, which was released in 2018. Any plans to support a newer version of eve?

I'd be happy to provide compatibility for newer Eve versions, but my personal dev time is limited and I'm not able to use Eve-SQLAlchemy anymore at work. If anyone steps in and does the necessary work, I'd be happy to provide some guidance and review.

from eve-sqlalchemy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.