Sitelet https://github.com/usingnamespace/usingnamespace/pull/1/files
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
848ec07
Remove management stuff...
Aug 26, 2017
1acfad7
These tests are no longer necessary
Aug 26, 2017
57b320f
Remove management stuff
Aug 26, 2017
acd8830
This was updated, not sure what changed
Aug 26, 2017
fcc9227
Remove jquery
Aug 26, 2017
ba2f167
Remove CSS framework stuff
Aug 26, 2017
2996bc2
Remove not used package
Aug 26, 2017
8d47fec
Add TODO file
Aug 26, 2017
810c4bd
Remove extra line
Aug 26, 2017
9338512
Move tests
Aug 26, 2017
56a2662
Update setup.py
Aug 26, 2017
0442c65
No more deform
Aug 26, 2017
5f9a0db
PEP8 __init__.py
Aug 26, 2017
120e672
Add new dependencies
Aug 26, 2017
ddf6ed6
Use non-threadlocal dbsession
Aug 26, 2017
cc6fbc5
PEP8 cleanups
Aug 29, 2017
18fd086
Make sure to set time to None when clearing
Aug 29, 2017
41eef59
Fix bug
Aug 29, 2017
ee5b5ee
More PEP8 cleanups
Aug 29, 2017
717cecf
Allow pubdate to be set to None
Aug 29, 2017
8f3c601
Tags should be unique across sites
Aug 29, 2017
96e1d19
Models should not contain code that requires access to the DBSession
Aug 29, 2017
5289380
Update README
Sep 30, 2017
12c7531
Rename from txt to rst
Sep 30, 2017
6aeff1e
Pygments is a dependency
Sep 30, 2017
e930315
Update copyright
Sep 30, 2017
174cc26
Add missing comma
Oct 29, 2017
ff220d7
Removing forms
Oct 29, 2017
c7e304b
Remove no longer needed code
Oct 29, 2017
1698633
Remove utility functions
Oct 29, 2017
a1f16cf
Remove authentication component
Oct 29, 2017
17cd318
Update development config
Oct 29, 2017
d82a138
Re-organise things a little
Oct 29, 2017
e5b460a
Don't include the .api unless configured to do so
Oct 29, 2017
302841b
Remove ticket/auth
Oct 29, 2017
fd59e7d
Remove no longer required file
Oct 29, 2017
37fc9f5
Make PEP8 happy
Oct 29, 2017
95b5960
Use properties rather than some finalisation function
Oct 29, 2017
0b5879d
No longer depend on FinaliseContext
Oct 29, 2017
03e1202
Listen on IPv{4,6}
Oct 29, 2017
6d068a4
We no longer have 'management'
Oct 29, 2017
c8f6eda
FinaliseContext is no more
Oct 29, 2017
86ce9a0
Cleanup api.__init__
Oct 29, 2017
295e22f
Explicitly include everything we need for api
Oct 29, 2017
79a308a
Change required_setting name
Oct 29, 2017
95ad544
Require specific version of pyramid_authsanity
Oct 30, 2017
0cd62d8
Setup authentication/authorization
Oct 30, 2017
dde710a
Move includeme stuff from meta.py
Dec 4, 2017
f6639a2
Accept datetime.time for the time
Dec 4, 2017
cbe8ac3
No bare except
Dec 4, 2017
bebb4d7
Make the id unique, and an index
Dec 4, 2017
205260e
Tag is no longer unique or an index
Dec 4, 2017
af4473e
Tag has a site_id, so each tag name should be unique per site
Dec 4, 2017
388a5d3
Add relationship
Dec 4, 2017
8664677
Cleanup initdb script to work with new world order
Dec 4, 2017
c09208b
We no longer have a management app
Dec 4, 2017
d2a2c15
If we convert to datetime.time, store the result
Dec 4, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012-2013 Bert JW Regeer <bertjw@regeer.org>
Copyright (c) 2012-2017 Bert JW Regeer <bertjw@regeer.org>

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
Expand Down
57 changes: 57 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
usingnamespace
==============

