Can anyone please post a Python example that demonstrates the use of a request/response messaging model that utilizes the zeromq queue?.
I have done a lot of online searching but have not as yet been able to locate such an example. The article here does a great job of explaining the concept of the queue, but unfortunately, does not provide an example.
You will find several examples here http://zguide.zeromq.org/page:all#Chapter-Four-Reliable-Request-Reply
Most of the patterns have a source code example of a client app and a server app in several languages. Even when there is a Python source code example, I find it useful to look at the C source code version to fully understand how it works.
I have made use of the Lazy Pirate pattern http://zguide.zeromq.org/py:lpclient and from memory, I had to change something about the way it loops and retries in order to get it to work reliably for me. It wasn't hard to figure out; I just added a few more print statements to see what was going on.
Related
I've read through multiple articles online, but I can't seem to find any way to properly implement my own oauth solution in python.
I'm using the tornado framework for python and I ended up converting python-oauth2's tornado solution to their most modern API with the hopes of understanding what makes up oauth2 work. I even made a contribution to the github. The biggest problem is that even after reading a large portion of the original oauth documentation, I don't understand everything. It leaves me confused when trying to make a simple oauth log-in.
A place I've looked are:
http://www.slideshare.net/leahculver/implementing-oauth -- Good slides, but since the speaker explained a lot in person of it I'm lost on some generic parts.
If you want to skip the reading, allow me to summarize:
I need a simple, yet well thought out explanation of how O-Auth 2.0 works, and how I could implement my own O-Auth 2.0.
I would like to know a good way to use python to do it.
I think about writing a Python bot for a MoinMoin-based wiki, so if anyone is aware about some code sources I can use or re-use, please share a link.
If it were a MediaWiki-based robot, there is a Wikipedia page to take as a start.
The target wiki engine is MoinMoin 1.9.2 .
So far I have found a project based on xml-rpc approach and the editmoin utility.
I'd rather prefer the xml-rpc route, but my first understanding was that it may need applying a patch to the server, what is not an option.
So the second link at the moment looks more promising as a start.
Any hints and suggestions are welcome.
Edit : Should also take a look at wiki-xmlrpc-extensions (an example) .
How do I begin learning Twisted? What books, documentation or tutorial do you guys recommend?
The reason I asked this question is that I think learning Twisted would help me otherwise also in learning concepts related to network programming (terminologies and how it works and stuff) I have heard that the documentation for Twisted is not that good. Is is true?
Note that I am looking for some advise that actually helped you. I am looking for your experience. PS: I am aware of the official documentation. There is also the O'Reilly Book on Twisted; is that good?
I'm finding this tutorial, linked to from the third party documentation section of the main twisted documentation page, to be well-written and instructive.
The tutorial consists of numerous iterations of the implementation of a "Poetry Server and Client". It starts with a blocking, non-Twisted version, and works up to a full Twisted version. Each step introduces new abstractions and presents problems which are resolved in the succeeding steps.
The code which implements each step is made available as a git repo.
The way i learned twisted was by starting a small project and lots of googling around; the twisted tutorials are sometimes not very clear, its just getting used to the framework and the way it works...
EDIT:
itd also recommend trying to understand what twisted is based on, the whole idea of twisted is to provide event driven programming for python, along with some other features such as asynchronous sockets and web server classes.
A quick explanation of deferreds and callbacks, which is the whole idea behind twisted, is creating an event (deferred object), then attaching a callback to it; then at some point ur going to fire the event, and the callback is triggered with a result (it could be null) from ur event operation. A good example is, if you have a button on a form, you create an event (a deferred object) then u attach a callback, when the user clicks a button, they fire the event, and the callback function is called to handle that event.
i hope this will give u a good general idea of what twisted is and how it can be used in a python environment, there is also IronPython (.NET) which has eventing as well.
~george
Look at the samples that come with twisted's documentation. Also, the documentation is not bad, but it is not very complete. Also, the API docs are quite good in fact.
When you know with which part you start, just try and play with the code until you're stuck, then google samples relating to your code and ask on stackoverflow.
As mentioned before the Krondo Twisted Introduction is pretty nice. But the Twisted book by o'reilly isn't bad either.
I've only got the first edition (from 2005) of the book and I think it is better structured than the Krondo tutorial.
It includes standard tasks (like downloading a web page) and gives two sections to every task.
"How do I do that" and afterwards "How does it work".
I think the book is pretty good if you don't have the time (or don't want to take it) to read through the Krondo tutorial.
One thing I miss in the o'rilley book though is inline callbacks. Maybe they've added some chapter about it in new editions, since inline callbacks were added later to twisted.
Especially if you are not a fan of reading from a screen I would suggest getting the book.
(Also it includes an interresting foreword from the twisted inventor)
I have some really nice Python code to do what I need to do. I don't particularly like any of the Python GUI choices though. wxPython is nice, but for what I need, the speed on resizing, refreshing and dynamically adding controls just isn't there. I would like to create the GUI in VB.NET. I imagine I could use IronPython to link the two, but that creates a dependency on a rather large third-party product. I was perusing the MSDN documentation on Windows IPC and got the idea to use sockets. I copied the Python echo server code from the Python documentation and in under 5 minutes was able to create a client in VB.NET without even reading the System.Net.Sockets documentation, so this certainly doesn't seem too hard.
The question I have is... is this a terrible idea? If so, what should I be doing instead?
If this is a good idea, how do I go about it?
It's not a terrible idea. In fact, if you write the Python code to have a RESTful interface, and then access that from VB.NET, it is a downright good idea. Later on you could reuse that Python server from any other application written in Python or VB.NET or something else. Because REST is standard and easy to test, people can even do GETs from a browser and maybe that will be useful in itself.
Here is a Yahoo page that gives you code examples to do REST GET, POST and so on, in VB.NET.
If you think REST has too much overhead and need something more lightweight, please don't try to invent your own protocol. Consider something like Google's Protocol Buffers which can also be used from VB.NET.
I think this is an excellent idea. I'll second Michael Dillon's recommendation for a REST API, and I'll further recommend that you use Django to implement your REST server.
I wrote a REST web service using Django, and Django made it really easy and fun. Django made it really simple to set up the URLs the way I wanted them, to run whatever code a URL called for, and to interact with the database as needed. My web service was rock solid reliable, and I was able to test it for debugging simply using a web browser.
If you already have your code working in Python and just want to slap on a glue interface, and if REST doesn't seem like what you want, you could look at the Twisted networking framework. Here is a nice article on how to do networking in Python with both the standard Python modules and with Twisted.
I want to learn it but I have no idea where to start. Everything out there suggests reading the libpurple source but I don't think I understand enough c to really get a grasp of it.
There isn't much about it yet... the intro, the howto, and the sources (here browsing them online but of course you can git clone them) are about it. In particular, the tiny example client you can get from here does have some miniscule example of use of purple's facilities (definitely not enough, but maybe it can get you started with the help of some 'dir', 'help' and the like...?)
Not sure how much help this will be but based on information from here, it seems like you just install python-purple and import and call the functions as normal Python functions.
Can't help you with a concrete example as I decided to use something else. However, one of the first things I wanted to do after I cloned the repo was remove the ecore dependency. Here's a patch submitted to the mailing list to do just that: https://garage.maemo.org/pipermail/python-purple-devel/2009-March/000000.html
Incidentally, if you're looking for AIM take a look at twisted.words. For Yahoo, trying getting the source for curphoo or zinc (both are console YMSG clients). For GTalk/Jabber, I've had good experiences with xmpppy.