diff --git a/TODO.txt b/TODO.txt index 953bb38..e69de29 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,2 +0,0 @@ -lbbulk/view/restfulview.py line 41 -lbbulk/view/restfulview.py line 48 \ No newline at end of file diff --git a/development.ini b/development.ini deleted file mode 100644 index 18888c3..0000000 --- a/development.ini +++ /dev/null @@ -1,60 +0,0 @@ -[app:main] -use = egg:LBBulk - -pyramid.reload_templates = true -pyramid.debug_authorization = false -pyramid.debug_notfound = false -pyramid.debug_routematch = false -pyramid.default_locale_name = en -pyramid.includes = - pyramid_tm - -sqlalchemy.url = postgresql://rest:rest@localhost/projeto1 - -domain = http://api.brlight.org -base_name = wmi_teste - -[server:main] -use = egg:waitress#main -host = 0.0.0.0 -port = 6543 - -### -# logging configuration -# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html -### - -[loggers] -keys = root, lbbulk, sqlalchemy - -[handlers] -keys = console - -[formatters] -keys = generic - -[logger_root] -level = INFO -handlers = console - -[logger_lbbulk] -level = DEBUG -handlers = -qualname = lbbulk - -[logger_sqlalchemy] -level = WARN -handlers = -qualname = sqlalchemy.engine -# "level = INFO" logs SQL queries. -# "level = DEBUG" logs SQL queries and results. -# "level = WARN" logs neither. (Recommended for production systems.) - -[handler_console] -class = StreamHandler -args = (sys.stderr,) -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s diff --git a/development.ini-dist b/development.ini-dist new file mode 100644 index 0000000..815af3a --- /dev/null +++ b/development.ini-dist @@ -0,0 +1,60 @@ +[app:main] +use = egg:LBBulk + +pyramid.reload_templates = true +pyramid.debug_authorization = false +pyramid.debug_notfound = false +pyramid.debug_routematch = false +pyramid.default_locale_name = en +pyramid.includes = + pyramid_tm + +sqlalchemy.url = postgresql://rest:rest@localhost/lbbulk + +domain = http://api.brlight.org +base_name = wmi + +[server:main] +use = egg:waitress#main +host = 0.0.0.0 +port = 6543 + +### +# logging configuration +# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html +### + +[loggers] +keys = root, lbbulk, sqlalchemy + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = INFO +handlers = console + +[logger_lbbulk] +level = DEBUG +handlers = +qualname = lbbulk + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine +# "level = INFO" logs SQL queries. +# "level = DEBUG" logs SQL queries and results. +# "level = WARN" logs neither. (Recommended for production systems.) + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s diff --git a/lbbulk.wsgi-dist b/lbbulk.wsgi-dist new file mode 100644 index 0000000..a89ef91 --- /dev/null +++ b/lbbulk.wsgi-dist @@ -0,0 +1,7 @@ +from pyramid.paster import get_app, setup_logging + +ini_path = '/srv/lightbase/LBBulk/development.ini' +#ini_path = '/srv/lightbase/LBBulk/production.ini' + +setup_logging(ini_path) +application = get_app(ini_path, 'main') diff --git a/lbbulk/config/routing.py b/lbbulk/config/routing.py index fa102ed..55b35d5 100644 --- a/lbbulk/config/routing.py +++ b/lbbulk/config/routing.py @@ -1,6 +1,6 @@ # import lbbulk.model from lbbulk.model.BulkUpload import BulkUploadContextFactory -from lbbulk.model.BulkSources import BulkSourceContextFactory +from lbbulk.model.BulkSource import BulkSourceContextFactory from lbbulk.view.restfulview import RegCustomView def make_routes(config): diff --git a/lbbulk/model/BulkSource.py b/lbbulk/model/BulkSource.py new file mode 100644 index 0000000..e40ebeb --- /dev/null +++ b/lbbulk/model/BulkSource.py @@ -0,0 +1,20 @@ +from sqlalchemy import Table, Column, Integer, String +from pyramid_restler.model import SQLAlchemyORMContext +from lbbulk.model import Base, metadata, session + + +bulk_source = Table('lb_bulk_source', metadata, + Column('id_source', Integer, primary_key=True), + Column('name_source', String, nullable=False) + ) + + +# map to it +class BulkSource(Base): + __table__ = bulk_source + +class BulkSourceContextFactory(SQLAlchemyORMContext): + entity = BulkSource + + def session_factory(self): + return session diff --git a/lbbulk/model/BulkSources.py b/lbbulk/model/BulkSources.py deleted file mode 100644 index 5e3d92f..0000000 --- a/lbbulk/model/BulkSources.py +++ /dev/null @@ -1,20 +0,0 @@ -from sqlalchemy import Table, Column, Integer, String -from pyramid_restler.model import SQLAlchemyORMContext -from lbbulk.model import Base, metadata, session - - -bulk_source = Table('lb_bulk_sources', metadata, - Column('id_source', Integer, primary_key=True), - Column('nome_source', String, nullable=False) - ) - - -# map to it -class BulkSource(Base): - __table__ = bulk_source - -class BulkSourceContextFactory(SQLAlchemyORMContext): - entity = BulkSource - - def session_factory(self): - return session diff --git a/lbbulk/model/BulkUpload.py b/lbbulk/model/BulkUpload.py index 25ccc4d..ce9221e 100644 --- a/lbbulk/model/BulkUpload.py +++ b/lbbulk/model/BulkUpload.py @@ -1,4 +1,5 @@ from sqlalchemy import Table, Column, Integer, String, ForeignKey +from requests import get from pyramid_restler.model import SQLAlchemyORMContext from lbbulk.model import Base, metadata, session import json @@ -6,9 +7,9 @@ import json bulk_upload = Table('lb_bulk_upload', metadata, Column('id_reg', Integer, primary_key=True), - Column('chave_externa', String, nullable=False), + Column('external_key', String, nullable=False), Column('id_source', Integer, - ForeignKey('lb_bulk_sources.id_source'), + ForeignKey('lb_bulk_source.id_source'), nullable=False), extend_existing=True ) @@ -18,9 +19,13 @@ class BulkUpload(Base): __table__ = bulk_upload def verifica_registro(data): -# q = session.query(BulkUpload).filter_by(id_source=data['id_source'], chave_externa=data['json_reg']['id_reg'] ) - q = session.query(BulkUpload).filter_by(id_source=1, chave_externa=data['json_reg']['id_reg'] ) + # q = session.query(BulkUpload).filter_by(id_source=1, external_key=data['json_reg']['id_reg'] ) + get('localhost/') registro_existe = q.first() + if sim: + registro_existe = True + else: + registro_existe = False return registro_existe @@ -32,4 +37,4 @@ class BulkUploadContextFactory(SQLAlchemyORMContext): def get_member_id_as_string(self, member): id = self.get_member_id(member) - return json.dumps(id, cls=self.json_encoder) + return json.dumps(id, cls=self.json_encoder) \ No newline at end of file diff --git a/lbbulk/templates/mytemplate.pt b/lbbulk/templates/mytemplate.pt index ff1e344..fada32d 100644 --- a/lbbulk/templates/mytemplate.pt +++ b/lbbulk/templates/mytemplate.pt @@ -39,6 +39,9 @@
  • Fontes de Dados
  • +
  • +
    +