Git Product home page Git Product logo

restfulpy's Issues

NotImpletementedError when update_from_request boolean value

My tested model

class Product(DeclarativeBase):
    __tablename__ = 'products'
    id = Column(Integer, primary_key=True)
    title = Column(Unicode(220), nullable=False)
    visible = Column(Boolean)

implemention:

context.form['visible'] = 'true'
product = Prdocut()
product.update_from_request()
session.add(product)
session.commit()

return this errors:

File "/.../product.py", line 73, in post
    product.update_from_request()
  File "/.../restfulpy/restfulpy/orm/models.py", line 88, in update_from_request
    self.import_value(column, value)
  File "/.../restfulpy/restfulpy/orm/models.py", line 34, in import_value
    if c.type.python_type is bool and not isinstance(v, bool):
  File "/.../sqlalchemy/sql/type_api.py", line 387, in python_type
    raise NotImplementedError()
NotImplementedError

Maximum recursion depth, when using relations

from sqlalchemy import Column, String, Integer, create_engine, ForeignKey, MetaData
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session, relationship
from restfulpy.orm import BaseModel
metadata = MetaData()
Base = declarative_base(cls=BaseModel, metadata=metadata)


class Employee(Base):
    __tablename__ = 'employee'
    id = Column(Integer, primary_key=True)
    name = Column(String(50))
    type = Column(String(20))
    images = relationship('Image', secondary='image_relations', backref='employee')


class Image(Base):
    __tablename__ = 'images'
    id = Column(Integer, primary_key=True)
    src = Column(String(100))


class ImageRelation(Base):
    __tablename__ = 'image_relations'
    employee_id = Column(Integer, ForeignKey('employee.id'), primary_key=True)
    image_id = Column(Integer, ForeignKey('images.id'), primary_key=True)


engine = create_engine('sqlite://', echo=True)
Base.metadata.create_all(engine)
session = Session(engine, autoflush=False, autocommit=False, expire_on_commit=True)


@Employee.expose
def run():
    emp1 = Employee()
    emp1.id = 1
    emp1.name = 'dia gram'
    emp1.images.append(Image(src='lorem.com'))
    session.add(emp1)
    session.commit()
    return emp1


print(run().to_dict())

output:

[...]
File "env/lib/python3.5/site-packages/restfulpy/orm/models.py", line 140, in to_dict
    result.setdefault(*self.prepare_for_export(c, getattr(self, c.key)))
  File "env/lib/python3.5/site-packages/restfulpy/orm/models.py", line 43, in prepare_for_export
    result = [c.to_dict() for c in v]
  File "env/lib/python3.5/site-packages/restfulpy/orm/models.py", line 43, in <listcomp>
    result = [c.to_dict() for c in v]
[...]

Sorting on sqlite

