Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 59807d70
authored
Nov 22, 2025
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add global render subscriber and update default length for API queries
1 parent
a45c2b4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
38 deletions
opensipkd/base/__init__.py
opensipkd/base/views/api_base.py
opensipkd/base/__init__.py
View file @
59807d7
...
@@ -341,6 +341,31 @@ def init_db(settings):
...
@@ -341,6 +341,31 @@ def init_db(settings):
init_model
()
init_model
()
# @subscriber(BeforeRender)
def
add_global_render
(
event
):
event
[
'has_permission'
]
=
has_permission_
event
[
'get_base_menus'
]
=
BASE_CLASS
.
get_menus
event
[
'has_modules'
]
=
has_modules
event
[
'get_params'
]
=
get_params_
# event['urlencode'] = urlencode
# event['quote_plus'] = quote_plus
# event['quote'] = quote
# event['money'] = money
# event['should_int'] = should_int
# event['thousand'] = thousand
# event['as_timezone'] = as_timezone
# event['split'] = split
# event['allow_register'] = allow_register
# event['change_unit'] = change_unit
# event['get_urls'] = get_urls
# event['get_csrf_token'] = get_csrf_token
# # event['get_params'] = get_params
# # event['get_module_menus'] = get_module_menus
# # event['get_module_submenus'] = get_module_submenus
def
main
(
global_config
,
**
settings
):
def
main
(
global_config
,
**
settings
):
""" This function returns a Pyramid WSGI application.
""" This function returns a Pyramid WSGI application.
"""
"""
...
@@ -363,7 +388,8 @@ def main(global_config, **settings):
...
@@ -363,7 +388,8 @@ def main(global_config, **settings):
BASE_CLASS
.
route_from_csv
(
config
,
filename
=
routes_file
)
BASE_CLASS
.
route_from_csv
(
config
,
filename
=
routes_file
)
BASE_CLASS
.
route_from_list
(
config
)
BASE_CLASS
.
route_from_list
(
config
)
BASE_CLASS
.
static_view
(
config
,
settings
=
settings
)
BASE_CLASS
.
static_view
(
config
,
settings
=
settings
)
config
.
scan
()
config
.
add_subscriber
(
add_global_render
,
BeforeRender
)
# _logging.debug(config)
# _logging.debug(config)
return
config
.
make_wsgi_app
()
return
config
.
make_wsgi_app
()
...
@@ -566,7 +592,7 @@ class BaseApp():
...
@@ -566,7 +592,7 @@ class BaseApp():
if
p
[
"children"
]:
if
p
[
"children"
]:
self
.
route_children
(
p
[
"children"
],
row
)
self
.
route_children
(
p
[
"children"
],
row
)
def
route_from_csv_
(
self
,
config
,
paket
=
"
tangsel
.base.views"
,
rows
=
[]):
def
route_from_csv_
(
self
,
config
,
paket
=
"
opensipkd
.base.views"
,
rows
=
[]):
new_routes
=
[]
new_routes
=
[]
for
row
in
rows
:
for
row
in
rows
:
status
=
row
.
get
(
"status"
,
0
)
or
0
status
=
row
.
get
(
"status"
,
0
)
or
0
...
@@ -650,31 +676,6 @@ def has_permission_(request, perm_names, context=None):
...
@@ -650,31 +676,6 @@ def has_permission_(request, perm_names, context=None):
return
True
return
True
@subscriber
(
BeforeRender
)
def
add_global
(
event
):
event
[
'has_permission'
]
=
has_permission_
event
[
'get_base_menus'
]
=
BASE_CLASS
.
get_menus
event
[
'has_modules'
]
=
has_modules
event
[
'get_params'
]
=
get_params_
# event['urlencode'] = urlencode
# event['quote_plus'] = quote_plus
# event['quote'] = quote
# event['money'] = money
# event['should_int'] = should_int
# event['thousand'] = thousand
# event['as_timezone'] = as_timezone
# event['split'] = split
# event['allow_register'] = allow_register
# event['change_unit'] = change_unit
# event['get_urls'] = get_urls
# event['get_csrf_token'] = get_csrf_token
# event['get_base_menus'] = BASE_CLASS.get_menus
# # event['get_params'] = get_params
# # event['get_module_menus'] = get_module_menus
# # event['get_module_submenus'] = get_module_submenus
def
get_params_
(
params
,
alternate
=
None
,
settings
=
None
):
def
get_params_
(
params
,
alternate
=
None
,
settings
=
None
):
return
get_params
(
params
,
alternate
,
settings
)
return
get_params
(
params
,
alternate
,
settings
)
...
...
opensipkd/base/views/api_base.py
View file @
59807d7
...
@@ -114,9 +114,6 @@ class ApiViews(APIView):
...
@@ -114,9 +114,6 @@ class ApiViews(APIView):
else
:
else
:
query
=
self
.
list_filter
(
query
,
**
kwargs
)
query
=
self
.
list_filter
(
query
,
**
kwargs
)
# log.debug(str(columns))
# qry = query.add_columns(*[c.sqla_expr for c in columns])
# log.debug(str(qry))
row_table
=
DataTables
(
self
.
req
.
GET
,
query
,
columns
)
row_table
=
DataTables
(
self
.
req
.
GET
,
query
,
columns
)
result
=
row_table
.
output_result
()
result
=
row_table
.
output_result
()
data
=
result
and
result
.
get
(
"data"
)
or
{}
data
=
result
and
result
.
get
(
"data"
)
or
{}
...
@@ -127,10 +124,6 @@ class ApiViews(APIView):
...
@@ -127,10 +124,6 @@ class ApiViews(APIView):
for
r
in
vals
:
for
r
in
vals
:
if
r
and
str
(
r
)
==
str
(
res
[
k
]):
if
r
and
str
(
r
)
==
str
(
res
[
k
]):
res
[
k
]
=
vals
[
r
]
res
[
k
]
=
vals
[
r
]
# for k, v in d.items():
# if k in url and v:
# link = "/".join([self.home, nik_url, v])
# d[k] =f'<a href="{link}" target="_blank">View</a>'
if
result
.
get
(
"error"
):
if
result
.
get
(
"error"
):
_log
.
error
(
result
.
get
(
"error"
))
_log
.
error
(
result
.
get
(
"error"
))
_log
.
error
(
str
(
result
))
_log
.
error
(
str
(
result
))
...
@@ -288,12 +281,9 @@ class ApiViews(APIView):
...
@@ -288,12 +281,9 @@ class ApiViews(APIView):
if
"draw"
not
in
self
.
req
.
params
:
if
"draw"
not
in
self
.
req
.
params
:
self
.
req
.
GET
.
add
(
'draw'
,
"1"
)
self
.
req
.
GET
.
add
(
'draw'
,
"1"
)
if
"length"
not
in
self
.
req
.
params
:
if
"length"
not
in
self
.
req
.
params
:
self
.
req
.
GET
.
add
(
'length'
,
"
10
"
)
self
.
req
.
GET
.
add
(
'length'
,
"
25
"
)
if
"start"
not
in
self
.
req
.
params
:
if
"start"
not
in
self
.
req
.
params
:
self
.
req
.
GET
.
add
(
'start'
,
"0"
)
self
.
req
.
GET
.
add
(
'start'
,
"0"
)
# rec_id = self.req.matchdict.get('id')
# if rec_id:
# self.req.GET.add('columns[0][search][value]', rec_id)
return
self
.
get_list
(
**
kwargs
)
return
self
.
get_list
(
**
kwargs
)
def
get_custom_render
(
self
,
data
):
def
get_custom_render
(
self
,
data
):
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment