Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
Merge with branch 'janjaapdriessen-hurry.resource'.
Browse files Browse the repository at this point in the history
  • Loading branch information
janjaapdriessen committed Jan 2, 2011
2 parents 952058e + 76599f0 commit ded9ec0
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 56 deletions.
55 changes: 45 additions & 10 deletions grokproject/template/buildout.cfg_tmpl
@@ -1,20 +1,21 @@
[buildout]
extends = ${version_info_url}
extends = http://svn.zope.org/repos/main/groktoolkit/trunk/grok.cfg
extends-cache = extends-cache
find-links = ${find_links_url}
include-site-packages = ${include_site_packages}
develop = .
unzip = true
parts =
app
daemon
debug_ini
deploy_ini
paster_ini_debug
paster_ini_deploy
i18n
mkdirs
site_zcml
test
zope_conf
zope_conf_debug
zope_conf_deploy
zpasswd
interactive_debugger
# For backward compatibility, telling buildout not to throw away
Expand All @@ -28,8 +29,32 @@ versions = versions
# unless you specify an eggs-directory option here.
${eggs_dir}
extensions += buildout.dumppickedversions
mr.developer
always-checkout = true
auto-checkout = fanstatic
zope.fanstatic
grokcore.view
grok
grokcore.site
grokcore.rest
grokcore.xmlrpc
grokcore.traverser
grokui.admin
grokui.base

[sources]
fanstatic = hg http://bitbucket.org/fanstatic/fanstatic
zope.fanstatic = svn http://svn.zope.org/repos/main/zope.fanstatic/trunk
grok = svn http://svn.zope.org/repos/main/grok/trunk
grokcore.view = svn http://svn.zope.org/repos/main/grokcore.view/trunk
grokcore.site = svn http://svn.zope.org/repos/main/grokcore.site/trunk
grokcore.rest = svn http://svn.zope.org/repos/main/grokcore.rest/trunk
grokcore.xmlrpc = svn http://svn.zope.org/repos/main/grokcore.xmlrpc/trunk
grokcore.traverser = svn http://svn.zope.org/repos/main/grokcore.traverser/trunk

[versions]
WebOb = 1.0
zope.app.wsgi = 3.10.0
# Override versions here.
# This version pin can be removed after the next groktoolkit release.
collective.recipe.scriptgen = 0.2
Expand All @@ -50,14 +75,14 @@ arguments = serve $${buildout:parts-directory}/etc/deploy.ini
--daemon --pid-file=$${buildout:directory}/var/daemon.pid
--log-file=$${buildout:directory}/log/daemon.log

[debug_ini]
[paster_ini_debug]
recipe = collective.recipe.template
input = etc/debug.ini.in
output = $${buildout:parts-directory}/etc/debug.ini
host = 127.0.0.1
port = 8080

[deploy_ini]
[paster_ini_deploy]
recipe = collective.recipe.template
input = etc/deploy.ini.in
output = $${buildout:parts-directory}/etc/deploy.ini
Expand Down Expand Up @@ -91,14 +116,24 @@ eggs = ${egg}
defaults = ['-v']

[zope_conf]
recipe = collective.recipe.template
input = etc/zope.conf.in
output = $${buildout:parts-directory}/etc/zope.conf
filestorage = $${buildout:directory}/var/filestorage
blobstorage = $${buildout:directory}/var/blobstorage
logfiles = $${buildout:directory}/var/log
extra =
# 'extra' is copied verbatim. Use it for product config sections and so.
extra =

[zope_conf_debug]
<= zope_conf
recipe = collective.recipe.template
output = $${buildout:parts-directory}/etc/zope.debug.conf
devmode = on

[zope_conf_deploy]
<= zope_conf
recipe = collective.recipe.template
output = $${buildout:parts-directory}/etc/zope.deploy.conf
devmode = off

# This section is named so that the zpasswd utility is
# called `zpasswd`
Expand All @@ -115,7 +150,7 @@ recipe = z3c.recipe.scripts
eggs = ${egg}
entry-points =
interactive_debugger=grokcore.startup.startup:interactive_debug_prompt
arguments = zope_conf="$${zope_conf:output}"
arguments = zope_conf="$${zope_conf_debug:output}"

# The [data] and [log] parts are still in here to instruct buildout to not
# unintentionally throw away the parts/data and parts/log subdirectories
Expand Down
9 changes: 7 additions & 2 deletions grokproject/template/etc/debug.ini.in_tmpl
@@ -1,20 +1,25 @@
[DEFAULT]
zope_conf = %(here)s/zope.conf
zope_conf = %(here)s/zope.debug.conf

[server:main]
use = egg:Paste#http
host = $${:host}
port = $${:port}

[pipeline:main]
pipeline = accesslogging evalexception grok
pipeline = accesslogging evalexception fanstatic grok

[filter:accesslogging]
use = egg:Paste#translogger

[filter:evalexception]
use = egg:z3c.evalexception#ajax

[filter:fanstatic]
use = egg:fanstatic#fanstatic
devmode = $${zope_conf_debug:devmode}
hashing = true

[app:grok]
use = egg:grokcore.startup#debug
exempt-exceptions = zope.security.interfaces.IUnauthorized
Expand Down
19 changes: 15 additions & 4 deletions grokproject/template/etc/deploy.ini.in_tmpl
@@ -1,20 +1,31 @@
[DEFAULT]
zope_conf = %(here)s/zope.conf
zope_conf = %(here)s/zope.deploy.conf

[server:main]
use = egg:Paste#http
host = $${:host}
port = $${:port}

[pipeline:main]
pipeline = gzip grok
pipeline = accesslogging gzip fanstatic grok

