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

« back to all changes in this revision

Viewing changes to Quotient/xquotient/grabber.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:
17
17
from epsilon import descriptor, extime
18
18
 
19
19
from axiom import item, attributes, iaxiom
20
 
from axiom.scheduler import SubScheduler
21
20
from axiom.dependency import dependsOn
22
21
from axiom.upgrade import registerUpgrader
23
22
 
99
98
    Manages the creation, operation, and destruction of grabbers
100
99
    (items which retrieve information from remote sources).
101
100
    """
102
 
    schemaVersion = 2
 
101
    schemaVersion = 3
103
102
 
104
103
    paused = attributes.boolean(doc="""
105
104
    Flag indicating whether grabbers created by this Item will be
106
105
    allowed to run.
107
106
    """, default=False)
108
107
 
109
 
    scheduler = dependsOn(SubScheduler)
110
108
    privateApplication = dependsOn(PrivateApplication)
111
109
    deliveryAgent = dependsOn(DeliveryAgent)
112
110
 
129
127
        self.scheduler.schedule(pg, extime.Time())
130
128
        # OR MAYBE A LITTLE LATER
131
129
 
132
 
item.declareLegacyItem(GrabberConfiguration, 1, dict(
 
130
item.declareLegacyItem(GrabberConfiguration.typeName, 1, dict(
133
131
    paused=attributes.boolean(default=False),
134
132
    installedOn=attributes.reference()))
135
133
 
136
134
def _grabberConfiguration1to2(old):
137
135
    new = old.upgradeVersion(GrabberConfiguration.typeName, 1, 2,
138
136
                             paused=old.paused,
139
 
                             scheduler = old.store.findOrCreate(SubScheduler),
140
137
                             privateApplication = old.store.findOrCreate(PrivateApplication),
141
138
                             deliveryAgent = old.store.findOrCreate(DeliveryAgent))
142
139
    return new
143
140
registerUpgrader(_grabberConfiguration1to2, GrabberConfiguration.typeName, 1, 2)
144
141
 
 
142
item.declareLegacyItem(GrabberConfiguration.typeName, 2, dict(
 
143
    paused=attributes.boolean(default=False),
 
144
    scheduler=attributes.reference(),
 
145
    privateApplication=attributes.reference(),
 
146
    deliveryAgent=attributes.reference(),
 
147
    ))
 
148
 
 
149
 
 
150
def _grabberConfiguration2to3(old):
 
151
    """
 
152
    Copy all the remaining attributes.
 
153
    """
 
154
    new = old.upgradeVersion(GrabberConfiguration.typeName, 2, 3,
 
155
                             paused=old.paused,
 
156
                             privateApplication = old.store.findOrCreate(PrivateApplication),
 
157
                             deliveryAgent = old.store.findOrCreate(DeliveryAgent))
 
158
    return new
 
159
registerUpgrader(_grabberConfiguration2to3, GrabberConfiguration.typeName, 2, 3)
 
160
 
 
161
 
145
162
class POP3UID(item.Item):
146
163
    grabberID = attributes.text(doc="""
147
164
    A string identifying the email-address/port parts of a
425
442
        self.setStatus(u"Logging in...")
426
443
        yield d
427
444
        try:
428
 
            loginResult = d.getResult()
 
445
            d.getResult()
429
446
        except pop3client.ServerErrorResponse, e:
430
447
            self.setStatus(
431
448
                u'Login failed: ' + str(e).decode('ascii', 'replace'),