r7257 - in firehose: . firehose firehose/config firehose/jobs firehose/static firehose/static/css firehose/static/images firehose/templates firehose/tests firehose.egg-info
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7257 - in firehose: . firehose firehose/config firehose/jobs firehose/static firehose/static/css firehose/static/images firehose/templates firehose/tests firehose.egg-info
- Date: Thu, 24 Jan 2008 21:25:09 -0600 (CST)
Author: walters
Date: 2008-01-24 21:25:05 -0600 (Thu, 24 Jan 2008)
New Revision: 7257
Added:
firehose/README.txt
firehose/dev.cfg
firehose/firehose.egg-info/
firehose/firehose.egg-info/PKG-INFO
firehose/firehose.egg-info/SOURCES.txt
firehose/firehose.egg-info/dependency_links.txt
firehose/firehose.egg-info/not-zip-safe
firehose/firehose.egg-info/paster_plugins.txt
firehose/firehose.egg-info/requires.txt
firehose/firehose.egg-info/sqlobject.txt
firehose/firehose.egg-info/top_level.txt
firehose/firehose/
firehose/firehose/__init__.py
firehose/firehose/config/
firehose/firehose/config/__init__.py
firehose/firehose/config/app.cfg
firehose/firehose/config/log.cfg
firehose/firehose/controllers.py
firehose/firehose/jobs/
firehose/firehose/jobs/master.py
firehose/firehose/jobs/poller.py
firehose/firehose/jobs/tasks.py
firehose/firehose/json.py
firehose/firehose/model.py
firehose/firehose/release.py
firehose/firehose/sqlobject-history/
firehose/firehose/static/
firehose/firehose/static/css/
firehose/firehose/static/css/style.css
firehose/firehose/static/images/
firehose/firehose/static/images/favicon.ico
firehose/firehose/static/images/header_inner.png
firehose/firehose/static/images/info.png
firehose/firehose/static/images/ok.png
firehose/firehose/static/images/tg_under_the_hood.png
firehose/firehose/static/images/under_the_hood_blue.png
firehose/firehose/static/javascript/
firehose/firehose/templates/
firehose/firehose/templates/__init__.py
firehose/firehose/templates/login.kid
firehose/firehose/templates/master.kid
firehose/firehose/templates/welcome.kid
firehose/firehose/tests/
firehose/firehose/tests/__init__.py
firehose/firehose/tests/test_controllers.py
firehose/firehose/tests/test_model.py
firehose/sample-prod.cfg
firehose/setup.py
firehose/start-firehose.py
firehose/test.cfg
Log:
Add firehose app.
Added: firehose/README.txt
===================================================================
--- firehose/README.txt 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/README.txt 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,4 @@
+firehose
+
+This is a TurboGears (http://www.turbogears.org) project. It can be
+started by running the start-firehose.py script.
\ No newline at end of file
Added: firehose/dev.cfg
===================================================================
--- firehose/dev.cfg 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/dev.cfg 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,66 @@
+[global]
+# This is where all of your settings go for your development environment
+# Settings that are the same for both development and production
+# (such as template engine, encodings, etc.) all go in
+# firehose/config/app.cfg
+
+# DATABASE
+
+# pick the form for your database
+# sqlobject.dburi="postgres://username hostname/databasename"
+# sqlobject.dburi="mysql://username:password hostname:port/databasename"
+# sqlobject.dburi="sqlite:///file_name_and_path"
+
+firehose.taskdbpath="'%(current_dir_uri)s/dev-tasks.sqlite"
+firehose.slaveport="8090"
+
+# if you are using a database or table type without transactions
+# (MySQL default, for example), you should turn off transactions
+# by prepending notrans_ on the uri
+# sqlobject.dburi="notrans_mysql://username:password hostname:port/databasename"
+
+# for Windows users, sqlite URIs look like:
+# sqlobject.dburi="sqlite:///drive_letter:/path/to/file"
+
+# SERVER
+
+# Some server parameters that you may want to tweak
+# server.socket_port=8080
+
+# Enable the debug output at the end on pages.
+# log_debug_info_filter.on = False
+
+server.environment="development"
+autoreload.package="firehose"
+
+# Auto-Reload after code modification
+# autoreload.on = True
+
+# Set to True if you'd like to abort execution if a controller gets an
+# unexpected parameter. False by default
+tg.strict_parameters = True
+
+tg.scheduler = True
+
+# LOGGING
+# Logging configuration generally follows the style of the standard
+# Python logging module configuration. Note that when specifying
+# log format messages, you need to use *() for formatting variables.
+# Deployment independent log configuration is in firehose/config/log.cfg
+[logging]
+
+[[loggers]]
+[[[firehose]]]
+level='DEBUG'
+qualname='firehose'
+handlers=['debug_out']
+
+[[[allinfo]]]
+level='INFO'
+handlers=['debug_out']
+
+[[[access]]]
+level='INFO'
+qualname='turbogears.access'
+handlers=['access_out']
+propagate=0
Added: firehose/firehose/__init__.py
===================================================================
Added: firehose/firehose/config/__init__.py
===================================================================
Added: firehose/firehose/config/app.cfg
===================================================================
--- firehose/firehose/config/app.cfg 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/config/app.cfg 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,52 @@
+[global]
+# The settings in this file should not vary depending on the deployment
+# environment. dev.cfg and prod.cfg are the locations for
+# the different deployment settings. Settings in this file will
+# be overridden by settings in those other files.
+
+# The commented out values below are the defaults
+
+# VIEW
+
+# which view (template engine) to use if one is not specified in the
+# template name
+# tg.defaultview = "kid"
+
+# The following kid settings determine the settings used by the kid serializer.
+
+# Kid output method (e.g. html, html-strict, xhtml, xhtml-strict, xml, json)
+# and formatting (e.g. default, straight, compact, newlines, wrap, nice)
+# kid.outputformat="html default"
+
+# kid.encoding="utf-8"
+
+# The sitetemplate is used for overall styling of a site that
+# includes multiple TurboGears applications
+# tg.sitetemplate="<packagename.templates.templatename>"
+
+# Allow every exposed function to be called as json,
+# tg.allow_json = False
+
+# List of Widgets to include on every page.
+# for exemple ['turbogears.mochikit']
+# tg.include_widgets = []
+
+# Set to True if the scheduler should be started
+# tg.scheduler = False
+
+# Set session or cookie
+# session_filter.on = True
+
+
+# compress the data sends to the web browser
+# [/]
+# gzip_filter.on = True
+# gzip_filter.mime_types = ["application/x-javascript", "text/javascript", "text/html", "text/css", "text/plain"]
+
+[/static]
+static_filter.on = True
+static_filter.dir = "%(top_level_dir)s/static"
+
+[/favicon.ico]
+static_filter.on = True
+static_filter.file = "%(top_level_dir)s/static/images/favicon.ico"
Added: firehose/firehose/config/log.cfg
===================================================================
--- firehose/firehose/config/log.cfg 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/config/log.cfg 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,29 @@
+# LOGGING
+# Logging is often deployment specific, but some handlers and
+# formatters can be defined here.
+
+[logging]
+[[formatters]]
+[[[message_only]]]
+format='*(message)s'
+
+[[[full_content]]]
+format='*(asctime)s *(name)s *(levelname)s *(message)s'
+
+[[handlers]]
+[[[debug_out]]]
+class='StreamHandler'
+level='DEBUG'
+args='(sys.stdout,)'
+formatter='full_content'
+
+[[[access_out]]]
+class='StreamHandler'
+level='INFO'
+args='(sys.stdout,)'
+formatter='message_only'
+
+[[[error_out]]]
+class='StreamHandler'
+level='ERROR'
+args='(sys.stdout,)'
Added: firehose/firehose/controllers.py
===================================================================
--- firehose/firehose/controllers.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/controllers.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,19 @@
+from turbogears import controllers, expose, flash
+# from model import *
+# import logging
+# log = logging.getLogger("firehose.controllers")
+
+class Root(controllers.RootController):
+ @expose(template="firehose.templates.welcome")
+ def index(self):
+ import time
+ # log.debug("Happy TurboGears Controller Responding For Duty")
+ flash("Your application is now running")
+ return dict(now=time.ctime())
+
+ @expose("json", as_format="json", accept_format="text/javascript")
+ def addtask(self, taskid):
+ from firehose.jobs.master import MasterPoller
+ master = MasterPoller.get()
+ master.add_task(taskid)
+ return {}
\ No newline at end of file
Added: firehose/firehose/jobs/master.py
===================================================================
--- firehose/firehose/jobs/master.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/jobs/master.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,153 @@
+#!/usr/bin/python
+
+import os,sys,re,heapq,time,httplib
+
+if sys.version_info[0] < 2 or sys.version_info[1] < 5:
+ from pysqlite2 import dbapi2 as sqlite3
+else:
+ import sqlite3
+import boto
+
+from boto.sqs.connection import SQSConnection
+from boto.s3.connection import S3Connection
+from boto.s3.key import Key
+
+from turbogears import config
+import turbogears.jsonify
+
+from tasks import TaskKey
+
+_logger = logging.getLogger('firehose.Master')
+
+aws_config_path = os.path.expanduser('~/.aws')
+execfile(aws_config_path)
+
+DEFAULT_POLL_TIME_SECS = 45 * 60 # 45 minutes
+MIN_POLL_TIME_SECS = 15
+TASKSET_TIMEOUT_SECS = 7 * 60 # 7 minutes
+MAX_TASKSET_SIZE = 30
+MAX_TASKSET_WORKERS = 1
+
+class QueuedTask(object):
+ __slots__ = ['eligibility', 'task']
+ def __init__(self, eligibility, task):
+ self.eligibility = eligibility
+ self.task = task
+
+ def __cmp__(self, other):
+ return cmp(self.eligibility, other.eligibility)
+
+_instance = None
+class MasterPoller(object):
+
+ @staticmethod
+ def get():
+ global _instance
+ if _instance is None:
+ _instance = MasterPoller()
+ return _instance
+
+ def __add_task_for_key(self, key):
+ try:
+ self.__task_lock.acquire()
+ taskkey = TaskKey(key)
+ for qtask in self.__tasks:
+ if qtask.task == taskkey:
+ return qtask
+ newtask = QueuedTask(time.time(), taskkey)
+ self.__tasks.append(newtask)
+ finally:
+ self.__task_lock.release()
+
+ def add_task(self, taskkey):
+ cursor = self.__conn.cursor()
+ cursor.execute('''INSERT INTO Tasks VALUES (?)''',
+ taskkey)
+ self.__add_task_for_key(taskkey)
+
+ def taskset_status(self, status_str):
+ pass
+
+ def __init__(self):
+ self.__tasks = []
+ self.__poll_task = None
+ self.__task_lock = threading.Lock()
+
+ # Default to one slave on localhost
+ self.__worker_urls = ['localhost:%d' + int(config.get('firehose.slaveport'))]
+
+ path = config.get('firehose.taskdbpath')
+ self.__conn = sqlite3.connect(path, isolation_level=None)
+ cursor = self.__conn.cursor()
+ cursor.execute('''CREATE TABLE IF NOT EXISTS Tasks (tid INTEGER PRIMARY KEY AUTOINCREMENT,
+ key TEXT UNIQUE IGNORE)''')
+ cursor.execute('''CREATE INDEX IF NOT EXISTS TasksIdx on Tasks (key)''')
+
+ curtime = time.time()
+ for v in cursor.execute('''SELECT key from Tasks'''):
+ task = QueuedTask(curtime, TaskKey(v))
+ heapq.heappush(self.__tasks, task)
+
+ def __unset_poll(self):
+ try:
+ self.__task_lock.acquire()
+ if self.__poll_task is None:
+ return
+ turbogears.scheduler.cancel(self.__poll_task)
+ self.__poll_task = None
+ finally:
+ self.__task_lock.release()
+
+ def __activate_workers(self):
+ raise NotImplementedError()
+
+ def __enqueue_taskset(self, worker, taskset):
+ jsonstr = turbogears.jsonify.encode(taskset)
+ conn = httplib.HTTPConnection(worker)
+ req = conn.request('POST', '/', jsonstr)
+
+ def __do_poll(self):
+ _logger.debug("in poll")
+ self.__unset_poll()
+
+ tasksets = []
+ curtime = time.time()
+ taskset_limit = curtime + TASKSET_TIMEOUT_SECS
+ try:
+ self.__task_lock.acquire()
+ taskset = []
+ for i,task in enumerate(self.__tasks):
+ if i >= MAX_TASKSET_SIZE:
+ if len(tasksets) >= MAX_TASKSET_WORKERS:
+ break
+ tasksets.append(taskset)
+ taskset = []
+ if task.eligibility < taskset_limit:
+ taskset.extend(task)
+ finally:
+ self.__task_lock.release()
+ taskset_count = len(tasksets)
+ if taskset_count > len(self.__worker_urls):
+ self.__activate_workers()
+ for worker,taskset in zip(tasksets, self.__worker_urls):
+ self.__enqueue_taskset(worker, taskset)
+ self.__requeue_poll()
+
+ def __requeue_poll(self):
+ _logger.debug("doing poll requeue")
+ try:
+ self.__unset_poll()
+ self.__task_lock.acquire()
+
+ assert self.__poll_task is None
+ if len(self.__tasks) == 0:
+ _logger.debug("no tasks")
+ return
+ curtime = time.time()
+ next_timeout = self.__tasks[0].eligibility - curtime
+ if next_timeout < MIN_POLL_TIME_SECS:
+ next_timeout = MIN_POLL_TIME_SECS
+ _logger.debug("requeuing check for %r", next_timeout)
+ self.__poll_task = turbogears.scheduler.add_interval_task(action=self.__do_poll, taskname='FirehoseMasterPoll', initialdelay=next_timeout, interval=1)
+ finally:
+ self.__task_lock.release()
Added: firehose/firehose/jobs/poller.py
===================================================================
--- firehose/firehose/jobs/poller.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/jobs/poller.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,116 @@
+#!/usr/bin/python
+
+import os,sys,re,heapq,time,Queue,sha
+import BaseHTTPServer,httplib,urlparse
+from email.Utils import formatdate,parsedate
+
+import boto
+
+from boto.sqs.connection import SQSConnection
+from boto.s3.connection import S3Connection
+from boto.s3.key import Key
+from boto.sqs.connection import SQSConnection
+
+import simplejson
+from turbogears import config
+
+_logger = logging.getLogger('firehose.Poller')
+
+aws_config_path = os.path.expanduser('~/.aws')
+execfile(aws_config_path)
+
+class TaskHandler(object):
+ FAMILY = None
+
+ def run(self, id, prev_hash, prev_timestamp):
+ """Receives a task id, result SHA1, and result timestamp integer.
+Should compute a new result (newhash, newtimestamp)"""
+ raise NotImplementedError()
+
+class FeedTaskHandler(object):
+ FAMILY = 'http-feed'
+
+ def run(self, id, prev_hash, prev_timestamp):
+ targeturl = urllib.unquote(id)
+ parsedurl = urlparse.urlparse(targeturl)
+ try:
+ connection = httplib.HTTPConnection(parsedurl.host, parsedurl.port)
+ connection.request('GET', parsedurl.path,
+ headers={'If-Modified-Since':
+ formatdate(prev_timestamp)})
+ response = connection.getresponse()
+ if response.status == 304:
+ return (prev_hash, prev_timestamp)
+ data = response.read()
+ new_timestamp = resp_headers
+ hash = sha.new()
+ hash.update(data)
+ hash_hex = hash.hexdigest()
+ timestamp_str = response.getheader('Last-Modified')
+ if timestamp_str is not None:
+ timestamp = parsedate(timestamp_str)
+ else:
+ _logger.debug("no last-modified for %r", targeturl)
+ timestamp = time.time()
+ if prev_hash != hash_hex:
+ return (hash_hex, timestamp)
+ return (prev_hash, prev_timestamp)
+ finally:
+ try:
+ connection.close()
+ except:
+ pass
+
+class TaskRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ def do_POST(self):
+ _logger.debug("handling POST")
+ data = rfile.read()
+ taskids = simplejson.load(data)
+ poller = TaskPoller.get()
+ poller.poll_tasks(taskids)
+
+_instance = None
+class TaskPoller(SimpleHTTPServer.BaseHTTPServer):
+
+ @staticmethod
+ def get():
+ global _instance
+ if _instance is None:
+ _instance = MasterPoller()
+ return _instance
+
+ def __init__(self):
+ bindport = int(config.get('firehose.slaveport'))
+ self.__server = BaseHTTPServer.HTTPServer(('', bindport), TaskRequestHandler)
+ self.__active_collectors = set()
+
+ def run(self):
+ self.__server.serve_forever()
+
+ def __send_results(self, ):
+
+ def __run_collect_tasks(self, taskqueue, resultqueue):
+ _logger.debug("doing join on taskqueue")
+ taskqueue.join()
+ _logger.debug("all tasks complete")
+ results = []
+ while True:
+ try:
+ result = resultqueue.get(False)
+ results.append(result)
+ except Queue.Empty:
+ break
+ self.__send_results(results)
+
+ def poll_tasks(self, taskids):
+ taskqueue = Queue.Queue()
+ resultqueue = Queue.Queue()
+ for task in taskids:
+ taskqueue.put(task)
+ thread = threading.Thread(target=self.__run_task, args=(task,resultqueue))
+ thread.start()
+ collector = threading.Thread(target=self.__run_collect_tasks, args=(taskqueue,resultqueue))
+ collector.start()
+
+ def run(self):
+ pass
Added: firehose/firehose/jobs/tasks.py
===================================================================
--- firehose/firehose/jobs/tasks.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/jobs/tasks.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+import os,sys,re
+
+class TaskKey(object):
+ family = property(lambda self: self._family)
+ id = property(lambda self: self._id)
+ def __init__(self, keystr):
+ (self._family, self._id) = keystr.split('/', 1)
+
+ def __cmp__(self, other):
+ v = cmp(self.family, other.family)
+ if v != 0:
+ return v
+ return cmp(self.id, other.id)
+
+ def __json__(self):
+ return {
+ "family" : self.family,
+ "id" : self.id,
+ }
\ No newline at end of file
Added: firehose/firehose/json.py
===================================================================
--- firehose/firehose/json.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/json.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,10 @@
+# A JSON-based API(view) for your app.
+# Most rules would look like:
+# @jsonify.when("isinstance(obj, YourClass)")
+# def jsonify_yourclass(obj):
+# return [obj.val1, obj.val2]
+# @jsonify can convert your objects to following types:
+# lists, dicts, numbers and strings
+
+from turbojson.jsonify import jsonify
+
Added: firehose/firehose/model.py
===================================================================
--- firehose/firehose/model.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/model.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,9 @@
+from turbogears.database import PackageHub
+from sqlobject import *
+
+hub = PackageHub('firehose')
+__connection__ = hub
+
+# class YourDataClass(SQLObject):
+# pass
+
Added: firehose/firehose/release.py
===================================================================
--- firehose/firehose/release.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/release.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,14 @@
+# Release information about firehose
+
+version = "1.0"
+
+# description = "Your plan to rule the world"
+# long_description = "More description about your plan"
+# author = "Your Name Here"
+# email = "YourEmail YourDomain"
+# copyright = "Vintage 2006 - a good year indeed"
+
+# if it's open source, you might want to specify these
+# url = "http://yourcool.site/"
+# download_url = "http://yourcool.site/download"
+# license = "MIT"
Added: firehose/firehose/static/css/style.css
===================================================================
--- firehose/firehose/static/css/style.css 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/static/css/style.css 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,134 @@
+/*
+ * Quick mash-up of CSS for the TG quick start page.
+ */
+
+html, body {
+ color: black;
+ background-color: #ddd;
+ font: x-small "Lucida Grande", "Lucida Sans Unicode", geneva, verdana, sans-serif;
+ margin: 0;
+ padding: 0;
+}
+
+td, th {padding:3px;border:none;}
+tr th {text-align:left;background-color:#f0f0f0;color:#333;}
+tr.odd td {background-color:#edf3fe;}
+tr.even td {background-color:#fff;}
+
+#header {
+ height: 80px;
+ width: 777px;
+ background: blue URL('../images/header_inner.png') no-repeat;
+ border-left: 1px solid #aaa;
+ border-right: 1px solid #aaa;
+ margin: 0 auto 0 auto;
+}
+
+a.link, a, a.active {
+ color: #369;
+}
+
+
+#main_content {
+ color: black;
+ font-size: 127%;
+ background-color: white;
+ width: 757px;
+ margin: 0 auto 0 auto;
+ border-left: 1px solid #aaa;
+ border-right: 1px solid #aaa;
+ padding: 10px;
+}
+
+#sidebar {
+ border: 1px solid #aaa;
+ background-color: #eee;
+ margin: 0.5em;
+ padding: 1em;
+ float: right;
+ width: 200px;
+ font-size: 88%;
+}
+
+#sidebar h2 {
+ margin-top: 0;
+}
+
+#sidebar ul {
+ margin-left: 1.5em;
+ padding-left: 0;
+}
+
+h1,h2,h3,h4,h5,h6,#getting_started_steps {
+ font-family: "Century Schoolbook L", Georgia, serif;
+ font-weight: bold;
+}
+
+h2 {
+ font-size: 150%;
+}
+
+#getting_started_steps a {
+ text-decoration: none;
+}
+
+#getting_started_steps a:hover {
+ text-decoration: underline;
+}
+
+#getting_started_steps li {
+ font-size: 80%;
+ margin-bottom: 0.5em;
+}
+
+#getting_started_steps h2 {
+ font-size: 120%;
+}
+
+#getting_started_steps p {
+ font: 100% "Lucida Grande", "Lucida Sans Unicode", geneva, verdana, sans-serif;
+}
+
+#footer {
+ border: 1px solid #aaa;
+ border-top: 0px none;
+ color: #999;
+ background-color: white;
+ padding: 10px;
+ font-size: 80%;
+ text-align: center;
+ width: 757px;
+ margin: 0 auto 1em auto;
+}
+
+.code {
+ font-family: monospace;
+}
+
+span.code {
+ font-weight: bold;
+ background: #eee;
+}
+
+#status_block {
+ margin: 0 auto 0.5em auto;
+ padding: 15px 10px 15px 55px;
+ background: #cec URL('../images/ok.png') left center no-repeat;
+ border: 1px solid #9c9;
+ width: 450px;
+ font-size: 120%;
+ font-weight: bolder;
+}
+
+.notice {
+ margin: 0.5em auto 0.5em auto;
+ padding: 15px 10px 15px 55px;
+ width: 450px;
+ background: #eef URL('../images/info.png') left center no-repeat;
+ border: 1px solid #cce;
+}
+
+.fielderror {
+ color: red;
+ font-weight: bold;
+}
\ No newline at end of file
Added: firehose/firehose/static/images/favicon.ico
===================================================================
(Binary files differ)
Property changes on: firehose/firehose/static/images/favicon.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: firehose/firehose/static/images/header_inner.png
===================================================================
(Binary files differ)
Property changes on: firehose/firehose/static/images/header_inner.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: firehose/firehose/static/images/info.png
===================================================================
(Binary files differ)
Property changes on: firehose/firehose/static/images/info.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: firehose/firehose/static/images/ok.png
===================================================================
(Binary files differ)
Property changes on: firehose/firehose/static/images/ok.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: firehose/firehose/static/images/tg_under_the_hood.png
===================================================================
(Binary files differ)
Property changes on: firehose/firehose/static/images/tg_under_the_hood.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: firehose/firehose/static/images/under_the_hood_blue.png
===================================================================
(Binary files differ)
Property changes on: firehose/firehose/static/images/under_the_hood_blue.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: firehose/firehose/templates/__init__.py
===================================================================
Added: firehose/firehose/templates/login.kid
===================================================================
--- firehose/firehose/templates/login.kid 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/templates/login.kid 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,114 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://purl.org/kid/ns#">
+
+<head>
+ <meta content="text/html; charset=UTF-8"
+ http-equiv="content-type" py:replace="''"/>
+ <title>Login</title>
+ <style type="text/css">
+ #loginBox
+ {
+ width: 30%;
+ margin: auto;
+ margin-top: 10%;
+ padding-left: 10%;
+ padding-right: 10%;
+ padding-top: 5%;
+ padding-bottom: 5%;
+ font-family: verdana;
+ font-size: 10px;
+ background-color: #eee;
+ border: 2px solid #ccc;
+ }
+
+ #loginBox h1
+ {
+ font-size: 42px;
+ font-family: "Trebuchet MS";
+ margin: 0;
+ color: #ddd;
+ }
+
+ #loginBox p
+ {
+ position: relative;
+ top: -1.5em;
+ padding-left: 4em;
+ font-size: 12px;
+ margin: 0;
+ color: #666;
+ }
+
+ #loginBox table
+ {
+ table-layout: fixed;
+ border-spacing: 0;
+ width: 100%;
+ }
+
+ #loginBox td.label
+ {
+ width: 33%;
+ text-align: right;
+ }
+
+ #loginBox td.field
+ {
+ width: 66%;
+ }
+
+ #loginBox td.field input
+ {
+ width: 100%;
+ }
+
+ #loginBox td.buttons
+ {
+ text-align: right;
+ }
+
+ </style>
+</head>
+
+<body>
+ <div id="loginBox">
+ <h1>Login</h1>
+ <p>${message}</p>
+ <form action="${previous_url}" method="POST">
+ <table>
+ <tr>
+ <td class="label">
+ <label for="user_name">User Name:</label>
+ </td>
+ <td class="field">
+ <input type="text" id="user_name" name="user_name"/>
+ </td>
+ </tr>
+ <tr>
+ <td class="label">
+ <label for="password">Password:</label>
+ </td>
+ <td class="field">
+ <input type="password" id="password" name="password"/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="buttons">
+ <input type="submit" name="login" value="Login"/>
+ </td>
+ </tr>
+ </table>
+
+ <input py:if="forward_url" type="hidden" name="forward_url"
+ value="${forward_url}"/>
+
+ <div py:for="name,values in original_parameters.items()" py:strip="1">
+ <input py:for="value in isinstance(values, list) and values or [values]"
+ type="hidden" name="${name}" value="${value}"/>
+ </div>
+ </form>
+ </div>
+</body>
+</html>
Added: firehose/firehose/templates/master.kid
===================================================================
--- firehose/firehose/templates/master.kid 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/templates/master.kid 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,47 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?python import sitetemplate ?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" py:extends="sitetemplate">
+
+<head py:match="item.tag=='{http://www.w3.org/1999/xhtml}head'" py:attrs="item.items()">
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
+ <title py:replace="''">Your title goes here</title>
+ <meta py:replace="item[:]"/>
+ <style type="text/css">
+ #pageLogin
+ {
+ font-size: 10px;
+ font-family: verdana;
+ text-align: right;
+ }
+ </style>
+ <style type="text/css" media="screen">
+ import "${tg.url('/static/css/style.css')}";
+</style>
+</head>
+
+<body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'" py:attrs="item.items()">
+ <div py:if="tg.config('identity.on') and not defined('logging_in')" id="pageLogin">
+ <span py:if="tg.identity.anonymous">
+ <a href="${tg.url('/login')}">Login</a>
+ </span>
+ <span py:if="not tg.identity.anonymous">
+ Welcome ${tg.identity.user.display_name}.
+ <a href="${tg.url('/logout')}">Logout</a>
+ </span>
+ </div>
+ <div id="header"> </div>
+ <div id="main_content">
+ <div id="status_block" class="flash" py:if="value_of('tg_flash', None)" py:content="tg_flash"></div>
+
+ <div py:replace="[item.text]+item[:]"/>
+
+ <!-- End of main_content -->
+ </div>
+<div id="footer"> <img src="${tg.url('/static/images/under_the_hood_blue.png')}" alt="TurboGears under the hood" />
+ <p>TurboGears is a open source front-to-back web development
+ framework written in Python</p>
+ <p>Copyright © 2007 Kevin Dangoor</p>
+</div>
+</body>
+
+</html>
Added: firehose/firehose/templates/welcome.kid
===================================================================
--- firehose/firehose/templates/welcome.kid 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/templates/welcome.kid 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,47 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
+ py:extends="'master.kid'">
+<head>
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/>
+<title>Welcome to TurboGears</title>
+</head>
+<body>
+
+ <div id="sidebar">
+ <h2>Learn more</h2>
+ Learn more about TurboGears and take part in its
+ development
+ <ul class="links">
+ <li><a href="http://www.turbogears.org">Official website</a></li>
+ <li><a href="http://docs.turbogears.org">Documentation</a></li>
+ <li><a href="http://trac.turbogears.org/turbogears/">Trac
+ (bugs/suggestions)</a></li>
+ <li><a href="http://groups.google.com/group/turbogears"> Mailing list</a> </li>
+ </ul>
+ <span py:replace="now">now</span>
+ </div>
+ <div id="getting_started">
+ <ol id="getting_started_steps">
+ <li class="getting_started">
+ <h3>Model</h3>
+ <p> <a href="http://docs.turbogears.org/1.0/GettingStarted/DefineDatabase">Design models</a> in the <span class="code">model.py</span>.<br/>
+ Edit <span class="code">dev.cfg</span> to <a href="http://docs.turbogears.org/1.0/GettingStarted/UseDatabase">use a different backend</a>, or start with a pre-configured SQLite database. <br/>
+ Use script <span class="code">tg-admin sql create</span> to create the database tables.</p>
+ </li>
+ <li class="getting_started">
+ <h3>View</h3>
+ <p> Edit <a href="http://docs.turbogears.org/1.0/GettingStarted/Kid">html-like templates</a> in the <span class="code">/templates</span> folder;<br/>
+ Put all <a href="http://docs.turbogears.org/1.0/StaticFiles">static contents</a> in the <span class="code">/static</span> folder. </p>
+ </li>
+ <li class="getting_started">
+ <h3>Controller</h3>
+ <p> Edit <span class="code"> controllers.py</span> and <a href="http://docs.turbogears.org/1.0/GettingStarted/CherryPy">build your
+ website structure</a> with the simplicity of Python objects. <br/>
+ TurboGears will automatically reload itself when you modify your project. </p>
+ </li>
+ </ol>
+ <div class="notice"> If you create something cool, please <a href="http://groups.google.com/group/turbogears">let people know</a>, and consider contributing something back to the <a href="http://groups.google.com/group/turbogears">community</a>.</div>
+ </div>
+ <!-- End of getting_started -->
+</body>
+</html>
Added: firehose/firehose/tests/__init__.py
===================================================================
Added: firehose/firehose/tests/test_controllers.py
===================================================================
--- firehose/firehose/tests/test_controllers.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/tests/test_controllers.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,32 @@
+import unittest
+import turbogears
+from turbogears import testutil
+from firehose.controllers import Root
+import cherrypy
+
+cherrypy.root = Root()
+
+class TestPages(unittest.TestCase):
+
+ def setUp(self):
+ turbogears.startup.startTurboGears()
+
+ def tearDown(self):
+ """Tests for apps using identity need to stop CP/TG after each test to
+ stop the VisitManager thread.
+ See http://trac.turbogears.org/turbogears/ticket/1217 for details.
+ """
+ turbogears.startup.stopTurboGears()
+
+ def test_method(self):
+ "the index method should return a string called now"
+ import types
+ result = testutil.call(cherrypy.root.index)
+ assert type(result["now"]) == types.StringType
+
+ def test_indextitle(self):
+ "The indexpage should have the right title"
+ testutil.createRequest("/")
+ response = cherrypy.response.body[0].lower()
+ assert "<title>welcome to turbogears</title>" in response
+
Added: firehose/firehose/tests/test_model.py
===================================================================
--- firehose/firehose/tests/test_model.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose/tests/test_model.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,22 @@
+# If your project uses a database, you can set up database tests
+# similar to what you see below. Be sure to set the db_uri to
+# an appropriate uri for your testing database. sqlite is a good
+# choice for testing, because you can use an in-memory database
+# which is very fast.
+
+from turbogears import testutil, database
+# from firehose.model import YourDataClass, User
+
+# database.set_db_uri("sqlite:///:memory:")
+
+# class TestUser(testutil.DBTest):
+# def get_model(self):
+# return User
+# def test_creation(self):
+# "Object creation should set the name"
+# obj = User(user_name = "creosote",
+# email_address = "spam python not",
+# display_name = "Mr Creosote",
+# password = "Wafer-thin Mint")
+# assert obj.display_name == "Mr Creosote"
+
Added: firehose/firehose.egg-info/PKG-INFO
===================================================================
--- firehose/firehose.egg-info/PKG-INFO 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose.egg-info/PKG-INFO 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,15 @@
+Metadata-Version: 1.0
+Name: firehose
+Version: 1.0
+Summary: UNKNOWN
+Home-page: UNKNOWN
+Author: UNKNOWN
+Author-email: UNKNOWN
+License: UNKNOWN
+Description: UNKNOWN
+Platform: UNKNOWN
+Classifier: Development Status :: 3 - Alpha
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Framework :: TurboGears
Added: firehose/firehose.egg-info/SOURCES.txt
===================================================================
--- firehose/firehose.egg-info/SOURCES.txt 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose.egg-info/SOURCES.txt 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,21 @@
+README.txt
+setup.py
+start-firehose.py
+firehose/__init__.py
+firehose/controllers.py
+firehose/json.py
+firehose/model.py
+firehose/release.py
+firehose.egg-info/PKG-INFO
+firehose.egg-info/SOURCES.txt
+firehose.egg-info/dependency_links.txt
+firehose.egg-info/not-zip-safe
+firehose.egg-info/paster_plugins.txt
+firehose.egg-info/requires.txt
+firehose.egg-info/sqlobject.txt
+firehose.egg-info/top_level.txt
+firehose/config/__init__.py
+firehose/templates/__init__.py
+firehose/tests/__init__.py
+firehose/tests/test_controllers.py
+firehose/tests/test_model.py
Added: firehose/firehose.egg-info/dependency_links.txt
===================================================================
--- firehose/firehose.egg-info/dependency_links.txt 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose.egg-info/dependency_links.txt 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1 @@
+
Added: firehose/firehose.egg-info/not-zip-safe
===================================================================
--- firehose/firehose.egg-info/not-zip-safe 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose.egg-info/not-zip-safe 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1 @@
+
Added: firehose/firehose.egg-info/paster_plugins.txt
===================================================================
--- firehose/firehose.egg-info/paster_plugins.txt 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose.egg-info/paster_plugins.txt 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,2 @@
+TurboGears
+PasteScript
Added: firehose/firehose.egg-info/requires.txt
===================================================================
--- firehose/firehose.egg-info/requires.txt 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose.egg-info/requires.txt 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1 @@
+TurboGears >= 1.0.3.2
\ No newline at end of file
Added: firehose/firehose.egg-info/sqlobject.txt
===================================================================
--- firehose/firehose.egg-info/sqlobject.txt 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose.egg-info/sqlobject.txt 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,2 @@
+db_module=firehose.model
+history_dir=$base/firehose/sqlobject-history
Added: firehose/firehose.egg-info/top_level.txt
===================================================================
--- firehose/firehose.egg-info/top_level.txt 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/firehose.egg-info/top_level.txt 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1 @@
+firehose
Added: firehose/sample-prod.cfg
===================================================================
--- firehose/sample-prod.cfg 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/sample-prod.cfg 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,84 @@
+[global]
+# This is where all of your settings go for your production environment.
+# You'll copy this file over to your production server and provide it
+# as a command-line option to your start script.
+# Settings that are the same for both development and production
+# (such as template engine, encodings, etc.) all go in
+# firehose/config/app.cfg
+
+# DATABASE
+
+# pick the form for your database
+# sqlobject.dburi="postgres://username hostname/databasename"
+# sqlobject.dburi="mysql://username:password hostname:port/databasename"
+# sqlobject.dburi="sqlite:///file_name_and_path"
+
+# If you have sqlite, here's a simple default to get you started
+# in development
+sqlobject.dburi="sqlite://%(current_dir_uri)s/devdata.sqlite"
+
+
+# if you are using a database or table type without transactions
+# (MySQL default, for example), you should turn off transactions
+# by prepending notrans_ on the uri
+# sqlobject.dburi="notrans_mysql://username:password hostname:port/databasename"
+
+# for Windows users, sqlite URIs look like:
+# sqlobject.dburi="sqlite:///drive_letter:/path/to/file"
+
+
+# SERVER
+
+server.environment="production"
+
+# Sets the number of threads the server uses
+# server.thread_pool = 1
+
+# if this is part of a larger site, you can set the path
+# to the TurboGears instance here
+# server.webpath=""
+
+# Set to True if you are deploying your App behind a proxy
+# e.g. Apache using mod_proxy
+# base_url_filter.on = False
+
+# Set to True if your proxy adds the x_forwarded_host header
+# base_url_filter.use_x_forwarded_host = True
+
+# If your proxy does not add the x_forwarded_host header, set
+# the following to the *public* host url.
+# (Note: This will be overridden by the use_x_forwarded_host option
+# if it is set to True and the proxy adds the header correctly.
+# base_url_filter.base_url = "http://www.example.com"
+
+# Set to True if you'd like to abort execution if a controller gets an
+# unexpected parameter. False by default
+# tg.strict_parameters = False
+
+# LOGGING
+# Logging configuration generally follows the style of the standard
+# Python logging module configuration. Note that when specifying
+# log format messages, you need to use *() for formatting variables.
+# Deployment independent log configuration is in firehose/config/log.cfg
+[logging]
+
+[[handlers]]
+
+[[[access_out]]]
+# set the filename as the first argument below
+args="('server.log',)"
+class='FileHandler'
+level='INFO'
+formatter='message_only'
+
+[[loggers]]
+[[[firehose]]]
+level='ERROR'
+qualname='firehose'
+handlers=['error_out']
+
+[[[access]]]
+level='INFO'
+qualname='turbogears.access'
+handlers=['access_out']
+propagate=0
Added: firehose/setup.py
===================================================================
--- firehose/setup.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/setup.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,69 @@
+from setuptools import setup, find_packages
+from turbogears.finddata import find_package_data
+
+import os
+execfile(os.path.join("firehose", "release.py"))
+
+packages=find_packages()
+package_data = find_package_data(where='firehose',
+ package='firehose')
+if os.path.isdir('locales'):
+ packages.append('locales')
+ package_data.update(find_package_data(where='locales',
+ exclude=('*.po',), only_in_packages=False))
+
+setup(
+ name="firehose",
+ version=version,
+
+ # uncomment the following lines if you fill them out in release.py
+ #description=description,
+ #author=author,
+ #author_email=email,
+ #url=url,
+ #download_url=download_url,
+ #license=license,
+
+ install_requires=[
+ "TurboGears >= 1.0.3.2",
+ ],
+ scripts=["start-firehose.py"],
+ zip_safe=False,
+ packages=packages,
+ package_data=package_data,
+ keywords=[
+ # Use keywords if you'll be adding your package to the
+ # Python Cheeseshop
+
+ # if this has widgets, uncomment the next line
+ # 'turbogears.widgets',
+
+ # if this has a tg-admin command, uncomment the next line
+ # 'turbogears.command',
+
+ # if this has identity providers, uncomment the next line
+ # 'turbogears.identity.provider',
+
+ # If this is a template plugin, uncomment the next line
+ # 'python.templating.engines',
+
+ # If this is a full application, uncomment the next line
+ # 'turbogears.app',
+ ],
+ classifiers=[
+ 'Development Status :: 3 - Alpha',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Topic :: Software Development :: Libraries :: Python Modules',
+ 'Framework :: TurboGears',
+ # if this is an application that you'll distribute through
+ # the Cheeseshop, uncomment the next line
+ # 'Framework :: TurboGears :: Applications',
+
+ # if this is a package that includes widgets that you'll distribute
+ # through the Cheeseshop, uncomment the next line
+ # 'Framework :: TurboGears :: Widgets',
+ ],
+ test_suite='nose.collector',
+ )
+
Added: firehose/start-firehose.py
===================================================================
--- firehose/start-firehose.py 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/start-firehose.py 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+__requires__="TurboGears"
+import pkg_resources
+
+from turbogears import config, update_config, start_server
+import cherrypy
+cherrypy.lowercase_api = True
+from os.path import *
+import sys
+
+# first look on the command line for a desired config file,
+# if it's not on the command line, then
+# look for setup.py in this directory. If it's not there, this script is
+# probably installed
+if len(sys.argv) > 1:
+ update_config(configfile=sys.argv[1],
+ modulename="firehose.config")
+elif exists(join(dirname(__file__), "setup.py")):
+ update_config(configfile="dev.cfg",modulename="firehose.config")
+else:
+ update_config(configfile="prod.cfg",modulename="firehose.config")
+config.update(dict(package="firehose"))
+
+from firehose.controllers import Root
+start_server(Root())
Property changes on: firehose/start-firehose.py
___________________________________________________________________
Name: svn:executable
+ *
Added: firehose/test.cfg
===================================================================
--- firehose/test.cfg 2008-01-25 03:18:17 UTC (rev 7256)
+++ firehose/test.cfg 2008-01-25 03:25:05 UTC (rev 7257)
@@ -0,0 +1,4 @@
+# You can place test-specific configuration options here (like test db uri, etc)
+
+sqlobject.dburi = "sqlite:///:memory:"
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]