class Referrer(Item): """ An item which just refers to another kind of item which will be upgraded. """ # Don't import the old schema. -exarkun typeName = normalize( "axiom.test.upgrade_fixtures.replace_attribute_old.Referrer") referee = reference()
def test_getColumnName(self): """ Test that L{Store.getColumnName} returns something made up of the attribute's type's typeName and the attribute's name. """ s = Store() self.assertIn('dummyAttribute', s.getColumnName(SQLAttributeDummyClass.dummyAttribute)) self.assertIn(normalize(qual(SQLAttributeDummyClass)), s.getColumnName(SQLAttributeDummyClass.dummyAttribute))
class Referee(Item): """ An item the upgrader of which replaces itself on L{Referrer} with a new instance with a different value. """ # Don't import the old schema. -exarkun typeName = normalize( "axiom.test.upgrade_fixtures.replace_attribute_old.Referee") schemaVersion = 2 value = integer()
def test_getColumnName(self): """ Test that L{Store.getColumnName} returns something made up of the attribute's type's typeName and the attribute's name. """ s = Store() self.assertIn( 'dummyAttribute', s.getColumnName(SQLAttributeDummyClass.dummyAttribute)) self.assertIn( normalize(qual(SQLAttributeDummyClass)), s.getColumnName(SQLAttributeDummyClass.dummyAttribute))
class Simple(Item): # Don't import the old version, otherwise its schema will get loaded. This # is valid in the upgrade tests, but not at other times. -exarkun typeName = normalize( "axiom.test.upgrade_fixtures.override_init_old.Simple") schemaVersion = 2 dummy = integer() verify = inmemory() def __init__(self, **stuff): """ Override Item's __init__ to re-retrieve this Item from the store. """ Item.__init__(self, **stuff) self.verify = (self, self.store.getItemByID(self.storeID))
newIndexer.reset() return newIndexer def _declareLegacyIndexerItem(typeClass, version): item.declareLegacyItem(typeClass.typeName, version, dict(indexCount=attributes.integer(), installedOn=attributes.reference(), indexDirectory=attributes.text())) for cls in [HypeIndexer, XapianIndexer, PyLuceneIndexer]: _declareLegacyIndexerItem(cls, 2) registerUpgrader( remoteIndexer1to2, item.normalize(reflect.qual(cls)), 1, 2) registerUpgrader( remoteIndexer2to3, item.normalize(reflect.qual(cls)), 2, 3) del cls _declareLegacyIndexerItem(PyLuceneIndexer, 3) # Copy attributes. Rely on pyLuceneIndexer4to5 to reset the index due to # sorting changes. registerAttributeCopyingUpgrader(PyLuceneIndexer, 3, 4)
listeningPort = inmemory(doc=""" A reference to the L{IListeningPort} returned by C{self.listen} which is set whenever there there is one listening. """) def listen(self): if self._listen is not None: _listen = self._listen else: from twisted.internet import reactor _listen = reactor.listenTCP return _listen(self.portNumber, self.factory.getFactory(), interface=self.interface.encode('ascii')) declareLegacyItem( typeName=normalize(qual(TCPPort)), schemaVersion=1, attributes=dict( portNumber=integer(), factory=reference(), parent=inmemory(), _listen=inmemory(), listeningPort=inmemory())) registerAttributeCopyingUpgrader(TCPPort, 1, 2) class SSLPort(PortMixin, Item): """ An Axiom Service Item which will bind a TCP port to a protocol factory when
class Simple(Item): # Don't import the old schema. -exarkun typeName = normalize("axiom.test.upgrade_fixtures.reentrant_old.Simple") schemaVersion = 2 dummy = integer() selfReference = reference()
class Referrer(Item): # Don't import the old schema. -exarkun typeName = normalize( 'axiom.test.upgrade_fixtures.two_upgrades_old.Referrer') schemaVersion = 2 referee = reference()
class Referee(Item): # Don't import the old schema. -exarkun typeName = normalize( 'axiom.test.upgrade_fixtures.two_upgrades_old.Referee') schemaVersion = 2 dummy = integer()
A reference to the L{IListeningPort} returned by C{self.listen} which is set whenever there there is one listening. """) def listen(self): if self._listen is not None: _listen = self._listen else: from twisted.internet import reactor _listen = reactor.listenTCP return _listen(self.portNumber, self.factory.getFactory(), interface=self.interface.encode('ascii')) declareLegacyItem(typeName=normalize(qual(TCPPort)), schemaVersion=1, attributes=dict(portNumber=integer(), factory=reference(), parent=inmemory(), _listen=inmemory(), listeningPort=inmemory())) registerAttributeCopyingUpgrader(TCPPort, 1, 2) class SSLPort(PortMixin, Item): """ An Axiom Service Item which will bind a TCP port to a protocol factory when it is started. """
newIndexer.reset() return newIndexer def _declareLegacyIndexerItem(typeClass, version): item.declareLegacyItem( typeClass.typeName, version, dict(indexCount=attributes.integer(), installedOn=attributes.reference(), indexDirectory=attributes.text())) for cls in [HypeIndexer, XapianIndexer, PyLuceneIndexer]: _declareLegacyIndexerItem(cls, 2) registerUpgrader(remoteIndexer1to2, item.normalize(reflect.qual(cls)), 1, 2) registerUpgrader(remoteIndexer2to3, item.normalize(reflect.qual(cls)), 2, 3) del cls _declareLegacyIndexerItem(PyLuceneIndexer, 3) # Copy attributes. Rely on pyLuceneIndexer4to5 to reset the index due to # sorting changes. registerAttributeCopyingUpgrader(PyLuceneIndexer, 3, 4) _declareLegacyIndexerItem(PyLuceneIndexer, 4) def pyLuceneIndexer4to5(old):