Example #1
0
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()
Example #2
0
 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))
Example #3
0
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()
Example #4
0
 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))
Example #5
0
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))
Example #6
0
        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)
Example #7
0
    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
Example #8
0
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()
Example #9
0
class Referrer(Item):
    # Don't import the old schema. -exarkun
    typeName = normalize(
        'axiom.test.upgrade_fixtures.two_upgrades_old.Referrer')
    schemaVersion = 2
    referee = reference()
Example #10
0
class Referee(Item):
    # Don't import the old schema. -exarkun
    typeName = normalize(
        'axiom.test.upgrade_fixtures.two_upgrades_old.Referee')
    schemaVersion = 2
    dummy = integer()
Example #11
0
    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.
    """
Example #12
0
        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):