ERROR:main:Internal server error
Traceback (most recent call last):
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: near "NULLS": syntax error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/vahid/workspace/nanohttp/nanohttp/application.py", line 56, in __call__
    result = self.__root__(*remaining_paths)
  File "/home/vahid/workspace/restfulpy/restfulpy/controllers.py", line 21, in __call__
    return super().__call__(*remaining_paths)
  File "/home/vahid/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__
    return self._serve_handler(handler, *remaining_paths)
  File "/home/vahid/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler
    return handler(*remaining_paths)
  File "/home/vahid/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__
    return self._serve_handler(handler, *remaining_paths)
  File "/home/vahid/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler
    return handler(*remaining_paths)
  File "/home/vahid/workspace/nanohttp/nanohttp/decorators.py", line 35, in wrapper
    result = func(*args, **kwargs)
  File "/home/vahid/workspace/restfulpy/restfulpy/orm/models.py", line 191, in wrapper
    return cls.dump_query(result)
  File "/home/vahid/workspace/restfulpy/restfulpy/orm/models.py", line 178, in dump_query
    for o in cls.filter_paginate_sort_query_by_request(query):
  File "/home/vahid/workspace/restfulpy/restfulpy/orm/models.py", line 171, in filter_paginate_sort_query_by_request
    query = cls.paginate_by_request(query=query)
  File "/home/vahid/workspace/restfulpy/restfulpy/orm/mixines.py", line 143, in paginate_by_request
    context.response_headers.add_header('X-Pagination-Count', str(query.count()))
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/orm/query.py", line 3089, in count
    return self.from_self(col).scalar()
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/orm/query.py", line 2843, in scalar
    ret = self.one()
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/orm/query.py", line 2814, in one
    ret = self.one_or_none()
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/orm/query.py", line 2784, in one_or_none
    ret = list(self)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/orm/query.py", line 2855, in __iter__
    return self._execute_and_instances(context)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/orm/query.py", line 2878, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
    exc_info
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/home/vahid/.virtualenvs/restfulpy-client.js/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near "NULLS": syntax error [SQL: 'SELECT count(*) AS count_1 \nFROM (SELECT resource.id AS resource_id, resource.title AS resource_title \nFROM resource ORDER BY resource.title DESC NULLS FIRST) AS anon_1']
127.0.0.1 - - [12/Jul/2017 23:02:13] "GET /resources?sort=-title HTTP/1.1" 500 5355

Captured error in tests is not printed properly

Traceback (most recent call last):
  File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/lib/python3.6/unittest/case.py", line 601, in run
    testMethod()
  File "/home/mohammad/workspace/wombat/wombat/tests/test_member.py", line 73, in test_crud_client
    self.request(As.god, 'METADATA', self.url)
  File "/home/mohammad/workspace/restfulpy/restfulpy/testing/testcases.py", line 146, in request
    **kwargs
  File "/home/mohammad/workspace/restfulpy/restfulpy/testing/testcases.py", line 98, in request
    self.assertEqual(resp.status_code, expected_status)
  File "/usr/lib/python3.6/unittest/case.py", line 821, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/lib/python3.6/unittest/case.py", line 814, in _baseAssertEqual
    raise self.failureException(msg)
Exception: 500 != 200

-------------------- >> begin captured logging << --------------------
alembic.runtime.migration: INFO: Context impl PostgresqlImpl.
alembic.runtime.migration: INFO: Will assume transactional DDL.
--------------------- >> end captured logging << ---------------------

