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 3597880
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:10:25+00:00 2026-05-18T20:10:25+00:00

I am doing agressive caching and I’d like to make sure that nobody accidentally

  • 0

I am doing agressive caching and I’d like to make sure that nobody accidentally writes code that updates the database directly. I would imagine that the way to solve this would be to rename the normal object manager .rw_objects for the caches use, and replace .objects with a manager that logs a warning on a non-updating access and throws an exception if someone tries to do an update from it.

I’ve written an object manager and a query set but I’m not sure how to go about checking whether a query is updating the database.

Any suggestions?

  • 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-05-18T20:10:26+00:00Added an answer on May 18, 2026 at 8:10 pm

    I’m thinking about two approaches here.

    1. Create a custom Manager, override _insert(), _update() to raise exception / log the query, and get_query_set() to return custom QuerySet that overrides create(), get_or_create(), and update().

    2. If you’re using django 1.2, Create another database connection in settings.py call it "READ_ONLY", and create a custom manager that returns QuerSet using that connection (like def get_query_set() return super(ReadOnlyManager, self).get_query_set().using("READ_ONLY"), and mark the connection read-only. (One way to do it is create read-only user for the database connection "READ_ONLY"…. If you’re using Postgres, you can do stuff like How do you create a read-only user in PostgreSQL?)

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

Sidebar

Related Questions

I am doing agressive caching and I'd like to make sure that nobody accidentally
Doing some code reviews lately I came across a number of classes that have
Im doing something like this to get a list of all users that have
Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing my first tryouts with foreign keys in a mySQL database and are trying
Doing code analysis of the project and get the message Reference-counted object is used
Doing a simple Squeryl database lookup, but trying to exclude a value. I've tried:
Doing a code review I've stumbled over GWM in Java-Spring-GWT web-application. As this product
Doing some refactoring in some legacy code I've found in a project. This is
Doing a simple query I'm finding two very different results, and I'm not sure

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.