def generateDomainFromSpecFile(namespace, spec): domain = dict() template = jinjaEnv.get_template('sqlalchemy.py') for modelname, modelspec in spec.iteritems(): for propspec in modelspec.properties: ttype = propspec.type if ttype.startswith('list'): ttype = 'list' elif ttype.startswith('dict'): ttype = 'dict' propspec.ttype = ttype result = template.render(spec=spec) sqlalchemyfolder = j.system.fs.joinPaths(tmplDir, '..', '..', 'models', 'sqlalchemy') sqlalchemyfolder = os.path.abspath(sqlalchemyfolder) namespacefile = j.system.fs.joinPaths(sqlalchemyfolder, '%s.py' % namespace) j.system.fs.writeFile(namespacefile, result) module = importlib.import_module("models.sqlalchemy.%s" % namespace) for modelname, modelspec in spec.iteritems(): modelclass = getattr(module, modelname) registerSchema(modelspec.name)(modelclass) domain[modelname] = modelclass._eve_schema[modelspec.name] domain[modelname].update({'item_url': 'regex(".*")'}) return domain
def generate_eve_domain_configuration(self): domain = {} for table in self.metadata.tables: DB = getattr(self.base.classes, table) registerSchema(table)(DB) domain[table] = DB._eve_schema[table] domain[table].update({ 'id_field': 'id', 'item_url': 'regex("[-a-z0-9]{8}-[-a-z0-9]{4}-' '[-a-z0-9]{4}-[-a-z0-9]{4}-[-a-z0-9]{12}")', 'item_lookup_field': 'id', 'resource_methods': ['GET', 'POST', 'DELETE'], 'item_methods': ['PATCH', 'DELETE', 'PUT', 'GET'], 'public_methods': [], 'public_item_methods': [], }) domain[table]['schema']['created_at']['required'] = False domain[table]['schema']['updated_at']['required'] = False domain[table]['schema']['etag']['required'] = False domain[table]['datasource']['default_sort'] = [('created_at', 1)] if 'team_id' in domain[table]['schema']: domain[table]['schema']['team_id']['required'] = False domain[table]['auth_field'] = 'team_id' if hasattr(DB, 'name'): domain[table].update({ 'additional_lookup': { 'url': 'regex("[-_\w\d]+")', 'field': 'name' }}) domain[table]['description'] = self.get_table_description(table) # NOTE(Goneri): optional, if the key is missing, we dynamically pick # a testversion that fit. domain['jobs']['schema']['testversion_id']['required'] = False domain['jobs']['datasource']['projection']['jobstates_collection'] = 1 return domain
def generateDomainFromModelFiles(namespace, modelfiles): domain = dict() for filename in modelfiles: module = importlib.import_module("models.osis.sql.%s.%s" % (namespace, filename)) for modelname, obj in inspect.getmembers(module): if inspect.isclass(obj) and hasattr(obj, '__table__'): registerSchema(modelname)(obj) domain[modelname] = obj._eve_schema[modelname] domain[modelname].update({'item_url': 'regex(".*")'}) return domain
def RegisterTable(tableClass): """When creating SQLAlchemy models, they need to be registered with the eve_sqlalchemy interface library. Additionally, add the schema to the DOMAIN dictionary, which will be used later during construction of the Eve app to inform it of which tables to create CRUD interfaces for. """ nm = tableClass.__tablename__ registerSchema(nm)(tableClass) DOMAIN[nm] = tableClass._eve_schema[nm]
def build_app(disable_auth=False): '''Build WSGI APP setting up the DB and EVE''' parameters = { 'validator': ValidatorSQL, 'data': SQL, 'settings': settings.SETTINGS, } # Auth via tokens is enabled by default if not disable_auth: parameters['auth'] = token_auth.TokenAuth # Setup EVE app = Eve(**parameters) # Eve automatic token creation and role assigment when a user is # inserted. tasks.set_on_insert_account_token(app) register.log_user(app) # Setup DB engine db = app.data.driver Base.metadata.bind = db.engine # Bind the model to the engine and create tables if needed db.Model = Base db.create_all() # Add a route to fetch camera frames in order to do a visual # inspection of the monitored room init_camera_app(app=app) # Measurements can be stored either on InfluxDB or in a relational # DB, depending on the user configuration. if settings.use_influxdb: # Register influx for /measurements influx_handler = InfluxDBHandler( settings.influxdb_host, settings.influxdb_port, settings.influxdb_username, settings.influxdb_password, settings.influxdb_db, app, ) else: # Use a relational DB for measurements from eve_sqlalchemy.decorators import registerSchema from .models.measurement import Measurement registerSchema(Measurement.__tablename__)(Measurement) settings.SETTINGS['DOMAIN']['measurement'] = Measurement._eve_schema[ 'measurement'] return app
def _eve_schema(obj, cls): """auto creator eve schema""" schema_name = cls.resource_name registerSchema(schema_name)(cls) # *!* modify standard access point cls._eve_schema = cls._eve_schema[schema_name] # protect Eve-API for modify by clients app # * rows _created, _updated, _etag protected by Eve, and not add to schema access. cls._eve_schema['schema']['_id'].update({'readonly': True}) return cls._eve_schema
def register(cls): '''Decorator that registers it and keeps track of it''' plural = cls.__name__.lower() + 's' registerSchema(plural)(cls) domain[plural] = cls._eve_schema[plural] # make sure id is our id_field # I think this should happen automatically but it doesn't domain[plural]['id_field'] = config.ID_FIELD domain[plural]['description'] = {'general': cls.__name__ + 's'} if cls.__doc__: domain[plural]['description'].update({'methods': {'GET': cls.__doc__}}) # make all ids of type objectid # should not be necceassry, but feels good :) domain[plural]['schema']['id']['type'] = 'objectid' # change data_relation's schema a bit for field, value in domain[plural]['schema'].items(): # is it a field with data_relation if 'data_relation' in value: # resource is the table name by default # eve-sqlalchemy juts hopes it will be the same # since we rename things, we need to rename it here as well # fortunately, we are consistent and can construct it value['data_relation']['resource'] = field + 's' # make it embeddable, cannot enable it globally value['data_relation']['embeddable'] = True if hasattr(cls, '__authentication__'): domain[plural]['authentication'] = cls.__authentication__ if hasattr(cls, '__auth_field__'): domain[plural]['auth_field'] = cls.__auth_field__ if hasattr(cls, '__additional_lookup__'): domain[plural]['additional_lookup'] = cls.__additional_lookup__ classes[plural] = cls return cls
def generate_eve_domain_configuration(self): domain = {} for table in self.metadata.tables: DB = getattr(self.base.classes, table) registerSchema(table)(DB) domain[table] = DB._eve_schema[table] domain[table].update({ 'id_field': 'id', 'item_url': 'regex("[-a-z0-9]{8}-[-a-z0-9]{4}-' '[-a-z0-9]{4}-[-a-z0-9]{4}-[-a-z0-9]{12}")', 'item_lookup_field': 'id', 'resource_methods': ['GET', 'POST', 'DELETE'], 'item_methods': ['PATCH', 'DELETE', 'PUT', 'GET'], 'public_methods': [], 'public_item_methods': [], }) domain[table]['schema']['created_at']['required'] = False domain[table]['schema']['updated_at']['required'] = False domain[table]['schema']['etag']['required'] = False if 'team_id' in domain[table]['schema']: domain[table]['schema']['team_id']['required'] = False domain[table]['auth_field'] = 'team_id' if hasattr(DB, 'name'): domain[table].update({ 'additional_lookup': { 'url': 'regex("[-_\w\d]+")', 'field': 'name' } }) domain[table]['description'] = self.get_table_description(table) # NOTE(Goneri): optional, if the key is missing, we dynamically pick # a testversion that fit. domain['jobs']['schema']['testversion_id']['required'] = False return domain
def generateDomainFromSpecFile(namespace, spec): domain = dict() template = jinjaEnv.get_template('sqlalchemy.py') for modelname, modelspec in spec.iteritems(): for propspec in modelspec.properties: ttype=propspec.type if ttype.startswith('list'): ttype = 'list' elif ttype.startswith('dict'): ttype = 'dict' propspec.ttype = ttype result = template.render(spec=spec) sqlalchemyfolder = j.system.fs.joinPaths(tmplDir, '..', '..', 'models', 'sqlalchemy') sqlalchemyfolder = os.path.abspath(sqlalchemyfolder) namespacefile = j.system.fs.joinPaths(sqlalchemyfolder, '%s.py' % namespace) j.system.fs.writeFile(namespacefile, result) module = importlib.import_module("models.sqlalchemy.%s" % namespace) for modelname, modelspec in spec.iteritems(): modelclass = getattr(module, modelname) registerSchema(modelspec.name)(modelclass) domain[modelname] = modelclass._eve_schema[modelspec.name] domain[modelname].update({'item_url': 'regex(".*")'}) return domain
# -*- coding: utf-8 -*- """ Normal settings file for Eve. Differently from a configuration file for an Eve application backed by Mongo we need to define the schema using the registerSchema decorator. """ from eve_sqlalchemy.decorators import registerSchema from tables import People, Invoices registerSchema('people')(People) registerSchema('invoices')(Invoices) SQLALCHEMY_DATABASE_URI = 'sqlite://' # The following two lines will output the SQL statements executed by SQLAlchemy. Useful while debugging # and in development. Turned off by default # -------- # SQLALCHEMY_ECHO = True # SQLALCHEMY_RECORD_QUERIES = True DEBUG = True # The default schema is generated by the decorator DOMAIN = { 'people': People._eve_schema['people'], 'invoices': Invoices._eve_schema['invoices'] } # but you can always customize it:
#@app.route("/debate/<regex('[0-9].*'):debate_id>/stats") #def get_stats(debate_id): # return Debate.query.get(debate_id).speakers ID_FIELD = 'id' ITEM_LOOKUP_FIELD = ID_FIELD config.ID_FIELD = ID_FIELD config.ITEM_LOOKUP_FIELD = ID_FIELD registerSchema('statement')(Statement) registerSchema('speaker')(Speaker) registerSchema('debate')(Debate) registerSchema('debate_speakers')(DebateSpeaker) # The default schema is generated by the decorator SETTINGS = { 'XML': False, 'DEBUG': True, 'SQLALCHEMY_DATABASE_URI': app.config['SQLALCHEMY_DATABASE_URI'], 'DOMAIN' : { 'statement': Statement._eve_schema['statement'], 'speaker': Speaker._eve_schema['speaker'], 'debate': Debate._eve_schema['debate'], 'debate_speakers': DebateSpeaker._eve_schema['debate_speakers'],
import os from eve_sqlalchemy.decorators import registerSchema from tables import Users, Resources, Cards, Logs registerSchema('users')(Users) registerSchema('resources')(Resources) registerSchema('cards')(Cards) registerSchema('logs')(Logs) SQLALCHEMY_DATABASE_URI = 'sqlite:////' + os.path.join(os.path.dirname(__file__), 'rfid.db') SQLALCHEMY_ECHO = False SQLALCHEMY_RECORD_QUERIES = False SQLALCHEMY_TRACK_MODIFICATIONS = False RESOURCE_METHODS = ['GET', 'POST'] ITEM_METHODS = ['GET', 'PATCH', 'PUT', 'DELETE'] CACHE_CONTROL = 'no-cache' URL_PREFIX = 'api' DEBUG = False DOMAIN = { 'users': Users._eve_schema['users'], 'resources': Resources._eve_schema['resources'], 'cards': Cards._eve_schema['cards'], 'logs': Logs._eve_schema['logs'] } DOMAIN['users'].update({ 'public_methods': [''], 'public_item_methods': [''],
Base = declarative_base() class People(Base): __tablename__ = 'people' id = Column(Integer, primary_key=True, autoincrement=True) firstname = Column(String(80)) lastname = Column(String(120)) fullname = column_property(firstname + " " + lastname) @classmethod def from_tuple(cls, data): """Helper method to populate the db""" return cls(firstname=data[0], lastname=data[1]) registerSchema('people')(People) SETTINGS = { 'DEBUG': True, 'SQLALCHEMY_DATABASE_URI': 'sqlite://', 'DOMAIN': { 'people': People._eve_schema['people'], } } app = Eve(auth=None, settings=SETTINGS, validator=ValidatorSQL, data=SQL) # bind SQLAlchemy db = app.data.driver Base.metadata.bind = db.engine db.Model = Base
import recastdb.models from recastdb.database import db from eve import Eve from eve_sqlalchemy import SQL from eve_sqlalchemy.validation import ValidatorSQL from eve_sqlalchemy.decorators import registerSchema from recastfrontend.frontendconfig import config as frontendconf registerSchema('users')(recastdb.models.User) registerSchema('Analysis')(recastdb.models.Analysis) registerSchema('Subscription')(recastdb.models.Subscription) SETTINGS = { 'DEBUG': True, 'SQLALCHEMY_DATABASE_URI': frontendconf['DBPATH'], 'DOMAIN': { 'users': recastdb.models.User._eve_schema['users'], 'Analysis': recastdb.models.Analysis._eve_schema['Analysis'], 'Subscription': recastdb.models.Subscription._eve_schema['Subscription'], } } app = Eve(auth=None, settings=SETTINGS, validator=ValidatorSQL, data=SQL) #app.app_context().push() Base = recastdb.database.db.Model
) class Keywords(CommonColumns): __tablename__ = 'keywords' kw = Column(String(80)) class ProductsKeywords(Base): __tablename__ = 'products_keywords' product_id = Column(Integer, ForeignKey('products._id'), primary_key=True) keyword_id = Column(Integer, ForeignKey('keywords._id'), primary_key=True) product = relationship( 'Products', backref=backref('products_keywords_assoc', cascade="all,delete-orphan") ) keyword = relationship('Keywords') # Since the corresponding mappers of the following classes are not yet fully # configured, we need to make a direct call the registerSchema() decorator. # Note(Kevin Roy): Maybe we should use mapper.configure_mappers() and the # decorator registerSchema should be triggered for each model class on the # Mappers event 'after_configured'. registerSchema('products')(Products) registerSchema('keywords')(Keywords)
# Enable reads (GET), inserts (POST) and DELETE for resources/collections # (if you omit this line, the API will default to ['GET'] and provide # read-only access to the endpoint). RESOURCE_METHODS = ['GET', 'POST', 'DELETE'] # Enable reads (GET), edits (PATCH), replacements (PUT) and deletes of # individual items (defaults to read-only item access). ITEM_METHODS = ['GET', 'PATCH', 'PUT', 'DELETE'] # The following two lines will output the SQL statements executed by SQLAlchemy. Useful while debugging # and in development. Turned off by default # -------- SQLALCHEMY_ECHO = True SQLALCHEMY_RECORD_QUERIES = True registerSchema('users')(User) registerSchema('devices')(Device) # registerSchema('locations')(Location) registerSchema('inputs')(Input) # The default schema is generated by the decorator DOMAIN = { 'users': User._eve_schema['users'], 'devices': Device._eve_schema['devices'], # 'locations': Location._eve_schema['locations'], 'inputs': Input._eve_schema['inputs'], } DOMAIN['users'].update({ # 'item_title': 'name', 'authentication': Sha1Auth,
from eve_sqlalchemy.decorators import registerSchema from tables import Users, Requests, Deliveries, Shifts registerSchema('users')(Users) registerSchema('requests')(Requests) registerSchema('deliveries')(Deliveries) registerSchema('shifts')(Shifts) DEBUG = True # Exclude links to parent and sibling pages in server responses HATEOAS = False # Disable etag attribute IF_MATCH = False # Name of the field used to store the owner of each document AUTH_FIELD = 'user_id' # DB connection string in format dbusername:password@domain/databasename # SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://sidekick:halpme@localhost/sidekick_dev?unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock' SQLALCHEMY_DATABASE_URI = 'postgresql://*****:*****@localhost/sidekick_dev' # Enable reads (GET) for resources/collections RESOURCE_METHODS = ['GET', 'POST'] # Enable reads (GET) and edits (PATCH) of individual items. ITEM_METHODS = ['GET', 'PATCH'] # Register schemas defined in tables.py DOMAIN = {
# Eve imports from eve import Eve from eve_sqlalchemy import SQL from eve_sqlalchemy.validation import ValidatorSQL # Eve-SQLAlchemy imports from eve_sqlalchemy.decorators import registerSchema import entities registerSchema('player')(entities.Player) registerSchema('pitch')(entities.Pitch) SETTINGS = { 'DEBUG': True, 'SQLALCHEMY_DATABASE_URI': 'sqlite:///./fillbass.db', 'DOMAIN': { 'people': entities.Player._eve_schema['player'], 'pitch': entities.Pitch._eve_schema['pitch'] } } print(entities.Player._eve_schema['player']) app = Eve(auth=None, settings=SETTINGS, validator=ValidatorSQL, data=SQL) # bind SQLAlchemy db = app.data.driver entities.Entity.metadata.bind = db.engine db.Model = entities.Entity db.create_all()
from eve_sqlalchemy.decorators import registerSchema from schema import User from eve.utils import config registerSchema('user')(User) DEBUG = True SQLALCHEMY_DATABASE_URI = 'sqlite://' SQLALCHEMY_TRACK_MODIFICATIONS = True IF_MATCH = False DOMAIN = {'user': User._eve_schema['user']} DOMAIN['user'].update({ 'item_lookup_field': 'id', 'item_title': 'user', 'additional_lookup': { 'url': '<regex("[\w]+"):id>', 'field': 'id' }, 'cache_control': 'max-age=10,must-revalidate', 'cache_expires': 10, 'resource_methods': ['GET', 'POST'], 'item_methods': ['GET', 'PUT', 'DELETE'] }) ID_FIELD = 'id' ITEM_LOOKUP_FIELD = ID_FIELD config.ID_FIELD = ID_FIELD config.ITEM_LOOKUP_FIELD = ID_FIELD
''' Created on Apr 21, 2016 @author: neil ''' from database import DBTweets, Base from eve import Eve from eve_sqlalchemy import SQL from eve_sqlalchemy.validation import ValidatorSQL from eve_sqlalchemy.decorators import registerSchema # It appears that this creates the _eve_schema object. registerSchema('tweets')(DBTweets) SETTINGS = { 'DEBUG': True, 'X_DOMAINS': '*', 'SQLALCHEMY_DATABASE_URI': 'sqlite:////tmp/tweets.db', 'XML': False, 'JSON': True, 'PAGINATION': False, 'DOMAIN': { 'tweets': DBTweets._eve_schema['tweets'], } } def main(): app = Eve(auth=None, settings=SETTINGS, validator=ValidatorSQL, data=SQL)
class Feedback(CommonColumns): __tablename__ = 'feedback' text = Column(Text) author_id = Column('author_id', Integer, ForeignKey('user._id')) author = relationship('User') def image_path(self): return os.path.join(frt_server.config.FEEDBACK_UPLOAD_FOLDER, str(self._id)) + '.png' def ensure_folder_exists(self): if not os.path.exists(frt_server.config.FEEDBACK_UPLOAD_FOLDER): os.makedirs(frt_server.config.FEEDBACK_UPLOAD_FOLDER) registerSchema('user')(User) registerSchema('tag')(Tag) registerSchema('sample_text')(SampleText) registerSchema('family')(Family) registerSchema('font')(Font) registerSchema('glyph')(Glyph) registerSchema('thread')(Thread) registerSchema('codepoint')(Codepoint) registerSchema('comment')(Comment) registerSchema('attachment')(Attachment) registerSchema('thread_glyph_association')(ThreadGlyphAssociation) registerSchema('thread_subscription')(ThreadSubscription) registerSchema('feedback')(Feedback)
# db_table = 'users' class Auth(Base): __tablename__ = 'auth' uid = Column(Integer, primary_key=True, autoincrement=True) serverid = Column(Integer) token = Column(String(60)) tokentime = Column(DateTime) # Field name made lowercase. # class Meta: # managed = False # db_table = 'auth' registerSchema('people')(People) registerSchema('users')(Users) registerSchema('auth')(Auth) SETTINGS = { 'DEBUG': True, 'SQLALCHEMY_DATABASE_URI': 'mysql://*****:*****@192.168.0.2:3306/xuebaedu', 'DOMAIN': { 'people': People._eve_schema['people'], 'users': Users._eve_schema['users'], 'auth': Auth._eve_schema['auth'], } } app = Eve(auth=None, settings=SETTINGS, validator=ValidatorSQL, data=SQL)
lastname = Column(String(120)) fullname = column_property(firstname + " " + lastname) @classmethod def from_tuple(cls, data): """Helper method to populate the db""" return cls(firstname=data[0], lastname=data[1]) class Files(Base): __tablename__ = 'files' id = Column(Integer, primary_key=True, autoincrement=True) name = Column(String(80)) registerSchema('people')(People) registerSchema('files')(Files) SETTINGS = { 'DEBUG': True, 'SQLALCHEMY_DATABASE_URI': 'sqlite://', 'DOMAIN': { 'people': People._eve_schema['people'], 'files': Files._eve_schema['files'], } } app = Eve(auth=None, settings=SETTINGS, validator=ValidatorSQL, data=SQL) # bind SQLAlchemy db = app.data.driver
id = Column(Integer, autoincrement=True, unique=True) title = Column(String, primary_key=True, unique=True) prefix = Column(String) users = Column(String) def is_authorized(user, is_authenticated, allowed_roles, resource, method, lookup): if 'anonymous' in allowed_roles: return True if 'registered' in allowed_roles: if is_authenticated: return True if 'moderators' in allowed_roles: pass #if 'owner' in allowed_roles: #login = user.login registerSchema('boards')(Boards) registerSchema('posts')(Posts) registerSchema('users')(Users) Boards._eve_schema['boards'].update(boards_schema) Posts._eve_schema['posts'].update(posts_schema) Users._eve_schema['users'].update(users_schema)
CONSOLE.setLevel(logging.INFO) # set a format which is simpler for console use FORMATTER = logging.Formatter('%(levelname)-8s:%(name)-8s:%(message)s') # tell the handler to use this format CONSOLE.setFormatter(FORMATTER) # add the handler to the root logger logging.getLogger('').addHandler(CONSOLE) LOGGER = logging.getLogger('MAIN') # ################################################# # # Settings # ################################################# registerSchema('pin')(Pin) registerSchema('sequence')(Sequence) pin_schema = Pin._eve_schema['pin'] pin_schema['schema']['state'] = {'type': 'string'} settings = { 'SQLALCHEMY_DATABASE_URI': 'sqlite:////{0}/{1}'.format(os.getcwd(), ARGS.schedule_file), 'SQLALCHEMY_TRACK_MODIFICATIONS': True, 'URL_PREFIX': 'api', 'RESOURCE_METHODS': ['GET', 'POST', 'DELETE'], 'ITEM_METHODS': ['GET', 'PATCH', 'PUT', 'DELETE'], 'DOMAIN': { 'pin': pin_schema, 'sequence': Sequence._eve_schema['sequence'] }
def check_auth(self, orcid_id, token, allowed_roles, resource, method): """ Token based authentications """ try: user = recastdb.models.User.query.filter( recastdb.models.User.orcid_id == orcid_id).one() access_token = recastdb.models.AccessToken.query.filter( recastdb.models.AccessToken.token == token).one() return access_token.user_id == user.id except MultipleResultsFound, e: return False except NoResultFound, e: return False registerSchema('users')(recastdb.models.User) registerSchema('analysis')(recastdb.models.Analysis) registerSchema('subscriptions')(recastdb.models.Subscription) registerSchema('run_conditions')(recastdb.models.RunCondition) registerSchema('models')(recastdb.models.Model) registerSchema('scan_requests')(recastdb.models.ScanRequest) registerSchema('point_requests')(recastdb.models.PointRequest) registerSchema('basic_requests')(recastdb.models.BasicRequest) registerSchema('parameters')(recastdb.models.Parameters) registerSchema('point_coordinates')(recastdb.models.PointCoordinate) registerSchema('request_archives')(recastdb.models.RequestArchive) registerSchema('scan_responses')(recastdb.models.ScanResponse) registerSchema('point_responses')(recastdb.models.PointResponse) registerSchema('basic_responses')(recastdb.models.BasicResponse) registerSchema('response_archives')(recastdb.models.ResponseArchive)
''' Created on Apr 21, 2016 @author: neil ''' from database import DBTweets, Base from eve import Eve from eve_sqlalchemy import SQL from eve_sqlalchemy.validation import ValidatorSQL from eve_sqlalchemy.decorators import registerSchema # It appears that this creates the _eve_schema object. registerSchema('tweets')(DBTweets) SETTINGS = { 'DEBUG': True, 'X_DOMAINS': '*', 'SQLALCHEMY_DATABASE_URI': 'sqlite:////tmp/tweets.db', 'XML': False, 'JSON': True, 'PAGINATION': False, 'DOMAIN': { 'tweets': DBTweets._eve_schema['tweets'], } } def main():
import os basedir = os.path.abspath(os.path.dirname(__file__)) from eve_sqlalchemy.decorators import registerSchema from proof_companion.models import Contact registerSchema('contact')(Contact) class Config: SECRET_KEY = os.environ.get('SECRET_KEY') or 'secret_key' SQLALCHEMY_COMMIT_ON_TEARDOWN = True EVE_SETTINGS = { 'DOMAIN': { 'contact': Contact._eve_schema['contact'] }, 'URL_PREFIX': 'api' } class DevelopmentConfig(Config): DEBUG = True SQLALCHEMY_ECHO = True SQLALCHEMY_RECORD_QUERIES = True SQLALCHEMY_DATABASE_URI = 'postgresql://host/database' class TestingConfig(Config): TESTING = True
EMBEDDABLE = True # removes pagination and meta field PAGINATION = False ID_FIELD = 'id' ITEM_LOOKUP_FIELD = ID_FIELD config.ID_FIELD = ID_FIELD config.ITEM_LOOKUP_FIELD = ID_FIELD XML = True JSON = True from recastrestapi.apiconfig import config as apiconf registerSchema('users')(recastdb.models.User) registerSchema('analysis')(recastdb.models.Analysis) registerSchema('subscriptions')(recastdb.models.Subscription) registerSchema('run_conditions')(recastdb.models.RunCondition) registerSchema('models')(recastdb.models.Model) registerSchema('scan_requests')(recastdb.models.ScanRequest) registerSchema('point_requests')(recastdb.models.PointRequest) registerSchema('basic_requests')(recastdb.models.BasicRequest) registerSchema('parameters')(recastdb.models.Parameters) registerSchema('point_coordinates')(recastdb.models.PointCoordinate) registerSchema('request_archives')(recastdb.models.RequestArchive) registerSchema('scan_responses')(recastdb.models.ScanResponse) registerSchema('point_responses')(recastdb.models.PointResponse) registerSchema('basic_responses')(recastdb.models.BasicResponse) registerSchema('response_archives')(recastdb.models.ResponseArchive)