コード例 #1
0
ファイル: website.py プロジェクト: jonathanj/mantissa
class APIKey(Item):
    """
    Persistent record of a key used for accessing an external API.

    @cvar URCHIN: Constant name for the "Google Analytics" API
    (http://code.google.com/apis/maps/)
    @type URCHIN: C{unicode}
    """
    URCHIN = u'Google Analytics'

    apiName = text(
        doc="""
        L{APIKey} constant naming the API this key is for.
        """, allowNone=False)


    apiKey = text(
        doc="""
        The key.
        """, allowNone=False)


    def getKeyForAPI(cls, siteStore, apiName):
        """
        Get the API key for the named API, if one exists.

        @param siteStore: The site store.
        @type siteStore: L{axiom.store.Store}

        @param apiName: The name of the API.
        @type apiName: C{unicode} (L{APIKey} constant)

        @rtype: L{APIKey} or C{NoneType}
        """
        return siteStore.findUnique(
            cls, cls.apiName == apiName, default=None)
    getKeyForAPI = classmethod(getKeyForAPI)


    def setKeyForAPI(cls, siteStore, apiName, apiKey):
        """
        Set the API key for the named API, overwriting any existing key.

        @param siteStore: The site store to install the key in.
        @type siteStore: L{axiom.store.Store}

        @param apiName: The name of the API.
        @type apiName: C{unicode} (L{APIKey} constant)

        @param apiKey: The key for accessing the API.
        @type apiKey: C{unicode}

        @rtype: L{APIKey}
        """
        existingKey = cls.getKeyForAPI(siteStore, apiName)
        if existingKey is None:
            return cls(store=siteStore, apiName=apiName, apiKey=apiKey)
        existingKey.apiKey = apiKey
        return existingKey
    setKeyForAPI = classmethod(setKeyForAPI)
コード例 #2
0
ファイル: listversions.py プロジェクト: perkinslr/axiom-py3
class SoftwareVersion(item.Item):
    """
    An Item subclass to map L{twisted.python.versions.Version} objects.
    """

    systemVersion = attributes.reference(
        doc="The system version this package version was observed in.",
        allowNone=False)

    package = attributes.text(doc="The software package.",
                              allowNone=False)
    version = attributes.text(doc="The version string of the software.",
                              allowNone=False)
    major = attributes.integer(doc='Major version number.',
                               allowNone=False)
    minor = attributes.integer(doc='Minor version number.',
                               allowNone=False)
    micro = attributes.integer(doc='Micro version number.',
                               allowNone=False)


    def asVersion(self):
        """
        Convert the version data in this item to a
        L{twisted.python.versions.Version}.
        """
        return versions.Version(self.package, self.major, self.minor, self.micro)


    def __repr__(self):
        return '<SoftwareVersion %s: %s>' % (self.package, self.version)
コード例 #3
0
ファイル: test_tdb.py プロジェクト: jonathanj/mantissa
class X(Item):
    typeName = 'test_tdb_model_dummy'
    schemaVersion = 1

    number = integer()
    textNumber = text()
    phoneticDigits = text()
コード例 #4
0
ファイル: exercise.py プロジェクト: NazoSnare/merlyn
class Exercise(item.Item):
    """An exercise.

    """
    identifier = attributes.bytes(allowNone=False)
    title = attributes.text(allowNone=False)
    description = attributes.text(allowNone=False)

    def solvedBy(self, user):
        """Stores that this user has just solved this exercise.

        You probably want to notify the user when this happens. For
        that, see ``solveAndNotify``.

        """
        _Solution(store=self.store, who=user, what=self)


    def wasSolvedBy(self, user):
        """Checks if this exercise has previously been solved by the user.

        """
        thisExercise = _Solution.what == self
        byThisUser = _Solution.who == user
        condition = q.AND(thisExercise, byThisUser)
        return self.store.query(_Solution, condition, limit=1).count() == 1
コード例 #5
0
ファイル: sipserver.py プロジェクト: MartyTremblay/sine
class Call(Item):
    typeName = "sine_call"
    schemaVersion = 1
    name = text()
    uri = text()
    time = timestamp()
    kind = text()
