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

« back to all changes in this revision

Viewing changes to Quotient/xquotient/inbox.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:
18
18
from axiom import attributes
19
19
from axiom.upgrade import registerUpgrader, registerAttributeCopyingUpgrader
20
20
from axiom.dependency import dependsOn, installOn, installedOn, _DependencyConnector
21
 
from axiom.scheduler import SubScheduler
22
21
 
23
22
from xmantissa import ixmantissa, webnav, people, webtheme
24
23
from xmantissa.webapp import PrivateApplication
96
95
    implements(ixmantissa.INavigableElement)
97
96
 
98
97
    typeName = 'quotient_inbox'
99
 
    schemaVersion = 5
 
98
    schemaVersion = 6
100
99
 
101
100
    powerupInterfaces = (ixmantissa.INavigableElement,)
102
101
 
103
102
    privateApplication = dependsOn(PrivateApplication)
104
 
    scheduler = dependsOn(SubScheduler)
105
103
    messageSource = dependsOn(MessageSource)
106
104
    quotientPrefs = dependsOn(QuotientPreferenceCollection)
107
105
    deliveryAgent = dependsOn(DeliveryAgent)
379
377
    new = old.upgradeVersion(
380
378
        Inbox.typeName, 3, 4,
381
379
        privateApplication=privapp,
382
 
        scheduler=old.store.findOrCreate(SubScheduler),
383
380
        messageSource=old.store.findOrCreate(MessageSource),
384
381
        quotientPrefs=old.store.findOrCreate(QuotientPreferenceCollection),
385
382
        deliveryAgent=old.store.findOrCreate(DeliveryAgent),
414
411
    new = old.upgradeVersion(
415
412
        Inbox.typeName, 4, 5,
416
413
        privateApplication=old.privateApplication,
417
 
        scheduler=old.scheduler,
418
414
        messageSource=old.messageSource,
419
415
        quotientPrefs=old.quotientPrefs,
420
416
        deliveryAgent=old.deliveryAgent,
428
424
        _DependencyConnector(installee=src, target=old.store,
429
425
                             explicitlyInstalled=True,
430
426
                             store=old.store)
431
 
    # Cannot do either of these before the upgradeVersion call: while
432
 
    # examining dependencies, it is likely that the Inbox being upgraded
433
 
    # will be encountered, causing this upgrade function to run again.
434
 
    # Repeat until the stack is full, then explode. -exarkun
435
427
    filter = new.store.findFirst(spam.Filter, default=None)
436
428
    if filter is None:
437
429
        filter = spam.Filter(store=new.store)
438
 
        installOn(filter, new.store)
439
430
    new.filter = filter
440
431
 
441
 
    installOn(focus, old.store)
442
432
    new.focus = focus
443
433
    return new
444
434
registerUpgrader(inbox4to5, Inbox.typeName, 4, 5)
445
435
 
 
436
declareLegacyItem(Inbox.typeName, 5,
 
437
                  dict(privateApplication=attributes.reference(),
 
438
                       scheduler=attributes.reference(),
 
439
                       messageSource=attributes.reference(),
 
440
                       quotientPrefs=attributes.reference(),
 
441
                       deliveryAgent=attributes.reference(),
 
442
                       messageDisplayPrefs=attributes.reference(),
 
443
                       uiComplexity=attributes.integer(),
 
444
                       showMoreDetail=attributes.boolean(),
 
445
                       filter=attributes.reference(),
 
446
                       focus=attributes.reference()))
 
447
 
 
448
def inbox5to6(old):
 
449
    """
 
450
    Copy over all attributes except C{scheduler}.
 
451
    """
 
452
    new = old.upgradeVersion(
 
453
        Inbox.typeName, 5, 6,
 
454
        privateApplication=old.privateApplication,
 
455
        messageSource=old.messageSource,
 
456
        quotientPrefs=old.quotientPrefs,
 
457
        messageDisplayPrefs=old.messageDisplayPrefs,
 
458
        deliveryAgent=old.deliveryAgent,
 
459
        uiComplexity=old.uiComplexity,
 
460
        showMoreDetail=old.showMoreDetail,
 
461
        filter=old.filter,
 
462
        focus=old.focus)
 
463
 
 
464
    # If the old item was original schema version 5 in the database, focus and
 
465
    # filter have already been installed, because the 4 to 5 upgrader used to
 
466
    # install them.  However, now that 5 is not the newest version of Inbox, it
 
467
    # cannot do that.  Only the upgrader to the newest version can.  So do it
 
468
    # here, instead, if it is necessary (which is when the original schema
 
469
    # version was older than 5).
 
470
    if installedOn(new.filter) is None:
 
471
        installOn(new.filter, new.store)
 
472
    if installedOn(new.focus) is None:
 
473
        installOn(new.focus, new.store)
 
474
    return new
 
475
 
 
476
registerUpgrader(inbox5to6, Inbox.typeName, 5, 6)
 
477
 
446
478
 
447
479
class MailboxScrollingFragment(Scrollable, ScrollableView, LiveElement):
448
480
    """