File: kiwi.model.PickledModel.html

package info (click to toggle)
kiwi 1.9.22-4
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 11,976 kB
  • ctags: 5,619
  • sloc: python: 15,767; ansic: 193; xml: 77; makefile: 53; sh: 18
file content (267 lines) | stat: -rw-r--r-- 8,477 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>API docs for &ldquo;kiwi.model.PickledModel&rdquo;</title>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
    <link href="apidocs.css" type="text/css" rel="stylesheet" />
    
    
  </head>
  <body>
    <h1 class="class">Class k.m.PickledModel(<a href="kiwi.model.Model.html">Model</a>):</h1>
    <p>
      <span id="part">Part of <a href="kiwi.html">kiwi</a>.<a href="kiwi.model.html">model</a></span>
      
      <a href="classIndex.html#kiwi.model.PickledModel">View In Hierarchy</a>
    </p>
    <div>
      
    </div>
    <div>PickledModel is a model that is able to save itself into a pickle using 
save().  This has all the limitations of a pickle: its instance variables 
must be picklable, or pickle.dump() will raise exceptions. You can prefix 
variables with an underscore to make them non-persistent (and you can 
restore them accordingly by overriding __setstate__, but don't forget to 
call PickledModel.__setstate__)
<table class="fieldTable"></table></div>
    
    
    <div id="splitTables">
      <table class="children sortable" id="id356">
  
  
  
  
  <tr class="method">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.PickledModel.html#__init__">__init__</a></td>
    <td><span class="undocumented">Undocumented</span></td>
  </tr><tr class="method">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.PickledModel.html#__getstate__">__getstate__</a></td>
    <td><span>Gets the state from the instance to be pickled
</span></td>
  </tr><tr class="method">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.PickledModel.html#__setstate__">__setstate__</a></td>
    <td><span>Sets the state to the instance when being unpickled
</span></td>
  </tr><tr class="method">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.PickledModel.html#save">save</a></td>
    <td><span>Saves the instance to a pickle filename. If no filename argument is
</span></td>
  </tr><tr class="method">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.PickledModel.html#set_filename">set_filename</a></td>
    <td><span>Sets the name of the file which will be used to pickle the
</span></td>
  </tr><tr class="classmethod">
    
    
    <td>Class Method</td>
    <td><a href="kiwi.model.PickledModel.html#unpickle">unpickle</a></td>
    <td><span>Loads an instance from a pickle file; if it fails for some reason,
</span></td>
  </tr>
  
</table>
      
        <p>
          Inherited from <a href="kiwi.model.Model.html">Model</a>:
        </p>
        <table class="children sortable" id="id357">
  
  
  
  
  <tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#ensure_init">ensure_init</a></td>
    <td><span>Sets up the variables so the Model's getattr hook and proxy
</span></td>
  </tr><tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#disable_autonotify">disable_autonotify</a></td>
    <td><span>disable automatic notification to proxies based on __setattr__.
</span></td>
  </tr><tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#notify_proxies">notify_proxies</a></td>
    <td><span>Notify proxies that an attribute value has changed.
</span></td>
  </tr><tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#register_proxy_for_attribute">register_proxy_for_attribute</a></td>
    <td><span>Attach a proxy to an attribute. The proxy will be notified of
</span></td>
  </tr><tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#unregister_proxy_for_attribute">unregister_proxy_for_attribute</a></td>
    <td><span>Detach a proxy from an attribute.
</span></td>
  </tr><tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#unregister_proxy">unregister_proxy</a></td>
    <td><span>Deattach a proxy completely from the model
</span></td>
  </tr><tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#flush_proxies">flush_proxies</a></td>
    <td><span>Removes all proxies attached to Model
</span></td>
  </tr><tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#block_proxy">block_proxy</a></td>
    <td><span>Temporarily block a proxy from receiving any notification. See
</span></td>
  </tr><tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#unblock_proxy">unblock_proxy</a></td>
    <td><span>Re-enable notifications to a proxy
</span></td>
  </tr><tr class="basemethod">
    
    
    <td>Method</td>
    <td><a href="kiwi.model.Model.html#__setattr__">__setattr__</a></td>
    <td><span>A special setattr hook that notifies the registered proxies that
</span></td>
  </tr>
  
</table>
      
      
    </div>
    
    
    
    <div class="function">
        <a name="kiwi.model.PickledModel.__init__"></a>
        <a name="__init__"></a>
        <div class="functionHeader">
        
        def __init__(self):
        
      </div>
        <div class="functionBody">
          <div class="interfaceinfo">overrides <a href="kiwi.model.Model.html#__init__">kiwi.model.Model.__init__</a></div>
          <div class="undocumented">Undocumented</div>
        </div>
      </div><div class="function">
        <a name="kiwi.model.PickledModel.__getstate__"></a>
        <a name="__getstate__"></a>
        <div class="functionHeader">
        
        def __getstate__(self):
        
      </div>
        <div class="functionBody">
          
          <div>Gets the state from the instance to be pickled
<table class="fieldTable"></table></div>
        </div>
      </div><div class="function">
        <a name="kiwi.model.PickledModel.__setstate__"></a>
        <a name="__setstate__"></a>
        <div class="functionHeader">
        
        def __setstate__(self, dict):
        
      </div>
        <div class="functionBody">
          
          <div>Sets the state to the instance when being unpickled
<table class="fieldTable"></table></div>
        </div>
      </div><div class="function">
        <a name="kiwi.model.PickledModel.save"></a>
        <a name="save"></a>
        <div class="functionHeader">
        
        def save(self, filename=None):
        
      </div>
        <div class="functionBody">
          
          <div>Saves the instance to a pickle filename. If no filename argument is 
provided, will try to use the internal _filename attribute that is set 
using set_filename()
<table class="fieldTable"><tr class="fieldStart"><td class="fieldName">Parameters</td><td class="fieldArg">filename</td><td>optional filename to pass in
</td></tr></table></div>
        </div>
      </div><div class="function">
        <a name="kiwi.model.PickledModel.set_filename"></a>
        <a name="set_filename"></a>
        <div class="functionHeader">
        
        def set_filename(self, filename):
        
      </div>
        <div class="functionBody">
          
          <div>Sets the name of the file which will be used to pickle the model
<table class="fieldTable"></table></div>
        </div>
      </div><div class="function">
        <a name="kiwi.model.PickledModel.unpickle"></a>
        <a name="unpickle"></a>
        <div class="functionHeader">
        @classmethod<br />
        def unpickle(cls, filename=None):
        
      </div>
        <div class="functionBody">
          
          <div>Loads an instance from a pickle file; if it fails for some reason, 
create a new instance.
<ul>
  <li>
    filename: the file from which the pickle should be loaded. If file 
    is not provided, the name of the class suffixed by &quot;.pickle&quot; 
    is used (i.e.  &quot;FooClass.pickle&quot; for the class FooClass).
  </li>
</ul>
If the pickle file is damaged, it will be saved with the extension 
&quot;.err&quot;; if a file with that name also exists, it will use 
&quot;.err.1&quot; and so on. This is to avoid the damaged file being 
clobbered by an instance calling save() unsuspectingly.
<table class="fieldTable"></table></div>
        </div>
      </div>
    
    <address>
      <a href="index.html">API Documentation</a> for Kiwi, generated by <a href="http://codespeak.net/~mwh/pydoctor/">pydoctor</a> at 2008-05-29 16:06:17.
    </address>
  </body>
</html>