Subject Field Inconsistencies
Some suggestions I have for cleaning up our subject data
Well, looking at the subject fields, on our currently published
objects, we seem to have quite a bit of inconsistencies. The main
issue that I see is that courses have subjects as strings, whereas
module subjects are tuples. It seems to me like we should really
convert them to the same data type. Here is a run-down of our various
subjects, how many of each we have, and what I would suggest that we do
to them to make them more consistent:|
Current Value |
# of Objects |
Suggested Change |
|---|---|---|
| ('Social Sciences',) | 198 |
NO CHANGE |
| () | 29 | NO CHANGE |
| 'Science and Technology' | 117 |
('Science and Technology',) |
| ('Humanities',) | 106 |
NO CHANGE |
| ('Arts',) |
190 |
NO CHANGE |
| ('',) | 119 |
() |
| ('Mathematics and Statistics', ' Science and Technology') | 312 |
NO CHANGE |
| ('Business',) | 15 |
NO CHANGE |
| ('Business', ' Social Sciences') | 2 |
NO CHANGE |
| ('Mathematics and Statistics',) | 186 |
NO CHANGE |
| ('Science and Technology', ' Social Sciences') | 10 |
NO CHANGE |
| 'Social Sciences' | 3 |
('Social Sciences',) |
| ('Arts', ' Science and Technology') | 22 |
NO CHANGE |
| ('Humanities', ' Social Sciences') | 43 |
NO CHANGE |
| ('Humanities', ' Test/Draft') | 1 |
NO CHANGE |
| 'Mathematics and Statistics' | 6 |
('Mathematics and Statistics',) |
| 'Business' |
6 |
('Business',) |
| ('Arts', ' Social Sciences') | 53 |
NO CHANGE |
| ('Humanities', ' Science and Technology') | 40 |
NO CHANGE |
| ('Science and Technology',) | 2476 | NO CHANGE |
| 'Test' |
9 |
('Test/Draft') |
| 'Humanities' | 23 |
('Humanities',) |
| ('Test/Draft',) |
86 |
NO CHANGE |
| 'Arts' |
11 |
('Arts',) |
| '' |
1 |
() |
Any of the subjects that will be getting set to empty, (), would instead get set to the subject of an earlier version if it was somehow lost in republishing. This is mostly the case for the modules that now have ('',).
Anyone want to suggest other changes while I am at it?
Re: Subject Field Inconsistencies
Posted by
kef
at
2007-04-25 23:01
What is the status of the suggestion to make all subjects tuples? Is this Ross territory? Seems like a good idea to me.
Re: Re: Subject Field Inconsistencies
Posted by
jenn
at
2007-04-26 09:27
It's a data structure thing, but a ZODB/Plone code one, so in the general developer ballpark.
This was partially done in the newlook upgrade script pass where we set the module subjects; at the same time, all blank course subjects were changed to be empty tuples instead of empty strings. I don't think the code was changed to make new objects follow the new scheme, though, so we're still getting empty strings on at least some new courses (see depot 8080 where I published a bunch of copies of a new course that had been sitting in the workgroup since before newlook).
Do this in debug to see that there are plenty of courses out there in workgroups with string-type subjects: [[c.subject for c in wg.objectValues('Collection')] for wg in app.plone.GroupWorkspaces.objectValues() if wg.objectIds('Collection') != []]
This was partially done in the newlook upgrade script pass where we set the module subjects; at the same time, all blank course subjects were changed to be empty tuples instead of empty strings. I don't think the code was changed to make new objects follow the new scheme, though, so we're still getting empty strings on at least some new courses (see depot 8080 where I published a bunch of copies of a new course that had been sitting in the workgroup since before newlook).
Do this in debug to see that there are plenty of courses out there in workgroups with string-type subjects: [[c.subject for c in wg.objectValues('Collection')] for wg in app.plone.GroupWorkspaces.objectValues() if wg.objectIds('Collection') != []]
Re: Re: Re: Subject Field Inconsistencies
Posted by
jenn
at
2007-04-26 09:37
This seems to do the trick for objects in workgroups:
groups=app.plone.GroupWorkspaces.objectValues()
groups.extend(app.plone.Members.objectValues())
for wg in groups:
for c in wg.objectValues('Collection'):
if c.subject == '':
c.subject = ()
We can run it next time we're planning to test course publishing, along with another run of FixBadSubjects.zctl from the newlook scripts directory.
groups=app.plone.GroupWorkspaces.objectValues()
groups.extend(app.plone.Members.objectValues())
for wg in groups:
for c in wg.objectValues('Collection'):
if c.subject == '':
c.subject = ()
We can run it next time we're planning to test course publishing, along with another run of FixBadSubjects.zctl from the newlook scripts directory.
Re: Re: Re: Re: Subject Field Inconsistencies
Posted by
jenn
at
2007-04-26 09:38
Argh. Blasted formatting. Well, I'm sure you can see where the indentation should go.

No, this looks good to me, and the scripts work and everything.