Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Rene Jochum
    @pcdummy
    Yeah
    Marcin Lulek
    @ergo
    you CAN run tests on sqlite
    but without migrations
    just with in memory table creations
    Rene Jochum
    @pcdummy
    ahh good to know
    Marcin Lulek
    @ergo
    or you could in the past, i stopped testing it
    how the hell do you copy code in gitter :/
    Rene Jochum
    @pcdummy
    its markdown here
    code
    Marcin Lulek
    @ergo
    # -*- coding: utf-8 -*-
    from __future__ import absolute_import, unicode_literals
    
    import uuid
    
    import sqlalchemy as sa
    from pyramid.security import Allow, ALL_PERMISSIONS
    from sqlalchemy.dialects import postgresql
    from sqlalchemy.ext.hybrid import hybrid_property
    from ziggurat_cms.models.meta import Base
    from ziggurat_foundations.models.user import UserMixin
    
    
    class User(UserMixin, Base):
        __possible_permissions__ = [
            'root_administration', 'administration', 'admin_panel',
            'admin_users', 'admin_groups', 'admin_entries']
    
        # registration_ip = sa.Column(sa.Unicode())
    
        _public_user_name = sa.Column('public_user_name', sa.Unicode(128))
        _public_email = sa.Column('public_email', sa.Unicode(100))
    
        uuid = sa.Column('uuid', postgresql.UUID,
                         default=lambda x: str(uuid.uuid4()))
        tenant_pkey = sa.Column('tenant_pkey', sa.Integer,
                                sa.ForeignKey('resources.resource_id',
                                              onupdate='CASCADE',
                                              ondelete='CASCADE'))
        auth_tokens = sa.orm.relationship('AuthToken',
                                          cascade="all,delete-orphan",
                                          passive_deletes=True,
                                          passive_updates=True,
                                          backref='owner',
                                          order_by='AuthToken.pkey')
    
        resources = sa.orm.relationship(
            'Resource',
            cascade="all",
            passive_deletes=True,
            passive_updates=True,
            primaryjoin='users.c.id == resources.c.owner_user_id',
            backref='owner',
            lazy='dynamic')
    
        parent_resource = sa.orm.relationship(
            'Resource',
            passive_deletes=True,
            passive_updates=True,
            primaryjoin='users.c.tenant_pkey == resources.c.resource_id',
            backref='contains_users')
    
        def get_dict(self, exclude_keys=None, include_keys=None,
                     permission_info=False):
            if exclude_keys is None:
                exclude_keys = ['user_password', 'security_code',
                                'security_code_date']
    
            user_dict = super(User, self).get_dict(exclude_keys=exclude_keys,
                                                   include_keys=include_keys)
            return user_dict
    
        @hybrid_property
        def public_user_name(self):
            return self._public_user_name
    
        @public_user_name.setter
        def public_user_name(self, value):
            if not self.tenant_pkey:
                raise Exception('Tenant primary key is missing')
            self._public_user_name = value
            self.user_name = '{}:{}'.format(self.tenant_pkey, value)
    
        @hybrid_property
        def public_email(self):
            return self._public_email
    
        @public_email.setter
        def public_email(self, value):
            if not self.tenant_pkey:
                raise Exception('Tenant primary key is missing')
            self._public_email = value
            self.email = '{}:{}'.format(self.tenant_pkey, value)
    Rene Jochum
    @pcdummy
    three backticks
    Marcin Lulek
    @ergo
    ok, yeah im not testing sqlite anymore
    it doesnt make any sense really
    Rene Jochum
    @pcdummy
    Faster to setup tests than with creating a db/dropping it?
    Marcin Lulek
    @ergo
    travis runs them so I don't care :), but some queries failed in sqlite where they worked on mysql/pg
    no one will run zigg on sqlite since its doesnt support concurrent access in the first place
    Rene Jochum
    @pcdummy
    yes
    Marcin Lulek
    @ergo
    ok, I have to go, have a great evening
    Rene Jochum
    @pcdummy
    Thanks, cu
    Rene Jochum
    @pcdummy
    @ergo Think your schema switching idea, this is how i'll implement that.
    Daniel Dourvaris
    @dourvaris
    man i really like these foundations, strong, like marble
    Marcin Lulek
    @ergo
    @pcdummy new version of ziggurat with fixes is now released
    Marcin Lulek
    @ergo
    @pcdummy I've did more work on trunk, now removed all deprecated code from models, slowly preparing the 0.8 version
    Rene Jochum
    @pcdummy
    Great, i work on linting it:
    pylint --disable=all --enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode ziggurat_foundations/
    Rene Jochum
    @pcdummy
    Don't know howto fix that one:
    ************* Module ziggurat_foundations.models.services.resource_tree
    E: 11,28: Instance of 'ResourceTreeService' has no 'model' member (no-member)
    Marcin Lulek
    @ergo
    hmmmm
    my tests passed
    so something broke
    need to get some rest will look later
    Rene Jochum
    @pcdummy
    @ergo all checks passed on my PR :)
    Marcin Lulek
    @ergo
    @pcdummy thanks! I'm not quite sure why your linter required few of the changes :-) Like introduction of static props
    Rene Jochum
    @pcdummy
    @ergo it dislikes the usage of unknown properties as that introduces bugs. It found one: BaseService models_proxy vs. model_proxy
    Marcin Lulek
    @ergo
    Right, however, static property is something else than instance one.
    Rene Jochum
    @pcdummy
    True, how should a linter find instance ones?
    Fixing flake8 warnings atm.
    Marcin Lulek
    @ergo
    @pcdummy please dont break code like this
    users_permissions_pkey = insp.get_pk_constraint('users_permissions')[
    'name']
    @pcdummy the PR got quite big, its hard to review
    Marcin Lulek
    @ergo
    lets try to make changes smaller
    Marcin Lulek
    @ergo
    @pcdummy when you update the PR removing the changes I asked about I can try merging it in
    Marcin Lulek
    @ergo
    You did great job I think :-)
    Rene Jochum
    @pcdummy
    @ergo seems we have the same interests :) You also play with swagger, have a look at cornice and cornice_swagger!
    Rene Jochum
    @pcdummy
    @ergo Have you had a look at cornice?
    Marcin Lulek
    @ergo
    @pcdummy I actually have some patches merged in it ;-)
    Rene Jochum
    @pcdummy
    @ergo do you know cornice.ext.swagger aka cornice_swagger?
    It generates swagger.json for you :)
    Marcin Lulek
    @ergo
    cool
    Marcin Lulek
    @ergo
    @pcdummy In fact not long ago I commited support for marshmallow schemas to cornice :) Also a way to reuse pyramid views in services.
    Marcin Lulek
    @ergo
    I've released 0.8 zigg recently