From ae41cc2dd94fa5dc208bda76f13a9fb5d8c514d4 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 22 Jan 2008 19:09:37 +0000 Subject: [PATCH] created a shallow clone method git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1225 9efc2488-bf62-4759-914b-345cdb29e865 --- src/python/osrf/net_obj.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/python/osrf/net_obj.py b/src/python/osrf/net_obj.py index b71ee69..beed013 100644 --- a/src/python/osrf/net_obj.py +++ b/src/python/osrf/net_obj.py @@ -75,6 +75,16 @@ class NetworkObject(object): ''' Returns the registry object for this registered class ''' return self.__class__.registry + def shallow_clone(self): + ''' Makes a shallow copy ''' + reg = self.get_registry() + obj = new_object_from_hint(reg.hint) + for field in reg.keys: + obj.set_field(field, self.get_field(field)) + return obj + + + def new_object_from_hint(hint): ''' Given a hint, this will create a new object of that type and return it. If this hint is not registered, -- 2.43.2