This works and matches the pattern of def app_config() but since this method will be called frequently (every nbhd root request), I think we should change it to use self.app_configs which is a list that is already loaded into memory.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
--- a/Allura/allura/model/project.py+++ b/Allura/allura/model/project.py@@ -515,9 +515,9 @@ def app_config(self, mount_point): 'options.mount_point':mount_point}).first()
def app_config_by_tool_type(self, tool_type):
- return AppConfig.query.find({- 'project_id': self._id,- 'tool_name': tool_type}).first()+ for ac in self.app_configs:+ if ac.tool_name == tool_type:+ return ac
but got failed test:
======================================================================ERROR:allura.tests.test_commands.test_update_neighborhood----------------------------------------------------------------------Traceback(mostrecentcalllast):File"/var/tmp/buildenv/1a26a3f8009f89f489415fb1c0b257ece5282961/lib/python2.7/site-packages/nose/case.py",line197,inrunTestself.test(*self.arg)File"/home/deploy/buildbot/slave2/full/build/Allura/allura/tests/test_commands.py",line124,intest_update_neighborhoodcmd.command()File"/home/deploy/buildbot/slave2/full/build/Allura/allura/command/create_neighborhood.py",line69,incommandp.install_app('home','home','Home',ordinal=0)File"/home/deploy/buildbot/slave2/full/build/Allura/allura/model/project.py",line472,ininstall_app'Mount point "%s" is already in use'%mount_point)ToolError:Mountpoint"home"isalreadyinuse
After some debugging I found out that results of self.app_configs and querying the database directly differs:
I've encountered the same issue once before. I wish install_app() would refresh the app_configs list, but I don't think there is a way to do that, and its possible to work around it fairly well.
There were two parts of the problem:
In the test, cmd.run() runs the command, and cmd.command() is unnecessary. It runs it again.
If you close the session after the command is run, and before checking the result, then the Project object is queried anew, so it gets the latest values for everything.
I went ahead and committed [58e0e2] using your changes, plus those 2 fixes. I've pushed it on dev, so you can look at it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This will have the affect of avoiding project queries in the 2nd half of the nbhd index() method.
created #95: [#4457] Fix has_home_tool() implementation (1cp)
Related
Tickets:
#4457closed #95 and pushed changes into 42cc_4457
This works and matches the pattern of
def app_config()but since this method will be called frequently (every nbhd root request), I think we should change it to useself.app_configswhich is a list that is already loaded into memory.created #107: [#4457] Use self.app_configs instead of quering database each time (1cp)
Related
Tickets:
#4457I made the following changes:
but got failed test:
After some debugging I found out that results of
self.app_configsand querying the database directly differs:Seems like
self.app_configscontains cached result, but I can't find a way to update it properly.Could you point me in the right direction?
I've encountered the same issue once before. I wish install_app() would refresh the app_configs list, but I don't think there is a way to do that, and its possible to work around it fairly well.
There were two parts of the problem:
cmd.run()runs the command, andcmd.command()is unnecessary. It runs it again.I went ahead and committed [58e0e2] using your changes, plus those 2 fixes. I've pushed it on dev, so you can look at it.