Affichage des articles dont le libellé est cherrypy. Afficher tous les articles
Affichage des articles dont le libellé est cherrypy. Afficher tous les articles

lundi 14 janvier 2013

CherryPy and Python 3 : Port not bound / _Timer / _Event

Hi all,

I have recently updated my Python 3 and my CherryPy to the latest versions.

After that, different problems occur during the startup process of my application(using CherryPy):

These issues are marked as "resolved" ...  but in fact they are resolved in the release 3.2.3.

This release 3.2.3 is not easily accessible :
- not present on the CherryPy website on the "Download" section
- not present on the CherryPy bitbucket wiki
=>On the "Download" section and on the bitbucket wiki, the last version is the 3.2.2 :(

For downloading the 3.2.3, you must go to the project on bitbucket.org and click on "Downloads" 

Tada :)

mercredi 29 août 2012

Who uses cherrypy and web2py ? [updated]


I'm a little afraid on the future of CherryPy because :

- there are no new commits since April
- new issues are not assigned since April too
- the page on cherrypy.org detailing the websites running with CherryPy is very poor : http://docs.cherrypy.org/stable/appendix/success.html
- the last commits has been made only by Jason R. Coombs (only 1 person !)

Then I ask me some questions and I have some serious doubts.

Maybe it s time to choose a new framework... Maybe web2py. Why web2py ? Because when I look at this page I'm very impressed by the number of websites using web2py.
But it seems that the project is only maintained by Massimo Di Pierro (the creator). Bad point :o(

In conclusion : if you know a robust framework for Python 3, tell me ! :o)

[update] I realize that web2py doesn't support Python 3 :o( 
Flask doesn't support too.

[update] Bottle supports Python 3. Not a lot of commits, but issues are maintained/followed.

[update] Pyramid seems to be a serious framework (maintained by few members). And it is "Python 3 ready" !

vendredi 8 juillet 2011

Mettre en place plusieurs applications sous CherryPy

Avec CherryPy 3.X, il est possible d'associer plusieurs applications à un seul site. Nous allons voir comment mettre en place 3 applications basiques (ayant chacune son propre fichier de configuration) et les associer à une instance CherryPy (ayant lui aussi son propre fichier de configuration).

Les instructions que je donne ci-dessous se basent sur un environnement Windows. Mais très peu de choses varient pour Linux (ce qui changent, c'est la façon d'installer Python et CherryPy ainsi que les répertoires de Python et CherryPy).

1 - Installation de Python et CherryPy
  • installer Python 3.X : l'installer dans C:\Python3X
  • installer CherryPy 3.X : il s'installe dans C:\Python3X\Lib\site-packages\cherrypy

2 - Création d'une application
  • dans le répertoire de CherryPy, créer le répertoire app1
  • dans ce répertoire , créer les fichiers :
__init__.py

<fichier vide
>

appli1.conf (le contenu de ce fichier n'est qu'un exemple)

[Databases]

driver: "postgres"
host: "localhost"
port: 5432

appli1.py 

import cherrypy
class App1:    
   def index(self):        
      return "Hello world from app1 !"    
   index.exposed = True 

3 - Création d'une deuxième application

répéter les manips indiquées dans le chapitre "Creation d'une application", en remplacant "1" par "2" ("appli1.py"->"appli2.py" , "class App1"->"class App2", etc)


4 - Création d'une troisième application
 
répéter les manips indiquées dans le chapitre "Creation d'une application", en remplacant "1" par "3" ("appli1.py"->"appli3.py" , "class App1"->"class App3", etc)


5 - Création du script de démarrage du site
 
à la racine de CherryPy (dans notre cas il s'agit de C:\Python3X\Lib\site-packages\cherrypy), créer le fichier :
startup.py 

import cherrypy
import appli1.appli1
import appli2.appli2
import appli3.appli3

def initApp( path, confFileName=None, app=None):    
   appliConf = os.path.join(os.path.dirname(__file__), confFileName)    
   cherrypy.tree.mount(app, path, config=appliConf)

if __name__ == '__main__':    
   import os.path       
   #initialisation du fichier de configuration du site :    
   globalconf = os.path.join(os.path.dirname(__file__), 'global.conf')    
   cherrypy.config.update(globalconf)
   #initialisation des fichiers de configuration des appli1, 2 et 3 :    
   initApp('/1', 'appli1/appli1.conf',appli1.appli1.App1());    
   initApp('/2', 'appli2/appli2.conf',appli2.appli2.App2());    
   initApp('/3', 'appli3/appli3.conf',appli3.appli3.App3());        
   cherrypy.engine.start()    
   cherrypy.engine.block()


6 - Création du fichier de configuration du site
 
à la racine de cherrypy (dans notre cas il s'agit de C:\Python3X\Lib\site-packages\cherrypy), créer le fichier :
global.conf 
[global]server.socket_host = "127.0.0.1"
server.socket_port = 8088server.thread_pool = 10

7 - Lancement de CherryPy

  • taper la commande : python startup.py

  • lancer un navigateur et aller à : http://127.0.0.1:8088/1/
    =>"Hello world from app1 !" s'affiche :o)

  • lancer un navigateur et aller à : http://127.0.0.1:8088/2/
    =>"Hello world from app2 !" s'affiche :o)

  • lancer un navigateur et aller à : http://127.0.0.1:8088/3/
    =>"Hello world from app3 !" s'affiche :o)

 

Categories