Custom Search

Wednesday, January 2, 2013

How to create and run a pyramid alchemy project

How to create and run a pyramid alchemy project
===================================

(pyra_env)saju@saju-desktop:~/pyra_env/test$ pcreate -s alchemy alchemy_proj
Creating directory /home/saju/pyra_env/test/alchemy_proj
  Recursing into +package+
    Creating /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/
    Copying __init__.py to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/__init__.py
    Copying models.py to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/models.py
    Recursing into scripts
      Creating /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/scripts/
      Copying __init__.py to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/scripts/__init__.py
      Copying initializedb.py to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/scripts/initializedb.py
    Recursing into static
      Creating /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/
      Copying favicon.ico to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/favicon.ico
      Copying footerbg.png to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/footerbg.png
      Copying headerbg.png to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/headerbg.png
      Copying ie6.css to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/ie6.css
      Copying middlebg.png to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/middlebg.png
      Copying pylons.css to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/pylons.css
      Copying pyramid-small.png to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/pyramid-small.png
      Copying pyramid.png to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/pyramid.png
      Copying transparent.gif to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/static/transparent.gif
    Recursing into templates
      Creating /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/templates/
      Copying mytemplate.pt_tmpl to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/templates/mytemplate.pt
    Copying tests.py_tmpl to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/tests.py
    Copying views.py_tmpl to /home/saju/pyra_env/test/alchemy_proj/alchemy_proj/views.py
  Copying CHANGES.txt_tmpl to /home/saju/pyra_env/test/alchemy_proj/CHANGES.txt
  Copying MANIFEST.in_tmpl to /home/saju/pyra_env/test/alchemy_proj/MANIFEST.in
  Copying README.txt_tmpl to /home/saju/pyra_env/test/alchemy_proj/README.txt
  Copying development.ini_tmpl to /home/saju/pyra_env/test/alchemy_proj/development.ini
  Copying production.ini_tmpl to /home/saju/pyra_env/test/alchemy_proj/production.ini
  Copying setup.cfg_tmpl to /home/saju/pyra_env/test/alchemy_proj/setup.cfg
  Copying setup.py_tmpl to /home/saju/pyra_env/test/alchemy_proj/setup.py
Welcome to Pyramid.  Sorry for the convenience.
(pyra_env)saju@saju-desktop:~/pyra_env/test$


* The setup.py file in that directory can be used to distribute your application,
or install your application for deployment or development.

* To install a newly created project for development, you should cd to the newly
created project directory and run the command "#python setup.py develop".

* The file named setup.py will be in the root of the pcreate-generated project directory.

* The command "#python setup.py develop" will install a distribution representing your
project into the interpreter’s library set so it can be found by import statements and
by other console scripts such as pserve, pshell, proutes and pviews.


python setup.py develop
==================

(pyra_env)saju@saju-desktop:~/pyra_env/test/alchemy_proj$ python setup.py develop
running develop
running egg_info
creating alchemy_proj.egg-info
writing requirements to alchemy_proj.egg-info/requires.txt
writing alchemy_proj.egg-info/PKG-INFO
writing top-level names to alchemy_proj.egg-info/top_level.txt
writing dependency_links to alchemy_proj.egg-info/dependency_links.txt
...................
........this will install all dependencies...........
...................


Initialize Database
==============

a)
Open development.ini and add following line
sqlalchemy.url=mysql://root:paswword@localhost:3306/mydb1?charset=utf8

b)
Open models.py and replace "name = Column(Text, unique=True)" with "name = Column(String(255), unique=True)"

c)
(pyra_env)saju@saju-desktop:~/pyra_env/test/alchemy_proj$ initialize_alchemy_proj_db development.ini
2013-01-02 19:56:02,084 INFO  [sqlalchemy.engine.base.Engine][MainThread] SELECT DATABASE()
2013-01-02 19:56:02,085 INFO  [sqlalchemy.engine.base.Engine][MainThread] ()
2013-01-02 19:56:02,086 INFO  [sqlalchemy.engine.base.Engine][MainThread] SHOW VARIABLES LIKE 'character_set%%'
2013-01-02 19:56:02,086 INFO  [sqlalchemy.engine.base.Engine][MainThread] ()
2013-01-02 19:56:02,087 INFO  [sqlalchemy.engine.base.Engine][MainThread] SHOW VARIABLES LIKE 'sql_mode'
2013-01-02 19:56:02,087 INFO  [sqlalchemy.engine.base.Engine][MainThread] ()
2013-01-02 19:56:02,087 INFO  [sqlalchemy.engine.base.Engine][MainThread] DESCRIBE `models`
2013-01-02 19:56:02,088 INFO  [sqlalchemy.engine.base.Engine][MainThread] ()
2013-01-02 19:56:02,088 INFO  [sqlalchemy.engine.base.Engine][MainThread] ROLLBACK
2013-01-02 19:56:02,088 INFO  [sqlalchemy.engine.base.Engine][MainThread]
CREATE TABLE models (
    id INTEGER NOT NULL AUTO_INCREMENT,
    name VARCHAR(255),
    value INTEGER,
    PRIMARY KEY (id),
    UNIQUE (name)
)


2013-01-02 19:56:02,089 INFO  [sqlalchemy.engine.base.Engine][MainThread] ()
2013-01-02 19:56:02,183 INFO  [sqlalchemy.engine.base.Engine][MainThread] COMMIT
2013-01-02 19:56:02,184 INFO  [sqlalchemy.engine.base.Engine][MainThread] BEGIN (implicit)
2013-01-02 19:56:02,184 INFO  [sqlalchemy.engine.base.Engine][MainThread] INSERT INTO models (name, value) VALUES (%s, %s)
2013-01-02 19:56:02,185 INFO  [sqlalchemy.engine.base.Engine][MainThread] ('one', 1)
2013-01-02 19:56:02,185 INFO  [sqlalchemy.engine.base.Engine][MainThread] COMMIT
(pyra_env)saju@saju-desktop:~/pyra_env/test/alchemy_proj$


Running the Application
==================

(pyra_env)saju@saju-desktop:~/pyra_env/test/alchemy_proj$ pserve development.ini --reload
Starting subprocess with file monitor
===in  add_route=== home /
===in add_view=== function my_view at 0x3c81aa0> home
Starting server in PID 27614.
serving on http://0.0.0.0:6543

http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/project.html

No comments:

Post a Comment