OLD | NEW |
1 # Copyright (c) 2006-2008 Mitch Garnaat http://garnaat.org/ | 1 # Copyright (c) 2006-2008 Mitch Garnaat http://garnaat.org/ |
2 # | 2 # |
3 # Permission is hereby granted, free of charge, to any person obtaining a | 3 # Permission is hereby granted, free of charge, to any person obtaining a |
4 # copy of this software and associated documentation files (the | 4 # copy of this software and associated documentation files (the |
5 # "Software"), to deal in the Software without restriction, including | 5 # "Software"), to deal in the Software without restriction, including |
6 # without limitation the rights to use, copy, modify, merge, publish, dis- | 6 # without limitation the rights to use, copy, modify, merge, publish, dis- |
7 # tribute, sublicense, and/or sell copies of the Software, and to permit | 7 # tribute, sublicense, and/or sell copies of the Software, and to permit |
8 # persons to whom the Software is furnished to do so, subject to the fol- | 8 # persons to whom the Software is furnished to do so, subject to the fol- |
9 # lowing conditions: | 9 # lowing conditions: |
10 # | 10 # |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 prop_node.appendChild(items_node) | 402 prop_node.appendChild(items_node) |
403 for item in items: | 403 for item in items: |
404 item_node = doc.createElement('item') | 404 item_node = doc.createElement('item') |
405 items_node.appendChild(item_node) | 405 items_node.appendChild(item_node) |
406 if isinstance(item, Node): | 406 if isinstance(item, Node): |
407 item_node.appendChild(item) | 407 item_node.appendChild(item) |
408 else: | 408 else: |
409 text_node = doc.createTextNode(item) | 409 text_node = doc.createTextNode(item) |
410 item_node.appendChild(text_node) | 410 item_node.appendChild(text_node) |
411 | 411 |
412 def save_object(self, obj): | 412 def save_object(self, obj, expected_value=None): |
413 """ | 413 """ |
414 Marshal the object and do a PUT | 414 Marshal the object and do a PUT |
415 """ | 415 """ |
416 doc = self.marshal_object(obj) | 416 doc = self.marshal_object(obj) |
417 if obj.id: | 417 if obj.id: |
418 url = "/%s/%s" % (self.db_name, obj.id) | 418 url = "/%s/%s" % (self.db_name, obj.id) |
419 else: | 419 else: |
420 url = "/%s" % (self.db_name) | 420 url = "/%s" % (self.db_name) |
421 resp = self._make_request("PUT", url, body=doc.toxml()) | 421 resp = self._make_request("PUT", url, body=doc.toxml()) |
422 new_obj = self.get_object_from_doc(obj.__class__, None, parse(resp)) | 422 new_obj = self.get_object_from_doc(obj.__class__, None, parse(resp)) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 508 |
509 def get_property(self, prop, obj, name): | 509 def get_property(self, prop, obj, name): |
510 pass | 510 pass |
511 | 511 |
512 def load_object(self, obj): | 512 def load_object(self, obj): |
513 if not obj._loaded: | 513 if not obj._loaded: |
514 obj = obj.get_by_id(obj.id) | 514 obj = obj.get_by_id(obj.id) |
515 obj._loaded = True | 515 obj._loaded = True |
516 return obj | 516 return obj |
517 | 517 |
OLD | NEW |