コード例 #6
0
ファイル: sipserver.py プロジェクト: MartyTremblay/sine
class Registration(Item):
    typename = "sine_registration"
    schemaVersion = 1
    parent = reference()
    username = text()
    domain = text()
    password = text()
コード例 #7
0
ファイル: website.py プロジェクト: jonathanj/mantissa
class StaticSite(PrefixURLMixin, Item):
    implements(ISessionlessSiteRootPlugin,     # implements both so that it
               ISiteRootPlugin)                # works in both super and sub
                                               # stores.
    typeName = 'static_web_site'
    schemaVersion = 2

    prefixURL = text()
    staticContentPath = text()

    sessioned = boolean(default=False)
    sessionless = boolean(default=True)

    def __str__(self):
        return '/%s => file(%s)' % (self.prefixURL, self.staticContentPath)

    def createResource(self):
        return File(self.staticContentPath)

    def installSite(self):
        """
        Not using the dependency system for this class because it's only
        installed via the command line, and multiple instances can be
        installed.
        """
        for iface, priority in self.__getPowerupInterfaces__([]):
            self.store.powerUp(self, iface, priority)
コード例 #8
0
ファイル: website.py プロジェクト: jonathanj/mantissa
class StaticRedirect(Item, PrefixURLMixin):
    implements(inevow.IResource,
               ISessionlessSiteRootPlugin,
               ISiteRootPlugin)

    schemaVersion = 2
    typeName = 'web_static_redirect'

    targetURL = text(allowNone=False)

    prefixURL = text(allowNone=False)

    sessioned = boolean(default=True)
    sessionless = boolean(default=True)

    def __str__(self):
        return '/%s => url(%s)' % (self.prefixURL, self.targetURL)

    def locateChild(self, ctx, segments):
        return self, ()

    def renderHTTP(self, ctx):
        return URL.fromContext(ctx).click(self.targetURL)

    def createResource(self):
        return self
コード例 #9
0
class PartItem(Item):
    typeName = 'xquotient_test_part_item'
    schemaVersion = 1

    contentType = text()
    body = text()
    bodyLength = integer()
    preferred = inmemory()

    def walkAttachments(self):
        return (MockPart('foo.bar', 'XXX'), MockPart('bar.baz', 'YYY'))

    def getContentType(self):
        assert self.contentType is not None
        return self.contentType

    def getUnicodeBody(self):
        assert self.body is not None
        return self.body

    def getBody(self, decode=True):
        return self.getUnicodeBody().encode('ascii')

    def walkMessage(self, preferred):
        self.preferred = preferred
コード例 #10
0
class _TemplateNameResolver(Item):
    """
    An L{ixmantissa.ITemplateNameResolver} with an implementation of
    L{getDocFactory} which doesn't require the presence any disk templates.
    """
    powerupInterfaces = (ixmantissa.ITemplateNameResolver, )

    magicTemplateName = text(doc="""
    L{magicDocFactoryValue} will be returned by L{getDocFactory} if it is passed
    this string as the first argument.""")

    magicDocFactoryValue = text(
        doc="""
    The string value to be returned from L{getDocFactory} when the name it is
    passed matches L{magicTemplateName}."""

        # if anything starts to care too much about what the docFactory is, we
        # won't be able to get away with just using a string.
    )

    # ITemplateNameResolver
    def getDocFactory(self, name, default=None):
        """
        If C{name} matches L{self.magicTemplateName}, return
        L{self.magicTemplateName}, otherwise return C{default}.
        """
        if name == self.magicTemplateName:
            return self.magicDocFactoryValue
        return default
コード例 #11
0
ファイル: userbase.py プロジェクト: DalavanCloud/axiom-1
class LoginMethod(Item):
    typeName = 'login_method'
    schemaVersion = 2

    localpart = text(doc="""
    A local-part of my user's identifier.
    """,
                     indexed=True,
                     allowNone=False)

    domain = text(doc="""
    The domain part of my user's identifier. [XXX See TODO below]
    May be None (generally for "system" users).
    """,
                  indexed=True)

    internal = boolean(doc="""
    Flag indicating whether this is a method maintained by this server, or if
    it represents an external contact mechanism (such as a third-party email
    provider)
    """,
                       allowNone=False)

    protocol = text(indexed=True, allowNone=False)
    account = reference(doc="""
    A reference to the LoginAccount for which this is a login method.
    """,
                        allowNone=False)

    verified = boolean(indexed=True, allowNone=False)
