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 d1f012cc
authored
Feb 08, 2026
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: Update database configuration and improve logging in various modules
1 parent
17a61332
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
58 additions
and
39 deletions
development.ini
development.ini.tpl
opensipkd/base/__init__.py
opensipkd/base/models/users.py
opensipkd/base/scripts/data/group_permission.csv
opensipkd/base/scripts/data/users.csv
opensipkd/base/scripts/data/users_groups.csv
opensipkd/base/scripts/initializedb.py
opensipkd/base/security.py
opensipkd/base/tools/db.py
opensipkd/base/views/base_views.py
opensipkd/base/views/templates/403.pt
opensipkd/base/views/templates/403_old.pt
development.ini
View file @
d1f012c
...
@@ -14,17 +14,17 @@ pyramid.debug_notfound = true
...
@@ -14,17 +14,17 @@ pyramid.debug_notfound = true
pyramid.debug_routematch
=
true
pyramid.debug_routematch
=
true
pyramid.debug_templates
=
true
pyramid.debug_templates
=
true
default_locale_name
=
id
default_locale_name
=
id
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/
demo2
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/
asinan
session.url
=
postgresql://aagusti:a@localhost:5432/
demo2
session.url
=
postgresql://aagusti:a@localhost:5432/
asinan
pyramid.includes
=
pyramid.includes
=
pyramid_tm
pyramid_tm
pyramid_beaker
pyramid_beaker
pyramid_chameleon
pyramid_chameleon
pyramid_rpc.jsonrpc
pyramid_rpc.jsonrpc
pyramid_debugtoolbar
pyramid_debugtoolbar
opensipkd.pbb.models
;
opensipkd.pbb.models
opensipkd.pbb.esppt
;
opensipkd.pbb.esppt
opensipkd.pbb.monitoring
;
opensipkd.pbb.monitoring
session.type
=
ext:database
session.type
=
ext:database
...
@@ -85,7 +85,7 @@ map_center =
...
@@ -85,7 +85,7 @@ map_center =
;center.email_password =
;center.email_password =
;center.smtp_server =
;center.smtp_server =
;
;
;#_host = http://localhost:5433/
demo2
;#_host = http://localhost:5433/
asinan
;
;
;unoconv_py = C:\Program Files\LibreOffice\program\python.exe
;unoconv_py = C:\Program Files\LibreOffice\program\python.exe
;unoconv_bin = C:\product\venv-lates\Scripts\unoconv
;unoconv_bin = C:\product\venv-lates\Scripts\unoconv
...
@@ -185,11 +185,15 @@ format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
...
@@ -185,11 +185,15 @@ format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
[alembic_ziggurat]
[alembic_ziggurat]
script_location
=
ziggurat_foundations:migrations
script_location
=
ziggurat_foundations:migrations
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/
demo2
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/
asinan
[alembic_base]
[alembic_base]
script_location
=
opensipkd.base.scripts:alembic
script_location
=
opensipkd.base:alembic
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/demo2
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/asinan
[alembic_base_init]
script_location
=
opensipkd.base:alembic
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/asinan_db
[pytest]
[pytest]
filterwarnings
=
filterwarnings
=
...
...
development.ini.tpl
View file @
d1f012c
...
@@ -14,8 +14,11 @@ pyramid.debug_notfound = true
...
@@ -14,8 +14,11 @@ pyramid.debug_notfound = true
pyramid.debug_routematch = true
pyramid.debug_routematch = true
pyramid.debug_templates = true
pyramid.debug_templates = true
default_locale_name = id
default_locale_name = id
sqlalchemy.url = postgresql://aagusti:a@localhost:5432/demo2
sqlalchemy.url = postgresql://user:pass@server:port/db
session.url = postgresql://aagusti:a@localhost:5432/demo2
sqlalchemy.pool_pre_ping = True
sqlalchemy.pool_size = 20
sqlalchemy.echo = False
session.url = postgresql://user:pass@server:port/db
pyramid.includes =
pyramid.includes =
pyramid_tm
pyramid_tm
pyramid_beaker
pyramid_beaker
...
...
opensipkd/base/__init__.py
View file @
d1f012c
...
@@ -468,7 +468,7 @@ def add_cors_headers_response_callback(event):
...
@@ -468,7 +468,7 @@ def add_cors_headers_response_callback(event):
# _logging.debug(f"Headers: {headers}")
# _logging.debug(f"Headers: {headers}")
response
.
headers
.
update
(
headers
)
response
.
headers
.
update
(
headers
)
_logging
.
debug
(
response
.
headers
)
#
_logging.debug(response.headers)
event
.
request
.
add_response_callback
(
cors_headers
)
event
.
request
.
add_response_callback
(
cors_headers
)
...
...
opensipkd/base/models/users.py
View file @
d1f012c
from
calendar
import
c
from
datetime
import
datetime
from
datetime
import
datetime
import
logging
from
click
import
group
from
math
import
log
import
pytz
import
pytz
import
sqlalchemy
as
sa
import
sqlalchemy
as
sa
from
opensipkd.tools
import
as_timezone
from
pyramid.authorization
import
(
Allow
,
Authenticated
,
ALL_PERMISSIONS
)
from
pyramid.authorization
import
(
Allow
,
Authenticated
,
ALL_PERMISSIONS
)
from
sqlalchemy
import
(
from
sqlalchemy
import
(
Column
,
Integer
,
DateTime
,
String
)
Column
,
Integer
,
DateTime
,
String
)
...
@@ -23,12 +21,13 @@ from ziggurat_foundations.models.user_group import UserGroupMixin
...
@@ -23,12 +21,13 @@ from ziggurat_foundations.models.user_group import UserGroupMixin
from
ziggurat_foundations.models.user_permission
import
UserPermissionMixin
from
ziggurat_foundations.models.user_permission
import
UserPermissionMixin
from
ziggurat_foundations.models.user_resource_permission
import
\
from
ziggurat_foundations.models.user_resource_permission
import
\
UserResourcePermissionMixin
UserResourcePermissionMixin
from
sqlalchemy.ext.declarative
import
declared_attr
from
opensipkd.tools
import
as_timezone
from
.base
import
CommonModel
,
DBSession
,
DefaultModel
from
.base
import
CommonModel
,
DBSession
,
DefaultModel
from
.meta
import
Base
from
.meta
import
Base
from
.base
import
TABLE_ARGS
from
.base
import
TABLE_ARGS
log
=
logging
.
getLogger
(
__name__
)
class
_GroupPermission
(
GroupPermissionMixin
):
class
_GroupPermission
(
GroupPermissionMixin
):
pass
pass
...
@@ -298,6 +297,7 @@ class RootFactory:
...
@@ -298,6 +297,7 @@ class RootFactory:
for
gp
in
DBSession
.
query
(
GroupPermission
):
for
gp
in
DBSession
.
query
(
GroupPermission
):
acl_name
=
'group:{}'
.
format
(
gp
.
group_id
)
acl_name
=
'group:{}'
.
format
(
gp
.
group_id
)
self
.
__acl__
.
append
((
Allow
,
acl_name
,
gp
.
perm_name
))
self
.
__acl__
.
append
((
Allow
,
acl_name
,
gp
.
perm_name
))
# log.debug(f"RootFactory ACL: {self.__acl__}")
def
init_model
():
def
init_model
():
...
...
opensipkd/base/scripts/data/group_permission.csv
View file @
d1f012c
group_id/groups.group_name,perm_name
group_id/groups.group_name,perm_name
"Superuser","user-edit"
"Superuser","user-view"
"Superuser","user-group"
"Superuser","upload-logo"
"Superuser","departemen"
"Superuser","partner-departemen"
"Superuser","partner"
"Superuser","parameter"
"Superuser","permission"
"Web Service","web-service"
"Pindah Departemen","departemen-all"
"Guest", "guest"
\ No newline at end of file
\ No newline at end of file
Superuser,admin
Web Service,web-service
Pindah Departemen,departemen-all
Guest," ""guest"""
\ No newline at end of file
\ No newline at end of file
opensipkd/base/scripts/data/users.csv
View file @
d1f012c
email,status,user_name,registered_date
email,status,user_name,registered_date
admin@local.host,1,admin,
guest@local.host,1,guest,
guest@local.host,1,guest,
\ No newline at end of file
\ No newline at end of file
opensipkd/base/scripts/data/users_groups.csv
View file @
d1f012c
user_id
,group_id
user_id
/users.user_name,group_id/groups.group_name
1,1
admin,admin
\ No newline at end of file
\ No newline at end of file
opensipkd/base/scripts/initializedb.py
View file @
d1f012c
import
csv
import
csv
import
datetime
import
logging
import
logging
import
os
import
os
import
subprocess
import
subprocess
...
@@ -279,7 +280,7 @@ def append_csv(table, filename, keys, get_file_func=get_file,
...
@@ -279,7 +280,7 @@ def append_csv(table, filename, keys, get_file_func=get_file,
# merubah v1.4 ke v.2
# merubah v1.4 ke v.2
# sql = select([foreign_table]).where(foreign_field == value)
# sql = select([foreign_table]).where(foreign_field == value)
sql
=
select
(
foreign_table
)
.
where
(
foreign_field
==
value
)
sql
=
select
(
foreign_table
)
.
where
(
foreign_field
==
value
)
#
log.debug(f"Query Foreignkey: {str(sql)}")
log
.
debug
(
f
"Query Foreignkey: {str(sql)}"
)
# merubah v1.4 ke v.2
# merubah v1.4 ke v.2
# q = Base.metadata.bind.execute(sql)
# q = Base.metadata.bind.execute(sql)
with
eng
.
connect
()
as
conn
:
with
eng
.
connect
()
as
conn
:
...
@@ -320,6 +321,7 @@ def append_csv(table, filename, keys, get_file_func=get_file,
...
@@ -320,6 +321,7 @@ def append_csv(table, filename, keys, get_file_func=get_file,
if
fname_orig
==
"user_password"
:
if
fname_orig
==
"user_password"
:
user
=
True
user
=
True
password
=
val
password
=
val
else
:
else
:
if
fname_orig
in
fields
and
type
(
fields
[
fname_orig
])
is
BOOLEAN
:
if
fname_orig
in
fields
and
type
(
fields
[
fname_orig
])
is
BOOLEAN
:
val
=
(
val
==
'true'
or
val
==
val
=
(
val
==
'true'
or
val
==
...
@@ -330,6 +332,10 @@ def append_csv(table, filename, keys, get_file_func=get_file,
...
@@ -330,6 +332,10 @@ def append_csv(table, filename, keys, get_file_func=get_file,
for
c
in
columns_table
:
for
c
in
columns_table
:
# if (not c["nullable"] and c["name"] not in data and c["name"] != "id"):
# if (not c["nullable"] and c["name"] not in data and c["name"] != "id"):
if
(
not
c
[
"nullable"
]
and
c
[
"name"
]
not
in
data
and
c
[
"name"
]
!=
"id"
)
and
c
[
"default"
]
is
None
:
if
(
not
c
[
"nullable"
]
and
c
[
"name"
]
not
in
data
and
c
[
"name"
]
!=
"id"
)
and
c
[
"default"
]
is
None
:
if
c
[
"name"
]
==
"registered_date"
:
setattr
(
row
,
c
[
"name"
],
datetime
.
datetime
.
now
())
continue
# update: tambah periksa nilai default.
# update: tambah periksa nilai default.
# Jika default=None berarti wajib ada nilainya
# Jika default=None berarti wajib ada nilainya
# by tatang 2024-10-12
# by tatang 2024-10-12
...
@@ -460,3 +466,6 @@ def main(argv=sys.argv):
...
@@ -460,3 +466,6 @@ def main(argv=sys.argv):
# transaction.abort()
# transaction.abort()
# except Exception as e:
# except Exception as e:
# print(str(e))
# print(str(e))
if
__name__
==
'__main__'
:
main
(
sys
.
argv
)
\ No newline at end of file
\ No newline at end of file
opensipkd/base/security.py
View file @
d1f012c
...
@@ -91,6 +91,7 @@ class MySecurityPolicy:
...
@@ -91,6 +91,7 @@ class MySecurityPolicy:
return
identity
[
'userid'
]
return
identity
[
'userid'
]
def
permits
(
self
,
request
,
context
,
permission
):
def
permits
(
self
,
request
,
context
,
permission
):
# log.debug(f"MySecurityPolicy.permits: permission={permission}")
identity
=
request
.
identity
identity
=
request
.
identity
principals
=
set
([
Everyone
])
principals
=
set
([
Everyone
])
if
identity
is
not
None
:
if
identity
is
not
None
:
...
...
opensipkd/base/tools/db.py
View file @
d1f012c
from
tkinter
import
N
from
sqlalchemy
import
func
from
sqlalchemy
import
func
from
opensipkd.base.models
import
Parameter
from
opensipkd.base.models
import
Parameter
def
column_concat
(
cols
=
None
):
def
column_concat
(
*
args
):
cols
=
[]
for
arg
in
args
:
if
type
(
arg
)
==
list
:
for
a
in
arg
:
cols
.
append
(
a
)
else
:
cols
.
append
(
arg
)
if
not
cols
:
if
not
cols
:
return
''
return
''
elif
len
(
cols
)
==
1
:
elif
len
(
cols
)
==
1
:
return
cols
[
0
]
return
cols
[
0
]
# saat ini menggunakan recursive spertinya ada syntax pythonic
# saat ini menggunakan recursive spertinya ada syntax pythonic
# func.concat(cols[i], for col in cols)
# func.concat(cols[i], for col in cols)
return
func
.
concat
(
cols
[
0
],
column_concat
(
cols
[
1
:]))
# lambda_concat = lambda args: func.concat(x, y) for x, y in zip(args[:-1], args[1:])
return
func
.
concat
(
cols
[
0
],
column_concat
(
*
cols
[
1
:]))
def
column_date
(
field
,
dt_format
=
'YYYY-MM-DD HH:MI:SS'
):
def
column_date
(
field
,
dt_format
=
'YYYY-MM-DD HH:MI:SS'
):
...
...
opensipkd/base/views/base_views.py
View file @
d1f012c
...
@@ -999,7 +999,8 @@ class BaseView(object):
...
@@ -999,7 +999,8 @@ class BaseView(object):
return
values
return
values
def
get_item_table
(
self
,
parent
=
None
,
**
kwargs
):
def
get_item_table
(
self
,
**
kwargs
):
parent
=
kwargs
.
get
(
"parent"
,
None
)
if
not
self
.
form_list
:
if
not
self
.
form_list
:
return
None
return
None
self
.
list_schema
=
self
.
form_list
self
.
list_schema
=
self
.
form_list
...
...
opensipkd/base/views/templates/403.pt
View file @
d1f012c
<html
metal:use-macro=
"load: ./base5.pt"
>
<html
metal:use-macro=
"load: ./base5.pt"
>
<div
metal:fill-slot=
"content"
>
<div
metal:fill-slot=
"content"
>
<h3>
Forbidden
</h3>
<h3>
Forbidden
</h3>
<span
style=
"color: red;"
><b>
${request.exception.explanation}
</b></span><br>
Anda tidak berhak mengakses halaman
<span
style=
"color:red;"
>
${url}
</span><br>
Anda tidak berhak mengakses halaman
<span
style=
"color:red;"
>
${url}
</span><br>
<b>
Silahkan Hubungi Administrator
</b><br>
<b>
Silahkan Hubungi Administrator
</b><br>
<a
href=
"${request.referer}"
tal:condition=
request.referer
>
Kembali ke Halaman Sebelumnya
</a>
<a
href=
"${request.referer}"
tal:condition=
request.referer
>
Kembali ke Halaman Sebelumnya
</a>
...
...
opensipkd/base/views/templates/403_old.pt
View file @
d1f012c
...
@@ -16,9 +16,6 @@ Anda tidak berhak mengakses halaman <span style="color:red;">${url}</span><br>
...
@@ -16,9 +16,6 @@ Anda tidak berhak mengakses halaman <span style="color:red;">${url}</span><br>
<b>
Silahkan Hubungi Administrator
</b><br>
<b>
Silahkan Hubungi Administrator
</b><br>
<a
href=
"${request.referer}"
tal:condition=
request.referer
>
Kembali ke Halaman Sebelumnya
</a>
<a
href=
"${request.referer}"
tal:condition=
request.referer
>
Kembali ke Halaman Sebelumnya
</a>
<a
href=
"${home}/"
tal:condition=
"not request.referer"
>
Kembali ke Halaman Utama
</a>
<a
href=
"${home}/"
tal:condition=
"not request.referer"
>
Kembali ke Halaman Utama
</a>
</div>
</body>
</body>
</html>
</html>
\ No newline at end of file
\ No newline at end of file
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