################################################################################
{'message': 'Internal Server Error', 'description': 'Traceback (most recent call last):\n  File "/home/mohammad/workspace/nanohttp/nanohttp/application.py", line 56, in __call__\n    result = self.__root__(*remaining_paths)\n  File "/home/mohammad/workspace/restfulpy/restfulpy/controllers.py", line 21, in __call__\n    return super().__call__(*remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__\n    return self._serve_handler(handler, *remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler\n    return handler(*remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__\n    return self._serve_handler(handler, *remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler\n    return handler(*remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__\n    return self._serve_handler(handler, *remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler\n    return handler(*remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/decorators.py", line 35, in wrapper\n    result = func(*args, **kwargs)\n  File "/home/mohammad/workspace/restfulpy/restfulpy/controllers.py", line 29, in metadata\n    return self.__model__.json_metadata()\n  File "/home/mohammad/workspace/restfulpy/restfulpy/orm/models.py", line 82, in json_metadata\n    metadata_fields = MetadataField.from_column(cls.get_column(c), info=c.info)\n  File "/home/mohammad/workspace/restfulpy/restfulpy/orm/metadata.py", line 58, in from_column\n    type_ = c.type.python_type\n  File "/home/mohammad/.virtualenvs/wombat/lib/python3.6/site-packages/sqlalchemy/sql/type_api.py", line 387, in python_type\n    raise NotImplementedError()\nNotImplementedError\n'}
################################################################################
F.......
======================================================================
FAIL: test_crud_client (wombat.tests.test_member.MemberTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mohammad/workspace/wombat/wombat/tests/test_member.py", line 73, in test_crud_client
    self.request(As.god, 'METADATA', self.url)
  File "/home/mohammad/workspace/restfulpy/restfulpy/testing/testcases.py", line 146, in request
    **kwargs
  File "/home/mohammad/workspace/restfulpy/restfulpy/testing/testcases.py", line 98, in request
    self.assertEqual(resp.status_code, expected_status)
AssertionError: 500 != 200
-------------------- >> begin captured stdout << ---------------------
################################################################################
{'message': 'Internal Server Error', 'description': 'Traceback (most recent call last):\n  File "/home/mohammad/workspace/nanohttp/nanohttp/application.py", line 56, in __call__\n    result = self.__root__(*remaining_paths)\n  File "/home/mohammad/workspace/restfulpy/restfulpy/controllers.py", line 21, in __call__\n    return super().__call__(*remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__\n    return self._serve_handler(handler, *remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler\n    return handler(*remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__\n    return self._serve_handler(handler, *remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler\n    return handler(*remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__\n    return self._serve_handler(handler, *remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler\n    return handler(*remaining_paths)\n  File "/home/mohammad/workspace/nanohttp/nanohttp/decorators.py", line 35, in wrapper\n    result = func(*args, **kwargs)\n  File "/home/mohammad/workspace/restfulpy/restfulpy/controllers.py", line 29, in metadata\n    return self.__model__.json_metadata()\n  File "/home/mohammad/workspace/restfulpy/restfulpy/orm/models.py", line 82, in json_metadata\n    metadata_fields = MetadataField.from_column(cls.get_column(c), info=c.info)\n  File "/home/mohammad/workspace/restfulpy/restfulpy/orm/metadata.py", line 58, in from_column\n    type_ = c.type.python_type\n  File "/home/mohammad/.virtualenvs/wombat/lib/python3.6/site-packages/sqlalchemy/sql/type_api.py", line 387, in python_type\n    raise NotImplementedError()\nNotImplementedError\n'}
################################################################################

--------------------- >> end captured stdout << ----------------------
-------------------- >> begin captured logging << --------------------
alembic.runtime.migration: INFO: Context impl PostgresqlImpl.
alembic.runtime.migration: INFO: Will assume transactional DDL.
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 8 tests in 0.834s

FAILED (failures=1)

Error when using association_proxy at to_dict()

When using association_proxy on my model, BaseModel.to_dict() return this errors:

 File ".../nanohttp/nanohttp/decorators.py", line 37, in wrapper
    result = result.to_dict()
  File ".../restfulpy/restfulpy/orm/models.py", line 143, in to_dict
    result.setdefault(*self.prepare_for_export(c, getattr(self, c.key)))
AttributeError: 'Product' object has no attribute '_AssociationProxy_tags_140239047097872'

Ordering nullslast problem

I think the nullslast filter should be only on asc ordering. On desc ordering it should be change to nullsfirst. Because, for example when we want to order by is_active, we will get the same response now. because all of ordering ways, the is_active=False records (which will be translate to activated_at=None) will be at the end of the response.

Filtering mixin doesn't work properly with Activation mixin

When we want to use filter for is_active property, we always get False on query expression returned from _filter_by_column_value method. Because of this part:

expression = column == import_value(column, value)

When we use is_active, column will be type of SynonymProperty and he condition column == import_value(column, value) will always return False value.

Map to different field name.

account_code = Field('AccountCode', VARCHAR(15), default=0)

AttributeError: 'Account' object has no attribute 'AccountCode'

Error in getting metadata of a class with activation mixin

Traceback (most recent call last):
  File "/home/mohammad/workspace/nanohttp/nanohttp/application.py", line 56, in __call__
    result = self.__root__(*remaining_paths)
  File "/home/mohammad/workspace/restfulpy/restfulpy/controllers.py", line 21, in __call__
    return super().__call__(*remaining_paths)
  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__
    return self._serve_handler(handler, *remaining_paths)
  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler
    return handler(*remaining_paths)
  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__
    return self._serve_handler(handler, *remaining_paths)
  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler
    return handler(*remaining_paths)
  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 59, in __call__
    return self._serve_handler(handler, *remaining_paths)
  File "/home/mohammad/workspace/nanohttp/nanohttp/controllers.py", line 30, in _serve_handler
    return handler(*remaining_paths)
  File "/home/mohammad/workspace/nanohttp/nanohttp/decorators.py", line 35, in wrapper
    result = func(*args, **kwargs)
  File "/home/mohammad/workspace/restfulpy/restfulpy/controllers.py", line 29, in metadata
    return self.__model__.json_metadata()
  File "/home/mohammad/workspace/restfulpy/restfulpy/orm/models.py", line 81, in json_metadata
    metadata_fields = MetadataField.from_column(cls.get_column(c), info=c.info)
  File "/home/mohammad/workspace/restfulpy/restfulpy/orm/metadata.py", line 58, in from_column
    type_ = c.type.python_type
  File "/home/mohammad/.virtualenvs/wombat/lib/python3.6/site-packages/sqlalchemy/sql/type_api.py", line 387, in python_type
    raise NotImplementedError()
NotImplementedError

################################################################################

Failure
Traceback (most recent call last):
  File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/lib/python3.6/unittest/case.py", line 601, in run
    testMethod()
  File "/home/mohammad/workspace/wombat/wombat/tests/test_member.py", line 73, in test_crud_client
    self.request(As.god, 'METADATA', self.url)
  File "/home/mohammad/workspace/restfulpy/restfulpy/testing/testcases.py", line 154, in request
    **kwargs
  File "/home/mohammad/workspace/restfulpy/restfulpy/testing/testcases.py", line 106, in request
    self.assertEqual(resp.status_code, expected_status)
  File "/usr/lib/python3.6/unittest/case.py", line 821, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/lib/python3.6/unittest/case.py", line 814, in _baseAssertEqual
    raise self.failureException(msg)
Exception: 500 != 200

test_base_model Fails

▶ python restfulpy/tests/test_base_model.py
E
======================================================================
ERROR: setUpClass (__main__.BaseModelTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 1122, in _do_get
    return self._pool.get(wait, self._timeout)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/util/queue.py", line 145, in get
    raise Empty
sqlalchemy.util.queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 2147, in _wrap_pool_connect
    return fn()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 328, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 766, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 516, in checkout
    rec = pool._do_get()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 1138, in _do_get
    self._dec_overflow()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
    raise value
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 1135, in _do_get
    return self._create_connection()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 333, in _create_connection
    return _ConnectionRecord(self)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 461, in __init__
    self.__connect(first_connect_check=True)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 651, in __connect
    connection = pool._invoke_creator(self)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/strategies.py", line 105, in connect
    return dialect.connect(*cargs, **cparams)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 393, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/.../env/lib/python3.5/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
	Is the server running on host "localhost" (127.0.0.1) and accepting
	TCP/IP connections on port 5432?


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/.../restfulpy/restfulpy/testing/testcases.py", line 49, in setUpClass
    cls.prepare_database()
  File "/.../restfulpy/restfulpy/testing/testcases.py", line 22, in prepare_database
    with DatabaseManager() as m:
  File "/.../restfulpy/restfulpy/db.py", line 45, in __enter__
    super().__enter__()
  File "/.../restfulpy/restfulpy/db.py", line 20, in __enter__
    self.connection = self.engine.connect()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 2091, in connect
    return self._connection_cls(self, **kwargs)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 90, in __init__
    if connection is not None else engine.raw_connection()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 2177, in raw_connection
    self.pool.unique_connection, _connection)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 2151, in _wrap_pool_connect
    e, dialect, self)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1465, in _handle_dbapi_exception_noconnection
    exc_info
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 2147, in _wrap_pool_connect
    return fn()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 328, in unique_connection
    return _ConnectionFairy._checkout(self)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 766, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 516, in checkout
    rec = pool._do_get()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 1138, in _do_get
    self._dec_overflow()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
    raise value
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 1135, in _do_get
    return self._create_connection()
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 333, in _create_connection
    return _ConnectionRecord(self)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 461, in __init__
    self.__connect(first_connect_check=True)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/pool.py", line 651, in __connect
    connection = pool._invoke_creator(self)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/strategies.py", line 105, in connect
    return dialect.connect(*cargs, **cparams)
  File "/.../env/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 393, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/.../env/lib/python3.5/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
	Is the server running on host "localhost" (127.0.0.1) and accepting
	TCP/IP connections on port 5432?