コード例 #12
0
class Header(item.Item):
    """
    Database resident representation of a MIME header.
    """
    typeName = 'quotient_mime_header'
    schemaVersion = 1

    message = attributes.reference(
        "A reference to the stored top-level L{xquotient.exmess.Message} "
        "object to which this header pertains.",
        reftype=exmess.Message,
        whenDeleted=attributes.reference.CASCADE)
    part = attributes.reference(
        "A reference to the stored MIME part object to which this header "
        "directly pertains.")

    name = attributes.text("The name of this header.  What it is called.",
                           allowNone=False)
    value = attributes.text("The decoded value of this header.",
                            allowNone=False)
    index = attributes.integer("The position of this header within a part.",
                               indexed=True,
                               allowNone=False)

    # This compound index matches the getHeader[s] query and is critical for
    # interactive performance.

    attributes.compoundIndex(part, name)
コード例 #13
0
class Recording(Item, website.PrefixURLMixin):
    typeName = "sine_confession_recording"
    schemaVersion = 1

    prefixURL = text()
    length = integer()  #seconds in recording
    fromAddress = text()
    time = timestamp()

    sessioned = True
    sessionless = False

    def __init__(self, **args):
        super(Recording, self).__init__(**args)
        self.time = Time()
        self.prefixURL = unicode("private/recordings/%s.wav" %
                                 str(self.storeID))

    def getFile(self):
        dir = self.store.newDirectory("recordings")
        if not dir.exists():
            dir.makedirs()  #should i really have to do this?
        return dir.child("%s.wav" % self.storeID)

    file = property(getFile)

    def audioFromFile(self, filename):
        f = self.file.path
        filepath.FilePath(filename).moveTo(self.file)
        w = wave.open(f)
        self.length = w.getnframes() / w.getframerate()
        w.close()

    def createResource(self):
        return static.File(self.file.path)
コード例 #14
0
ファイル: paste.py プロジェクト: jonathanj/Codetip
class Paste(Item):
    """
    Paste item.
    """
    created = timestamp(defaultFactory=lambda: Time(),
                        doc=u'Creation timestamp')
    languageHint = text(doc=u'Paste content language hint')
    name = text(allowNone=False, indexed=True, doc=u'Paste name')
    content = text(allowNone=False, doc=u'Paste content')

    def run(self):
        self.deleteFromStore()

    def toJSON(self):
        """
        Describe the L{Paste} item as I{JSON}.
        """
        attrs = dict(self.persistentValues())
        attrs['id'] = attrs['name']
        return json.dumps(attrs, default=jsonSerialize)

    @classmethod
    def findByName(cls, store, name):
        """
        Get a L{Paste} item by name.
        """
        return store.findUnique(Paste, Paste.name == name)
コード例 #15
0
ファイル: mediadb_storage.py プロジェクト: unintended/Cohen
class Artist(item.Item, BackendItem):
    """ definition for an artist """

    schemaVersion = 1
    typeName = 'artist'
    mimetype = 'directory'

    name = attributes.text(allowNone=False, indexed=True)
    musicbrainz_id = attributes.text()

    get_path = None

    def get_artist_all_tracks(self, start=0, request_count=0):
        children = [
            x[1] for x in list(
                self.store.query((Album, Track),
                                 attributes.AND(Album.artist == self,
                                                Track.album == Album.storeID),
                                 sort=(Album.title.ascending,
                                       Track.track_nr.ascending)))
        ]
        if request_count == 0:
            return children[start:]
        else:
            return children[start:request_count]

    def get_children(self, start=0, request_count=0):
        all_id = 'artist_all_tracks_%d' % (self.storeID + 1000)
        self.store.containers[all_id] = \
                Container(all_id, self.storeID + 1000, 'All tracks of %s' % self.name,
                          children_callback=self.get_artist_all_tracks,
                          store=self.store, play_container=True)

        children = [self.store.containers[all_id]] + list(
            self.store.query(
                Album, Album.artist == self, sort=Album.title.ascending))
        if request_count == 0:
            return children[start:]
        else:
            return children[start:request_count]

    def get_child_count(self):
        return len(list(self.store.query(Album, Album.artist == self))) + 1

    def get_item(self):
        item = DIDLLite.MusicArtist(self.storeID + 1000,
                                    AUDIO_ARTIST_CONTAINER_ID, self.name)
        item.childCount = self.get_child_count()
        return item

    def get_id(self):
        return self.storeID + 1000

    def get_name(self):
        return self.name

    def __repr__(self):
        return '<Artist %d name="%s" musicbrainz="%s">' \
               % (self.storeID, self.name.encode('ascii', 'ignore'), self.musicbrainz_id)
