Show More
@@ -49,9 +49,10 b' else:' | |||||
49 |
|
49 | |||
50 |
|
50 | |||
51 | class CannedObject(object): |
|
51 | class CannedObject(object): | |
52 | def __init__(self, obj, keys=[]): |
|
52 | def __init__(self, obj, keys=[], hook=None): | |
53 | self.keys = keys |
|
53 | self.keys = keys | |
54 | self.obj = copy.copy(obj) |
|
54 | self.obj = copy.copy(obj) | |
|
55 | self.hook = can(hook) | |||
55 | for key in keys: |
|
56 | for key in keys: | |
56 | setattr(self.obj, key, can(getattr(obj, key))) |
|
57 | setattr(self.obj, key, can(getattr(obj, key))) | |
57 |
|
58 | |||
@@ -60,8 +61,13 b' class CannedObject(object):' | |||||
60 | def get_object(self, g=None): |
|
61 | def get_object(self, g=None): | |
61 | if g is None: |
|
62 | if g is None: | |
62 | g = {} |
|
63 | g = {} | |
|
64 | obj = self.obj | |||
63 | for key in self.keys: |
|
65 | for key in self.keys: | |
64 |
setattr( |
|
66 | setattr(obj, key, uncan(getattr(obj, key), g)) | |
|
67 | ||||
|
68 | if self.hook: | |||
|
69 | self.hook = uncan(self.hook, g) | |||
|
70 | self.hook(obj, g) | |||
65 | return self.obj |
|
71 | return self.obj | |
66 |
|
72 | |||
67 |
|
73 |
General Comments 0
You need to be logged in to leave comments.
Login now