----------------------------------------------------------------------
Ran 0 tests in 0.060s

FAILED (errors=1)

update_from_request method on boolean variables not work

For exp, when we want to change is_active value from webservice, update_from_request method parse value as string. Then when we reach to this method:

self.activated_at = (datetime.now() if v else None)

it will always set is_active True, because v is actually string instead of bool and the above condition is always True

refresh token,

SignatureExpircurl http://nc.carrene.com/apiv1/collections -H"Authorization: Bearer $T" -H"Cookie: refresh-token=$RT" -D-
HTTP/1.1 500 (<class 'itsdangerous.SignatureExpired'>, SignatureExpired('Signature expired',), <traceback object at 0x7fad2340e188>)
Server: nginx/1.10.0 (Ubuntu)
Date: Sun, 07 May 2017 10:45:40 GMT
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: http://localhost:8080
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, UNDELETE, METADATA, PATCH
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Expose-Headers: Content-Type, X-Pagination-Count, X-Pagination-Skip, X-Pagination-Take, X-New-JWT-Token
Access-Control-Allow-Credentials: true

Internal Server Error
Traceback (most recent call last):
  File "/home/dev/.virtualenvs/leo/lib/python3.5/site-packages/nanohttp/controllers.py", line 71, in _handle_request
    self._hook('begin_request')
  File "/home/dev/.virtualenvs/leo/lib/python3.5/site-packages/nanohttp/controllers.py", line 31, in _hook
    return getattr(self, name)(*args, **kwargs)
  File "/home/dev/.virtualenvs/leo/lib/python3.5/site-packages/restfulpy/controllers.py", line 34, in begin_request
    context.identity = new_token = self.refresh_jwt_token(refresh_token_encoded, session_id)
  File "/home/dev/workspace/leo/leo/controllers/root.py", line 39, in refresh_jwt_token
    return Member.refresh_jwt_token(refresh_token_encoded, session_id)
  File "/home/dev/workspace/leo/leo/models/membership.py", line 186, in refresh_jwt_token
    refresh_token = JwtRefreshToken.decode(refresh_token_encoded)
  File "/home/dev/.virtualenvs/leo/lib/python3.5/site-packages/restfulpy/principal.py", line 74, in decode
    payload = cls.create_serializer().loads(encoded)
  File "/home/dev/.virtualenvs/leo/lib/python3.5/site-packages/itsdangerous.py", line 807, in loads
    date_signed=self.get_issue_date(header))

Activation mixin still has problem with filtering query string

Still we have problem on this section:

        elif value == 'null':
            expression = column.is_(None)
        elif value == '!null':
            expression = column.isnot(None)
        elif value.startswith('!'):
            expression = column != import_value(column, value[1:])
        elif value.startswith('>='):
            expression = column >= import_value(column, value[2:])
        elif value.startswith('>'):
            expression = column > import_value(column, value[1:])
        elif value.startswith('<='):
            expression = column <= import_value(column, value[2:])
        elif value.startswith('<'):
            expression = column < import_value(column, value[1:])
        elif value.startswith('%~'):
            expression = column.ilike('%%%s%%' % import_value(column, value[2:]))
        elif value.startswith('%'):
            expression = column.like('%%%s%%' % import_value(column, value[1:]))
        else:
            expression = column == import_value(column, value)

because hybrid property operators don't make sqlalchemy query. For example this line always return False:
column == import_value(column, value)

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.