##// END OF EJS Templates
bundle2: the ability to set ``data`` attribute of the part is now official...
Pierre-Yves David -
r21604:c399bf96 default
parent child Browse files
Show More
@@ -554,13 +554,17 class bundlepart(object):
554 554
555 555 The part `type` is used to route the part to the application level
556 556 handler.
557
558 The part payload is contained in ``part.data``. It could be raw bytes or a
559 generator of byte chunks. The data attribute cannot be modified after the
560 generation has begun.
557 561 """
558 562
559 563 def __init__(self, parttype, mandatoryparams=(), advisoryparams=(),
560 564 data=''):
561 565 self.id = None
562 566 self.type = parttype
563 self.data = data
567 self._data = data
564 568 self.mandatoryparams = mandatoryparams
565 569 self.advisoryparams = advisoryparams
566 570 # status of the part's generation:
@@ -569,6 +573,15 class bundlepart(object):
569 573 # - True: generation done.
570 574 self._generated = None
571 575
576 # methods used to defines the part content
577 def __setdata(self, data):
578 if self._generated is not None:
579 raise ReadOnlyPartError('part is being generated')
580 self._data = data
581 def __getdata(self):
582 return self._data
583 data = property(__getdata, __setdata)
584
572 585 # methods used to generates the bundle2 stream
573 586 def getchunks(self):
574 587 if self._generated is not None:
@@ -84,8 +84,9 Create an extension to test bundle2 API
84 84 > bundler.newpart('b2x:replycaps', data=capsstring)
85 85 >
86 86 > if opts['pushrace']:
87 > dummynode = '01234567890123456789'
88 > bundler.newpart('b2x:check:heads', data=dummynode)
87 > # also serve to test the assignement of data outside of init
88 > part = bundler.newpart('b2x:check:heads')
89 > part.data = '01234567890123456789'
89 90 >
90 91 > revs = opts['rev']
91 92 > if 'rev' in opts:
General Comments 0
You need to be logged in to leave comments. Login now