コード例 #16
0
class SubscribedFeed(Item):
    """
    Persistent state for subscribed feeds.

    Subscription identifiers must be unique to the subscriber.
    """
    id = text(doc="""
    Subscription identifier unique to C{subscriber}.
    """,
              allowNone=False)

    url = text(doc="""
    URL of the subscribed feed.
    """,
               allowNone=False)

    subscriber = text(doc="""
    Application specific subscriber identifier.
    """,
                      allowNone=False)

    formatting = text(doc="""
    Entry formatting type.
    """,
                      allowNone=False)

    source = inmemory()
    _unsubscribe = inmemory()

    def activate(self):
        self.source = None
        self._unsubscribe = None

    def subscribe(self, service, callback):
        """
        Subscribe to notifications for this item's URL.
        """
        d = service.subscribe(self.url, callback)

        @d.addCallback
        def subscribed(unsubscribe):
            self._unsubscribe = unsubscribe
            return self

        return d

    def unsubscribe(self, service):
        """
        Unsubscribe from notifications for this item's URL and delete the item.
        """
        if self._unsubscribe is not None:
            self._unsubscribe()
            self._unsubscribe = None

        def _unsubscribe(dummy):
            self.deleteFromStore()
            self.source = None

        return service.unsubscribe(self.url).addCallback(_unsubscribe)
コード例 #17
0
class Sample(Item):
    """
    A sample item which will be used as the rows in the table displayed.
    """

    quantity = integer(indexed=True)
    title = text()
    date = timestamp(indexed=True)
    color = text(allowNone=False)
コード例 #18
0
ファイル: agi2.py プロジェクト: weareforests/weareforests
class Recording(Item):
    """
    A certain recording.
    """

    created = timestamp()
    caller_id = text()
    filename = text()
    duration = integer()  # in frames
コード例 #19
0
class ThingWithCharacterAndByteStrings(Item):
    schemaVersion = 1

    typeName = 'ThingWithCharacterAndByteStrings'

    characterString = text(caseSensitive=True)
    caseInsensitiveCharString = text(caseSensitive=False)

    byteString = bytes()
コード例 #20
0
class File(item.Item):
    typeName = 'quotient_file'
    schemaVersion = 1

    type = attributes.text(allowNone=False)
    body = attributes.path(allowNone=False)
    name = attributes.text(allowNone=False)

    message = attributes.reference()
    cabinet = attributes.reference(allowNone=False)
コード例 #21
0
class QueryStatBucket(item.Item):
    """
    Obsolete.  Only present for schema compatibility.  Do not use.
    """
    type = attributes.text("the SQL query string")
    value = attributes.ieee754_double(default=0.0, doc='Total number of events for this time period')
    interval = attributes.text(doc='A time period, e.g. "quarter-hour" or "minute" or "day"')
    index = attributes.integer(doc='The position in the round-robin list for non-daily stats')
    time = attributes.timestamp(doc='When this bucket was last updated')
    attributes.compoundIndex(interval, type, index)
