Positions CLI #11
Loading…
Reference in New Issue
No description provided.
Delete Branch "positions-cli"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #9
One change from #8 is that the
get
subcommand is not optional, makes it easier to implement using click.Looking good - just a few minor adjustments.
Also, we still need CLI unit tests.
@ -0,0 +24,4 @@
@positions.command(short_help='Update positions')
def update(**kwargs):
I think that this should be called 'set' instead of 'update'.
@ -0,0 +47,4 @@
required = cfg.get('positions_required')
for pos in avail:
update = click.option(f'--{pos}', metavar='USER', required=(pos in required))(update)
metavar should be 'USERNAME'.
Also, users should be prompted for required positions (set
prompt=True
).@ -29,3 +29,3 @@
self.positions = defaultdict(list)
for position, username in positions_reversed.items():
self.positions[username].append(position)
if username is not None:
If you're going to allow clients to POST null values, you need to check them in api/positions.py as well.
In particular, you have a snippet of code which does this:
If the body has a required position set to null, this check will fail to catch that.
It might be easier to simply remove null entries from the body at the very beginning.
the change doesn't allow positions to be null, only usernames. So it should handle it fine.
This sort of thing is now possible:
The API should return a 400 error for a request like this.
Here's an easy fix: change
to
ah I see what you mean. Will fix
6b289a1ec4
to5bae89a9fd
Added unit tests. I changed more provideUtility with registerUtility() so the dynamic position parameter works correctly. (It seems like it's where the library want people to use too judging by this comment
5bd246ed53/src/zope/component/globalregistry.py (L66)
)@ -0,0 +39,4 @@
def _handler(event):
global set
if not (IUtilityRegistration.providedBy(event.object) and IConfig.providedBy(event.object.component)):
What is this doing?
zope's
registerUtility
emits an IUtilityRegistration containing the component that got registered. Here I'm just checking for that, and whether the registered component is an IConfig.The reason why this whole thing is here is to make the parameters (--president, --syscom, etc) follow what is in the config.
After I merged v1 in I couldn't get the zope callback to work anymore, so I just created an explicit funtion which is called in positions().