raddevon / flask-permissions Goto Github PK
View Code? Open in Web Editor NEWA simple permissions system for Flask
License: MIT License
A simple permissions system for Flask
License: MIT License
the sql is like this
I'm getting the following error on Python 3 (while the setup.py
file makes no claims about supported Python versions):
File "/Users/dinu/miniconda3/lib/python3.5/site-packages/flask_permissions/models.py", line 112, in __init__
if roles and isinstance(roles, basestring):
NameError: name 'basestring' is not defined
Is this still being developed?
I download this package by pip, the version is 0.2.3, error has occurred:
sqlalchemy.orm.exc.UnmappedColumnError: Can't execute sync rule for source column 'fp_user.id'; mapper 'Mapper|UserMixin|fp_user' does not map this column. Try using an explicit foreign_keys
collection which does not include destination column 'fp_user_role.user_id' (or use a viewonly=True relation).
how to solve this problem~
if I clone package from github,choose the newest version,error has occurred:
AttributeError: 'str' object has no attribute 'fget'
Hi,
I know the project is not really active but it remains a useful flask extension.
I struggled using the UserMixin class because Flask-Permissions on pip is outdated.
$ pip install Flask-Permissions
Pip installs a version dating from 2014-04-21.
However, the doc and the the last commit date from 2016-08-14, changing the behaviour of the UserMixin class. I could get around the problem by using:
$ pip install git+https://github.com/raddevon/flask-permissions.git
However it could help other users if you add a new version on Pypi.
Best,
Roch
I get this when I try to hit a protected page with an anonymous (not logged in) user.
Should maybe check roles in a try catch?
Please change strings 35 and 57 in decorators.py from return "You do not have access" to return "You do not have access", 403
Hi
I use UserMixin to create my User class:
class User(UserMixin):
email = db.Column(db.String(255), unique=True, nullable=False)
password = db.Column(db.String(255), nullable=False)
registered_on = db.Column(db.DateTime, nullable=False)
admin = db.Column(db.Boolean, nullable=False, default=False)
I can save data to the database but I can't fetch anything from database! I think the problem is on type part, when I check the query statement I can see this:
print(User.query)
SELECT fp_user.id AS fp_user_id, fp_user.type AS fp_user_type, fp_user.email AS fp_user_email, fp_user.password AS fp_user_password, fp_user.registered_on AS fp_user_registered_on, fp_user.admin AS fp_user_admin
FROM fp_user
WHERE fp_user.type IN (NULL)
and because of this where part nothing coming out from this query!
The user.add_abilities() method works just like role.add_abilities(). Pass in a string name or a series of string names. New roles will be created for you. Existing roles will simply be applied to the user. Don't forget to add and commit to the database!
user.add_abilities() should be user.add_roles()?
http://flask.pocoo.org/docs/0.12/patterns/appfactories/
Exception: Permissions app must be initialized before importing models
I've just cloned your repository and tried do run tests locally and they've failed. I've run build on travis and it also failed.
edit:
I found problem here:
user_role_table = make_user_role_table(self.__tablename__, self._id_column_name)
calling self._id_column_name
returns proxy object instead of column name (which is being found correctly).
I changed that line to
user_role_table = make_user_role_table(self.__tablename__, self._id_column_name.fget(self))
and build passes, but I am not sure if that fget()
can be here called with self
Hi, i'm trying to follow the steps but i'm getting a error when i try to add roles to user (UserMIxin instance) and i'm not sure how to put all together..
my_user = UserMixin()
my_user.add_roles('admin', 'superadmin')
db.session.add(my_user)
db.session.commit()
But when i create a normal user, i usually do
my_user = User(name="xxx", email="[email protected]", pass="1234")
db.session.add(my_user)
db.session.commit()
my model is like this:
class User(UserMixin):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False)
email = db.Column(db.String(50), nullable=False, unique=True)
password = db.Column(db.String(50), nullable=False)
def __init__(self, name, email, password, roles=None):
"""Setting params to the object."""
self.name = name
self.email = email.lower()
self.password = bcrypt.hashpw(
password.encode('utf-8'), bcrypt.gensalt())
UserMixin.__init__(self, roles)
.... other methods ...
any tips on how to do i right? :)
(im using @bepetersn fork)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.