Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
olapy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
olapy
Commits
7a5c977e
Commit
7a5c977e
authored
May 10, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preparing some rest services for web
parent
795ad74c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
olapy/rest_services.py
olapy/rest_services.py
+48
-0
No files found.
olapy/rest_services.py
0 → 100644
View file @
7a5c977e
from
spyne
import
Unicode
,
Iterable
,
Application
from
spyne.decorator
import
rpc
from
spyne.protocol.http
import
HttpRpc
from
spyne.protocol.json
import
JsonDocument
from
spyne.server.wsgi
import
WsgiApplication
from
spyne.service
import
ServiceBase
from
olapy.core.mdx.executor.execute
import
MdxEngine
class
OlapyService
(
ServiceBase
):
executer
=
MdxEngine
(
'sales'
)
@
rpc
(
_returns
=
Iterable
(
Unicode
))
def
get_cubes_names
(
ctx
):
return
MdxEngine
.
get_cubes_names
()
@
rpc
(
_returns
=
Unicode
)
def
get_star_schema
(
ctx
):
return
OlapyService
.
executer
.
load_star_schema_dataframe
.
to_json
()
@
rpc
(
_returns
=
Unicode
)
def
get_tables
(
ctx
):
return
{
table_name
:
table_dataframe
.
to_json
()
for
table_name
,
table_dataframe
in
OlapyService
.
executer
.
tables_loaded
.
items
()}
@
rpc
(
_returns
=
Iterable
(
Unicode
))
def
get_measures
(
ctx
):
return
OlapyService
.
executer
.
measures
application
=
Application
([
OlapyService
],
tns
=
'spyne.olapy.services'
,
in_protocol
=
HttpRpc
(
validator
=
'soft'
),
out_protocol
=
JsonDocument
()
)
if
__name__
==
'__main__'
:
# You can use any Wsgi server. Here, we chose
# Python's built-in wsgi server but you're not
# supposed to use it in production.
from
wsgiref.simple_server
import
make_server
wsgi_app
=
WsgiApplication
(
application
)
server
=
make_server
(
'0.0.0.0'
,
8000
,
wsgi_app
)
server
.
serve_forever
()
\ No newline at end of file
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