Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
coba
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e67a0978
authored
Feb 25, 2025
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perbaikan Class modules
1 parent
bbc4c548
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
39 deletions
opensipkd/coba/__init__.py
opensipkd/coba/__init__.py
View file @
e67a097
import
logging
import
logging
from
opensipkd.base
import
get_params
from
opensipkd.base
import
get_params
,
BaseApp
from
opensipkd.base
import
titles
,
_add_view_config
from
opensipkd.base
import
titles
,
_add_view_config
from
pyramid.events
import
subscriber
,
BeforeRender
from
pyramid.events
import
subscriber
,
BeforeRender
_logging
=
logging
.
getLogger
(
__name__
)
_logging
=
logging
.
getLogger
(
__name__
)
routes
=
[
ROUTES
=
[
{
"kode"
:
"coba"
,
{
"kode"
:
"coba"
,
"nama"
:
"Home"
,
"nama"
:
"Home"
,
"path"
:
"/coba"
,
"path"
:
"/coba"
,
...
@@ -117,48 +117,16 @@ routes = [
...
@@ -117,48 +117,16 @@ routes = [
]
]
class
CobaModules
():
class
CobaModules
(
BaseApp
):
def
__init__
(
self
):
def
__init__
(
self
):
s
elf
.
menus
=
[]
s
uper
()
.
__init__
()
self
.
uploads
=
None
self
.
uploads
=
None
def
add_menu
(
self
,
config
,
route_menus
,
parent
=
None
):
def
set_static
(
self
,
config
):
route_names
=
[]
for
route
in
route_menus
:
route
[
"route_names"
]
=
[
route
[
"kode"
]]
route
[
"permission"
]
=
route
.
get
(
"permission"
,
""
)
route
[
"icon"
]
=
route
.
get
(
"icon"
,
None
)
route
[
"type"
]
=
route
.
get
(
"type"
,
0
)
route
[
"is_menu"
]
=
route
.
get
(
"is_menu"
,
0
)
route
[
"path"
]
=
route
.
get
(
"path"
,
"#"
)
children
=
route
.
get
(
"children"
,
[])
route
[
"children"
]
=
[]
if
route
.
get
(
"class_view"
):
_add_view_config
(
config
,
"opensipkd.coba.views"
,
route
)
if
route
.
get
(
"is_menu"
,
None
):
if
not
parent
:
self
.
menus
.
append
(
route
)
else
:
parent
[
"children"
]
.
append
(
route
)
if
children
:
route
[
"route_names"
]
.
extend
(
self
.
add_menu
(
config
,
children
,
route
)
)
route_names
.
append
(
route
[
"kode"
])
return
route_names
def
set_routes
(
self
,
config
):
self
.
uploads
=
get_params
(
'coba_upload'
,
'/tmp/coba/upload/'
)
self
.
uploads
=
get_params
(
'coba_upload'
,
'/tmp/coba/upload/'
)
_logging
.
debug
(
self
.
uploads
)
config
.
add_static_view
(
config
.
add_static_view
(
'/coba/uploads'
,
self
.
uploads
,
cache_max_age
=
0
)
'/coba/uploads'
,
self
.
uploads
,
cache_max_age
=
0
)
self
.
add_menu
(
config
,
routes
)
_logging
.
debug
(
"Menu Coba"
)
_logging
.
debug
(
self
.
menus
)
# config.add_route(route["kode"], route["path"])
config
.
scan
(
'.'
)
# titles[route["kode"]] = route["path"]
def
get_menus
(
self
):
def
get_menus
(
self
):
return
self
.
menus
return
self
.
menus
...
@@ -171,7 +139,8 @@ def includeme(config):
...
@@ -171,7 +139,8 @@ def includeme(config):
# for route in routes:
# for route in routes:
# config.add_route(route[0], route[1])
# config.add_route(route[0], route[1])
# titles[route[0]] = route[2]
# titles[route[0]] = route[2]
MODULE_CLASS
.
set_routes
(
config
)
MODULE_CLASS
.
set_static
(
config
)
MODULE_CLASS
.
add_menu
(
config
,
ROUTES
)
config
.
scan
(
'.'
)
config
.
scan
(
'.'
)
...
...
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