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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:06:23+00:00 2026-05-24T12:06:23+00:00

I have a legacy application which is (currently) using Django to effectively display data.

  • 0

I have a legacy application which is (currently) using Django to effectively display data. A sample of one of my working tests looks like this.

def test_add_property_value(self):
    """Test set / get a value"""
    # This will do some external process which occcurs to the db.
    pm = Pm(mysql_db='test_bugs')
    tree =  pm.add_release_tree()
    prop_type, pmvalue = ("string", "Funny Business")
    pmproperty = "%s_%s_basic" % (tree[0].name, prop_type)
    pm.add_property_definition(pmproperty, prop_type=prop_type)
    pm.add_propval(pmproperty, value=pmvalue, project=tree[0].name)

    # Now use Django to pull the value back out..
    project = Project.objects.get(name=tree[0].name)
    property = project.get_property(pmproperty) # Custom query using sql.raw
    self.assertEqual(pmvalue, property.value)

As you can see it’s basic A/B Testing. Now I’ve found a limitations and I can’t seem to get around in that multiple external add – check – loop queries are failing. Modifying the above code fails because it appears query is failing to even run.

def test_add_property_value(self):
    """Test set / get a value"""

    # This will do some external process which occcurs to the db.
    pm = Pm(mysql_db='test_bugs', p4_port = settings.ICMSERVER_TEST_PORT)
    tree = pm.add_release_tree()
    prop_type, pmvalue = ("string", "Funny Business")
    pmproperty = "%s_%s_basic" % (tree[1].name, prop_type)
    pm.add_property_definition(pmproperty, prop_type=prop_type)
    pm.add_propval(pmproperty, value=pmvalue, project=tree[1].name)

    # Now use Django to pull the value back out..
    project = Project.objects.get(name=tree[1].name)
    property = project.get_property(pmproperty)
    self.assertEqual(pmvalue, property.value)

    # ONLY CHANGE WAS TO ADD THIS..

    # This will do some external process which occcurs to the db.
    pmproperty = "%s_%s_basic_two" % (tree[1].name, prop_type)
    pm.add_property_definition(pmproperty, prop_type=prop_type)
    pm.add_propval(pmproperty, value=pmvalue, project=tree[1].name)

    # Now use Django to pull the value back out..
    project = Project.objects.get(name=tree[1].name)
    property = project.get_property(pmproperty)
    self.assertEqual(pmvalue, property.value)

I’ve read about the CACHE_BACKEND but that didn’t seem to help. Any other ideas?? After further investigation this appears to not be related to my external db at all. Arghh.. It feels like monday!

  1. Is this a cache problem BTW – Setting CACHE_BACKEND = ‘dummy:///’ or ‘locmem:///’ did nothing.
  2. How do I better diagnosis this problem??

Thanks

Update

Here was the final answer – 2 small tweaks.. Based on Daniel and Severio. Much appreciated the pointers!!

class PropertyTests(TransactionTestCase):  #CHANGE1
    def test_add_property_value(self):
        """Test set / get a value"""

        import logging
        l = logging.getLogger('django.db.backends')
        l.setLevel(logging.DEBUG)
        l.addHandler(logging.StreamHandler())

        # This will do some external process which occcurs to the db.
        pm = Pm(mysql_db='test_bugs', p4_port = settings.ICMSERVER_TEST_PORT)
        tree = pm.add_release_tree()
        prop_type, pmvalue = ("string", "Funny Business")
        pmproperty = "%s_%s_basic" % (tree[1].name, prop_type)
        pm.add_property_definition(pmproperty, prop_type=prop_type)
        pm.add_propval(pmproperty, value=pmvalue, project=tree[1].name)

        # Now use Django to pull the value back out..
        project = Project.objects.get(name=tree[1].name)
        property = project.get_property(pmproperty)
        self.assertEqual(pmvalue, property.value)

        # This will do some external process which occcurs to the db.
        pmproperty = "%s_%s_basic_two" % (tree[1].name, prop_type)
        pm.add_property_definition(pmproperty, prop_type=prop_type)
        pm.add_propval(pmproperty, value=pmvalue, project=tree[1].name)

        # Now use Django to pull the value back out..
        Project.objects.update() #CHANGE2
        project = Project.objects.get(name=tree[1].name)
        property = project.get_property(pmproperty)
        self.assertEqual(pmvalue, property.value)
  • 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-24T12:06:25+00:00Added an answer on May 24, 2026 at 12:06 pm

    That’s probably not a transaction issue. The Manager (Project.objects) needs to be informed of a data change, because it’s designed to live for a short period of time.

    You are querying twice the same query Project.objects.get(name=tree[1].name) and the manager won’t execute it again, because it thinks it has already the correct data.

    Just before the second query, do

    Project.objects.update()
    

    to invalidate the manager cache. The results after the invalidation should be up to date.

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

Sidebar

Related Questions

No related questions found

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.