Comments (1)
Closing as I no longer believe that the below code (partial) is a significant improvement over the above, and the performance penalty of loading identity per request doesn't seem worth it. I'd rather add a utility method on the User and/or Experiment models.
@app.route('/posts/<post_id>', methods=['PUT', 'PATCH'])
def edit_post(post_id):
permission = EditBlogPostPermission(post_id)
if permission.can():
# Save the edits ...
return render_template('edit_post.html')
abort(403) # HTTP Forbidden
Per request!
@identity_loaded.connect_via(app)
def on_identity_loaded(sender, identity):
# Set the identity user object
identity.user = current_user
# Add the UserNeed to the identity
if hasattr(current_user, 'id'):
identity.provides.add(UserNeed(current_user.id))
# Assuming the User model has a list of roles, update the
# identity with the roles that the user provides
if hasattr(current_user, 'roles'):
for role in current_user.roles:
identity.provides.add(RoleNeed(role.name))
# Assuming the User model has a list of posts the user
# has authored, add the needs to the identity
if hasattr(current_user, 'posts'):
for post in current_user.posts:
identity.provides.add(EditBlogPostNeed(unicode(post.id)))
from ctesi.
Related Issues (20)
- Create separate celery queues
- Do not error out experiment if email notification fails to send. HOT 1
- Difficulty downloading large datasets HOT 1
- tmp folder not getting cleared can cause issues
- Retry retrieving of dta-select following ip2 job finish
- Respect user choices for ip2 login memory and email notifications
- Propagate experiment deletion to ip2
- Verify that experiments with the same name can be resolved
- Do not refresh status page if it is currently not in view
- ip2 credentials sometimes go stale transparently
- Do not auth against AD unless local auth fails HOT 1
- Experiments start getting processed even if uploads fail
- Status page sometimes loads empty
- Individual file uploads should go green as they return successfully
- Check how 403 Unauthorized responses are handled throughout the app
- Allow retry for individual file uploads
- Do not allow multiple submits of the same experiment
- Database lock error when updating experiment status
- Conversion to mzXML sometimes fails partially
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 ctesi.