197 Commits

Author SHA1 Message Date
Elrond
ac8212fe65 Remove mongo style .id = ObjectId()
On SQL we can't generate the primary key on our own. So
just remove this stuff.
2012-12-24 00:07:24 +01:00
Elrond
b39d1f2351 Mongo removal: Remove the validate=True arg to obj.save()
all callers were forced to use validate=True anyway. So
remove this useless stuff.
2012-12-24 00:07:24 +01:00
Elrond
1eac751bd2 Fix some unicode related issues in oauth and the api.
Found using the previous commit.
2012-12-23 23:55:44 +01:00
Joar Wandborg
57c6473aa2 Added API tests 2012-12-23 21:45:46 +01:00
Sebastian Spaeth
cfa922295e Convert return HttpException to raise HttpException
controllers (view function) raise HttpException's and do not return them.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-23 11:58:51 +01:00
Sebastian Spaeth
cc195d5b82 plugins/api: webob.Response -> werkzeug.Response 2012-12-21 08:12:25 +01:00
Sebastian Spaeth
7c552c0bd7 plugins/api: use headers.set(), not headers.update()
The werkzeug.Response().headers do not offer an update() method as
the same key can be twice in the header 'dict'. Thus, iterate over
the header keys and use header.set(key, value) which replaces an
existing header key.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:12:25 +01:00
Sebastian Spaeth
74af60bb32 replace webob.Response with werkzeug Response
Replace webob usage in one more file. Document a TODO that should
be clarified, we should probably be using json_response rather than
Response() here.

Modify the TestMeddleware to not rely on the content_type attribute
being present, while werkzeug.wrappers Response() has it the BaseResponse()
object which is often returned in tests does not have it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:12:25 +01:00
Sebastian Spaeth
bf3b9e783d Transition webob BadRequest|HTTPFound to webob/redirect
More transitioning away from webob
Response import from webob was unused
2012-12-21 08:12:25 +01:00
Sebastian Spaeth
62d14bf50b Transition webob.HttpForbidden to webob's exceptions Forbidden
Also the BadRequest exception.
2012-12-21 08:11:40 +01:00
Sebastian Spaeth
5c2b84869f Move DBModel._id -> DBModel.id
We were refering to model._id in most of the code base as this is
what Mongo uses. However, each use of _id required a) fixup of queries:
e.g. what we did in our find() and find_one() functions moving all
'_id' to 'id'. It also required using AliasFields to make the ._id
attribute available. This all means lots of superfluous fixing and
transitioning in a SQL world.

It will also not work in the long run. Much newer code already refers
to the objects by model.id (e.g. in the oauth plugin), which will break
with Mongo. So let's be honest, rip out the _id mongoism and live with
.id as the one canonical way to address objects.

This commit modifies all users and providers of model._id to use
model.id instead. This patch works with or without Mongo removed first,
but will break Mongo usage (even more than before)

I have not bothered to fixup db.mongo.* and db.sql.convert
(which converts from Mongo to SQL)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 00:30:48 +01:00
Sebastian Spaeth
2f5926a65d Fiy python2.7'ism (#566)
The oauth plugin used timedelta.total_seconds which was introduced
in python 2.7 only. To preserve backwards compatability, we simply
calculate the time difference in seconds manually.

I considered monkeypatching total_seconds to the timedelta object,
but it is a built-in type written in C (I believe) and modifying
attributes failed horribly. Switch this to use total_seconds once we
require python 2.7 as minimum version.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-14 11:52:53 +01:00
Sebastian Spaeth
9945468603 trim_whitespace meddleware plugin
Our HTML output is very verbose (=whitespacy) as our templates are
written with an 80 char limit and lots of newlines between blocks,
variables etc....

This is a plugin that naively strips of all but the first whitespace
from the HTML response. We might want to have an all-fancy html tidy
interface here at some point, but it nicely decreases the HTML size
about a third on some simple pages.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-01 20:19:43 +01:00
Elrond
316e1dfdde SQL Migrations: Rewrite table creation completely.
We have migrations creating new tables. Those currently use
"raw" table definitions. This easily gives errors (we
already had this problem).

So instead rewrite those to use declarative tables and use
those to create new tables. Just copy the new table over to
the migration, strip it down to the bare minimum, rename to
_v0, base it on declarative_base() and be done!

Do this for the current migrations.
2012-11-24 19:23:08 +01:00
Joar Wandborg
ac4c5aef57 Added HTTP API auth plugin 2012-10-20 23:56:00 +02:00
Joar Wandborg
5b60ec41ee Removed Routes dependency, added admin routes 2012-10-20 12:35:03 +02:00
Joar Wandborg
d56e82635f Fixed OAuth access_token duplicate route
Changed route name to "[...]list_connections"
2012-10-15 22:59:53 +02:00
Joar Wandborg
7742dcc1fb Switched most stuff over from Routes
Removed the Routes routing functionality and replaced it with
werkzeug.routes. Most views are functional.

Known issues:

 - Translation integration with the request object is not yet figured
   out. This breaks 404 pages.