コード例 #22
0
ファイル: mediadb_storage.py プロジェクト: Python3pkg/Cohen
class Album(item.Item, BackendItem):
    """ definition for an album """

    schemaVersion = 1
    typeName = 'album'
    mimetype = 'directory'

    title = attributes.text(allowNone=False, indexed=True)
    musicbrainz_id = attributes.text()
    artist = attributes.reference(allowNone=False, indexed=True)
    cd_count = attributes.integer(default=1)
    cover = attributes.text(default='')

    get_path = None

    def get_children(self, start=0, request_count=0):
        children = list(self.store.query(Track, Track.album == self, sort=Track.track_nr.ascending))
        if request_count == 0:
            return children[start:]
        else:
            return children[start:request_count]

    def get_child_count(self):
        return len(list(self.store.query(Track, Track.album == self)))

    def get_item(self):
        item = DIDLLite.MusicAlbum(self.storeID + 1000, AUDIO_ALBUM_CONTAINER_ID, self.title)
        item.artist = self.artist.name
        item.childCount = self.get_child_count()
        if len(self.cover) > 0:
            _, ext = os.path.splitext(self.cover)
            item.albumArtURI = ''.join((self.store.urlbase, str(self.get_id()), '?cover', ext))

        if self.get_child_count() > 0:
            res = DIDLLite.PlayContainerResource(self.store.server.uuid, cid=self.get_id(), fid=self.get_children()[0].get_id())
            item.res.append(res)
        return item

    def get_id(self):
        return self.storeID + 1000

    def get_name(self):
        return self.title

    def get_cover(self):
        return self.cover

    def __repr__(self):
        return '<Album %d title="%s" artist="%s" #cds %d cover="%s" musicbrainz="%s">' \
               % (self.storeID, self.title.encode('ascii', 'ignore'),
                  self.artist.name.encode('ascii', 'ignore'),
                  self.cd_count,
                  self.cover.encode('ascii', 'ignore'),
                  self.musicbrainz_id)
コード例 #23
0
class _PasswordResetAttempt(Item):
    """
    I represent as as-yet incomplete attempt at password reset
    """

    typeName = 'password_reset_attempt'
    schemaVersion = 1

    key = text()
    username = text()
    timestamp = timestamp()
コード例 #24
0
ファイル: service.py プロジェクト: shiradz/fusion-index
class FusionIndexService(Item, Service):
    """
    REMOVED: Old service powerup.
    """
    schemaVersion = 2
    powerupInterfaces = [IService]

    interface = a.bytes(default='', allowNone=False)
    port = a.integer(default=8443, allowNone=False)
    caPath = a.text(allowNone=False)
    certPath = a.text(allowNone=False)
コード例 #25
0
class DataService(item.Item, service.Service):
    powerupInterfaces = (service.IService, )
    schemaVersion = 1
    smtpFrom = A.text(doc="The email address used as From: in emails")
    smtpServer = A.text(doc="The SMTP server used for outgoing email")

    parent = A.inmemory()
    running = A.inmemory()

    def startService(self):
        log.msg("Starting service %r" % (self, ))
コード例 #26
0
class FileMeta(item.Item):
    """A file that has been uploaded."""
    schemaVersion = 1
    data = A.reference(doc="The FileData item that holds this file's data")
    thumbnail = A.reference(
        doc="The FileData item that holds the image thumbnail, if any")
    filename = A.text(doc="The basename of the file")
    mimeType = A.text(doc="The mime-type of the file")
    md5 = A.text(doc="The md5 hash of the file data")
    user = A.reference(doc="The User item who uploaded (owns?) the file")
    width = A.integer(doc="The width in pixels of the image, if an image")
    height = A.integer(doc="The height in pixels of the image, if an image")
コード例 #27
0
ファイル: library.py プロジェクト: DalavanCloud/axiom-1
class Book(Item):
    typeName = 'book'
    schemaVersion = 1

    title = text()
    author = text()
    isbn = text()
    pages = integer()
    datePublished = timestamp()

    lentTo = reference()
    library = reference()
コード例 #28
0
class Toaster(Item):
    implements(IBreadConsumer)
    powerupInterfaces = (IAppliance, IBreadConsumer)

    powerStrip = dependency.dependsOn(PowerStrip,
                                      lambda ps: ps.setForUSElectricity(),
                                      doc="the power source for this toaster")
    description = text()
    breadFactory = dependency.dependsOn(
        Breadbox,
        doc="the thing we get bread input from",
        whenDeleted=reference.CASCADE)

    callback = inmemory()

    def activate(self):
        self.callback = None

    def installed(self):
        if self.callback is not None:
            self.callback("installed")

    def uninstalled(self):
        if self.callback is not None:
            self.callback("uninstalled")

    def toast(self):
        self.powerStrip.draw(100)
        self.breadFactory.dispenseBread(2)