Installation
------------

Not available yet...

Developing
----------

Prerequisites:

0. PostgreSQL 9.6, modify config/development.ini to configure the connection
string
1. Create new database for usingnamespace, and make sure to run as a database
administrator in the new database:

.. code::

CREATE EXTENSION pgcrypto;

This is used by the application to create UUID's.

If PostgreSQL >9.4 is not available, you may also use the ``uuid-ossp`` extension:

.. code::

CREATE EXTENSION "uuid-ossp";

Then add a new function:

.. code::

CREATE FUNCTION gen_random_uuid()
RETURNS uuid
AS '
BEGIN
RETURN uuid_generate_v4();
END'
LANGUAGE 'plpgsql';

2. Yarn has to be installed (node as well...)

Getting the application set up locally:

0. Change directory to this project
1. Create virtualenv for Project in $venv
2. $venv/bin/pip install -e .
3. $venv/bin/usingnamespace_db_init config/development.ini
4. cd webassets
yarn install
5. In a seperate terminal window:
yarn run watch
6. In a seperate terminal window:
$venv/bin/pserve --reload config/development.ini
7. Visit the URL printed on the console
16 changes: 0 additions & 16 deletions README.txt

This file was deleted.

9 changes: 9 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
TODO:

- Move remote_addr from user_tickets and user_api_tickets into a seperate table
so that one can see a list of what remote endpoints have used a particular
ticket. This will allow user for example to know if their API token has been
stolen, or if their session is being used from a location they aren't
expecting.

-
21 changes: 7 additions & 14 deletions config/development.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,33 @@ pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en

sqlalchemy.url = postgresql://usingnamespace:usingnamespace@127.0.0.1/usingnamespace
sqlalchemy.url = postgresql://127.0.0.1/usingnamespace
pyramid.includes =
pyramid_debugtoolbar

pyramid.secret.session = INSERTSECRETHERE
pyramid.secret.auth = INSERTOTHERSECRETHERE
usingnamespace.secret.session = INSERTSECRETHERE
usingnamespace.secret.auth = INSERTOTHERSECRETHERE
usingnamespace.upload_path = /tmp
usingnamespace.management.domain = management.usingnamespace.net
usingnamespace.name = Using Namespace
usingnamespace.api.sub = true
usingnamespace.api.domain = api.usingnamespace.net
usingnamespace.api.route_path =

[app:main]
use = egg:usingnamespace#main

[app:api]
use = egg:usingnamespace#api

[app:management]
use = egg:usingnamespace#management

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6545
listen = 0.0.0.0:6545 [::]:6545

[server:api]
use = egg:waitress#main
host = 0.0.0.0
port = 6546

[server:management]
use = egg:waitress#main
host = 0.0.0.0
port = 6547

# Begin logging configuration

[loggers]
Expand Down
91 changes: 46 additions & 45 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,70 @@
from setuptools import setup, find_packages

here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.txt')).read()
README = open(os.path.join(here, 'README.rst')).read()
CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()

requires = [
'SQLAlchemy',
'pyramid',
'pyramid_tm',
'transaction',
'waitress',
'zope.sqlalchemy',

'cryptacular',
'deform',
'misaka',
'psycopg2',
'pyramid_deform',
'pygments',
'pyramid',
'pyramid_authsanity~=1.1.0,<2.0.0',
'pyramid_mailer',
'pyramid_mako',
]
'pyramid_services',
'pyramid_retry',
'pyramid_tm',
'sqlalchemy',
'transaction',
'waitress',
'zope.sqlalchemy',
]

tests_require = []

testing_requires = tests_require + [
'nose',
testing_requires = tests_require + [
'pytest',
'pytest-cov',
'coverage',
]
]

develop_requires = [
'pyramid_debugtoolbar',
]
]

