Пример #1
0
 def insertRow(self, rowObject):
     """insert a new row for this object instance. do not include the "container" attribute.
     """
     proxy = XMLRowProxy(rowObject)
     filename = self.makeFilenameFor(rowObject)
     f = open(filename,"w")
     marmalade.jellyToXML(proxy, f)
     f.close()
     return defer.succeed(1)
Пример #2
0
 def insertRow(self, rowObject):
     """insert a new row for this object instance. do not include the "container" attribute.
     """
     proxy = XMLRowProxy(rowObject)
     filename = self.makeFilenameFor(rowObject)
     f = open(filename,"w")
     marmalade.jellyToXML(proxy, f)
     f.close()
     return defer.succeed(1)
Пример #3
0
 def testMarmaladeable(self):
     m = Marmaladeable(1, B(), "testing", [1, 2, 3])
     s = marmalade.jellyToXML(m)
     u = marmalade.unjellyFromXML(s)
     assert u.sequence == [u.instance, u.instance]
     u.sequence.append(u.instance)
     u.jellyDOMVersion = 2
     s2 = marmalade.jellyToXML(u)
     u2 = marmalade.unjellyFromXML(s2)
     self.assertEquals( u2.sequence,  [u2.instance, u2.instance, u2.instance])
Пример #4
0
 def testMarmaladeable(self):
     m = Marmaladeable(1, B(), "testing", [1, 2, 3])
     s = marmalade.jellyToXML(m)
     u = marmalade.unjellyFromXML(s)
     assert u.sequence == [u.instance, u.instance]
     u.sequence.append(u.instance)
     u.jellyDOMVersion = 2
     s2 = marmalade.jellyToXML(u)
     u2 = marmalade.unjellyFromXML(s2)
     self.assertEquals( u2.sequence,  [u2.instance, u2.instance, u2.instance])
Пример #5
0
 def testMethodSelfIdentity(self):
     a = A()
     b = B()
     a.bmethod = b.bmethod
     b.a = a
     im_ = marmalade.unjellyFromXML(marmalade.jellyToXML(b)).a.bmethod
     self.assertEquals(im_.im_class, im_.im_self.__class__)
Пример #6
0
 def testMethodSelfIdentity(self):
     a = A()
     b = B()
     a.bmethod = b.bmethod
     b.a = a
     im_ = marmalade.unjellyFromXML(marmalade.jellyToXML(b)).a.bmethod
     self.assertEquals(im_.im_class, im_.im_self.__class__)
Пример #7
0
 def test_unjellyUnknownNodeType(self):
     """
     L{marmalade.unjellyFromXML} should raise a C{TypeError} when trying
     to unjelly an unknown type.
     """
     data = marmalade.jellyToXML({})
     data = data.replace('dictionary', 'unknowntype')
     self.assertRaises(TypeError, marmalade.unjellyFromXML, data)
Пример #8
0
 def test_unjellyWrongRole(self):
     """
     When trying to unjelly a dictionnary dump, C{role} attributes
     should have the C{key}. Otherwise, L{marmalade.unjellyFromXML}
     should raise a C{TypeError}.
     """
     data = marmalade.jellyToXML({"a": 1})
     data = data.replace('role="key"', 'role="foo"')
     self.assertRaises(TypeError, marmalade.unjellyFromXML, data)
Пример #9
0
 def test_methodNotSelfIdentity(self):
     """
     If a class change after an instance has been created,
     L{marmalade.unjellyFromXML} shoud raise a C{TypeError} when trying
     to unjelly the instance.
     """
     a = A()
     b = B()
     a.bmethod = b.bmethod
     b.a = a
     savedbmethod = B.bmethod
     del B.bmethod
     try:
         self.assertRaises(TypeError, marmalade.unjellyFromXML,
                           marmalade.jellyToXML(b))
     finally:
         B.bmethod = savedbmethod
Пример #10
0
 def testBasicIdentity(self):
     dj = marmalade.DOMJellier().jellyToNode
     d = {'hello': 'world', "method": dj}
     l = [1, 2, 3,
          "he\tllo\n\n\"x world!",
          u"goodbye \n\t\u1010 world!",
          1, 1.0, 100 ** 100l, unittest, marmalade.DOMJellier, d,
          funktion,
          True, False,
          (2, 4, [2]),
          ]
     t = tuple(l)
     l.append(l)
     l.append(t)
     l.append(t)
     uj = marmalade.unjellyFromXML(marmalade.jellyToXML([l, l]))
     assert uj[0] is uj[1]
     assert uj[1][0:5] == l[0:5]
Пример #11
0
 def testBasicIdentity(self):
     # Anyone wanting to make this datastructure more complex, and thus this
     # test more comprehensive, is welcome to do so.
     dj = marmalade.DOMJellier().jellyToNode
     d = {'hello': 'world', "method": dj}
     l = [1, 2, 3,
          "he\tllo\n\n\"x world!",
          u"goodbye \n\t\u1010 world!",
          1, 1.0, 100 ** 100l, unittest, marmalade.DOMJellier, d,
          funktion
          ]
     t = tuple(l)
     l.append(l)
     l.append(t)
     l.append(t)
     uj = marmalade.unjellyFromXML(marmalade.jellyToXML([l, l]))
     assert uj[0] is uj[1]
     assert uj[1][0:5] == l[0:5]
Пример #12
0
 def testBasicIdentity(self):
     # Anyone wanting to make this datastructure more complex, and thus this
     # test more comprehensive, is welcome to do so.
     dj = marmalade.DOMJellier().jellyToNode
     d = {'hello': 'world', "method": dj}
     l = [1, 2, 3,
          "he\tllo\n\n\"x world!",
          u"goodbye \n\t\u1010 world!",
          1, 1.0, 100 ** 100l, unittest, marmalade.DOMJellier, d,
          funktion,
          True, False,
          (2, 4, [2]),
          ]
     t = tuple(l)
     l.append(l)
     l.append(t)
     l.append(t)
     uj = marmalade.unjellyFromXML(marmalade.jellyToXML([l, l]))
     assert uj[0] is uj[1]
     assert uj[1][0:5] == l[0:5]
Пример #13
0
 def testCopyReg(self):
     s = "foo_bar"
     sio = StringIO.StringIO()
     sio.write(s)
     assert marmalade.unjellyFromXML(marmalade.jellyToXML({1:sio}))[1].getvalue() == s
Пример #14
0
 def testCopyReg(self):
     s = "foo_bar"
     sio = StringIO.StringIO()
     sio.write(s)
     assert marmalade.unjellyFromXML(marmalade.jellyToXML({1:sio}))[1].getvalue() == s