Commits

Łukasz Fidosz committed 1315ef7

fixed all sqlalchemy unicode warnings

  • Participants
  • Parent commits d69883b

Comments (0)

Files changed (2)

File ziggurat_foundations/models.py

         """ returns all non-resource permissions based on what groups user
             belongs and directly set ones for this user"""
         db_session = get_db_session(None, self)
-        q = db_session.query(('group:' + self.GroupPermission.group_name).label('owner_name'),
+        q = db_session.query((u'group:' + self.GroupPermission.group_name).label('owner_name'),
                              self.GroupPermission.perm_name.label('perm_name'))
         q = q.filter(self.GroupPermission.group_name == self.UserGroup.group_name)
         q = q.filter(self.User.user_name == self.UserGroup.user_name)
         """ returns all permissions that given user has for this resource
             from groups and directly set ones too"""
         db_session = get_db_session(db_session, self)
-        q = db_session.query('group:' + self.GroupResourcePermission.group_name,
+        q = db_session.query(u'group:' + self.GroupResourcePermission.group_name,
                              self.GroupResourcePermission.perm_name)
         q = q.filter(self.GroupResourcePermission.group_name.in_(
                                         [gr.group_name for gr in user.groups]
         """ returns permissions that given user has for this resource
             that are inherited from groups """        
         db_session = get_db_session(db_session, self)
-        q = db_session.query('group:' + self.GroupResourcePermission.group_name,
+        q = db_session.query(u'group:' + self.GroupResourcePermission.group_name,
                              self.GroupResourcePermission.perm_name)
         q = q.filter(self.GroupResourcePermission.group_name.in_(
                                     [gr.group_name for gr in user.groups]

File ziggurat_foundations/tests.py

     pass
 
 class TestResource(Resource):
-    __mapper_args__ = {'polymorphic_identity': 'test_resource'}
+    __mapper_args__ = {'polymorphic_identity': u'test_resource'}
 
 class UserPermission(UserPermissionMixin, Base):
     pass
     
     def __set_up_user_group_and_perms(self):
         created_user = self._addUser()
-        created_user2 = self._addUser(user_name='foouser',email='new_email')
-        created_user3 = self._addUser(user_name='foouser2',email='new_email2')
-        created_user4 = self._addUser(user_name='foouser3',email='new_email3')
+        created_user2 = self._addUser(user_name=u'foouser',email=u'new_email')
+        created_user3 = self._addUser(user_name=u'foouser2',email=u'new_email2')
+        created_user4 = self._addUser(user_name=u'foouser3',email=u'new_email3')
         resource = self._addResource(1, u'test_resource')
         group = self._addGroup()
-        group2 = self._addGroup(group_name='group2')
+        group2 = self._addGroup(group_name=u'group2')
         group.users.append(created_user)
         group2.users.append(created_user4)
         group_permission = GroupResourcePermission(
     def test_users_for_perm(self):
         self.__set_up_user_group_and_perms()
         self.assertEqual(
-                sorted(self.resource.users_for_perm('foo_perm',
+                sorted(self.resource.users_for_perm(u'foo_perm',
                                                     db_session=self.session)),
                 sorted([(self.user, u'foo_perm',),(self.user2, u'foo_perm',)])
                         )