Skip to content

Commit

Permalink
Ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
shazow committed Sep 30, 2011
1 parent 9128c43 commit d90b119
Show file tree
Hide file tree
Showing 27 changed files with 510 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
.*
*.pyc
*.egg-info
/dist
/build
19 changes: 19 additions & 0 deletions LICENSE
@@ -0,0 +1,19 @@
This is the MIT license: http://www.opensource.org/licenses/mit-license.php

Copyright 2011 Andrey Petrov

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Empty file.
Empty file.
Empty file.
@@ -0,0 +1,36 @@
"""Helper functions

This module is available as the ``h`` variable in templates, and can also be
imported into handler modules or elsewhere. Put any common functions you want
to access in all templates here. Helpers are normally functions that format
data for output or perform simple calculations. If your objects would never
be called from a template, they're not helpers and you should create a separate
module under 'lib' for them. If you have helpers that are module-sized,
put them in a module under 'lib' and import them here, or import them directly
into the templates and views that need them.

The WebHelpers package (http://python.org/pypi/WebHelpers) contains some
commonly used helpers for HTML tag creation, text formatting, number
formatting, etc.

The template globals (``h`` et al) are set in
``{{package}}/web/environment.py``.
"""

import time
from webhelpers.html import tags


_server_time_launched = str(int(time.time()))


# Handy wrappers for appending a timestamp to include urls:

def url_append_timestamp(url):
return url + '?' + _server_time_launched

def stylesheet_link(*urls, **attrs):
return tags.stylesheet_link(*(url_append_timestamp(u) for u in urls), **attrs)

def javascript_link(*urls, **attrs):
return tags.javascript_link(*(url_append_timestamp(u) for u in urls), **attrs)
Empty file.
@@ -0,0 +1,24 @@
import unittest
from pyramid.config import Configurator
from pyramid import testing

def _initTestingDB():
from sqlalchemy import create_engine
from {{package}}.models import initialize_sql
session = initialize_sql(create_engine('sqlite://'))
return session

