Makes sense. Thanks. I'll see if I can get it working in JAVA d3developer.com | twitter.com/fractastical | twitter.com/jdietz
On Fri, Apr 23, 2010 at 8:37 AM, Bart Thate <[email protected]> wrote: > On Fri, Apr 23, 2010 at 5:24 PM, Joel Dietz <[email protected]> wrote: > > > > hoi Joel, > > > I have mostly finished a test suite which tests various robot related > > functionality and wanted to add in BlindWavelet. > > > > Unfortunately, I have no idea what the intended usage is. > > > > Can someone explain please? > > Best is to look at the code itself, i'll paste it here (in > waveapi/robot.py): > > > def blind_wavelet(self, json, proxy_for_id=None): > """Construct a blind wave from a json string. > > Call this method if you have a snapshot of a wave that you > want to operate on outside of an event. Since the wave might > have changed since you last saw it, you should take care to > submit operations that are as safe as possible. > > Args: > json: a json object or string containing at least a key > wavelet defining the wavelet and a key blips defining the > blips in the view. > > proxy_for_id: the proxying information that will be set on the > wavelet's > operation queue. > > Returns: > A new wavelet with its own operation queue. It the > responsibility of the caller to make sure this wavelet gets > submited to the server, either by calling robot.submit() or > by calling .submit_with() on the returned wavelet. > """ > return self._wavelet_from_json(json, ops.OperationQueue(proxy_for_id)) > > Basically it allows you to create a wavelet based on a json string. > You can save this json when the bot enters a wave and then use it to > send responses to it instead of calling fetch_wavelet() which does > have a round-trip penalty (you need to query the server). > > Hmm after writing this i remembered i hacked the waveapi to hook the > json as received into the event, so i can save it .. > > > def process_events(self, json): > """Process an incoming set of events encoded as json.""" > parsed = simplejson.loads(json) > pending_ops = ops.OperationQueue() > event_wavelet = self._wavelet_from_json(parsed, pending_ops) > > for event_data in parsed['events']: > for payload in self._handlers.get(event_data['type'], []): > handler, event_class, context, filter = payload > event = event_class(event_data, event_wavelet) > event.json = json > handler(event, event_wavelet) > > pending_ops.set_capability_hash(self.capabilities_hash()) > return simplejson.dumps(pending_ops.serialize()) > > Its the event.json = json thing. Maybe i should file a feature request > to include the raw json data into the event. > > Bart > > -- > You received this message because you are subscribed to the Google Groups > "Google Wave API" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-wave-api%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-wave-api?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en.