コード例 #29
0
ファイル: util.py プロジェクト: Aeroglyphic/twisted-quotient
class DummyMessageImplementation(Item, DummyMessageImplementationMixin):
    senderInfo = text(
        doc="""
        The sender as passed by the factory which created this implementation;
        used to provide a sensible implementation of relatedAddresses.
        """,
        default=None, allowNone=True)
コード例 #30
0
class RecordAttributeRequired(Item, WithRecordAttributes):
    """
    An item for testing record attributes with mandatory attributes.
    """
    alpha = text(allowNone=False)
    beta = integer(allowNone=False)
    sigma = RecordAttribute(Sigma, [alpha, beta])
コード例 #31
0
ファイル: morenewapp.py プロジェクト: ldanielburr/axiom
    newsword.damagePerHit = oldsword.damagePerHit
    invent = InventoryEntry(store=newsword.store, owner=oldsword.owner, owned=newsword)
    return newsword


registerUpgrader(sword2to3, "test_app_sword", 2, 3)


####### DOUBLE-LEGACY UPGRADE SPECTACULAR !! ###########

# declare legacy class.

from axiom.item import declareLegacyItem


declareLegacyItem(typeName="test_app_player", schemaVersion=2, attributes=dict(name=text(allowNone=True)))

registerAttributeCopyingUpgrader(Adventurer, 2, 3)

declareLegacyItem(
    typeName="test_app_sword",
    schemaVersion=2,
    attributes=dict(name=text(), damagePerHit=integer(), owner=reference(), activated=inmemory()),
)


def upgradePlayerAndSword(oldplayer):
    newplayer = oldplayer.upgradeVersion("test_app_player", 1, 2)
    newplayer.name = oldplayer.name

    oldsword = oldplayer.sword
コード例 #32
0
ファイル: signup.py プロジェクト: fusionapp/mantissa
    emailTemplate = file(sibpath(__file__, 'signup.rfc2822')).read()
    emailTemplate %= {'blurb': u'',
                      'subject': 'Welcome to a Generic Axiom Application!',
                      'linktext': "Click here to claim your 'generic axiom application' account"}

    return old.upgradeVersion('free_signup', 2, 3,
                              prefixURL=old.prefixURL,
                              booth=old.booth,
                              benefactor=old.benefactor,
                              emailTemplate=emailTemplate)

upgrade.registerUpgrader(freeTicketSignup2To3, 'free_signup', 2, 3)

declareLegacyItem(typeName='free_signup',
                  schemaVersion=3,
                  attributes=dict(prefixURL=text(),
                                  booth=reference(),
                                  benefactor=reference(),
                                  emailTemplate=text()))



def freeTicketSignup3To4(old):
    return old.upgradeVersion('free_signup', 3, 4,
                              prefixURL=old.prefixURL,
                              booth=old.booth,
                              benefactor=old.benefactor,
                              emailTemplate=old.emailTemplate,
                              prompt=u'Sign Up')