setup(name='usingnamespace',
version='0.0',
description='usingnamespace',
long_description=README + '\n\n' + CHANGES,
classifiers=[
setup(
name='usingnamespace',
version='0.0',
description='usingnamespace',
long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
author='Bert JW Regeer',
author_email='bertjw@regeer.org',
url='http://usingnamespace.com/',
keywords='web wsgi pylons pyramid blog',
packages=find_packages('.', exclude=['tests']),
include_package_data=True,
zip_safe=False,
install_requires=requires,
extras_require={
'develop': develop_requires,
'testing': testing_requires,
},
entry_points={
"paste.app_factory": [
'main = usingnamespace:main',
'api = usingnamespace:api',
],
author='Bert JW Regeer',
author_email='bertjw@regeer.org',
url='http://usingnamespace.com/',
keywords='web wsgi bfg pylons pyramid',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
test_suite='usingnamespace.tests',
install_requires=requires,
tests_require=tests_require,
extras_require = {
'develop': develop_requires,
'testing': testing_requires,
},
entry_points="""\
[paste.app_factory]
main = usingnamespace:main
api = usingnamespace.api:main
management = usingnamespace.management:main
[console_scripts]
usingnamespace_init_db = usingnamespace.scripts.initializedb:main
usingnamespace_destroy_db = usingnamespace.scripts.destroydb:main
""",
)

"console_scripts": [
'usingnamespace_init_db = usingnamespace.scripts.initializedb:main',
'usingnamespace_destroy_db = usingnamespace.scripts.destroydb:main',
],
}
)
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

77 changes: 35 additions & 42 deletions usingnamespace/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
import logging
log = logging.getLogger(__name__)

from pyramid.config import Configurator
from pyramid.settings import asbool

from sqlalchemy import engine_from_config
from sqlalchemy.exc import DBAPIError

from .models import DBSession
log = logging.getLogger(__name__)

required_settings = [
'usingnamespace.name',
]
'usingnamespace.name',
'usingnamespace.api.sub',
]

def includeme(config):
config.include('pyramid_retry')
config.include('pyramid_services')
config.include('pyramid_mako')
config.include('pyramid_mailer')

config.include('.models.meta')

config.add_static_view('static', 'static', cache_max_age=3600)
config.add_static_view(
'files',
config.registry.settings['usingnamespace.upload_path'],
cache_max_age=3600
)

config.add_route(
'main',
'/*traverse',
use_global_views=True
)

config.scan('.views')
config.scan('.subscribers')


def main(global_config, **app_settings):
""" This function returns a Pyramid WSGI application.
Expand All @@ -19,10 +42,6 @@ def main(global_config, **app_settings):
settings = global_config.copy()
settings.update(app_settings)

engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
config = Configurator(settings=settings, root_factory='.traversal.MainRoot')

do_start = True

for _req in required_settings:
Expand All @@ -34,37 +53,11 @@ def main(global_config, **app_settings):
log.error('Unable to start due to missing configuration')
exit(-1)

# Include the transaction manager
config.include('pyramid_tm')

# We use mako for template rendering
config.include('pyramid_mako')

# Set-up pyramid_deform
config.include('pyramid_deform')

# Add in pyramid_mailer for sending out emails
config.include('pyramid_mailer')

# Add in the API...
config.include('.api')

# Add in the Management interface...
config.include('.management')

config.add_static_view('static', 'static', cache_max_age=3600)
config.add_static_view('deform_static', 'deform:static', cache_max_age=3600)
config.add_static_view('files', config.registry.settings['usingnamespace.upload_path'], cache_max_age=3600)

config.add_route('main',
'/*traverse',
use_global_views=True
)

# Scan the views sub-module
config.scan('.views')
settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager'
config = Configurator(settings=settings, root_factory='.traversal.MainRoot')
config.include('.')

# Scan the subscribers for events sub-module
config.scan('.subscribers')
if asbool(settings['usingnamespace.api.sub']) is True:
config.include('.api')

return config.make_wsgi_app()
Loading