← Back to team overview

launchpad-dev team mailing list archive

Re: [Branch ~launchpad-pqm/launchpad/devel] Rev 9762: [r=intellectronica][ui=none][bug=452070] Optimise

 

On Fri, Oct 23, 2009 at 10:13:14PM -0000, noreply@xxxxxxxxxxxxx wrote:
> Merge authors:
>   Muharem Hrnjadovic (al-maisan)
> Related merge proposals:
>   https://code.launchpad.net/~al-maisan/launchpad/clog-oops-452070/+merge/13789
>   proposed by: Muharem Hrnjadovic (al-maisan)
>   review: Approve - Tom Berger (intellectronica)
> ------------------------------------------------------------
> revno: 9762 [merge]
> committer: Launchpad Patch Queue Manager <launchpad@xxxxxxxxxxxxxxxxx>
> branch nick: launchpad
> timestamp: Fri 2009-10-23 23:09:49 +0100
> message:
>   [r=intellectronica][ui=none][bug=452070] Optimise
>   	<distro>/+source/<package>/+changelog pages in order to prevent OOPSs
> removed:
>   lib/lp/soyuz/templates/sourcepackagerelease-change-summary.pt
> modified:
>   lib/canonical/launchpad/webapp/tales.py
>   lib/lp/bugs/doc/bug.txt
>   lib/lp/bugs/interfaces/bug.py
>   lib/lp/bugs/model/bug.py
>   lib/lp/registry/browser/distributionsourcepackage.py
>   lib/lp/registry/configure.zcml
>   lib/lp/registry/doc/sourcepackage.txt
>   lib/lp/registry/model/distributionsourcepackage.py
>   lib/lp/soyuz/browser/configure.zcml
>   lib/lp/soyuz/browser/sourcepackagerelease.py
>   lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt
>   lib/lp/soyuz/templates/distributionsourcepackagerelease-changes.pt


> === modified file 'lib/lp/bugs/doc/bug.txt'
> --- lib/lp/bugs/doc/bug.txt	2009-07-08 03:14:59 +0000
> +++ lib/lp/bugs/doc/bug.txt	2009-10-22 15:39:19 +0000
> @@ -37,6 +37,34 @@
>        ...
>      NotFoundError: 'Unable to locate bug with nickname +bugs.'
>  
> +It is also possible to retrieve a number of bugs by specifying the bug numbers
> +of interest.
> +
> +    >>> result_set = bugset.getByNumbers([6, 1234])
> +    >>> print result_set.count()
> +    1

What's a bug number? Don't we usually talk about bug ids?

Also, it's highly confusing that you specify two ids/numbers, yet you
get only one result!


> +
> +    >>> [the_bug_found] = result_set
> +    >>> print the_bug_found.title
> +    Firefox crashes when Save As dialog for a nonexistent window is closed
> +
> +    >>> result_set = bugset.getByNumbers([6, 4321, 1])
> +    >>> print result_set.count()
> +    2

Again, you get one bug less then you asked for. Does it always return
one result less than you ask for?


> +
> +    >>> second_bug_found = result_set[1]

Where do the results get ordered? Are you guaranteed that you will get
this bug as the second result?


> +    >>> print second_bug_found.title
> +    Firefox does not support SVG

How about showing the actual ids of the bugs returned? It's quite hard
to associating a title with an id.


> === modified file 'lib/lp/bugs/model/bug.py'
> --- lib/lp/bugs/model/bug.py	2009-08-26 01:54:39 +0000
> +++ lib/lp/bugs/model/bug.py	2009-10-22 10:33:00 +0000
> @@ -33,7 +33,7 @@
>  from sqlobject import SQLMultipleJoin, SQLRelatedJoin
>  from sqlobject import SQLObjectNotFound
>  from storm.expr import And, Count, In, LeftJoin, Select, SQLRaw, Func
> -from storm.store import Store
> +from storm.store import EmptyResultSet, Store
>  
>  from lazr.lifecycle.event import (
>      ObjectCreatedEvent, ObjectDeletedEvent, ObjectModifiedEvent)
> @@ -49,6 +49,7 @@
>  from canonical.launchpad.interfaces.hwdb import IHWSubmissionBugSet
>  from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
>  from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
> +from canonical.launchpad.interfaces.lpstorm import IStore
>  from canonical.launchpad.interfaces.message import (
>      IMessage, IndexedMessage)
>  from canonical.launchpad.interfaces.structuralsubscription import (
> @@ -1627,6 +1628,14 @@
>  
>          return bugs
>  
> +    def getByNumbers(self, bug_numbers):
> +        """see `IBugSet`."""
> +        if bug_numbers is None or len(bug_numbers) < 1:

Can len(bug_numbers) ever be less than 0?


> +            return EmptyResultSet()
> +        store = IStore(Bug)
> +        result_set = store.find(Bug, In(Bug.id, bug_numbers))
> +        return result_set
> +
>  
>  class BugAffectsPerson(SQLBase):
>      """A bug is marked as affecting a user."""


> === modified file 'lib/lp/registry/model/distributionsourcepackage.py'
> --- lib/lp/registry/model/distributionsourcepackage.py	2009-09-16 04:31:39 +0000
> +++ lib/lp/registry/model/distributionsourcepackage.py	2009-10-22 15:04:42 +0000
> @@ -408,6 +412,23 @@
>              'BugTask.distribution = %s AND BugTask.sourcepackagename = %s' %
>                  sqlvalues(self.distribution, self.sourcepackagename))
>  
> +    @staticmethod
> +    def getPersonsByEmail(email_addresses):
> +        """[(EmailAddress,Person), ..] iterable for given email addresses."""
> +        if email_addresses is None or len(email_addresses) < 1:
> +            return EmptyResultSet()
> +        # Perform basic sanitization of email addresses.
> +        email_addresses = [
> +            address.lower().strip() for address in email_addresses]
> +        store = IStore(Person)
> +        origin = [
> +            Person, Join(EmailAddress, EmailAddress.personID == Person.id)]
> +        # Get all persons whose email addresses are in the list.
> +        result_set = store.using(*origin).find(
> +            (EmailAddress, Person),
> +            In(Lower(EmailAddress.email), email_addresses))
> +        return result_set

Why is getPersonsByEmail a static method on DistributionSourcePackage???
What does it have to do with source packages? Why is it not in
PersonSet?

Where are the tests for this method?


-- 
Björn Tillenius | https://launchpad.net/~bjornt



Follow ups