Skip to content

Develop a syntax to "ensure" a certain object exists on the server #12

Open
@nvarscar

Description

Example of how it should look like:

cluster.roles.ensure(name='foo', superuser=True)

The pseudocode of what it does behind the scenes:

try:
  role = cluster.roles['foo']
except KeyError:
  role = cluster.roles.new(name='foo')  # potentially, kwargs could go here as well
for k,v in kwargs.items():
  if not hasattr(role, k):
     raise AttributeError
  setattr(role, k, v)  # not sure if setattr works with @property

role.create() if role._ephemeral else role.alter()

Metadata

Assignees

No one assigned

    Labels

    corePython-related, no Postgres knowledge neededenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions