Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
w2pext
plugin_dbui
Commits
6a4b5e58
Commit
6a4b5e58
authored
Nov 06, 2019
by
LE GAC Renaud
Browse files
Update modules/plugin_dbui applying 2to3 converter.
parent
862aec78
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
170 additions
and
176 deletions
+170
-176
modules/plugin_dbui/__init__.py
modules/plugin_dbui/__init__.py
+88
-88
modules/plugin_dbui/callback.py
modules/plugin_dbui/callback.py
+2
-3
modules/plugin_dbui/constant.py
modules/plugin_dbui/constant.py
+0
-1
modules/plugin_dbui/converter.py
modules/plugin_dbui/converter.py
+33
-35
modules/plugin_dbui/dbsvc.py
modules/plugin_dbui/dbsvc.py
+10
-10
modules/plugin_dbui/dbui.py
modules/plugin_dbui/dbui.py
+1
-2
modules/plugin_dbui/directsvc.py
modules/plugin_dbui/directsvc.py
+4
-4
modules/plugin_dbui/fieldsmodifier.py
modules/plugin_dbui/fieldsmodifier.py
+1
-1
modules/plugin_dbui/filters.py
modules/plugin_dbui/filters.py
+2
-2
modules/plugin_dbui/formmodifier.py
modules/plugin_dbui/formmodifier.py
+6
-6
modules/plugin_dbui/gridmodifier.py
modules/plugin_dbui/gridmodifier.py
+1
-1
modules/plugin_dbui/helper.py
modules/plugin_dbui/helper.py
+4
-4
modules/plugin_dbui/mapper.py
modules/plugin_dbui/mapper.py
+1
-1
modules/plugin_dbui/modifier.py
modules/plugin_dbui/modifier.py
+2
-2
modules/plugin_dbui/navtree.py
modules/plugin_dbui/navtree.py
+3
-3
modules/plugin_dbui/selector.py
modules/plugin_dbui/selector.py
+5
-5
modules/plugin_dbui/storemodifier.py
modules/plugin_dbui/storemodifier.py
+2
-2
modules/plugin_dbui/validator.py
modules/plugin_dbui/validator.py
+3
-4
modules/plugin_dbui/viewportmodifier.py
modules/plugin_dbui/viewportmodifier.py
+2
-2
No files found.
modules/plugin_dbui/__init__.py
View file @
6a4b5e58
...
...
@@ -7,91 +7,91 @@ The most import ones are:
* *dbsvc* linking the user interface to the database
"""
from
callback
import
INHIBIT_DELETE_UNDEF
,
INHIBIT_UPDATE_UNDEF
from
constant
import
(
INLINE_ALERT
,
UNDEF
,
UNDEF_ID
,
UNKNOWN
)
from
converter
import
(
to_field
,
to_fields
,
to_formPanel
,
to_gridColumn
,
to_gridColumnModel
,
to_gridFilter
,
to_gridPanel
,
to_jsonstore
,
to_model
,
to_panelWithUrlSelector
,
to_treeNodes
,
to_viewport
)
from
dbui
import
Dbui
from
dbsvc
import
CALLBACK_ERRORS
,
DbSvc
from
directsvc
import
DBUI
,
DirectSvc
,
JSONEncoder
from
extjs
import
(
ArrayStore
,
CheckBox
,
ComboBox
,
DirectStore
,
Field
,
FieldAceEditor
,
FieldContainer
,
FieldDate
,
FieldDict
,
FieldList
,
FieldNumber
,
FieldSet
,
FieldText
,
FieldTextArea
,
FieldTime
,
FormPanel
,
GridColumn
,
GridColumnModel
,
GridFilter
,
GridPanel
,
GridRowNumberer
,
GridTemplateColumn
,
GridWithFilter
,
JsonStore
,
Model
,
Panel
,
PanelWithUrlSelector
,
Store
,
TabPanel
,
Viewport
,
Window
,
XmlStore
)
from
fieldsmodifier
import
FieldsModifier
from
filters
import
CLEAN_COMMA
,
CLEAN_SPACES
from
formmodifier
import
configure_forms
,
FormModifier
from
gridmodifier
import
configure_grids
,
GridModifier
from
storemodifier
import
AddStore
,
StoreModifier
from
helper
import
(
as_list
,
close_user_session
,
decode_field
,
dummy_row
,
encode_field
,
encode_validator_errors
,
get_all_tables
,
get_create_id
,
get_field_validators
,
get_file_paths
,
get_foreign_field
,
get_id
,
get_language
,
get_plugin_path
,
get_reference_paths
,
get_script_path
,
get_set_field
,
get_store_id
,
get_versions
,
get_where_query
,
inline_alert
,
is_foreign_field
,
is_mathjax
,
is_set_field
,
is_table_with_foreign_fields
,
rows_serializer
)
from
mapper
import
map_default
,
map_tabpanel
from
navtree
import
Node
from
selector
import
Selector
from
validator
import
IS_IN_USET
from
viewportmodifier
import
ViewportModifier
from
.
callback
import
INHIBIT_DELETE_UNDEF
,
INHIBIT_UPDATE_UNDEF
from
.
constant
import
(
INLINE_ALERT
,
UNDEF
,
UNDEF_ID
,
UNKNOWN
)
from
.
converter
import
(
to_field
,
to_fields
,
to_formPanel
,
to_gridColumn
,
to_gridColumnModel
,
to_gridFilter
,
to_gridPanel
,
to_jsonstore
,
to_model
,
to_panelWithUrlSelector
,
to_treeNodes
,
to_viewport
)
from
.
dbui
import
Dbui
from
.
dbsvc
import
CALLBACK_ERRORS
,
DbSvc
from
.
directsvc
import
DBUI
,
DirectSvc
,
JSONEncoder
from
.
extjs
import
(
ArrayStore
,
CheckBox
,
ComboBox
,
DirectStore
,
Field
,
FieldAceEditor
,
FieldContainer
,
FieldDate
,
FieldDict
,
FieldList
,
FieldNumber
,
FieldSet
,
FieldText
,
FieldTextArea
,
FieldTime
,
FormPanel
,
GridColumn
,
GridColumnModel
,
GridFilter
,
GridPanel
,
GridRowNumberer
,
GridTemplateColumn
,
GridWithFilter
,
JsonStore
,
Model
,
Panel
,
PanelWithUrlSelector
,
Store
,
TabPanel
,
Viewport
,
Window
,
XmlStore
)
from
.
fieldsmodifier
import
FieldsModifier
from
.
filters
import
CLEAN_COMMA
,
CLEAN_SPACES
from
.
formmodifier
import
configure_forms
,
FormModifier
from
.
gridmodifier
import
configure_grids
,
GridModifier
from
.
storemodifier
import
AddStore
,
StoreModifier
from
.
helper
import
(
as_list
,
close_user_session
,
decode_field
,
dummy_row
,
encode_field
,
encode_validator_errors
,
get_all_tables
,
get_create_id
,
get_field_validators
,
get_file_paths
,
get_foreign_field
,
get_id
,
get_language
,
get_plugin_path
,
get_reference_paths
,
get_script_path
,
get_set_field
,
get_store_id
,
get_versions
,
get_where_query
,
inline_alert
,
is_foreign_field
,
is_mathjax
,
is_set_field
,
is_table_with_foreign_fields
,
rows_serializer
)
from
.
mapper
import
map_default
,
map_tabpanel
from
.
navtree
import
Node
from
.
selector
import
Selector
from
.
validator
import
IS_IN_USET
from
.
viewportmodifier
import
ViewportModifier
modules/plugin_dbui/callback.py
View file @
6a4b5e58
# -*- coding: utf-8 -*-
""" callback
"""
from
constant
import
UNDEF_ID
from
dbsvc
import
CALLBACK_ERRORS
from
.
constant
import
UNDEF_ID
from
.
dbsvc
import
CALLBACK_ERRORS
from
gluon
import
current
...
...
modules/plugin_dbui/constant.py
View file @
6a4b5e58
# -*- coding: utf-8 -*-
""" constant
"""
...
...
modules/plugin_dbui/converter.py
View file @
6a4b5e58
...
...
@@ -5,42 +5,42 @@ import gluon.dal
import
re
from
datetime
import
date
,
datetime
,
time
from
extjs
import
(
Base
,
CheckBox
,
ComboBox
,
DirectStore
,
FieldContainer
,
FieldDate
,
FieldDict
,
FieldList
,
FieldNumber
,
FieldSet
,
FieldText
,
FieldTextArea
,
FieldTime
,
FormPanel
,
GridColumn
,
GridColumnModel
,
GridFilter
,
GridPanel
,
GridRowNumberer
,
GridTemplateColumn
,
GridWithFilter
,
Model
,
PanelWithUrlSelector
)
from
.
extjs
import
(
Base
,
CheckBox
,
ComboBox
,
DirectStore
,
FieldContainer
,
FieldDate
,
FieldDict
,
FieldList
,
FieldNumber
,
FieldSet
,
FieldText
,
FieldTextArea
,
FieldTime
,
FormPanel
,
GridColumn
,
GridColumnModel
,
GridFilter
,
GridPanel
,
GridRowNumberer
,
GridTemplateColumn
,
GridWithFilter
,
Model
,
PanelWithUrlSelector
)
from
gluon
import
current
from
gluon.languages
import
lazyT
from
gluon.storage
import
Storage
from
gluon.tools
import
PluginManager
from
gridmodifier
import
ROW_NUMBERING
from
helper
import
(
encode_field
,
get_field_validators
,
get_foreign_field
,
get_set_field
,
get_store_id
,
is_foreign_field
,
is_set_field
)
from
mapper
import
map_default
from
.
gridmodifier
import
ROW_NUMBERING
from
.
helper
import
(
encode_field
,
get_field_validators
,
get_foreign_field
,
get_set_field
,
get_store_id
,
is_foreign_field
,
is_set_field
)
from
.
mapper
import
map_default
# Associated gluon.dal.field type with an ExtJS widget
# The dictionary contains configuration parameters of the Ext JS widget
...
...
@@ -82,11 +82,9 @@ JSON_TYPES = (bool,
int
,
lazyT
,
list
,
long
,
str
,
time
,
tuple
,
unicode
)
tuple
)
# xtype defining linked comboBoxes
X_LINKED_COMBO
=
[
"xcomboboxmaster"
,
"xcomboboxslave"
]
...
...
modules/plugin_dbui/dbsvc.py
View file @
6a4b5e58
...
...
@@ -4,17 +4,17 @@
import
re
from
basesvc
import
BaseSvc
from
converter
import
ROOT
,
SUCCESS
,
TOTAL
from
.
basesvc
import
BaseSvc
from
.
converter
import
ROOT
,
SUCCESS
,
TOTAL
from
gluon
import
current
from
gluon.storage
import
Storage
from
helper
import
(
decode_field
,
encode_field
,
encode_validator_errors
,
get_all_tables
,
get_foreign_field
,
is_foreign_field
,
rows_serializer
)
from
.
helper
import
(
decode_field
,
encode_field
,
encode_validator_errors
,
get_all_tables
,
get_foreign_field
,
is_foreign_field
,
rows_serializer
)
CALLBACK_ERRORS
=
"_callback_errors"
...
...
@@ -262,7 +262,7 @@ class DbSvc(BaseSvc):
di
=
{}
db
=
current
.
globalenv
[
"db"
]
for
(
field
,
val
)
in
fields
.
items
():
for
field
,
val
in
list
(
fields
.
items
()
)
:
# NOTE: checks are not applied to foreign fields since
# consistency is garanty by the interface via the use of
...
...
modules/plugin_dbui/dbui.py
View file @
6a4b5e58
# -*- coding: utf-8 -*-
""" dbui
"""
...
...
@@ -10,7 +9,7 @@ from collections import OrderedDict
from
gluon
import
current
from
gluon.storage
import
Storage
from
gluon.tools
import
PluginManager
from
helper
import
get_language
from
.
helper
import
get_language
defaults
=
Storage
(
...
...
modules/plugin_dbui/directsvc.py
View file @
6a4b5e58
...
...
@@ -5,12 +5,12 @@ import datetime
import
json
from
basesvc
import
BaseSvc
from
.
basesvc
import
BaseSvc
from
gluon
import
current
from
gluon.http
import
HTTP
from
gluon.languages
import
lazyT
from
gluon.restricted
import
RestrictedError
from
helper
import
as_list
from
.
helper
import
as_list
DBUI
=
"Dbui"
...
...
@@ -49,7 +49,7 @@ class JSONEncoder(json.JSONEncoder):
self
.
allow_nan
=
allow_nan
self
.
sort_keys
=
sort_keys
self
.
use_decimal
=
use_decimal
if
isinstance
(
indent
,
(
int
,
long
)
):
if
isinstance
(
indent
,
int
):
indent
=
" "
*
indent
self
.
indent
=
indent
if
separators
is
not
None
:
...
...
@@ -183,7 +183,7 @@ class DirectSvc(BaseSvc):
# and to the name of the class for a method
action
=
DBUI
if
"im_class"
in
dir
(
f
):
action
=
f
.
im
_class
.
__name__
action
=
f
.
__self__
.
_
_class
__
.
__name__
k
=
PROC_KEY
%
(
action
,
f
.
__name__
)
self
.
procedures
[
k
]
=
f
...
...
modules/plugin_dbui/fieldsmodifier.py
View file @
6a4b5e58
...
...
@@ -2,7 +2,7 @@
"""
from
gluon.storage
import
Storage
from
modifier
import
Modifier
from
.
modifier
import
Modifier
MODIFIER_FIELDS
=
"modifier_fields"
...
...
modules/plugin_dbui/filters.py
View file @
6a4b5e58
...
...
@@ -19,7 +19,7 @@ def CLEAN_COMMA(value):
the return the value is unchanged when it is not a string.
"""
if
not
isinstance
(
value
,
(
str
,
unicode
)
):
if
not
isinstance
(
value
,
str
):
return
value
return
re
.
sub
(
REG_COMMA
,
""
,
value
)
...
...
@@ -37,7 +37,7 @@ def CLEAN_SPACES(value):
the return the value is unchanged when it is not a string.
"""
if
not
isinstance
(
value
,
(
str
,
unicode
)
):
if
not
isinstance
(
value
,
str
):
return
value
return
" "
.
join
(
value
.
strip
().
split
())
modules/plugin_dbui/formmodifier.py
View file @
6a4b5e58
...
...
@@ -4,14 +4,14 @@
import
copy
from
fieldsmodifier
import
FieldsModifier
from
.
fieldsmodifier
import
FieldsModifier
from
gluon.dal
import
DAL
from
gluon.storage
import
Storage
from
helper
import
(
encode_field
,
get_foreign_field
,
get_store_id
,
is_foreign_field
)
from
modifier
import
Modifier
from
.
helper
import
(
encode_field
,
get_foreign_field
,
get_store_id
,
is_foreign_field
)
from
.
modifier
import
Modifier
MODIFIER_FORMS
=
"modifier_forms"
...
...
modules/plugin_dbui/gridmodifier.py
View file @
6a4b5e58
...
...
@@ -6,7 +6,7 @@ import copy
from
gluon.dal
import
DAL
from
gluon.storage
import
Storage
from
modifier
import
Modifier
from
.
modifier
import
Modifier
MODIFIER_GRIDS
=
"modifier_grids"
...
...
modules/plugin_dbui/helper.py
View file @
6a4b5e58
...
...
@@ -6,7 +6,7 @@ import re
import
subprocess
from
constant
import
INLINE_ALERT
from
.
constant
import
INLINE_ALERT
from
gluon
import
current
from
gluon.dal
import
Row
,
Table
from
gluon.http
import
HTTP
...
...
@@ -114,7 +114,7 @@ def dummy_row(table, val=""):
if
is_foreign_field
(
field
):
k_tablename
,
k_fieldname
,
k_id
=
get_foreign_field
(
field
)
if
k_tablename
not
in
row
:
for
k
,
v
in
dummy_row
(
db
[
k_tablename
],
val
=
val
).
iter
items
():
for
k
,
v
in
list
(
dummy_row
(
db
[
k_tablename
],
val
=
val
).
items
()
)
:
if
k
not
in
row
:
row
[
k
]
=
v
...
...
@@ -158,7 +158,7 @@ def encode_validator_errors(error):
"""
di
=
{}
for
k
,
v
in
error
.
iter
items
():
for
k
,
v
in
list
(
error
.
items
()
)
:
tablename
,
fieldname
=
decode_field
(
k
)
di
[
k
]
=
"%s %s"
%
(
current
.
T
(
fieldname
.
title
()),
v
)
return
di
...
...
@@ -393,7 +393,7 @@ def get_id(table, **kwargs):
"""
query
=
None
for
k
,
v
in
kwargs
.
iter
items
():
for
k
,
v
in
list
(
kwargs
.
items
()
)
:
el
=
table
[
k
]
==
v
if
query
:
...
...
modules/plugin_dbui/mapper.py
View file @
6a4b5e58
""" the collections of mapper functions.
"""
from
extjs
import
TabPanel
from
.
extjs
import
TabPanel
def
map_default
(
fields
):
...
...
modules/plugin_dbui/modifier.py
View file @
6a4b5e58
...
...
@@ -103,7 +103,7 @@ class Modifier(object):
# list of existing ptypes
ptypes
=
[]
for
el
in
self
.
data
.
extjs
[
"plugins"
]:
if
isinstance
(
el
,
(
str
,
unicode
)
):
if
isinstance
(
el
,
str
):
ptypes
.
append
(
el
)
elif
isinstance
(
el
,
dict
):
ptypes
.
append
(
el
[
"ptype"
])
...
...
@@ -114,7 +114,7 @@ class Modifier(object):
for
plugin
in
plugins
:
ptype
=
""
if
isinstance
(
plugin
,
(
str
,
unicode
)
):
if
isinstance
(
plugin
,
str
):
ptype
=
plugin
elif
isinstance
(
plugin
,
dict
):
ptype
=
plugin
[
"ptype"
]
...
...
modules/plugin_dbui/navtree.py
View file @
6a4b5e58
...
...
@@ -5,7 +5,7 @@ import json
import
locale
from
directsvc
import
JSONEncoder
from
.
directsvc
import
JSONEncoder
from
gluon
import
current
...
...
@@ -76,7 +76,7 @@ class Node(object):
# NOTE: str is required to force the translation when lazyT is on
cvt
[
str
(
T
(
el
))]
=
el
translate_leaves
=
cvt
.
keys
()
translate_leaves
=
list
(
cvt
.
keys
()
)
translate_leaves
.
sort
(
cmp
=
locale
.
strcoll
)
# fill the node with its children
...
...
@@ -112,7 +112,7 @@ class Node(object):
for
child
in
self
.
children
:
di
[
child
[
"text"
]]
=
child
names
=
di
.
keys
()
names
=
list
(
di
.
keys
()
)
names
.
sort
(
cmp
=
locale
.
strcoll
)
self
.
children
=
[]
...
...
modules/plugin_dbui/selector.py
View file @
6a4b5e58
...
...
@@ -22,10 +22,10 @@ on the view::
from
datetime
import
date
,
datetime
,
time
from
gluon
import
current
from
gluon.storage
import
Storage
from
helper
import
(
decode_field
,
get_foreign_field
,
is_foreign_field
,
is_table_with_foreign_fields
)
from
.
helper
import
(
decode_field
,
get_foreign_field
,
is_foreign_field
,
is_table_with_foreign_fields
)
class
Selector
(
Storage
):
...
...
@@ -203,7 +203,7 @@ class Selector(Storage):
tablename
=
self
.
_tablename
tablename
=
tablename
[
0
].
upper
()
+
tablename
[
1
:]
for
(
k
,
v
)
in
current
.
request
.
vars
.
iter
items
():
for
k
,
v
in
list
(
current
.
request
.
vars
.
items
()
)
:
if
k
.
startswith
(
tablename
)
and
len
(
v
):
data
.
append
(
"%s=%s"
%
(
k
,
v
))
...
...
modules/plugin_dbui/storemodifier.py
View file @
6a4b5e58
...
...
@@ -2,8 +2,8 @@
"""
from
gluon.tools
import
PluginManager
from
helper
import
get_store_id
from
modifier
import
Modifier
from
.
helper
import
get_store_id
from
.
modifier
import
Modifier
MODIFIER_STORES
=
"modifier_stores"
...
...
modules/plugin_dbui/validator.py
View file @
6a4b5e58
# -*- coding: utf-8 -*-
""" validator
"""
...
...
@@ -16,14 +15,14 @@ class IS_IN_USET(IS_IN_SET):
if
isinstance
(
theset
,
(
list
,
tuple
)):
for
el
in
theset
:
if
isinstance
(
el
,
unicode
):
if
isinstance
(
el
,
str
):
el
=
el
.
encode
(
"utf-8"
)
myset
.
append
(
el
)
elif
isinstance
(
theset
,
dict
):
myset
=
{}
for
key
in
theset
:
if
isinstance
(
key
,
unicode
):
if
isinstance
(
key
,
str
):
myset
[
key
.
encode
(
"utf-8"
)]
=
theset
[
key
]
else
:
myset
[
key
]
=
theset
[
key
]
...
...
@@ -32,7 +31,7 @@ class IS_IN_USET(IS_IN_SET):
def
__call__
(
self
,
value
):
if
isinstance
(
value
,
unicode
):
if
isinstance
(
value
,
str
):
value
=
value
.
encode
(
"utf-8"
)
return
IS_IN_SET
.
__call__
(
self
,
value
)
modules/plugin_dbui/viewportmodifier.py
View file @
6a4b5e58
""" the viewport modifier.
"""
from
modifier
import
Modifier
from
navtree
import
Node
from
.
modifier
import
Modifier
from
.
navtree
import
Node
MSG_INVALID_NODE
=
"Node object is not an instance of NodeBase class."
...
...
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