-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Define TrackedCommand for use as base class for tracking management commands #2079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
common/djangoapps/track/command.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some documentation about the edx.mgmt.command context? And example of the generated context would also be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following django conventions, I would spec command.py to be located in common/djangoapps/track/management/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In looking at the doc (e.g. https://docs.djangoproject.com/en/dev/howto/custom-management-commands/), I find nothing about where to define code to be used when defining management commands elsewhere. I believe that only management commands should be put in management/commands (and this is not a management command). I haven't seen any example about adding code to management. This might be a reasonable place, but it's not based on any precedence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I am not saying it to put it in managent/commands, just in management. I have seen that pattern in other django projects. In addition, BaseCommand lives in django.core.management.base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll do that, and I'll move the test to a tests subdirectory of management.
…ommands. Use in create_user command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave these two entries (course_id, org_id) out until they are actually being added by the create_user command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are added by the enrollment call itself. Only "command" is now being added by the TrackedCommand class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, I suppose they would be. Awesome.
|
Close the PR accidentally, sorry. |
|
:LGTM: One thing we have to watch out is events that assume the context contains the However, maybe events that semantically require a |
|
Those events that require a course_id can put it in their context themselves as well as in their event data. At least that's what the enrollment code does. (See CourseEnrollment.emit_event() for particulars.) |
|
My concern is that the enrollment event is currently the only one (from what I remember) that emitted while setting the context at the same time. The other events assume the context is set up for them. I think we should only deal with this problem if we find an example. Right now it is just hypothetical. |
|
🚀 |
Define TrackedCommand for use as base class for tracking management commands
Use in create_user command instead of inheriting from BaseCommand.
@rocha @mulby This seems like the least intrusive way to get command information into context.