[Twisted-Python] Generalised data/metadata storage/retrieval

Jp Calderone exarkun at meson.dyndns.org
Wed Aug 28 16:45:33 EDT 2002


Interface description attached.  Written in response to glyph's comments
that Twisted.news was waaay too NNTPy.  Suggestions and other comments
appreciated.

-- 
Seduced, shaggy Samson snored.
She scissored short.  Sorely shorn,
Soon shackled slave, Samson sighed,
Silently scheming,
Sightlessly seeking
Some savage, spectacular suicide.
                -- Stanislaw Lem, "Cyberiad"
--
 4:00pm up 99 days, 16:51, 5 users, load average: 0.11, 0.13, 0.09
-------------- next part --------------


class NewsStorage:
    """
    A generic interface to metadata/data pairs
    """


    def lookupByHeader(self, predicate, max = 1):
        """
        Search for a message by examining its headers.  'predicate' 
        is called with a mapping of header name/values.  If it returns
        a true value, the Message-ID of the message is added to the
        result list.  When the result list is 'max' items long, or
        there are no more articles, it is returned.  If 'max' is None,
        it is disregarded.
        """


    def searchHeaders(self, predicate, max = None):
        """
        Collect a list of headers.  'predicate' is called with a mapping
        of header name/values.  If it returns something other than None,
        that object is added to the result list.  When the result list is
        'max' items long, or there are no more articles, it is returned.
        If 'max' is None, it is disregarded.
        """


    def lookupByBody(self, predicate, max = 1):
        """
        Search by a message by examining its body.  'predicate'
        is passed the body of each message in the database.  If
        it returns a true value, the Message-ID of  the message
        is added to the result list.  When the result list is
        'max' items long, or there are no more articles, it is
        returned.  If 'max' is None, it is disregarded.
        """


    def lookupByID(self, id):
        """
        Return the headers and body for the article with the specified
        Message-ID.
        """


    def insertMessage(self, headers, body):
        """
        Insert a new message.  'header' is a mapping of header name/values.
        If it does not contain a 'Message-ID' header one will be added.  If
        the Message-ID is already assigned 
        """


    def removeMessage(self, id):
        """
        Remove the message with the specified Message-ID
        """
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 237 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20020828/1b56f943/attachment.pgp 


More information about the Twisted-Python mailing list