Example #1
0
    def test_load_unknown_class(self):
        def class_loader(x):
            return None

        pyamf.register_class_loader(class_loader)

        with self.assertRaises(pyamf.UnknownClassAlias):
            pyamf.load_class('spam.eggs')
Example #2
0
    def test_load_unknown_class(self):
        def class_loader(x):
            return None

        pyamf.register_class_loader(class_loader)

        with self.assertRaises(pyamf.UnknownClassAlias):
            pyamf.load_class('spam.eggs')
Example #3
0
    def test_load_class_by_alias(self):
        def class_loader(x):
            self.assertEquals(x, "spam.eggs")
            return pyamf.ClassAlias(Spam, "spam.eggs")

        pyamf.register_class_loader(class_loader)

        self.assertTrue("spam.eggs" not in pyamf.CLASS_CACHE.keys())
        pyamf.load_class("spam.eggs")
        self.assertTrue("spam.eggs" in pyamf.CLASS_CACHE.keys())
Example #4
0
    def test_load_class_by_alias(self):
        def class_loader(x):
            self.assertEqual(x, 'spam.eggs')
            return pyamf.ClassAlias(Spam, 'spam.eggs')

        pyamf.register_class_loader(class_loader)

        self.assertTrue('spam.eggs' not in pyamf.CLASS_CACHE.keys())
        pyamf.load_class('spam.eggs')
        self.assertTrue('spam.eggs' in pyamf.CLASS_CACHE.keys())
Example #5
0
    def test_load_class_by_alias(self):
        def class_loader(x):
            self.assertEqual(x, 'spam.eggs')
            return pyamf.ClassAlias(Spam, 'spam.eggs')

        pyamf.register_class_loader(class_loader)

        self.assertTrue('spam.eggs' not in pyamf.CLASS_CACHE.keys())
        pyamf.load_class('spam.eggs')
        self.assertTrue('spam.eggs' in pyamf.CLASS_CACHE.keys())
Example #6
0
    def test_load_class(self):
        def class_loader(x):
            self.assertEqual(x, 'spam.eggs')

            return Spam

        pyamf.register_class_loader(class_loader)

        self.assertTrue('spam.eggs' not in list(pyamf.CLASS_CACHE.keys()))
        pyamf.load_class('spam.eggs')
        self.assertTrue('spam.eggs' in list(pyamf.CLASS_CACHE.keys()))
Example #7
0
def loadTable_amf(login, classAlias, filterStr, orderStr):
  table = npi.loadTable(login, classAlias.replace("models.",""), filterStr, orderStr)
  tl = []
  for row in table:
    trow = pyamf.load_class(classAlias).createInstance()
    trow.__dict__ = row
    tl.append(trow)
  return ArrayCollection(tl)
Example #8
0
def loadTable_amf(login, classAlias, filterStr, orderStr):
    table = npi.loadTable(login, classAlias.replace("models.", ""), filterStr,
                          orderStr)
    tl = []
    for row in table:
        trow = pyamf.load_class(classAlias).createInstance()
        trow.__dict__ = row
        tl.append(trow)
    return ArrayCollection(tl)
    def readTypedObject(self):
        """
        Reads an ActionScript object from the stream and attempts to
        'cast' it.

        @see: L{load_class<pyamf.load_class>}
        """
        classname = self.readString()
        alias = pyamf.load_class(classname)

        ret = alias()
        self.context.addObject(ret)
        self._readObject(ret, alias)

        return ret
Example #10
0
    def readTypedObject(self):
        """
        Reads an ActionScript object from the stream and attempts to
        'cast' it.

        @see: L{load_class<pyamf.load_class>}
        """
        classname = self.readString()
        alias = pyamf.load_class(classname)

        ret = alias()
        self.context.addObject(ret)
        self._readObject(ret, alias)

        return ret
Example #11
0
    def readTypedObject(self):
        """
        Reads an ActionScript object from the stream and attempts to
        'cast' it.

        @see: L{load_class<pyamf.load_class>}
        """
        classname = self.readString()
        alias = None

        try:
            alias = pyamf.load_class(classname)

            ret = alias.createInstance()
        except pyamf.UnknownClassAlias:
            if self.strict:
                raise

            ret = pyamf.TypedObject(classname)

        self.context.addObject(ret)
        self._readObject(ret, alias)

        return ret
Example #12
0
    def readTypedObject(self):
        """
        Reads an ActionScript object from the stream and attempts to
        'cast' it.

        @see: L{load_class<pyamf.load_class>}
        """
        classname = self.readString()
        alias = None

        try:
            alias = pyamf.load_class(classname)

            ret = alias.createInstance(codec=self)
        except pyamf.UnknownClassAlias:
            if self.strict:
                raise

            ret = pyamf.TypedObject(classname)

        self.context.addObject(ret)
        self._readObject(ret, alias)

        return ret
Example #13
0
 def load(self, class_alias, key):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).get(key)
Example #14
0
 def test_load_class_by_module(self):
     pyamf.load_class('__builtin__.tuple')
Example #15
0
 def remove(self, class_alias, key):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     obj = session.query(klass).get(key)
     session.delete(obj)
     session.commit()
Example #16
0
 def test_load_class_by_module_bad(self):
     with self.assertRaises(pyamf.UnknownClassAlias):
         pyamf.load_class('__builtin__.tuple.')
Example #17
0
 def test_load_class_by_module_bad(self):
     with self.assertRaises(pyamf.UnknownClassAlias):
         pyamf.load_class('__builtin__.tuple.')
Example #18
0
 def test_load_class_by_module(self):
     pyamf.load_class('__builtin__.tuple')
Example #19
0
 def load(self, class_alias, key):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).get(key)
Example #20
0
 def loadAll(self, class_alias):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).all()
Example #21
0
 def loadAll(self, class_alias):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     return session.query(klass).all()
Example #22
0
 def remove(self, class_alias, key):
     klass = pyamf.load_class(class_alias).klass
     session = Schema().session
     obj = session.query(klass).get(key)
     session.delete(obj)
     session.commit()