Merge lp:~sinzui/launchpad/listify-cached-licences into lp:launchpad
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Curtis Hovey | ||||||||
Approved revision: | no longer in the source branch. | ||||||||
Merged at revision: | 14797 | ||||||||
Proposed branch: | lp:~sinzui/launchpad/listify-cached-licences | ||||||||
Merge into: | lp:launchpad | ||||||||
Diff against target: |
286 lines (+164/-24) 5 files modified
lib/lp/registry/browser/person.py (+21/-6) lib/lp/registry/browser/tests/test_commercialsubscription.py (+96/-3) lib/lp/registry/tests/test_commercialprojects_vocabularies.py (+21/-6) lib/lp/registry/vocabularies.py (+10/-9) lib/lp/testing/__init__.py (+16/-0) |
||||||||
To merge this branch: | bzr merge lp:~sinzui/launchpad/listify-cached-licences | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
j.c.sackett (community) | Approve | ||
Review via email: mp+92893@code.launchpad.net |
Description of the change
Listify the precached commercial licenses.
Launchpad bug: https:/
Pre-
+voucher has always had a performance problem because the saleforce
voucher data is slow to collect, the data is cached. When a voucher is
applied to add the commercial subscription to the projects, the view
issues a next_url signal to itself to reload the data cached by
setUpFields and SetUpWidgets. This breaks because I switched the
Commercial Admin query (not the query used by most users) to use
productset.search which is fast and has cached goodness. next_url is in
conflict with the model cache which does not want to reload the object.
Module zope.app.
term = self.vocabulary
Module lp.registry.
for search_result in search_results:
Module lp.services.
self.pre_
Module lp.registry.
cache._
AttributeError: 'tuple' object has no attribute 'append'
-------
RULES
* The cache issue was caused more by the vocabulary than by the
view. The view calls the vocabulary multiple times during field and
widget setup. getTermByToken() performs a search of search
was previously called during a iter operation. Search is not needed
in the case of for commercial admins...the token must be an active
project name and that is faster to lookup that doing another
search.
* Do not search for tokens when the user is a commercial_admin. We
only care if the token is for an active project.
* Avoid setting next_url. Setup the fields and widgets again
without the redeemed voucher.
QA
* As a commercial admin, apply a voucher on qastaging for any project
LINT
lib/
lib/
lib/
lib/
lib/
TEST
./bin/test -vvc -t test_commercial -t voucher lp.registry
^ This also runs xx-voucher-
identifing identify the need to regregister the current utility.
IMPLEMENTATION
Update getTermByToken() to just get the product for the token. Removed
a function that obsucured the number of calls to _do_search(). This subtle
change allowed me to redeem vouchers.
lib/
lib/
I did not need to do this set of changes to unblock my work as a
commercial admin. I see timeouts that I was certain I could fix by
removing the redeemed voucher from the view's cache instead of reloading
the whole view. This was not as simple as I thought it would be because
The fields and wdigets needed to be setup again *without* the submitted
form. I also changed redeemable_vouchers to guarantee a list since the
value could be None or just a voucher. I updated the FakeAdapterMixin
with a help that lets me register a test utility.
lib/
lib/
lib/
Curtis--
This looks good. I have a few little concerns in the diff below, but they're not blockers to approval. I would like to see them address before landing, though.
> === modified file 'lib/lp/ registry/ browser/ person. py' registry/ browser/ person. py 2012-02-11 04:45:42 +0000 registry/ browser/ person. py 2012-02-14 00:55:20 +0000 vouchers( self): getRedeemableCo mmercialSubscri ptionVouchers( ) getRedeemableCo mmercialSubscri ptionVouchers( )] eVouchers( self, voucher): cache(self) .redeemable_ vouchers remove( voucher) ectField( ) + self.createVouc herField( )) fields. select( 'project' , 'voucher'), initial_ values, ignore_ request= True)
> --- lib/lp/
> +++ lib/lp/
> @@ -2139,10 +2141,27 @@
>
> @cachedproperty
> def redeemable_
> - """Get the redeemable vouchers owned by the user."""
> - vouchers = self.context.
> + """Get the list redeemable vouchers owned by the user."""
> + vouchers = [
> + voucher for voucher in
> + self.context.
> return vouchers
>
> + def updateRedeemabl
> + """Remove the voucher from the cached list of redeemable vouchers.
> +
> + Updated the voucher field and widget so that the form can be reused.
> + """
> + vouchers = get_property_
> + vouchers.
> + # Setup the fields and widgets again, but withut the submitted data.
> + self.form_fields = (
> + self.createProj
> + self.widgets = form.setUpWidgets(
> + self.form_
> + self.prefix, self.context, self.request,
> + data=self.
This is, at heart, a nitpick. Feel free to ignore it if you disagree. It leVouchers" when the update is a secondary eVoucher, and note that the update occurs to keep
seems a little weird to name it "updateRedeemab
effect of removing the voucher to keep the form working. Could we just
call this removeRedeemabl
things in sync?
> @cachedproperty projects( self): emableVouchers( voucher) erProxyExceptio n, error:
> def has_commercial_
> """Does the user manage one or more commercial project?
> @@ -2181,7 +2200,8 @@
> # Force the page to reload so the just consumed voucher is
> # not displayed again (since the field has already been
> # created).
> - self.next_url = self.request.URL
> + self.updateRede
> + #self.next_url = self.request.URL
> except SalesforceVouch
> self.addError(
> _("The voucher could not be redeemed at this time."))
If we're commenting this line out, shouldn't we just delete it?
> === modified file 'lib/lp/ registry/ browser/ tests/test_ commercialsubsc ription. py' registry/ browser/ tests/test_ commercialsubsc ription. py 2012-02-09 18:49:14 +0000 registry/ browser/ tests/test_ commercialsubsc ription. py 2012-02-14 00:55:20 +0000 salesforce. interfaces import ISalesforceVouc herProxy salesforce. tests.proxy import TestSalesforceV oucherProxy webapp. publisher import canonical_url
> --- lib/lp/
> +++ lib/lp/
> @@ -5,20 +5,113 @@
>
> __metaclass__ = type
>
> +from lp.services.
> +from lp.services.
> from lp.services.
> -from lp.testing import TestCaseWithFactory
> +from lp.te...