Opened 17 years ago
Closed 14 years ago
#5848 closed (fixed)
post_syncdb signal callbacks: argument 'created_models' is sometimes a list, sometimes a set
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | post_syncdb signal created_models | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have a function hooked up to the post_syncdb signal. When the function is called as a result of running the 'syncdb' management command, the created_models argument is a set. But when the function is called from the 'flush' management command, the created_models argument is a list.
def type_test (sender, app, created_models, verbosity, interactive): print type (created_models) dispatcher.connect (type_test, signal = signals.post_syncdb)
$ p/manage.py test ... <type 'set'> <type 'set'> <type 'set'> ... <type 'list'> <type 'list'> <type 'list'>
This is a problem because one of my functions checks to see if it actually has to do something with a for loop that looks like for m in created_models.intersection (django.db.models.get_models (app))
. I don't mind changing that to something that works with both lists and sets, but it would be nice if this inconsistency was cleaned up anyway.
Attachments (2)
Change History (9)
comment:1 by , 17 years ago
Summary: | post_syncdb signal callbacks: argument 'created_models' is sometimes a list, sometimes an str → post_syncdb signal callbacks: argument 'created_models' is sometimes a list, sometimes a set |
---|
comment:2 by , 17 years ago
Has patch: | set |
---|---|
Keywords: | post_syncdb signal created_models added |
by , 17 years ago
Attachment: | 5848.core.management.commands.flush.diff added |
---|
comment:3 by , 17 years ago
Component: | Uncategorized → Core framework |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
Perhaps the syncdb
signal should be made to return a list instead?
by , 17 years ago
Attachment: | 5848.core.management.commands.syncdb.diff added |
---|
Make syncdb use a list for created_models instead
comment:4 by , 17 years ago
That does make more sense (also, the wiki says to expect created_models as a list) - patch attached.
comment:5 by , 14 years ago
Triage Stage: | Design decision needed → Accepted |
---|
This should be a set. It's not ordered, you can't have duplicates, and membership of collection is an important operation.
comment:6 by , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Actually -- looking at the patch, it's pretty much RFC, although the patch needs to be updated (since the Python 2.3 protection is no longer required).
comment:7 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Make flush use set for created_models