~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/doc/archivesubscriber.txt

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-15 13:35:36 UTC
  • mfrom: (13677.4.4 bug-690568)
  • Revision ID: launchpad@pqm.canonical.com-20110815133536-7oj1019k90cedwqs
[r=henninge][bug=690568] Fetch email addresses for potential PPA
        subscribers all in one query.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
= ArchiveSubscriber =
 
1
ArchiveSubscriber
 
2
=================
2
3
 
3
4
This content class represents a subscription by a person to an IArchive.
4
5
The subscription represents that person's ability to download items from
32
33
    >>> from lp.testing.mail_helpers import print_emails
33
34
 
34
35
 
35
 
== Creating new subscriptions ==
 
36
Creating new subscriptions
 
37
--------------------------
36
38
 
37
39
New subscriptions are created using IArchive.newSubscription()
38
40
 
229
231
    >>> from storm.store import Store
230
232
    >>> Store.of(new_sub).commit()
231
233
 
232
 
== Retrieving existing subscriptions ==
 
234
Retrieving existing subscriptions
 
235
---------------------------------
233
236
 
234
237
The ArchiveSubscriberSet utility allows you to retrieve subscriptions by
235
238
subscriber and archive.  To access subscriptions you need launchpad.View
323
326
 
324
327
First create a token for joesmith's subscription for cprov's archive:
325
328
 
326
 
    >>> joesmith_token = cprov_private_ppa.newAuthToken(joesmith, u"test_token")
 
329
    >>> joesmith_token = cprov_private_ppa.newAuthToken(
 
330
    ...     joesmith, u"test_token")
327
331
 
328
332
Now print out all subscriptions with their tokens for joesmith:
329
333
 
369
373
    PPA named p3a for Mark Shuttleworth          None
370
374
 
371
375
 
372
 
== Amending Subscriptions ==
 
376
Amending Subscriptions
 
377
----------------------
373
378
 
374
379
Some of the properties of subscriptions can change after they are created.
375
380
To do this, the changer needs to have launchpad.Edit on the subscription,
408
413
    ForbiddenAttribute:...
409
414
 
410
415
 
411
 
== Cancelling subscriptions ==
 
416
Cancelling subscriptions
 
417
------------------------
412
418
 
413
419
Subscriptions can only be cancelled after they are created.  The calling user
414
420
also needs launchpad.Edit on the subscription, which means either someone with
442
448
    >>> new_sub.cancel(cprov)
443
449
 
444
450
 
445
 
== Finding all non-active subscribers ==
 
451
Finding all non-active subscribers
 
452
----------------------------------
446
453
 
447
454
The method getNonActiveSubscribers() facilitates contacting all the people
448
455
included in this subscription who do not yet have an active token for the
461
468
So the getNonActiveSubscribers() method for this team subscription will
462
469
currently include Joe:
463
470
 
464
 
    >>> for person in subscription.getNonActiveSubscribers():
465
 
    ...     print person.displayname
466
 
    Celso Providelo
467
 
    Joe Smith
468
 
    John Smith
 
471
    >>> for person, email in subscription.getNonActiveSubscribers():
 
472
    ...     print person.displayname, email.email
 
473
    Celso Providelo   celso.providelo@canonical.com
 
474
    Joe Smith         joe@example.com
 
475
    John Smith        john@example.com
469
476
 
470
477
But if we create an auth token for joe to the archive (this could be via
471
478
a separate subscription), then he will no longer be listed as a non-active
472
479
subscriber for this subscription:
473
480
 
474
481
    >>> joesmith_token = mark_private_ppa.newAuthToken(joesmith)
475
 
    >>> for person in subscription.getNonActiveSubscribers():
 
482
    >>> for person, email in subscription.getNonActiveSubscribers():
476
483
    ...     print person.displayname
477
484
    Celso Providelo
478
485
    John Smith
487
494
    ...                                 email="harry@example.com")
488
495
    >>> subscription = mark_private_ppa.newSubscription(
489
496
    ...     harrysmith, mark, description=u"subscription for joesmith")
490
 
    >>> for person in subscription.getNonActiveSubscribers():
 
497
    >>> for person, email in subscription.getNonActiveSubscribers():
491
498
    ...     print person.displayname
492
499
    Harry Smith
493
500
 
507
514
    ...     team_cprov, mark, force_team_add=True)
508
515
    >>> subscription = mark_private_ppa.newSubscription(
509
516
    ...     launchpad_devs, mark, description=u"LP team too")
510
 
    >>> for person in subscription.getNonActiveSubscribers():
 
517
    >>> for person, email in subscription.getNonActiveSubscribers():
511
518
    ...     print person.displayname
512
519
    Celso Providelo
513
520
    John Smith