--
You received this message because you are subscribed to the Google Groups "meteor-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
$ pip install python-meteor -U
from MeteorClient import MeteorClient
client = MeteorClient('ws://127.0.0.1:3000/websocket')
def subscribed(subscription):
print '* SUBSCRIBED {}'.format(subscription)
def unsubscribed(subscription):
print '* UNSUBSCRIBED {}'.format(subscription)
def added(collection, id, fields):
print '* ADDED {} {}'.format(collection, id)
for key, value in fields.items():
print ' - FIELD {} {}'.format(key, value)
def connected():
print '* CONNECTED'
def subscription_callback(error):
if error:
print error
client.on('subscribed', subscribed)
client.on('unsubscribed', unsubscribed)
client.on('added', added)
client.on('connected', connected)
client.connect()
client.subscribe('lists')
client.subscribe('todos')
print client, client.__dict__, client.collection_data.data
all_lists = client.find('lists', selector={})
all_todos = client.find('todos', selector={})
print all_lists, all_todos
client.unsubscribe('lists')
client.unsubscribe('todos')
---output---
(py27env)Daxs-MacBook-Pro:util dax$ python sample_todo_ddp.py
* CONNECTED
<MeteorClient.MeteorClient object at 0x10f86c750> {'ddp_client': <DDPClient.DDPClient object at 0x10f86c7d0>, 'connected': True, '_events': defaultdict(<function <lambda> at 0x10f862c08>, {'added': [<function added at 0x10f86eaa0>], 'connected': [<function connected at 0x10f86eb18>], 'new_listener': [], 'subscribed': [<function subscribed at 0x10f86e9b0>], 'unsubscribed': [<function unsubscribed at 0x10f86ea28>]}), 'collection_data': <MeteorClient.CollectionData object at 0x10f86c790>, 'subscriptions': {'todos': '2', 'lists': '1'}} {}
[] []
* UNSUBSCRIBED lists
* UNSUBSCRIBED todos
Exception in thread WebSocketClient (most likely raised during interpreter shutdown):
Thanks,
Dax
Modified your example, added sqlalchemy and saved to an sqlite database the lists collection. So far data flow is just one way, meteor/mongo -> sqlalchemy/sqlite.I am currently looking at what others have done regarding integrating python apps and meteor.Thanks a lot for python-meteor!
On Wed, Jul 2, 2014 at 11:57 PM, Harrison Harnisch <hhar...@gmail.com> wrote:
That's awesome! I'm excited to see what you come up with, sounds worthy of a lightning talk when you get something going.
On Wednesday, July 2, 2014 8:38:42 AM UTC-7, Dax wrote:
The updated example works great! thanks a bunch.Next will try experimenting on including some sqlalchemy/django orm code
On Wed, Jul 2, 2014 at 9:40 AM, Harrison Harnisch <hhar...@gmail.com> wrote:
I played around with your example a bit (see below)
There's still an exception thrown if you try to do anything with the client after the while loop (like unsubscibe). I'll have to put some more work into getting the websocket to close out gracefully. But you should still be able to get the python logic flushed out in the mean time. Let me know how this works out for you!
from MeteorClient import MeteorClient
--
You received this message because you are subscribed to the Google Groups "meteor-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "meteor-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "meteor-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "meteor-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meteor-talk/JLr1Ho_y3vE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<meteor2sqlite.py>