Skip to content

Commit

Permalink
Merge pull request #1 from BlackCrystal/turbogears2-full
Browse files Browse the repository at this point in the history
Turbogears2 full
  • Loading branch information
miamibc authored Jun 29, 2021
2 parents 1d15d5b + 39764d7 commit 545af94
Show file tree
Hide file tree
Showing 53 changed files with 2,296 additions and 29 deletions.
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
recursive-include wiki/public *
include wiki/public/favicon.ico
recursive-include wiki/i18n *
recursive-include wiki/templates *
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Install requirements
pip install -r requirements.txt
```

Start server
Start "HelloWorld" server

```shell
python server.py
Expand All @@ -36,6 +36,33 @@ Now try to build something more incredible, like things we listed [here in the p

GL & HF.

## Something more incredible

Wiki folder contains application with TurboGears full framweork.

To set it up, execute these commands

```shell
cd wiki
python setup.py develop
gearbox setup-app
```

Then start server in development mode

```shell
gearbox serve --reload --debug
```

Or in production mode

```shell
gearbox serve
```

Open webpage [http://localhost:8080/](http://localhost:8080/) and You will see TurboGears2 welcome page with documentation.


## Useful links

- [Virtualenv](https://docs.python-guide.org/dev/virtualenvs/#lower-level-virtualenv)
Expand Down
Binary file added devdata.db
Binary file not shown.
164 changes: 164 additions & 0 deletions development.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#
# wiki - TurboGears 2 development environment configuration
#
# The %(here)s variable will be replaced with the parent directory of this file
#
# This file is for deployment specific config options -- other configuration
# that is always required for the app is done in the config directory,
# and generally should not be modified by end users.

[DEFAULT]
# WARNING: *THE LINE BELOW MUST BE FALSE ON A PRODUCTION ENVIRONMENT*
# Debug mode will enable the interactive debugging tool, allowing ANYONE to
# execute malicious code after an exception is raised.
debug = true

# ERROR REPORTING BY EMAIL
# Uncomment to enable email error reporting, you probably want this
# on production to receive application crashes by email
#trace_errors.error_email = [email protected]
trace_errors.from_address = turbogears@localhost
trace_errors.smtp_server = localhost

# Uncomment if email server requires authentication
#trace_errors.smtp_use_tls = true
#trace_errors.smtp_username = unknown
#trace_errors.smtp_password = unknown

# Uncomment to enable additional context data for email error reporting
#trace_errors.dump_request = true
#trace_errors.dump_local_frames = true

# ERROR REPORTING TO SENTRY
# Uncomment to enable reporting errors to a Sentry server
#trace_errors.sentry_dsn = http://public:[email protected]/1

# REPORT SLOW REQUESTS
#trace_slowreqs.enable = true
#trace_slowreqs.interval = 25
#trace_slowreqs.exclude = /tw2/resources

[server:main]
use = egg:gearbox#wsgiref
host = 127.0.0.1
port = 8080

[app:main]
use = egg:wiki

# Default application language, when available this will be
# used when none of the browser requested languages is available.
#i18n.lang = en

cache_dir = %(here)s/data
session.key = wiki
session.secret = 188e9296-a834-4027-9c8a-304f32836f45

#By default session is store in cookies to avoid the overhead
#of having to manage a session storage. On production you might
#want to switch to a better session storage.
session.type = cookie
session.validate_key = 188e9296-a834-4027-9c8a-304f32836f45

# If you'd like to fine-tune the individual locations of the cache data dirs
# un-comment the desired settings here:
#cache.data_dir = %(here)s/data/cache

# Disable template autoreload to boost performances in production
# WARNING: if you want to deploy your application using a zipped egg
# (ie: if your application's setup.py defines zip-safe=True, then you
# MUST put "false" for the production environment because there will
# be no disk and real files to compare time with.
#auto_reload_templates = false

# Turn off static files serving from public/ directory
# this can be a speed boost if you have a proxy server already
# serving them for you.
#serve_static = false

#turn this setting to "min" if you would like tw to produce minified
#javascript files (if your library supports that)
toscawidgets.framework.resource_variant=debug

# pick the form for your database
# %(here) may include a ':' character on Windows environments; this can
# invalidate the URI when specifying a SQLite db via path name
# sqlalchemy.url=postgres://username:password@hostname:port/databasename
# sqlalchemy.url=mysql://username:password@hostname:port/databasename


# If you have sqlite, here's a simple default to get you started
# in development

sqlalchemy.url = sqlite:///%(here)s/devdata.db
#echo shouldn't be used together with the logging module.
sqlalchemy.echo = false
sqlalchemy.echo_pool = false
sqlalchemy.pool_recycle = 3600

# This line ensures that Genshi will render xhtml when sending the
# output. Change to html or xml, as desired.
templating.genshi.method = xhtml
templating.genshi.doctype = html5

# This might be required to make Genshi work on Python3.4
#templating.genshi.name_constant_patch = true

# the compiled template dir is a directory that must be readable and writable
# by your webserver. It will be used to store the resulting templates once
# compiled by the TemplateLookup system.
# During development you generally don't need this option since paste's HTTP
# server will have access to you development directories, but in production
# you'll most certainly want to have apache or nginx to write in a directory
# that does not contain any source code in any form for obvious security
# reasons. If disabled, None, False, or not writable, it will fall back
# to an in-memory cache.
templating.mako.compiled_templates_dir = %(here)s/data/templates

# Logging configuration
# Add additional loggers, handlers, formatters here
# Uses python's logging config file format
# http://docs.python.org/lib/logging-config-fileformat.html
[loggers]
keys = root, wiki, sqlalchemy, auth

[handlers]
keys = console

[formatters]
keys = generic

# If you create additional loggers, add them as a key to [loggers]
[logger_root]
level = INFO
handlers = console

[logger_wiki]
level = DEBUG
handlers =
qualname = wiki
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither. (Recommended for production systems.)
# A logger for authentication, identification and authorization
# this is repoze.who:
[logger_auth]
level = WARN
handlers =
qualname = auth

# If you create additional handlers, add them as a key to [handlers]
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

# If you create additional formatters, add them as a key to [formatters]
[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
76 changes: 76 additions & 0 deletions migration/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
# from logging.config import fileConfig
# fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
from wiki import model
target_metadata = model.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.


def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url, version_table='migrate_version')

with context.begin_transaction():
context.run_migrations()


def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool
)

connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata,
version_table='migrate_version'
)

try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()


if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
22 changes: 22 additions & 0 deletions migration/script.py.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""${message}

Revision ID: ${up_revision}
Revises: ${down_revision}
Create Date: ${create_date}

"""

# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}

from alembic import op
import sqlalchemy as sa
${imports if imports else ""}

def upgrade():
${upgrades if upgrades else "pass"}


def downgrade():
${downgrades if downgrades else "pass"}
Empty file added migration/versions/empty.txt
Empty file.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ crank==0.8.1
MarkupSafe==2.0.1
repoze.lru==0.7
TurboGears2==2.4.3
WebOb==1.8.7
WebOb==1.8.7
setuptools==57.0.0
49 changes: 49 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[nosetests]
verbosity = 2
detailed-errors = 1
with-coverage = false
cover-erase = true
cover-package = wiki

# Babel configuration
[compile_catalog]
domain = wiki
directory = wiki/i18n
statistics = true

[extract_messages]
add_comments = TRANSLATORS:
output_file = wiki/i18n/wiki.pot
width = 80
keywords = l_

[init_catalog]
domain = wiki
input_file = wiki/i18n/wiki.pot
output_dir = wiki/i18n

[update_catalog]
domain = wiki
input_file = wiki/i18n/wiki.pot
output_dir = wiki/i18n
previous = true

# Static files extraction for TW
[archive_tw_resources]
output = wiki/public/toscawidgets/
distributions = wiki
#yuicompressor = /home/someuser/bin/yuicompressor.jar
#compresslevel = 2
onepass = true

[archive_tw2_resources]
output = wiki/public/tw2/
distributions = wiki
force = true
#yuicompressor = /home/someuser/bin/yuicompressor.jar
#compresslevel = 2
onepass = true

[aliases]
# A handy alias to make a release to pypi
release = egg_info -RDb "" sdist bdist_egg register upload
Loading

0 comments on commit 545af94

Please sign in to comment.