upgrade.registerUpgrader(freeTicketSignup3To4, 'free_signup', 3, 4)
コード例 #33
0
ファイル: publicweb.py プロジェクト: rcarmo/divmod.org
        of applications will be displayed.
        """,
        allowNone=True)

    def createResourceWith(self, crud):
        """
        Create a L{_PublicFrontPage} resource wrapping this object.
        """
        return _PublicFrontPage(self, crud)

item.declareLegacyItem(
    FrontPage.typeName,
    1,
    dict(publicViews = attributes.integer(),
         privateViews = attributes.integer(),
         prefixURL = attributes.text(allowNone=False)))

upgrade.registerAttributeCopyingUpgrader(FrontPage, 1, 2)



class PublicAthenaLivePage(_PublicPageMixin, website.MantissaLivePage):
    """
    PublicAthenaLivePage is a publicly viewable Athena-enabled page which slots
    a single fragment into the center of the page.
    """
    docFactory = ThemedDocumentFactory('shell', 'templateResolver')
    unsupportedBrowserLoader = ThemedDocumentFactory(
        'athena-unsupported', 'templateResolver')

    fragment = None
コード例 #34
0
ファイル: fulltext.py プロジェクト: fusionapp/mantissa
def _declareLegacyIndexerItem(typeClass, version):
    item.declareLegacyItem(typeClass.typeName, version,
                           dict(indexCount=attributes.integer(),
                                installedOn=attributes.reference(),
                                indexDirectory=attributes.text()))
コード例 #35
0
ファイル: webapp.py プロジェクト: fusionapp/mantissa
    # IPowerupIndirector
    def indirect(self, interface):
        """
        Indirect the implementation of L{IWebViewer} to
        L{_AuthenticatedWebViewer}.
        """
        if interface == IWebViewer:
            return _AuthenticatedWebViewer(self)
        return self



PrivateApplicationV2 = declareLegacyItem(PrivateApplication.typeName, 2, dict(
    installedOn = reference(),
    preferredTheme = text(),
    hitCount = integer(default=0),
    privateKey = integer(),
    privateIndexPage = reference(),
    ))

PrivateApplicationV3 = declareLegacyItem(PrivateApplication.typeName, 3, dict(
    preferredTheme=text(),
    hitCount=integer(default=0),
    privateKey=integer(),
    privateIndexPage=reference(),
    customizedPublicPage=reference("dependsOn(CustomizedPublicPage)"),
    authenticationApplication=reference("dependsOn(AuthenticationApplication)"),
    preferenceAggregator=reference("dependsOn(PreferenceAggregator)"),
    defaultPreferenceCollection=reference("dependsOn(DefaultPreferenceCollection)"),
    searchAggregator=reference("dependsOn(SearchAggregator)"),
コード例 #36
0
ファイル: onestepapp.py プロジェクト: bne/squeal
    raise RuntimeError("The database does not contain any swords of version 2,"
                       " so you should be able to skip this version.")


registerUpgrader(sword2to3, 'test_app_sword', 2, 3)


####### DOUBLE-LEGACY UPGRADE SPECTACULAR !! ###########

# declare legacy class.

from axiom.item import declareLegacyItem

declareLegacyItem(typeName = 'test_app_sword',
                  schemaVersion = 2,
                  attributes = dict(name=text(),
                                    damagePerHit=integer(),
                                    owner=reference(),
                                    activated=inmemory()))


def upgradePlayerAndSword(oldplayer):
    newplayer = oldplayer.upgradeVersion('test_app_player', 1, 2)
    newplayer.name = oldplayer.name

    oldsword = oldplayer.sword

    newsword = oldsword.upgradeVersion('test_app_sword', 1, 3,
                                       name=oldsword.name,
                                       damagePerHit=oldsword.hurtfulness * 2)
    invent = InventoryEntry(store=newsword.store,
コード例 #37
0
ファイル: compose.py プロジェクト: pombredanne/quotient
        @param toAddresses: L{mimeutil.EmailAddress} instances
        @type toAddresses: sequence
        """
        self.composer.redirect(fromAddress, toAddresses, self.message)


class ComposeBenefactor(item.Item):
    endowed = attributes.integer(default=0)
    powerupNames = ["xquotient.compose.Composer"]

registerAttributeCopyingUpgrader(ComposePreferenceCollection, 1, 2)

item.declareLegacyItem(ComposePreferenceCollection.typeName, 2,
                       dict(installedOn=attributes.reference(),
                            preferredSmarthost=attributes.text(),
                            smarthostUsername=attributes.text(),
                            smarthostPassword=attributes.text(),
                            smarthostPort=attributes.integer(),
                            smarthostAddress=attributes.text()))

