All pastes #259211 Raw Edit

Untitled

public text v1 · immutable
#259211 ·published 2006-11-27 06:22 UTC
rendered paste body
# an example use case for the as-yet mythical sugar.garden package.

from sugar.garden import Shared
from sugar.garden import sharedmethod

class SketchPad(Shared):
  @sharedmethod
  def somefunc(self):
    self.someattr = 42;

  def anotherfunc(self):
    self.anotherattr = self.someattr + 1



# I would use the SketchPad object something like this:

# instantiation would automatically set up sharing.  obviously for joining existing activities a different incantation would be necessary.
mysketch = SketchPad()
# since instance operations are decorated, they don't require transaction blocks to be used.
mysketch.somefunc()
mysketch.begintransaction()
mysketch.someattr = 300
mysketc.endtransaction()