class TestMyView(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
_initTestingDB()

def tearDown(self):
testing.tearDown()

def test_it(self):
from {{package}}.views import my_view
request = testing.DummyRequest()
info = my_view(request)
self.assertEqual(info['root'].name, 'root')
self.assertEqual(info['project'], '{{project}}')
Empty file.
@@ -0,0 +1,51 @@
from pyramid.config import Configurator
from pyramid_beaker import session_factory_from_settings

from {{package}}.lib import helpers


def _setup_models(settings):
"""
Attach connection to model modules.
"""
# from sqlalchemy import engine_from_config
# from {{package}} import models
#
# engine = engine_from_config(settings, 'sqlalchemy.')
# models.initialize_sql(engine)
pass


def _setup_routes(config):
config.add_route('index', '/', '{{package}}.web.views.index.index', renderer='index.mako')


def _template_globals_factory(system):
return {'h': helpers}


def setup(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)

# Globals for templates
config.set_renderer_globals_factory(_template_globals_factory)

# Beaker sessions
config.set_session_factory(session_factory_from_settings(settings))

# Routes
config.add_renderer(".mako", "pyramid.mako_templating.renderer_factory")
config.add_static_view("static", "{{package}}.web:static")

# More routes
_setup_routes(config)

# Module-level model global setup
_setup_models(settings)

# Need more setup? Do it here.
# ...

return config.make_wsgi_app()
@@ -0,0 +1,81 @@
/* Reset: */
html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{border:0;outline:0;vertical-align:baseline;background:transparent;margin:0;padding:0}html{overflow-y:scroll}select,input,textarea,button{font:99% sans-serif}h2,h3,h4{font-weight:400}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}a{font-size:100%;vertical-align:baseline;background:transparent;margin:0;padding:0}ins{background-color:#ff9;color:#000;text-decoration:none}mark{background-color:#ff9;color:#000;font-style:italic;font-weight:700}del{text-decoration:line-through}abbr[title],dfn[title]{border-bottom:1px dotted;cursor:help}table{border-collapse:collapse;border-spacing:0}hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0}pre,code,kbd,samp{font-family:monospace, sans-serif}a:hover,a:active{outline:none}ul{list-style-position:inside}ol{list-style-type:decimal;list-style-position:inside}small{font-size:85%}strong,th{font-weight:700}td,td img{vertical-align:top}sub{vertical-align:sub;font-size:smaller}sup{vertical-align:super;font-size:smaller}pre{white-space:pre-line;word-wrap:break-word;padding:15px}textarea{overflow:auto}input[type=radio]{vertical-align:text-bottom}label,input[type=button],input[type=submit],button{cursor:pointer}button,input,select,textarea{margin:0}::-moz-selection{background:#FF5E99;color:#fff;text-shadow:none}::selection{background:#4ba3de;color:#fff;text-shadow:none}a:link{-webkit-tap-highlight-color:#4ba3de}button{width:auto;overflow:visible}p{padding-bottom:1em;padding-top:.5em}input,select,input[type=checkbox]{vertical-align:middle}
/***/

body {
margin: 0;
padding: 0;
font: 16px 'Lucida Grande', Arial, sans-serif;
color: #333;
line-height: 1.6em;
}

h1, h2, h3, h4 {
font-family: 'Lucida Grande', Arial, sans-serif;
padding-top: 0.5em;
line-height: 1.6em;
color: #111;
}

ol > li {
list-style-position: outside;
margin-left: 1.5em;
}

/** Helpers: */

ul.vertical, ul.horizontal {
margin: 0; padding: 0; list-style: none;
}
ul.horizontal {
overflow: hidden;
}
ul.horizontal > li {
float: left; margin-right: 10px;
}
ul.horizontal > li:last-child {
margin-right: 0px;
}
.rounded-5 {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.rounded-10 {
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
.hidden {
display: none;
}

.container {
width: 760px;
margin: 0 auto;
}

.quiet {
font-size: 0.8em;
color: #888;
}

footer {
color: #666;
font-size: 10px;
text-align:center;
}
footer a {
color: #555;
}


header h1 {
padding-top: 0;
}
header h1 a {
color: #91be48;
text-decoration: none;
}

/***/
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />

<title>{{package}}</title>

${h.stylesheet_link('/static/css/base.css')}

<%block name="extra_head">
</%block>
</head>

<body>

<%block name="header">
<header>
<div class="container">
<h1 class="logo"><a href="/">{{package}}</a></h1>
</div>
</header>
</%block>

<%
flash = request.session.pop_flash()
%>
% if flash:
<div class="container">
<ul id="flash-messages">
% for message in flash:
<li class="info">${message}</li>
% endfor
</ul>
</div>
% endif

<div class="content">
${next.body()}
</div>

<footer>
<div class="container">
<p>
&hearts;
</p>
</div>
</footer>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>

<%block name="tail" />

</body>

</html>
@@ -0,0 +1,7 @@
<%inherit file="base.mako"/>

<div class="container">

<h2>Hello, ${hello}.</h2>

</div>
Empty file.
@@ -0,0 +1,4 @@
from {{package}} import models

def index(request):
return {'hello': 'world'}
@@ -0,0 +1,4 @@
0.0
---

- Initial version
@@ -0,0 +1,2 @@
include *.txt *.ini *.cfg *.rst
recursive-include {{package}} *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml
@@ -0,0 +1 @@
{{project}} README
@@ -0,0 +1,65 @@
[app:main]
use = egg:{{project}}

pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.debug_templates = true
pyramid.default_locale_name = en
pyramid.includes = pyramid_debugtoolbar

session.type = file
session.data_dir = %(here)s/data/sessions/data
session.lock_dir = %(here)s/data/sessions/lock
session.key = {{project}}
session.secret = somesecret

sqlalchemy.url = sqlite:///%(here)s/{{project}}.db

mako.directories = {{project}}.web:templates
mako.strict_undefined = true

[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 5000

# Begin logging configuration

[loggers]
keys = root, {{package_logger}}, sqlalchemy

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = INFO
handlers = console

[logger_{{package_logger}}]
level = DEBUG
handlers =
qualname = {{package}}

[logger_sqlalchemy]
level = INFO
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither. (Recommended for production systems.)

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s

# End logging configuration

0 comments on commit d90b119

Please sign in to comment.