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
1d843ea2
Commit
1d843ea2
authored
Apr 18, 2012
by
Jacek Furmankiewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
high level experiment with API for auto-generated SQL REST services
parent
44ad4dde
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
0 deletions
+60
-0
sql.py
corepost/ext/sql.py
+8
-0
__init__.py
corepost/ext/sql/__init__.py
+0
-0
sql_resource.py
corepost/test/sql_resource.py
+52
-0
No files found.
corepost/ext/sql.py
0 → 100644
View file @
1d843ea2
'''
Created on 2012-04-17
@author: jacekf
'''
class
SqlEntityService
:
pass
corepost/ext/sql/__init__.py
deleted
100644 → 0
View file @
44ad4dde
corepost/test/sql_resource.py
0 → 100644
View file @
1d843ea2
'''
Created on 2012-04-17
@author: jacekf
'''
from
corepost.web
import
route
from
twisted.python.constants
import
NamedConstant
,
Names
class
REST_METHOD
(
Names
):
GET_ALL
=
NamedConstant
()
GET_ONE
=
NamedConstant
()
POST
=
NamedConstant
()
PUT
=
NamedConstant
()
DELETE
=
NamedConstant
()
DELETE_ALL
=
NamedConstant
()
ALL
=
NamedConstant
()
class
DatabaseRegistry
:
__registry
=
{}
@
classmethod
def
getConnection
(
cls
,
name
=
None
):
return
DatabaseRegistry
.
__registery
[
name
]
@
classmethod
def
registerPool
(
cls
,
name
,
dbPool
):
"""Registers a DB connection pool under an appropriate name"""
DatabaseRegistry
.
__registry
[
name
]
=
dbPool
@
classmethod
def
getManager
(
cls
,
name
=
None
,
queriesFile
=
None
):
"""Returns the high-level SQL data manager for easy SQL manipulation"""
pass
class
SqlDataManager
:
def
__init__
(
self
,
table
,
columnMapping
=
{}):
pass
class
CustomerSqlService
:
path
=
"/customer"
entityId
=
"<customerId>"
dataManager
=
DatabaseRegistry
.
getManager
(
"customer"
)
methods
=
(
REST_METHOD
.
GET_ONE
,
REST_METHOD
.
POST
,
REST_METHOD
.
PUT
,
REST_METHOD
.
DELETE
)
class
CustomerAddressSqlService
:
path
=
"/customer/<customerId>/address"
entityId
=
"<addressId>"
dataManager
=
DatabaseRegistry
.
getManager
(
"customer_address"
)
methods
=
(
REST_METHOD
.
ALL
,)
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