def composePreferenceCollection2to3(old):
    """
    Create an L{smtpout.FromAddress} out of the appropriate
    L{userbase.LoginMethod} in the store, using L{_getFromAddressFromStore}.
    This probably should happen in the L{Composer} 2->3 upgrader, but we also
    make an L{smtpout.FromAddress} item out the smarthost attributes of C{old}
    if they are set, and we need to do that after creating the initial
    L{smtpout.FromAddress}, so it gets set as the default.

    Copy C{old.installedOn} onto the new L{ComposePreferenceCollection}
コード例 #38
0
ファイル: quotientapp.py プロジェクト: pombredanne/quotient
        for cls in GrabberConfiguration, spam.Filter:
            item = self.store.findUnique(cls, default=None)
            if item is not None:
                sections.append(item)
        if sections:
            return sections
        return None

    def getTabs(self):
        return (webnav.Tab('Mail', self.storeID, 0.0),)

registerAttributeCopyingUpgrader(QuotientPreferenceCollection, 1, 2)

declareLegacyItem(QuotientPreferenceCollection.typeName, 2,
                  dict(installedOn=attributes.reference(),
                       preferredMimeType=attributes.text(),
                       preferredMessageDisplay=attributes.text(),
                       showRead=attributes.boolean(),
                       showMoreDetail=attributes.boolean()))

def quotientPreferenceCollection2To3(old):
    """
    Remove the preference attributes of
    L{xquotient.quotientapp.QuotientPreferenceCollection}, and install
    a L{xquotient.exmess.MessageDisplayPreferenceCollection}, because
    the attributes have either been moved there, or removed entirely
    """
    mdpc = MessageDisplayPreferenceCollection(
        store=old.store,
        preferredFormat=old.preferredMimeType)
    mdpc.installedOn = old.store
コード例 #39
0
ファイル: smtpout.py プロジェクト: pombredanne/quotient
        if not self.running:
            self.running = True
            self.tries += 1

            d = self.sendmail()
            d.addCallback(self.mailSent, sch)
            d.addErrback(self.failureSending, sch)
            d.addErrback(log.err)



item.declareLegacyItem(DeliveryToAddress.typeName, 2,
                       dict(composer = attributes.reference(),
                            message = attributes.reference(),
                            fromAddress = attributes.reference(),
                            toAddress = attributes.text(),
                            tries = attributes.integer(default=0)))



def deliveryToAddress2to3(old):
    delivery = MessageDelivery(composer=old.composer,
                               message=old.message,
                               store=old.store)
    new = old.upgradeVersion(old.typeName, 2, 3,
                             delivery=delivery,
                             message=old.message,
                             fromAddress=old.fromAddress,
                             toAddress=old.toAddress,
                             tries=old.tries,
                             status=UNSENT)
コード例 #40
0
ファイル: website.py プロジェクト: rcarmo/divmod.org
        hitCount = integer(default=0),
        installedOn = reference(),
        portNumber = integer(default=0),
        securePortNumber = integer(default=0),
        certificateFile = bytes(default=None),
        httpLog = bytes(default=None)))

def upgradeWebsite3to6(oldSite):
    return _makeSiteConfiguration(3, oldSite, False)
upgrade.registerUpgrader(upgradeWebsite3to6, 'mantissa_web_powerup', 3, 6)

declareLegacyItem(
    WebSite.typeName, 4, dict(
        hitCount=integer(default=0),
        installedOn=reference(),
        hostname=text(default=None),
        portNumber=integer(default=0),
        securePortNumber=integer(default=0),
        certificateFile=bytes(default=0),
        httpLog=bytes(default=None)))

def upgradeWebsite4to6(oldSite):
    return _makeSiteConfiguration(4, oldSite, False)
upgrade.registerUpgrader(upgradeWebsite4to6, 'mantissa_web_powerup', 4, 6)

declareLegacyItem(
    WebSite.typeName, 5, dict(
        hitCount=integer(default=0),
        installedOn=reference(),
        hostname=text(default=None),
        httpLog=bytes(default=None)))
コード例 #41
0
ファイル: test_axiomtypes.py プロジェクト: lvh/txampext
 def test_text(self):
     self._test_typeFor(attributes.text(), amp.Unicode)
コード例 #42
0
ファイル: test_axiomtypes.py プロジェクト: lvh/txampext
 def test_optional(self):
     asAMP = axiomtypes.typeFor(attributes.text(), optional=True)
     self.assertTrue(asAMP.optional)