Differences between revisions 1 and 2
Revision 1 as of 2013-08-13 04:11:05
Size: 909
Comment:
Revision 2 as of 2013-08-13 04:43:32
Size: 2595
Comment:
Deletions are marked like this. Additions are marked like this.
Line 27: Line 27:
Checking the first version into revision control of your choosing.
Line 61: Line 62:

=== Enable Mako ===
In order to use Mako as in Pylons, you must specify a template search path in the settings. Edit development.ini:
{{{
[app:main]
...
mako.directories = myapp:templates
}}}

[[http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/templates.html#mako-templates|enable mako with pyramid]]
[[http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/pylons/templates.html|enable mako html with pyramid]]

Then in \__init\__.py add below. This will be needed so that designer can use .html mako template files in his software.
{{{
config = Configurator(settings=settings)
config.add_renderer(".html", "pyramid.mako_templating.renderer_factory")
}}}

=== Add first page ===

We will add new route in. This what tells pyramid program we want localhost/recall
{{{
vi __init__.py
#Add below home
}}}
Add below home
{{{
config.add_route('recall', '/recall')
}}}
Edit views.py and add our new page. This tells that anybody that calls localhost/recall should call our route_name called recall in views.py
{{{
@view_config(route_name='recall', renderer='recall.html')
def recall(request):
    return {'project':'Myapp'}
}}}
Now inside template folder add your new template
{{{
cd template
vi recall.html
}}}
Add
{{{
<html>
 <head>
     <title>${project} Application</title>
 </head>
   <body>
      <h1 class="title">Welcome to <code>${project}</code>, an
       application generated by the <a
       href="http://docs.pylonsproject.org/projects/pyramid/current/"
      >pyramid</a> web application framework.</h1>
   </body>
 </html>
}}}

Pyramid/enterprise

Pyramid Setup

aptitude install python-virtualenv

virtualenv --no-site-packages pyramid_env
cd pyramid_env
source ./bin/activate
easy_install pyramid

Pyramid Project: myapp

pcreate -s alchemy myapp

Install remaining components

cd myapp
python setup.py develop

[Optional] Checking the first version into revision control of your choosing.

aptitude install bzr
cd myapp
bzr init .
bzr add
bzr commit -m"Initial Import"

Run a test

python setup.py test -q

Check how much code is covered by tests

easy_install nose coverage
nosetests --cover-package=myapp --cover-erase --with-coverage

Populate the database

Replace myapp with your app name.

initialize_myapp_db development.ini

Start the Application

pserve development.ini --reload

Visit http://localhost:6543/

Write your application

Enable Mako

In order to use Mako as in Pylons, you must specify a template search path in the settings. Edit development.ini:

[app:main]
...
mako.directories = myapp:templates

enable mako with pyramid enable mako html with pyramid

Then in \init\.py add below. This will be needed so that designer can use .html mako template files in his software.

config = Configurator(settings=settings)
config.add_renderer(".html", "pyramid.mako_templating.renderer_factory")

Add first page

We will add new route in. This what tells pyramid program we want localhost/recall

vi __init__.py
#Add below home

Add below home

config.add_route('recall', '/recall')

Edit views.py and add our new page. This tells that anybody that calls localhost/recall should call our route_name called recall in views.py

@view_config(route_name='recall', renderer='recall.html')
def recall(request):
    return {'project':'Myapp'}

Now inside template folder add your new template

cd template
vi recall.html

Add

<html>
 <head>
     <title>${project} Application</title>
 </head>
   <body>
      <h1 class="title">Welcome to <code>${project}</code>, an
       application generated by the <a
       href="http://docs.pylonsproject.org/projects/pyramid/current/"
      >pyramid</a> web application framework.</h1>
   </body>
 </html>

MyWiki: Pyramid/enterprise (last edited 2016-09-26 02:43:53 by LukaszSzybalski)