Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8655001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:55:31+00:00 2026-06-12T14:55:31+00:00

I have tables in DB with the same interface for view and edit them

  • 0

I have tables in DB with the same interface for view and edit them with Pyramid app. For example:

Example of route for view record of report table: /birdreport/report/871;

Example of route for edit record of report table: /birdreport/report/871/edit;

Each record of report table has field which contains user_id – this value is the same as returned by authenticated_userid function. It is clear for me how I can disable acces to edit by adding permission to view. But how I can enable access to edit view only for those users which userid presents in corresponding record?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:55:32+00:00Added an answer on June 12, 2026 at 2:55 pm

    You can use the Pyramid authorization policy by defining __acl__() inside your Report model. For example:

    from sqlalchemy.orm import relationship, backref
    from pyramid.security import Everyone, Allow
    
    class Report(Base):
        # ...
        user_id = Column(Integer, ForeignKey('user.id'))
        # ...
    
    
        @property
        def __acl__(self):
            return [
                (Allow, Everyone, 'view'),
                (Allow, self.user_id, 'edit'),
            ]
    
        # this also works:
        #__acl__ = [
        #    (Allow, Everyone, 'view'),
        #    (Allow, self.user_id, 'edit'),
        #]
    
    class User(Base):
        # ...
        reports = relationship('Report', backref='user')
    

    The __acl__() above will allow everyone to call your view view, but only the user related to Report to edit it.


    It’s likely that you haven’t had authentication policy or authorization policy enabled, to quote the documentation:

    Use the set_authorization_policy() method of the Configurator to enable an authorization policy.

    You must also enable an authentication policy in order to enable the authorization policy. This is because authorization, in general, depends upon authentication. Use the set_authentication_policy() and method during application setup to specify the authentication policy.

    from pyramid.config import Configurator
    from pyramid.authentication import AuthTktAuthenticationPolicy
    from pyramid.authorization import ACLAuthorizationPolicy
    authentication_policy = AuthTktAuthenticationPolicy('seekrit')
    authorization_policy = ACLAuthorizationPolicy()
    config = Configurator()
    config.set_authentication_policy(authentication_policy)
    config.set_authorization_policy(authorization_policy)
    

    The above configuration enables a policy which compares the value of an “auth ticket” cookie passed in the request’s environment which contains a reference to a single principal against the principals present in any ACL found in the resource tree when attempting to call some view.

    While it is possible to mix and match different authentication and authorization policies, it is an error to configure a Pyramid application with an authentication policy but without the authorization policy or vice versa. If you do this, you’ll receive an error at application startup time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables with exactly the same fields. Table A contains 7160 records
I have three mysql table from same database Db1. Three tables have following columns.
I have a basic view that returns the same columns as a table (give
I have two tables with same structure **t1** +------+------+ | code | vid |
I have two tables with the same structure: id name 1 Merry 2 Mike
In the database we have tables called Sites, Organisations, Person, Department have the same
I have 2 databases with same tables. DBProduction and DBLocal both have testTable. How
i have two data tables with the same structure the first one has one
I have 2 tables that I am working with that use the same column;
I will have multiple tables used by different projects on the same mySql server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.