~divmod-dev/divmod.org/combinator-wants-user-site-packages-3002

« back to all changes in this revision

Viewing changes to Quotient/xquotient/spam.py

  • Committer: exarkun
  • Date: 2009-07-16 00:52:55 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:17773
Merge quotient-scheduler-2925

Author: exarkun
Reviewer: mithrandi
Fixes: #2925

Remove all code from Quotient which instantiates Schedulers or SubSchedulers and
upgrade away persistent attributes which refer to existing such items.  Replace
this with simple adaption of Stores to IScheduler where necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
from nevow import athena
14
14
 
15
15
from axiom import iaxiom, item, attributes, userbase
16
 
from axiom.scheduler import SubScheduler
17
16
from axiom.upgrade import registerAttributeCopyingUpgrader
18
17
from axiom.dependency import dependsOn
19
18
from axiom.upgrade import registerUpgrader
50
49
    C{Filter} can also be configured to just look at Postini headers and make a
51
50
    determination based on them.
52
51
    """
53
 
    schemaVersion = 3
 
52
    schemaVersion = 4
54
53
 
55
54
    usePostiniScore = attributes.boolean(doc="""
56
55
    Indicate whether or not to classify based on Postini headers.
62
61
    """, default=0.03)
63
62
 
64
63
    _filters = attributes.inmemory()
65
 
    scheduler = dependsOn(SubScheduler)
66
64
    messageSource = dependsOn(MessageSource)
67
65
    tiSource = dependsOn(_TrainingInstructionSource)
68
66
 
213
211
    s = old.store
214
212
    filter.usePostiniScore = old.usePostiniScore
215
213
    filter.postiniThreshhold = old.postiniThreshhold
216
 
    filter.scheduler = s.findOrCreate(SubScheduler)
217
214
    filter.messageSource = s.findOrCreate(MessageSource)
218
215
    filter.tiSource = s.findOrCreate(_TrainingInstructionSource)
219
216
    return filter
220
217
 
221
218
registerUpgrader(_filter2to3, Filter.typeName, 2, 3)
222
219
 
 
220
item.declareLegacyItem(Filter.typeName, 3,
 
221
    dict(messageSource=attributes.reference(),
 
222
         scheduler=attributes.reference(),
 
223
         tiSource=attributes.reference(),
 
224
         usePostiniScore=attributes.boolean(default=False,allowNone=False),
 
225
         postiniThreshhold=attributes.ieee754_double(default=0.03)))
 
226
 
 
227
def _filter3to4(old):
 
228
    """
 
229
    Drop the scheduler reference, preserve everything else.
 
230
    """
 
231
    return old.upgradeVersion(
 
232
        old.typeName, 3, 4,
 
233
        usePostiniScore=old.usePostiniScore,
 
234
        postiniThreshhold=old.postiniThreshhold,
 
235
        messageSource=old.messageSource,
 
236
        tiSource=old.tiSource)
 
237
 
 
238
registerUpgrader(_filter3to4, Filter.typeName, 3, 4)
 
239
 
223
240
 
224
241
class HamFilterFragment(ThemedFragment):
225
242
    fragmentName = 'ham-filter'