2012-10-14 13:46:31 +02:00
Joar Wandborg
111a609df5 Replaced all request.POST with request.form, ...
- Fixed error handling in OAuth plugin
- Changed request.POST file fields to request.files
2012-09-29 21:08:20 +02:00
Joar Wandborg
5354f954dc Added support for http callbacks on processing
Sends an HTTP POST request back to an URL given on submission to the API
submit view.
2012-09-26 23:53:51 +02:00
Christopher Allan Webber
315ac0a2d3 Correcting a couple of spelling errors. Thanks elesa, for finding them! 2012-09-24 11:40:47 -05:00
Joar Wandborg
5ee1ab2abb Fixed typos visisble, appplication 2012-09-22 12:03:32 +02:00
Joar Wandborg
6b8c66d44c Added name kwarg to Column(Enum(...)) in OAuth models 2012-09-21 13:20:56 +02:00
Joar Wandborg
88a9662be4 Added client registration caps to OAuth plugin
THE MIGRATIONS SUPPLIED WITH THIS COMMIT WILL DROP AND RE-CREATE YOUR
oauth__tokens AND oauth__codes TABLES. ALL YOUR OAUTH CODES AND TOKENS
WILL BE LOST.

- Fixed pylint issues in db/sql/migrations.
- Added __repr__ to the User model.
- Added _disable_cors option to json_response.
- Added crude error handling to the api.tools.api_auth decorator
- Updated the OAuth README.
- Added client registration, client overview, connection overview,
  client authorization views and templates.
- Added error handling to the OAuthAuth Auth object.
- Added AuthorizationForm, ClientRegistrationForm in oauth/forms.
- Added migrations for OAuth, added client registration migration.
- Added OAuthClient, OAuthUserClient models.
- Added oauth/tools with require_client_auth decorator method.
2012-09-21 13:09:42 +02:00
Joar Wandborg
d4c066abf0 Fixed typo in OAuth README 2012-09-19 22:13:16 +02:00
Joar Wandborg
6ed236d5b5 Added security warning to OAuth README 2012-09-19 22:12:13 +02:00
Joar Wandborg
f26224d433 Fixed a horrible security issue in the OAuth plugin.
Also added some real triggering logic to the OAuthAuth Auth object.
2012-09-19 21:57:59 +02:00
Joar Wandborg
a7b8c214e9 Added some more helpful links to the OAuth docs
- OAuth v2.25 draft
- IRC channel
- OAuth plugin source code
2012-09-18 21:51:22 +02:00
Joar Wandborg
4427b1bea4 Fixed typo in OAuth docs, recieve => receive 2012-09-18 21:44:02 +02:00
Joar Wandborg
df3147b986 Added documentation for the OAuth plugin 2012-09-18 21:42:10 +02:00
Joar Wandborg
09e528acbb Fixed validation in API post_entry.
Added state to API get_entry_serializable
2012-09-17 23:54:27 +02:00
Joar Wandborg
c92aa0d0b2 API: Fixed media file URLs, limits
- Added default limit and limit arg to get_entries
- Fixed URL generation for BasicFileStorage files in API
2012-09-15 22:34:34 +02:00
Joar Wandborg
965b39a84f Added CORS headers to API json_response 2012-09-15 22:18:49 +02:00
Joar Wandborg
3a1993288f Fixed ?next=<url> argument for require_active_login
It now includes the full URI, including GET args, not just the path.
2012-09-15 21:07:24 +02:00
Joar Wandborg
999f91eb8a Fixed typo in API post_entry 2012-09-15 16:54:14 +02:00
Joar Wandborg
4504dbba9b Added post_entry at /api/submit 2012-09-15 16:51:29 +02:00
Joar Wandborg
85726f7360 Added fields to /api/entries, wrote docstrings for api.tools 2012-09-15 15:54:22 +02:00
Joar Wandborg
42c837523e Added /api/entries view 2012-09-15 15:25:26 +02:00
Joar Wandborg
a062149e90 Created API plugin, moved api_auth to the API plugin 2012-09-13 20:59:00 +02:00
Joar Wandborg
f46e2a4db9 Add OAuth models, plugin DB migrations, api_auth 2012-09-13 20:38:59 +02:00
Christopher Allan Webber
7a690a5ae5 Updated flatpages example in plugins.rst to reflect reality & point to flatpages docs 2012-08-20 08:54:09 -05:00
Will Kahn-Greene
05e007c1db Rework plugin infrastructure to nix side-effects
This reworks the plugin infrastructure so as to remove module-loading
side-effects which were making things a pain in the ass to test.

With the new system, there's no auto-registering meta class. Instead
plugins do whatever they want and then specify a hooks dict that maps
hook names to callables for the things they're tying into. The most
common one (and the only one we've implemented so far) is "setup".

This also simplifies the sampleplugin a little by moving the code
to __init__.py.
2012-07-17 21:02:12 -04:00
Will Kahn-Greene
54b42ee564 Overhaul flatpages
* move contents of main.py to __init__.py
* update documentation in README
* change the key/value configuration specification
* added a recipe for passing values from the url to the template
* removed some unused code
2012-07-16 09:26:28 -04:00
Will Kahn-Greene
8815541c26 Fix template 2012-07-16 09:26:28 -04:00
Will Kahn-Greene
4bd65f69c7 Finish flatpagesplugin; add plugin docs 2012-07-16 09:26:28 -04:00
Will Kahn-Greene
8545dd50f0 Flatpages first pass
This fixes the template loader so that it can load plugin templates.

This adds code for registering template paths so that plugins can add
their own templates.

This adds the base code for the flatpagesfile plugin. It doesn't serve
pages, yet, but it's pretty close.
2012-07-16 09:26:28 -04:00
Will Kahn-Greene
29b6f91740 401. Plugin infrastructure
* implements installing, loading and setup for plugins
* codifies configuration
* has a sample plugin
* docs
* tests
2012-05-13 00:00:08 -04:00