[app:grok]
use = egg:grokcore.startup
[filter:accesslogging]
use = egg:Paste#translogger

[filter:gzip]
use = egg:Paste#gzip

[filter:fanstatic]
use = egg:fanstatic#fanstatic
devmode = $${zope_conf_deploy:devmode}
bottom = true
hashing = true
mode = minified
rollup = true

[app:grok]
use = egg:grokcore.startup

# Logging configuration

[loggers]
Expand Down
4 changes: 1 addition & 3 deletions grokproject/template/etc/zope.conf.in_tmpl
Expand Up @@ -31,9 +31,7 @@ site-definition $${site_zcml:output}
# logfiles are setup in the debug.ini and deploy.ini files.
</eventlog>

# Comment this line to disable developer mode. This should be done in
# production
devmode on
devmode $${devmode}

# Extra configuration lines can be added to zope_conf's extra option. Put for
# instance productconf sections in here.
Expand Down
8 changes: 7 additions & 1 deletion grokproject/template/setup.py_tmpl
Expand Up @@ -22,7 +22,13 @@ ${long_description|nothing}""",
'grok',
'grokui.admin',
'z3c.testsetup',
'fanstatic',
'zope.fanstatic',
'grokcore.startup',${install_requires|nothing}
# Add extra requirements here
],
)
entry_points={
'fanstatic.libraries': [
'${project_lowercase} = ${project_lowercase}.resource:library',
]
})
5 changes: 4 additions & 1 deletion grokproject/template/src/+package+/app.py_tmpl
@@ -1,7 +1,10 @@
import grok

from ${package} import resource

class ${app_class_name}(grok.Application, grok.Container):
pass

class Index(grok.View):
pass # see app_templates/index.pt
# see app_templates/index.pt
pass
5 changes: 5 additions & 0 deletions grokproject/template/src/+package+/app.txt_tmpl
Expand Up @@ -32,6 +32,10 @@ Check some basic information about the page you visit:
>>> print browser.contents
<html>
<head>
<link rel="stylesheet" type="text/css"
href="http://localhost/fanstatic/foo/style.css" />
<script type="text/javascript"
src="http://localhost/fanstatic/foo/hello.js"></script>
<base href="http://localhost/app/@@index" />
<BLANKLINE>
</head>
Expand All @@ -41,6 +45,7 @@ Check some basic information about the page you visit:
<p>Your Grok application is up and running.
Edit <code>${package}/app_templates/index.pt</code> to change
this page.</p>
<img src="http://localhost/fanstatic/foo/evencaveman.jpg" />
</body>
</html>
<BLANKLINE>
Expand Up @@ -7,5 +7,7 @@
<p>Your Grok application is up and running.
Edit <code>${package}/app_templates/index.pt</code> to change
this page.</p>

<img tal:attributes="src static/evencaveman.jpg"/>
</body>
</html>
7 changes: 7 additions & 0 deletions grokproject/template/src/+package+/resource.py_tmpl
@@ -0,0 +1,7 @@
from fanstatic import Library, Resource

library = Library('${project_lowercase}', 'static')

style = Resource(library, 'style.css')

hello = Resource(library, 'hello.js')
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions grokproject/template/src/+package+/static/hello.js
@@ -0,0 +1 @@
window.alert('hello from javascript');
3 changes: 3 additions & 0 deletions grokproject/template/src/+package+/static/style.css
@@ -0,0 +1,3 @@
body {
color: #f00;
}
7 changes: 6 additions & 1 deletion grokproject/template/src/+package+/tests.py_tmpl
@@ -1,10 +1,15 @@
import os.path
import z3c.testsetup
from zope.app.wsgi.testlayer import BrowserLayer
import fanstatic

import ${package}

browser_layer = BrowserLayer(${package})
class FanstaticLayer(BrowserLayer):
def setup_middleware(self, app):
return fanstatic.Fanstatic(app)

browser_layer = FanstaticLayer(${package})

test_suite = z3c.testsetup.register_all_tests(
'${package}', globs={'getRootFolder': browser_layer.getRootFolder})
3 changes: 2 additions & 1 deletion grokproject/templates.py
Expand Up @@ -72,6 +72,7 @@ def check_vars(self, vars, cmd):
# Escape values that go in site.zcml.
vars[var_name] = xml.sax.saxutils.quoteattr(vars[var_name])
vars['app_class_name'] = vars['project'].capitalize()
vars['project_lowercase'] = vars['project'].lower()

# Handling the version.cfg file.
version_url = vars.get('version_url')
Expand Down Expand Up @@ -127,7 +128,7 @@ def download(self, url):
sys.exit(1)
except IOError, e:
# Some serious problem: no connect to server...
print "Error: cannot download required %s" % version_info_url
print "Error: cannot download required %s" % url
print "Server may be down. Please try again later."
sys.exit(1)
return contents
Expand Down
10 changes: 3 additions & 7 deletions grokproject/utils.py
@@ -1,14 +1,10 @@
from base64 import urlsafe_b64encode
from paste.script.templates import var
from random import randint
import subprocess
import codecs
import logging
import os
import pkg_resources
import shutil
import sys
import tempfile
from base64 import urlsafe_b64encode

from paste.script.templates import var

try:
from hashlib import sha1
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Expand Up @@ -36,7 +36,9 @@
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=['PasteScript>=1.6'],
install_requires=[
'setuptools',
'PasteScript>=1.6'],
extras_require=dict(tests=['zope.testing',]),
test_suite='tests.test_suite',
entry_points={
Expand Down

0 comments on commit ded9ec0

Please sign in to comment.