Example #1
0
    def getAttributes(self, obj):
        """
        Returns a collection of attributes for an object
        Returns a C{tuple} containing a dict of static and dynamic attributes
        for C{obj}
        """
        dynamic_attrs = {}
        static_attrs = {}
        static_attr_names, dynamic_attr_names = self.getAttrs(obj)

        if static_attr_names is None and dynamic_attr_names is None:
            dynamic_attrs = util.get_attrs(obj)

        if static_attr_names is not None:
            for attr in static_attr_names:
                if hasattr(obj, attr):
                    static_attrs[attr] = getattr(obj, attr)
                else:
                    static_attrs[attr] = Undefined

        if dynamic_attr_names is not None:
            for attr in dynamic_attr_names:
                if attr in static_attrs:
                    continue

                if hasattr(obj, attr):
                    dynamic_attrs[attr] = getattr(obj, attr)

        return (static_attrs, dynamic_attrs)
Example #2
0
    def getAttributes(self, obj, codec=None):
        """
        Returns a collection of attributes for an object.
        Returns a C{tuple} containing a dict of static and dynamic attributes

        @param codec: An optional argument that will contain the en/decoder
            instance calling this function.
        """
        dynamic_attrs = {}
        static_attrs = {}
        static_attr_names, dynamic_attr_names = self.getAttrs(obj, codec=codec)

        if static_attr_names is None and dynamic_attr_names is None:
            dynamic_attrs = util.get_attrs(obj)

        if static_attr_names is not None:
            for attr in static_attr_names:
                if hasattr(obj, attr):
                    static_attrs[attr] = getattr(obj, attr)
                else:
                    static_attrs[attr] = Undefined

        if dynamic_attr_names is not None:
            for attr in dynamic_attr_names:
                if attr in static_attrs:
                    continue

                if hasattr(obj, attr):
                    dynamic_attrs[attr] = getattr(obj, attr)

        return (static_attrs, dynamic_attrs)
Example #3
0
    def getAttributes(self, obj):
        """
        Returns a collection of attributes for an object
        Returns a C{tuple} containing a dict of static and dynamic attributes
        for C{obj}
        """
        dynamic_attrs = {}
        static_attrs = {}
        static_attr_names, dynamic_attr_names = self.getAttrs(obj)

        if static_attr_names is None and dynamic_attr_names is None:
            dynamic_attrs = util.get_attrs(obj)

        if static_attr_names is not None:
            for attr in static_attr_names:
                if hasattr(obj, attr):
                    static_attrs[attr] = getattr(obj, attr)
                else:
                    static_attrs[attr] = Undefined

        if dynamic_attr_names is not None:
            for attr in dynamic_attr_names:
                if attr in static_attrs:
                    continue

                if hasattr(obj, attr):
                    dynamic_attrs[attr] = getattr(obj, attr)

        return (static_attrs, dynamic_attrs)
Example #4
0
    def _getObjectAttrs(self, o, alias):
        obj_attrs = None

        if alias is not None:
            attrs = alias.getAttrs(o)

            if attrs is not None:
                obj_attrs = {}

                for at in attrs:
                    obj_attrs[at] = getattr(o, at)

        if obj_attrs is None:
            obj_attrs = util.get_attrs(o)

        if obj_attrs is None:
            raise pyamf.EncodeError('Unable to determine object attributes')

        return obj_attrs
Example #5
0
    def _getObjectAttrs(self, o, alias):
        """
        @raise pyamf.EncodeError: Unable to determine object attributes.
        """
        obj_attrs = None

        if alias is not None:
            obj_attrs = {}

            for attrs in alias.getAttributes(o, codec=self):
                obj_attrs.update(attrs)

        if obj_attrs is None:
            obj_attrs = util.get_attrs(o)

        if obj_attrs is None:
            raise pyamf.EncodeError("Unable to determine object attributes")

        return obj_attrs
Example #6
0
    def _getObjectAttrs(self, o, alias):
        obj_attrs = None

        if alias is not None:
            attrs = alias.getAttrs(o)

            if attrs is not None:
                obj_attrs = {}

                for at in attrs:
                    obj_attrs[at] = getattr(o, at)

        if obj_attrs is None:
            obj_attrs = util.get_attrs(o)

        if obj_attrs is None:
            raise pyamf.EncodeError('Unable to determine object attributes')

        return obj_attrs
Example #7
0
    def _getObjectAttrs(self, o, alias):
        """
        @raise pyamf.EncodeError: Unable to determine object attributes.
        """
        obj_attrs = None

        if alias is not None:
            obj_attrs = {}

            for attrs in alias.getAttributes(o):
                obj_attrs.update(attrs)

        if obj_attrs is None:
            obj_attrs = util.get_attrs(o)

        if obj_attrs is None:
            raise pyamf.EncodeError('Unable to determine object attributes')

        return obj_attrs