How develop and deploy an application in the cloud. A referencial architecture (Part 1)

February 10th, 2014

Link: https://github.com/rancavil/django-py3-openshift-quickstart/wiki/How-develop-and-deploy-an-application-in-the-cloud.-A-referencial-architecture-(Part-1).

See how we can implement an Architecture using the cloud services, Openshift Django / Python and Redis in the Cloud.

Python and MongoLab (Mongo in the Cloud)

January 19th, 2014

This is a little tutorial how use MongoDB on the Cloud.

First we need find Mongo in the cloud...I will use MongoLab for demonstrate how work pymongo.

We need to create a account on https://mongolab.com and complete the form https://mongolab.com/signup/

Follow the instructions to create a database and create a user on MongoLab web console.

To connect using a driver via the standard URI:

mongodb://<dbuser>:<dbpassword>@ds0<port>.mongolab.com:<port>/<database>

When you create a database on MongoLab a port is assigned to the resource.

For our example, we create a database called db_posts.

Assume that port 28012 is created

mongodb://<dbuser>:<dbpassword>@ds028012.mongolab.com:28012/db_posts

Important: you must create the dbuser (https://mongolab.com/databases/db_posts#users), this is not the user account.

Well, now we go to write the python code.

Create the create.py file to insert a document into the collection:

1  from pymongo import MongoClient
2
3  client = MongoClient('ds028012.mongolab.com:28012')
4  client.db.authenticate('joe','pass12345',source='db_posts')
5 
6  db = client.db_posts
7  posts = db.posts
8  post = {'author':'rodrigo','text':'Hello world'}
9
10 id_post = posts.insert(post)
11 print 'Create the id : %s'%id_post
12 
13 client.close()

Create the read.py file to retrieve documents from the collection:

1  from pymongo import MongoClient
2
3  client = MongoClient('ds028012.mongolab.com:28012')
4  client.db.authenticate('joe','pass12345',source='db_posts')
5 
6  db = client.db_posts
7
8  results_posts = db.posts.find()
9  for post in results_posts:
10     print post
11 
12 client.close()

I hope with this you can see how work python and mongo in the cloud, If you like MongoHQ, that is similar to use MongoLab.

Enjoy!!!

El misterio de 2001, A Space Oddity implementado en Python

November 16th, 2013

Quienes hayan visto la película de Stanley Kubrick, 2001 A Space Oddity, sabrán que la computadora de la nave ocultaba un misterio mayor. Acá esta la solución en Python.

Paso 1: Crea un archivo hal.py

1  ori_word = 'HAL'
2 end_word = ''
3 for w in list(ori_word):
4 a = ord(w) + 1
5 end_word += chr(a)
6 print '(%s) + 1 = %s'%(ori_word,end_word)

Paso 2: Ejecuta el programa

$ python hal.py

Te sorprenderas del resultado....

PD: Esto es lo que haces un viernes en la noche despues de tomar unos tragos....

 

Tornado Web Services on the cloud

January 6th, 2013

We have deployed some examples of web services in the cloud.

http://tornadows-midom.rhcloud.com/

For this we use Red Hat OpenShift (a free cloud) ...

How create two or more soap method with @webservice in a class

April 23rd, 2012

 

We create a beta version of the API tornadows, to allow develop of web services with multiple operations.

You can see how to use the beta version in the Wiki here

First, you must download the beta version of the API from:

https://github.com/rancavil/tornado-webservices/downloads/tornadows-0.9.4-Beta.tar.gz