[Twisted-Python] foolscap copyable and constraint

Marco Giusti marco.giusti at gmail.com
Sat Aug 9 05:02:17 EDT 2008

ciao! i'm playing a bit with foolscap and i try to use RemoteInterface
to describe my constraint but i cannot understand how to use it with
pass-by-copy. this is a small example:

    from foolscap import RemoteInterface, registerCopier, \

    class Label:
        def __init__(self, text):
            self.text = text

    def copyLabel(label):
        return ('_Label', {'text': label.text})

    registerCopier(Label, copyLabel)

    def makeLabel(state):
        label = Label(state['text'])
        return label

    registerRemoteCopyFactory('_Label', makeLabel)

    class RITest(RemoteInterface):
        def getLabel():
            return Label

but what i get is:
foolscap.tokens.UnknownSchemaType: can't make constraint from
'__main__.Label' (<type 'classobj'>)

which is the correct way to define a constraint for a third party-class?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20080809/2f9591a5/attachment.pgp 

More information about the Twisted-Python mailing list