Exemplo n.º 1
0
    def test_serialize_path(self):
        users, addresses = (self.tables.users,
                                self.tables.addresses)

        umapper = mapper(User, users, properties={
            'addresses':relationship(Address, backref="user")
        })
        amapper = mapper(Address, addresses)

        # this is a "relationship" path with mapper, key, mapper, key
        p1 = (umapper, 'addresses', amapper, 'email_address')
        eq_(
            interfaces.deserialize_path(interfaces.serialize_path(p1)),
            p1
        )

        # this is a "mapper" path with mapper, key, mapper, no key
        # at the end.
        p2 = (umapper, 'addresses', amapper, )
        eq_(
            interfaces.deserialize_path(interfaces.serialize_path(p2)),
            p2
        )

        # test a blank path
        p3 = ()
        eq_(
            interfaces.deserialize_path(interfaces.serialize_path(p3)),
            p3
        )
Exemplo n.º 2
0
 def __getstate__(self):
     return {
         'instance': self.instance,
         'key': self.key,
         'options': self.options,
         'path': serialize_path(self.path)
     }
Exemplo n.º 3
0
    def __getstate__(self):
        d = {'instance': self.obj()}

        d.update((k, self.__dict__[k])
                 for k in ('committed_state', 'pending', 'parents', 'modified',
                           'expired', 'callables', 'key', 'load_options',
                           'mutable_dict') if k in self.__dict__)
        if self.load_path:
            d['load_path'] = interfaces.serialize_path(self.load_path)
        return d
Exemplo n.º 4
0
 def __getstate__(self):
     d = {
         "instance": self.obj(),
         "class_": self.class_,
         "load_options": self.load_options,
         "load_path": self.load_path,
     }
     if self.load_path:
         d['load_path'] = interfaces.serialize_path(self.load_path)
     return d
Exemplo n.º 5
0
 def __getstate__(self):
     d = {
         "instance": self.obj(),
         "class_": self.class_,
         "load_options": self.load_options,
         "load_path": self.load_path,
     }
     if self.load_path:
         d['load_path'] = interfaces.serialize_path(self.load_path)
     return d
Exemplo n.º 6
0
    def __getstate__(self):
        d = {'instance':self.obj()}

        d.update(
            (k, self.__dict__[k]) for k in (
                'committed_state', 'pending', 'parents', 'modified', 'expired', 
                'callables', 'key', 'load_options', 'mutable_dict'
            ) if k in self.__dict__ 
        )
        if self.load_path:
            d['load_path'] = interfaces.serialize_path(self.load_path)
        return d
Exemplo n.º 7
0
    def __getstate__(self):
        d = {"instance": self.obj()}

        d.update(
            (k, self.__dict__[k])
            for k in ("committed_state", "pending", "parents", "modified", "expired", "callables")
            if self.__dict__[k]
        )

        d.update(
            (k, self.__dict__[k])
            for k in ("key", "load_options", "expired_attributes", "mutable_dict")
            if k in self.__dict__
        )
        if self.load_path:
            d["load_path"] = interfaces.serialize_path(self.load_path)
        return d
Exemplo n.º 8
0
    def __getstate__(self):
        d = {"instance": self.obj()}
        d.update(
            (k, self.__dict__[k])
            for k in (
                "committed_state",
                "pending",
                "modified",
                "expired",
                "callables",
                "key",
                "parents",
                "load_options",
                "mutable_dict",
                "class_",
            )
            if k in self.__dict__
        )
        if self.load_path:
            d["load_path"] = interfaces.serialize_path(self.load_path)

        self.manager.dispatch.pickle(self, d)

        return d
Exemplo n.º 9
0
 def __getstate__(self):
     return (self.state, self.key, self.options, serialize_path(self.path))
Exemplo n.º 10
0
 def __getstate__(self):
     return {'instance':self.instance, 'key':self.key, 'options':self.options, 'path':serialize_path(self.path)}
Exemplo n.º 11
0
 def __getstate__(self):
     return (self.state, self.key, self.options, serialize_path(self.path))