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
Show 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
pyramid.debug_routematch
=
true
pyramid.debug_templates
=
true
default_locale_name
=
id
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/
demo2
session.url
=
postgresql://aagusti:a@localhost:5432/
demo2
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/
asinan
session.url
=
postgresql://aagusti:a@localhost:5432/
asinan
pyramid.includes
=
pyramid_tm
pyramid_beaker
pyramid_chameleon
pyramid_rpc.jsonrpc
pyramid_debugtoolbar
opensipkd.pbb.models
opensipkd.pbb.esppt
opensipkd.pbb.monitoring
;
opensipkd.pbb.models
;
opensipkd.pbb.esppt
;
opensipkd.pbb.monitoring
session.type
=
ext:database
...
...
@@ -85,7 +85,7 @@ map_center =
;center.email_password =
;center.smtp_server =
;
;#_host = http://localhost:5433/
demo2
;#_host = http://localhost:5433/
asinan
;
;unoconv_py = C:\Program Files\LibreOffice\program\python.exe
;unoconv_bin = C:\product\venv-lates\Scripts\unoconv
...
...
@@ -185,11 +185,15 @@ format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
[alembic_ziggurat]
script_location
=
ziggurat_foundations:migrations
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/
demo2
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/
asinan
[alembic_base]
script_location
=
opensipkd.base.scripts:alembic
sqlalchemy.url
=
postgresql://aagusti:a@localhost:5432/demo2
script_location
=
opensipkd.base:alembic
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]
filterwarnings
=
...
...
development.ini.tpl
View file @
d1f012c
...
...
@@ -14,8 +14,11 @@ pyramid.debug_notfound = true
pyramid.debug_routematch = true
pyramid.debug_templates = true
default_locale_name = id
sqlalchemy.url = postgresql://aagusti:a@localhost:5432/demo2
session.url = postgresql://aagusti:a@localhost:5432/demo2
sqlalchemy.url = postgresql://user:pass@server:port/db
sqlalchemy.pool_pre_ping = True
sqlalchemy.pool_size = 20
sqlalchemy.echo = False
session.url = postgresql://user:pass@server:port/db
pyramid.includes =
pyramid_tm
pyramid_beaker
...
...
opensipkd/base/__init__.py
View file @
d1f012c
...
...
@@ -468,7 +468,7 @@ def add_cors_headers_response_callback(event):
# _logging.debug(f"Headers: {headers}")
response
.
headers
.
update
(
headers
)
_logging
.
debug
(
response
.
headers
)
#
_logging.debug(response.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
click
import
group
import
logging
from
math
import
log
import
pytz
import
sqlalchemy
as
sa
from
opensipkd.tools
import
as_timezone
from
pyramid.authorization
import
(
Allow
,
Authenticated
,
ALL_PERMISSIONS
)
from
sqlalchemy
import
(
Column
,
Integer
,
DateTime
,
String
)
...
...
@@ -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_resource_permission
import
\
UserResourcePermissionMixin
from
sqlalchemy.ext.declarative
import
declared_attr
from
opensipkd.tools
import
as_timezone
from
.base
import
CommonModel
,
DBSession
,
DefaultModel
from
.meta
import
Base
from
.base
import
TABLE_ARGS
log
=
logging
.
getLogger
(
__name__
)
class
_GroupPermission
(
GroupPermissionMixin
):
pass
...
...
@@ -298,6 +297,7 @@ class RootFactory:
for
gp
in
DBSession
.
query
(
GroupPermission
):
acl_name
=
'group:{}'
.
format
(
gp
.
group_id
)
self
.
__acl__
.
append
((
Allow
,
acl_name
,
gp
.
perm_name
))
# log.debug(f"RootFactory ACL: {self.__acl__}")
def
init_model
():
...
...
opensipkd/base/scripts/data/group_permission.csv
View file @
d1f012c
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
Superuser,admin
Web Service,web-service
Pindah Departemen,departemen-all
Guest," ""guest"""
\ No newline at end of file
opensipkd/base/scripts/data/users.csv
View file @
d1f012c
email,status,user_name,registered_date
admin@local.host,1,admin,
guest@local.host,1,guest,
\ No newline at end of file
opensipkd/base/scripts/data/users_groups.csv
View file @
d1f012c
user_id
,group_id
1,1
user_id
/users.user_name,group_id/groups.group_name
admin,admin
\ No newline at end of file
opensipkd/base/scripts/initializedb.py
View file @
d1f012c
import
csv
import
datetime
import
logging
import
os
import
subprocess
...
...
@@ -279,7 +280,7 @@ def append_csv(table, filename, keys, get_file_func=get_file,
# merubah v1.4 ke v.2
# 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
# q = Base.metadata.bind.execute(sql)
with
eng
.
connect
()
as
conn
:
...
...
@@ -320,6 +321,7 @@ def append_csv(table, filename, keys, get_file_func=get_file,
if
fname_orig
==
"user_password"
:
user
=
True
password
=
val
else
:
if
fname_orig
in
fields
and
type
(
fields
[
fname_orig
])
is
BOOLEAN
:
val
=
(
val
==
'true'
or
val
==
...
...
@@ -330,6 +332,10 @@ def append_csv(table, filename, keys, get_file_func=get_file,
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"
)
and
c
[
"default"
]
is
None
:
if
c
[
"name"
]
==
"registered_date"
:
setattr
(
row
,
c
[
"name"
],
datetime
.
datetime
.
now
())
continue
# update: tambah periksa nilai default.
# Jika default=None berarti wajib ada nilainya
# by tatang 2024-10-12
...
...
@@ -460,3 +466,6 @@ def main(argv=sys.argv):
# transaction.abort()
# except Exception as e:
# print(str(e))
if
__name__
==
'__main__'
:
main
(
sys
.
argv
)
\ No newline at end of file
opensipkd/base/security.py
View file @
d1f012c
...
...
@@ -91,6 +91,7 @@ class MySecurityPolicy:
return
identity
[
'userid'
]
def
permits
(
self
,
request
,
context
,
permission
):
# log.debug(f"MySecurityPolicy.permits: permission={permission}")
identity
=
request
.
identity
principals
=
set
([
Everyone
])
if
identity
is
not
None
:
...
...
opensipkd/base/tools/db.py
View file @
d1f012c
from
tkinter
import
N
from
sqlalchemy
import
func
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
:
return
''
elif
len
(
cols
)
==
1
:
return
cols
[
0
]
# saat ini menggunakan recursive spertinya ada syntax pythonic
# 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'
):
...
...
opensipkd/base/views/base_views.py
View file @
d1f012c
...
...
@@ -999,7 +999,8 @@ class BaseView(object):
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
:
return
None
self
.
list_schema
=
self
.
form_list
...
...
opensipkd/base/views/templates/403.pt
View file @
d1f012c
<html
metal:use-macro=
"load: ./base5.pt"
>
<div
metal:fill-slot=
"content"
>
<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>
<b>
Silahkan Hubungi Administrator
</b><br>
<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>
<b>
Silahkan Hubungi Administrator
</b><br>
<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>
</div>
</body>
</html>
\ 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