Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
corepost
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
nexlab
corepost
Commits
2ff5ffb1
Commit
2ff5ffb1
authored
Feb 14, 2012
by
Jacek Furmankiewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 1: wrong class passed as self to router methods
parent
84b8be92
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
18 deletions
+30
-18
README.md
README.md
+2
-4
routing.py
corepost/routing.py
+2
-1
issues.feature
corepost/test/feature/issues.feature
+13
-0
home_resource.py
corepost/test/home_resource.py
+10
-1
setup.py
setup.py
+3
-12
No files found.
README.md
View file @
2ff5ffb1
Twisted REST micro-framework
================================
Based on
*Flask*
API, with integrated multiprocessing support for full usage of all CPUs.
Based on
*Flask*
API, with
plans
integrated multiprocessing support for full usage of all CPUs.
Provides a more Flask/Sinatra-style API on top of the core
*twisted.web*
APIs.
Geared towards creating REST-oriented server platforms.
...
...
@@ -222,7 +222,6 @@ Calling it with "Accept: text/yaml" will return:
- {test1: Test1}
- {test2: Test2}
*Note*
: marshalling to XML will be supported in a future release. There is no default Python library that does this automatically.
HTTP codes
------------------
...
...
@@ -255,5 +254,4 @@ Can be run using:
Plans
-----
*
match all the relevant features of the Flask API
*
integrate twisted.internet.processes in order to scale to multiple CPU cores : http://pypi.python.org/pypi/twisted.internet.processes
*
integrate multi core support
\ No newline at end of file
corepost/routing.py
View file @
2ff5ffb1
...
...
@@ -132,6 +132,7 @@ class RequestRouter:
self
.
__routers
=
{}
self
.
__schema
=
schema
self
.
__registerRouters
(
urlContainer
)
self
.
__urlContainer
=
urlContainer
@
property
def
path
(
self
):
...
...
@@ -205,7 +206,7 @@ class RequestRouter:
try
:
# if POST/PUT, check if we need to automatically parse JSON
self
.
__parseRequestData
(
request
)
val
=
urlrouter
.
call
(
self
,
request
,
**
allargs
)
val
=
urlrouter
.
call
(
self
.
__urlContainer
,
request
,
**
allargs
)
#handle Deferreds natively
if
isinstance
(
val
,
defer
.
Deferred
):
...
...
corepost/test/feature/issues.feature
0 → 100644
View file @
2ff5ffb1
Using step definitions from
:
'../steps'
@issues
Feature
:
Issues
Fixes for issues reported on github
@issue1
Scenario
:
Issue 1 (unable to access self.var in a router method)
Given 'home_resource' is running
When as user 'None
:
None' I GET 'http
:
//127.0.0.1
:
8080/issues/1'
Then
I expect HTTP code 200
And
I expect content contains 'issue 1'
corepost/test/home_resource.py
View file @
2ff5ffb1
...
...
@@ -12,6 +12,10 @@ import json, yaml
class
HomeApp
(
CorePost
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
CorePost
.
__init__
(
self
,
*
args
,
**
kwargs
)
self
.
issue1
=
"issue 1"
@
route
(
"/"
,
Http
.
GET
)
@
defer
.
inlineCallbacks
def
root
(
self
,
request
,
**
kwargs
):
...
...
@@ -105,7 +109,12 @@ class HomeApp(CorePost):
t2
.
test2
=
"Test2"
return
(
t1
,
t2
)
####################################
# Issues
####################################
@
route
(
"/issues/1"
)
def
test_issue_1
(
self
,
request
,
**
kwargs
):
return
self
.
issue1
def
run_app_home
():
app
=
HomeApp
()
...
...
setup.py
View file @
2ff5ffb1
...
...
@@ -54,19 +54,11 @@ Changelog
"""
import
os
from
setuptools
import
setup
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def
read
(
fname
):
return
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
fname
))
.
read
()
setup
(
name
=
"CorePost"
,
version
=
"0.0.
8
"
,
version
=
"0.0.
9
"
,
author
=
"Jacek Furmankiewicz"
,
author_email
=
"jacekeadE99@gmail.com"
,
description
=
(
"A Twisted Web REST micro-framework"
),
...
...
@@ -89,13 +81,12 @@ setup(
'twisted>=11.0.0'
,
'formencode>=1.2.4'
,
'pyyaml>=3.1.0'
,
'jinja2>=2.6'
'jinja2>=2.6'
,
'txZMQ>=0.3.1,'
],
tests_require
=
[
'httplib2>=0.7.1'
,
'freshen>=0.2'
,
],
zip_safe
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment