implement caching for get_hosting_package

This commit is contained in:
Jan Dittberner 2015-02-01 02:11:07 +01:00
parent 832a611602
commit 5e1f34c9d8
2 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,9 @@
Changelog
=========
* :support:`-` cache result of get_hosting_package method of
gvawebcore.views.HostingPackageAndCustomerMixin to improve page loading
performance
* :feature:`-` add ability to add, list and delete SSH public keys assigned to
a hosting package's operating system user and change their comments
* :feature:`-` add ability to add SSH public keys for operating system users

View File

@ -17,10 +17,14 @@ class HostingPackageAndCustomerMixin(object):
hosting_package_kwarg = 'package'
"""Keyword argument used to find the hosting package in the URL."""
hostingpackage = None
def get_hosting_package(self):
return get_object_or_404(
CustomerHostingPackage,
pk=int(self.kwargs[self.hosting_package_kwarg]))
if self.hostingpackage is None:
self.hostingpackage = get_object_or_404(
CustomerHostingPackage,
pk=int(self.kwargs[self.hosting_package_kwarg]))
return self.hostingpackage
def get_customer_object(self):
return self.get_hosting_package().customer