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.

Note that adding sample data may break other tests. Be ready to adjust these tests for the new sampledata or fix them to not use sample data at all.

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