Commit 6a4b5e58 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update modules/plugin_dbui applying 2to3 converter.

parent 862aec78
......@@ -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
# -*- 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
......
# -*- coding: utf-8 -*-
""" constant
"""
......
......@@ -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"]
......
......@@ -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
......
# -*- 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(
......
......@@ -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
......
......@@ -2,7 +2,7 @@
"""
from gluon.storage import Storage
from modifier import Modifier
from .modifier import Modifier
MODIFIER_FIELDS = "modifier_fields"
......
......@@ -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())
......@@ -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"
......
......@@ -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"
......
......@@ -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).iteritems():
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.iteritems():
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.iteritems():
for k, v in list(kwargs.items()):
el = table[k] == v
if query:
......
""" the collections of mapper functions.
"""
from extjs import TabPanel
from .extjs import TabPanel
def map_default(fields):
......
......@@ -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"]
......
......@@ -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 = []
......
......@@ -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.iteritems():
for k, v in list(current.request.vars.items()):
if k.startswith(tablename) and len(v):
data.append("%s=%s" % (k, v))
......
......@@ -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"
......
# -*- 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)
""" 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."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment