diff --git a/docs/changelog.rst b/docs/changelog.rst index c1e5e4c..45b9d11 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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 diff --git a/gnuviechadmin/gvawebcore/views.py b/gnuviechadmin/gvawebcore/views.py index 6e22e29..f6079bb 100644 --- a/gnuviechadmin/gvawebcore/views.py +++ b/gnuviechadmin/gvawebcore/views.py @@ -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