Giter VIP home page Giter VIP logo

Comments (2)

jmcarp avatar jmcarp commented on May 19, 2024

I encountered the same issue and wrote up a patch that simplifies the read-only use case by allowing a custom base model. The code is in #13, and it can be used like this:

from sandman2 import model, get_app
from sqlalchemy.ext.automap import automap_base

class Base(model.Model, model.db.Model):
    __abstract__ = True
    __methods__ = {'GET'}
AutomapModel = automap_base(cls=Base)
app = get_app(database_uri, Base=AutomapModel)
app.run()

from sandman2.

jeffknupp avatar jeffknupp commented on May 19, 2024

The tests have a simple example of this. From tests/automap_models.py:

from sandman2 import AutomapModel


class User(AutomapModel):

    """A user of the blogging application."""

    __tablename__ = 'user'

    def __unicode__(self):
        return self.name


class Blog(AutomapModel):

    """An online weblog."""

    __tablename__ = 'blog'

    def __unicode__(self):
        return self.name

class Post(AutomapModel):

    """An individual blog post."""

    __tablename__ = 'post'

    def __unicode__(self):
        return self.title

Then simply override the __methods__ property to only support GET:
__methods__ = {'GET'}

Will add to docs.

from sandman2.

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.