Comments (8)
Thanks for the kind words, @bepetersn! I'm glad flask-permissions is helpful to you.
class User(UserLoginMixin, UserPermissionMixin, db.Model):
I noticed this in your traceroute. This is just a hunch, but I wonder if sub-classing your db.Model
with your User class could be the problem since Flask-Permission's UserMixin
already inherits from that same class.
If you want to post your implementation somewhere, I'll play with it locally and see what I can figure out. If you just want to post a Gist instead, I'll look it over and see if I can find anything. You're also welcome to take a look at the full project the example in the documentation is pulled from. The additional context might be helpful.
from flask-permissions.
That's interesting, I hadn't considered that, but it makes sense that I shouldn't use both db.Model and your UserMixin. After dropping db.Model, I still get the NoForeignKeys error though, unless I do one of the two things above (I think now that the second one may be the wrong solution).
I will get back to you some more a bit later, and maybe take a look at your project.
from flask-permissions.
Definitely. I'd be curious to know what the UserLoginMixin
is that you're inheriting from. I assumed UserPermissionMixin
is Flask-Permissions' UserMixin
. I wonder if the __mapper_args__
are being clobbered by that inheritance.
from flask-permissions.
It's Flask-Login's (see https://flask-login.readthedocs.org/en/latest) UserMixin object. Same name as your mixin, so I switched to using the from x import y as z
syntax to import both of them. I checked their source code, it doesn't inherit from Model, it just adds methods to related to stuff like session management.
from flask-permissions.
Any progress on this, @bepetersn? If not, I'm happy to see if anything in your code jumps out at me if you have it up or would like to make it available somewhere. Can't make any promises, but I'm hoping I might be able to see something that would lead us to the issue.
Not trying to rush you, but I'm making sure you're not waiting on me. 😄
from flask-permissions.
Hey, so much later, I tried to throw together an example of this without making any assumptions, and still ended up getting this error: sqlalchemy.exc.NoForeignKeysError: Can't find any foreign key relationships between 'fp_user' and 'users'.
Here's a repo, if you find time to point me in the right direction: https://github.com/bepetersn/flask-permissions-ex
from flask-permissions.
@bepetersn I haven't touched this in a while, but I believe your problem is because you change the table for your user class (see https://github.com/bepetersn/flask-permissions-ex/blob/master/ex/database.py#L21). I think that's breaking the relationships the extension needs.
from flask-permissions.
Hi @raddevon, thanks for your reply. I realized that my example was slightly different from yours. I not only included the __tablename__
, but also a primary key id
. With either one I got the same error mentioned above, but removing both fixed it.
I didn't understand before that that the user table was being defined by you as fp_user
and mine was inheriting from it using Joined Table Inheritance. After I figured that out, things got easier. Thanks!
from flask-permissions.
Related Issues (13)
- hi how to delete user?
- No Python 3 supported HOT 3
- query problem HOT 2
- Problem with creating make_user_role_table
- Doesn't work with app factories HOT 4
- sqlalchemy.orm.exc.UnmappedColumnError HOT 1
- Outdated pip version
- return 403 code from decorators HOT 1
- Add tests for errors when user does not have permission HOT 1
- Possible typo in readme HOT 1
- AttributeError: 'AnonymousUserMixin' object has no attribute 'roles' HOT 2
- AttributeError: 'str' object has no attribute 'roles' HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-permissions.