Skip to content

Straighten out "id", "key", and "slug" #322

Open
@kdmccormick

Description

@kdmccormick

Working with Learning Core's authoring api is mostly a joy, except for the inconsistent usage of the terms "id", "key", and "slug". This applies to the LC-related objects and models in opaque-keys and edx-platform, as well.

I would propose standardizing on these meanings of each term for all new content-related code, and for any existing code which is not too burdensome to change:

  • *_id is an integer primary key.
  • *_uuid is a UUID.
  • *_slug is a URL-friendly string which identifies something within a local scope. On the Component model, we currently call this is a "local key".
  • *_key is a string (or an opaque-keys object) which uniquely identifies something across a whole Open edX instance. Can be composed of slugs, or of other slug-like things like a block/component type.

For example, one change I'd like to make is:

  • On the model, Collection.key should be renamed Collection.slug
  • The corresponding field on the opaque-keys object, LibraryCollectionLoctator.collection_id should be renamed LibraryCollectionLocator.slug.
  • Function arguments and dataclass members should be renamed accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions