FYI: The same example implemented using the db.Model methods would
look something like the following:
class StockTopic(db.Model):
symbol = db.StringProperty()
price = db.FloatProperty()
matcher.subscribe(StockTopic, "symbol:GOOG AND price > 500 AND price <
525", "ikai:GOOG")
# Wait some small amount of time for the subscription to become active
and then:
quote = StockTopic()
quote.symbol = "GOOG"
quote.price = 515.0
matcher.match(quote)
The neat thing about this is that, if you wanted to, you could then
just do quote.put() to insert the message into datastore. (Which might
not make sense for a stock price alerting app, but *would* make sense
for many other applications.
bob wyman
On Oct 20, 7:12 pm, "Ikai Lan (Google)" <
ikai.l+gro...@google.com>
wrote:
> I need to post a correction to my early example. Here's the code you should
> use:
>
> # First, define a schema for our StockTopic
> schema = {str: ["symbol"], float: ["price"]}
> matcher.subscribe(dict,
> "symbol:GOOG AND price > 500 AND price < 525",
> "ikai:GOOG",
> schema=schema,
> topic="StockTopic")
>
> # Note: A subscription is active if the state returned by list
> is: matcher.SubscriptionState.OK
> # After waiting for the subscription to become active, you can do the
> following:
>
> change = { "symbol" : "GOOG", "price" : 515.0 }
> matcher.match(change, topic="StockTopic")
>
> The reason you need to use this code is because you can't just pass an
> arbitrary dictionary. You need to register a schema to be used if you don't
> use a db.Model as the first argument to matcher.subscribe(), and you need to
> pass it to the subscribe() method.
>
> Note that the subscription needs to become active. This isn't instantaneous,
> but it's pretty darned fast.
>
> Anyway, here's the trusted tester signup link for anyone that didn't catch
> it:
>
>
https://spreadsheets.google.com/a/google.com/viewform?hl=en&formkey=d...
> <
ikai.l+gro...@google.com<
ikai.l%2Bgro...@google.com>
> > On Tue, Oct 19, 2010 at 7:27 PM, MasterGaurav <
gaurav.va...@gmail.com>wrote:
>
> >> Hi Ikai,
>
> >> That's a fantastic news!
>
> >> btw wondering if "processing pipeline" architecture is somewhere down
> >> the line in the roadmap?
> >> I have been working with FAST and OpenPipe, to name a couple, for
> >> document processing... and it will be great to have such a feature
> >> incorporated. Is something in roadmap yet? Or any visbility on the
> >> same?
>
> >> -Gaurav
> >>
www.mastergaurav.com
>
> >> On Oct 20, 5:36 am, "Ikai Lan (Google)" <
ikai.l+gro...@google.com<
ikai.l%2Bgro...@google.com>
> >>
ikai.l%2Bgro...@google.com <
ikai.l%252Bgro...@google.com>>
> ...
>
> read more »