File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -581,7 +581,7 @@ def clean(self):
581581 for i in self :
582582 i .clean ()
583583
584- def clone (self , children = True ):
584+ def clone (self , children = True , keep_id = False ):
585585 """
586586 Clone this object recursively allowing to copy it independently
587587 to another document
@@ -592,7 +592,7 @@ def clone(self, children=True):
592592 obj ._sections = SmartList (BaseSection )
593593 if children :
594594 for s in self ._sections :
595- obj .append (s .clone ())
595+ obj .append (s .clone (keep_id = keep_id ))
596596
597597 return obj
598598
Original file line number Diff line number Diff line change @@ -390,18 +390,26 @@ def remove(self, obj):
390390 else :
391391 raise ValueError ("Can only remove sections and properties" )
392392
393- def clone (self , children = True ):
393+ def clone (self , children = True , keep_id = False ):
394394 """
395- Clone this object recursively allowing to copy it independently
396- to another document
395+ Clone this Section allowing to copy it independently
396+ to another document. By default the id of any cloned
397+ object will be set to a new uuid.
398+
399+ :param children: If True, also clone child sections and properties
400+ recursively.
401+ :param keep_id: If this attribute is set to True, the uuids of the
402+ Section and all child objects will remain unchanged.
403+ :return: The cloned Section.
397404 """
398- obj = super (BaseSection , self ).clone (children )
399- obj .new_id ()
405+ obj = super (BaseSection , self ).clone (children , keep_id )
406+ if not keep_id :
407+ obj .new_id ()
400408
401409 obj ._props = base .SmartList (BaseProperty )
402410 if children :
403411 for p in self ._props :
404- obj .append (p .clone ())
412+ obj .append (p .clone (keep_id ))
405413
406414 return obj
407415
You can’t perform that action at this time.
0 commit comments