This repository was archived by the owner on Mar 23, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-16
lines changed
Expand file tree Collapse file tree 1 file changed +7
-16
lines changed Original file line number Diff line number Diff line change @@ -145,10 +145,9 @@ class Document(object):
145145 def __init__ (self , client , did ):
146146 self .client = client
147147 self .did = did
148- self .urls = None
149- self .sha1 = None
150148 self ._fetched = False
151149 self ._deleted = False
150+ self ._doc = None
152151 self .refresh ()
153152
154153 def _check_deleted (self ):
@@ -159,14 +158,7 @@ def _render(self, include_rev=True):
159158 self ._check_deleted ()
160159 if not self ._fetched :
161160 raise RuntimeError ("Document must be fetched from server with doc.refresh() before being rendered as json" )
162- json = {
163- "urls" : self .urls ,
164- "hashes" : self .hashes ,
165- "size" : self .size
166- }
167- if include_rev :
168- json ["rev" ] = self .rev
169- return json
161+ return self ._doc
170162
171163 def to_json (self , include_rev = True ):
172164 json = self ._render (include_rev = include_rev )
@@ -176,12 +168,11 @@ def to_json(self, include_rev=True):
176168 def refresh (self ):
177169 """refresh the document contents from the server"""
178170 self ._check_deleted ()
179- json = self .client ._get ("index" , self .did ).json ()
180- assert json ["did" ] == self .did
181- self .urls = json ["urls" ]
182- self .rev = json ["rev" ]
183- self .size = json ["size" ]
184- self .hashes = json ["hashes" ]
171+ response = self .client ._get ("index" , self .did ).json ()
172+ self ._doc = response
173+ # set attributes to current Document
174+ for k ,v in response .iteritems ():
175+ self .__dict__ [k ] = v
185176 self ._fetched = True
186177
187178 def patch (self ):
You can’t perform that action at this time.
0 commit comments