Diff for "AddingLaunchpadCelebrity"

Not logged in - Log In / Register

Differences between revisions 4 and 5
Revision 4 as of 2009-08-04 09:51:32
Size: 2301
Editor: jml
Comment:
Revision 5 as of 2009-08-04 10:59:44
Size: 3907
Editor: jml
Comment:
Deletions are marked like this. Additions are marked like this.
Line 24: Line 24:
The safest way to add the Person or Team to sampledata is by using the `IPersonSet` API: The safest way to add the Person or Team to sampledata is by using the `IPersonSet` API and `make harness`.
Line 26: Line 26:
'''XXX: This example is wrong, since it will update the dev sampledata, not the testrunner sampledata. Please fix.''' -- JonathanLange [[<<Date(2009-08-04T09:51:32Z)>>]] Note that it's very much worthwhile having the Python commands you want to run stored in some sort of text editor so you can copy and paste them, since you'll almost certainly get errors you didn't expect that force you to restart the process again.

==== Making a celebrity Person ====
Line 32: Line 34:
  ... 'celebrity@launchpad.net', PersonCreationRationale.UNKNOWN, name='my-celebrity',   ... 'celebrity@example.com', PersonCreationRationale.UNKNOWN, name='my-celebrity',
  ... displayname='My Celebrity', hide_email_addresses=True)
  >>> celebrity.validateAndEnsurePreferredEmail(celebrity_email)
  >>> transaction.commit()
  $ make harness LPCONFIG=test-playground
  >>> celebrity, celebrity_email = getUtility(IPersonSet).createPersonAndEmail(
  ... 'celebrity@example.com', PersonCreationRationale.UNKNOWN, name='my-celebrity',
Line 39: Line 47:

==== Making a celebrity Team ====

{{{
  $ make schema
  $ make harness
  >>> team_owner, team_owner_email = getUtility(IPersonSet).createPersonAndEmail(
  ... 'team-owner@example.com', PersonCreationRationale.UNKNOWN, name='my-celebrity',
  ... displayname='My Celebrity', hide_email_addresses=True)
  >>> team_owner.validateAndEnsurePreferredEmail(team_owner_email)
  >>> team = getUtility(IPersonSet).newTeam(team_owner, 'team-name', 'Team Name', subscriptionpolicy=TeamSubscriptionPolicy.RESTRICTED)
  >>> transaction.commit()
  $ make harness LPCONFIG=test-playground
  >>> team_owner, team_owner_email = getUtility(IPersonSet).createPersonAndEmail(
  ... 'team-owner@example.com', PersonCreationRationale.UNKNOWN, name='my-celebrity',
  ... displayname='My Celebrity', hide_email_addresses=True)
  >>> team_owner.validateAndEnsurePreferredEmail(team_owner_email)
  >>> team = getUtility(IPersonSet).newTeam(team_owner, 'team-name', 'Team Name', subscriptionpolicy=TeamSubscriptionPolicy.RESTRICTED)
  >>> transaction.commit()
  $ make newsampledata
}}}

Adding a new Launchpad Celebrity

Sometimes you need to define a new celebrity. A good example is when you add a script and you need a celebrity to own the content produced by that script.So here is the procedure to add a new LaunchpadCelebrities to ILaunchpadCelebrities.

  1. First step is to check if one of the existing celebrities can be used. If this is the case, use it and you're done!
  2. Before creating a new Person or Team, check if an existing one, either in sampledata or in production, can be used.
  3. You will need to add the Person or Team to sampledata. If the celebrity doesn't exist in production, you will also need to create a script to create it in production under database/schema/pending. Celebrity should have an email but no password.

  4. Add the celebrity name and description to canonical.launchpad.interfaces.launchpad.ILaunchpadCelebrities.

  5. Add a test for your celebrity to lib/canonical/launchpad/doc/celebrities.txt.

  6. Add the required CelebrityDescriptor to implement your celebrity to lib/canonical/launchpad/utilities/celebrities.py.

  7. If your celebrity doesn't exist in production: when your branch lands, don't forget to add a note to LaunchpadProductionStatus about the script that adds your celebrity to the database.

How to add a celebrity to sample data

The safest way to add the Person or Team to sampledata is by using the IPersonSet API and make harness.

Note that it's very much worthwhile having the Python commands you want to run stored in some sort of text editor so you can copy and paste them, since you'll almost certainly get errors you didn't expect that force you to restart the process again.

Making a celebrity Person

  $ make schema
  $ make harness
  >>> celebrity, celebrity_email = getUtility(IPersonSet).createPersonAndEmail(
  ...    'celebrity@example.com', PersonCreationRationale.UNKNOWN, name='my-celebrity', 
  ...    displayname='My Celebrity', hide_email_addresses=True)
  >>> celebrity.validateAndEnsurePreferredEmail(celebrity_email)
  >>> transaction.commit()
  $ make harness LPCONFIG=test-playground
  >>> celebrity, celebrity_email = getUtility(IPersonSet).createPersonAndEmail(
  ...    'celebrity@example.com', PersonCreationRationale.UNKNOWN, name='my-celebrity', 
  ...    displayname='My Celebrity', hide_email_addresses=True)
  >>> celebrity.validateAndEnsurePreferredEmail(celebrity_email)
  >>> transaction.commit()
  $ make newsampledata

Making a celebrity Team

  $ make schema
  $ make harness
  >>> team_owner, team_owner_email = getUtility(IPersonSet).createPersonAndEmail(
  ...    'team-owner@example.com', PersonCreationRationale.UNKNOWN, name='my-celebrity', 
  ...    displayname='My Celebrity', hide_email_addresses=True)
  >>> team_owner.validateAndEnsurePreferredEmail(team_owner_email)
  >>> team = getUtility(IPersonSet).newTeam(team_owner, 'team-name', 'Team Name', subscriptionpolicy=TeamSubscriptionPolicy.RESTRICTED)
  >>> transaction.commit()
  $ make harness LPCONFIG=test-playground
  >>> team_owner, team_owner_email = getUtility(IPersonSet).createPersonAndEmail(
  ...    'team-owner@example.com', PersonCreationRationale.UNKNOWN, name='my-celebrity', 
  ...    displayname='My Celebrity', hide_email_addresses=True)
  >>> team_owner.validateAndEnsurePreferredEmail(team_owner_email)
  >>> team = getUtility(IPersonSet).newTeam(team_owner, 'team-name', 'Team Name', subscriptionpolicy=TeamSubscriptionPolicy.RESTRICTED)
  >>> transaction.commit()
  $ make newsampledata

If you need to create a patch for production, examine the diff between the old sample data and the new. You'll need to determine the ID of the rows at run time using subselect though. An alternative is to use a python script similar to the above.

AddingLaunchpadCelebrity (last edited 2009-08-04 16:43:52 by jml)