Show More
@@ -554,13 +554,17 b' class bundlepart(object):' | |||||
554 |
|
554 | |||
555 | The part `type` is used to route the part to the application level |
|
555 | The part `type` is used to route the part to the application level | |
556 | handler. |
|
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 | def __init__(self, parttype, mandatoryparams=(), advisoryparams=(), |
|
563 | def __init__(self, parttype, mandatoryparams=(), advisoryparams=(), | |
560 | data=''): |
|
564 | data=''): | |
561 | self.id = None |
|
565 | self.id = None | |
562 | self.type = parttype |
|
566 | self.type = parttype | |
563 | self.data = data |
|
567 | self._data = data | |
564 | self.mandatoryparams = mandatoryparams |
|
568 | self.mandatoryparams = mandatoryparams | |
565 | self.advisoryparams = advisoryparams |
|
569 | self.advisoryparams = advisoryparams | |
566 | # status of the part's generation: |
|
570 | # status of the part's generation: | |
@@ -569,6 +573,15 b' class bundlepart(object):' | |||||
569 | # - True: generation done. |
|
573 | # - True: generation done. | |
570 | self._generated = None |
|
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 | # methods used to generates the bundle2 stream |
|
585 | # methods used to generates the bundle2 stream | |
573 | def getchunks(self): |
|
586 | def getchunks(self): | |
574 | if self._generated is not None: |
|
587 | if self._generated is not None: |
@@ -84,8 +84,9 b' Create an extension to test bundle2 API' | |||||
84 | > bundler.newpart('b2x:replycaps', data=capsstring) |
|
84 | > bundler.newpart('b2x:replycaps', data=capsstring) | |
85 | > |
|
85 | > | |
86 | > if opts['pushrace']: |
|
86 | > if opts['pushrace']: | |
87 | > dummynode = '01234567890123456789' |
|
87 | > # also serve to test the assignement of data outside of init | |
88 |
> bundler.newpart('b2x:check:heads' |
|
88 | > part = bundler.newpart('b2x:check:heads') | |
|
89 | > part.data = '01234567890123456789' | |||
89 | > |
|
90 | > | |
90 | > revs = opts['rev'] |
|
91 | > revs = opts['rev'] | |
91 | > if 'rev' in opts: |
|
92 | > if 'rev' in opts: |
General Comments 0
You need to be logged in to leave comments.
Login now