Commit b417aa72 by aa.gusti

Merge branch '5.0.3' into '5.0.3-oracle'

Migrasi ke deform 3

See merge request !11
2 parents f078cc11 dc7ed464
from pyramid.csrf import new_csrf_token, get_csrf_token from pyramid.csrf import new_csrf_token, get_csrf_token
from iso8601.iso8601 import ISO8601_REGEX from iso8601.iso8601 import ISO8601_REGEX
from deform.widget import string_types # from deform.widget import string_types
import json import json
import logging import logging
from colander import SchemaNode, null, Mapping, Invalid # , string_types from colander import SchemaNode, null, Mapping, Invalid # , string_types
# from colander import compat # tidak ada di colander 2.0 # from colander import compat # tidak ada di colander 2.0
from deform import widget from deform import widget
from deform.compat import sequence_types, text_type, text_ # from deform.compat import sequence_types, text_type, text_
from deform.form import Button from deform.form import Button
from deform.i18n import _ from deform.i18n import _
from deform.widget import ( from deform.widget import (
...@@ -257,12 +257,12 @@ class AutocompleteMsInputWidget(AutocompleteInputWidget): ...@@ -257,12 +257,12 @@ class AutocompleteMsInputWidget(AutocompleteInputWidget):
readonly = kw.get("readonly", self.readonly) readonly = kw.get("readonly", self.readonly)
options = {} options = {}
if isinstance(self.values, string_types): if isinstance(self.values, str):
options["remote"] = "%s?term=%%QUERY" % self.values options["remote"] = "%s?term=%%QUERY" % self.values
else: else:
# vals = [] # vals = []
# for v in self.values: # for v in self.values:
# if not isinstance(v, string_types): # if not isinstance(v, str):
# vals.append(v[1]) # vals.append(v[1])
# if not vals: # if not vals:
# vals = self.values # vals = self.values
...@@ -394,7 +394,7 @@ class CaptchaWidget(Widget): ...@@ -394,7 +394,7 @@ class CaptchaWidget(Widget):
def deserialize(self, field, pstruct): def deserialize(self, field, pstruct):
if pstruct is null: if pstruct is null:
return null return null
elif not isinstance(pstruct, string_types): elif not isinstance(pstruct, str):
raise Invalid(field.schema, "Pstruct is not a string") raise Invalid(field.schema, "Pstruct is not a string")
if self.strip: if self.strip:
pstruct = pstruct.strip() pstruct = pstruct.strip()
...@@ -460,7 +460,7 @@ class ImageWidget(Widget): ...@@ -460,7 +460,7 @@ class ImageWidget(Widget):
def deserialize(self, field, pstruct): def deserialize(self, field, pstruct):
if pstruct is null: if pstruct is null:
return null return null
elif not isinstance(pstruct, string_types): elif not isinstance(pstruct, str):
raise Invalid(field.schema, "Pstruct is not a string") raise Invalid(field.schema, "Pstruct is not a string")
if self.strip: if self.strip:
pstruct = pstruct.strip() pstruct = pstruct.strip()
...@@ -540,7 +540,7 @@ class MapWidget(Widget): ...@@ -540,7 +540,7 @@ class MapWidget(Widget):
def deserialize(self, field, pstruct): def deserialize(self, field, pstruct):
if pstruct is null: if pstruct is null:
return null return null
elif not isinstance(pstruct, string_types): elif not isinstance(pstruct, str):
raise Invalid(field.schema, "Pstruct is not a string") raise Invalid(field.schema, "Pstruct is not a string")
if self.strip: if self.strip:
pstruct = pstruct.strip() pstruct = pstruct.strip()
...@@ -622,7 +622,7 @@ class MapWidget(Widget): ...@@ -622,7 +622,7 @@ class MapWidget(Widget):
# def deserialize(self, field, pstruct): # def deserialize(self, field, pstruct):
# if pstruct is null: # if pstruct is null:
# return null # return null
# elif not isinstance(pstruct, string_types): # elif not isinstance(pstruct, str):
# raise Invalid(field.schema, "Pstruct is not a string") # raise Invalid(field.schema, "Pstruct is not a string")
# if self.strip: # if self.strip:
# pstruct = pstruct.strip() # pstruct = pstruct.strip()
...@@ -834,7 +834,7 @@ class TextInputWidget(widget.TextInputWidget): ...@@ -834,7 +834,7 @@ class TextInputWidget(widget.TextInputWidget):
def __init__(self, **kw): def __init__(self, **kw):
super(TextInputWidget, self).__init__(**kw) super(TextInputWidget, self).__init__(**kw)
# if isinstance(self.button, compat.string_types): # if isinstance(self.button, compat.str):
if self.button: if self.button:
if isinstance(self.button, str): if isinstance(self.button, str):
self.button = Button(self.button, type="button") self.button = Button(self.button, type="button")
...@@ -973,7 +973,7 @@ class FilterWidget(Widget): ...@@ -973,7 +973,7 @@ class FilterWidget(Widget):
# readonly = kw.get("readonly", self.readonly) # readonly = kw.get("readonly", self.readonly)
# #
# options = {} # options = {}
# if isinstance(self.values, string_types): # if isinstance(self.values, str):
# options["remote"] = "%s?term=%%QUERY" % self.values # options["remote"] = "%s?term=%%QUERY" % self.values
# else: # else:
# options["local"] = self.values # options["local"] = self.values
...@@ -1003,7 +1003,7 @@ class CSRFWidget(widget.HiddenWidget): ...@@ -1003,7 +1003,7 @@ class CSRFWidget(widget.HiddenWidget):
cstruct = get_csrf_token(request) cstruct = get_csrf_token(request)
if pstruct is null: if pstruct is null:
return null return null
elif not isinstance(pstruct, string_types): elif not isinstance(pstruct, str):
raise Invalid(field.schema, "Pstruct is not a string") raise Invalid(field.schema, "Pstruct is not a string")
if not pstruct: if not pstruct:
return null return null
......
...@@ -6,13 +6,17 @@ import re ...@@ -6,13 +6,17 @@ import re
import colander import colander
# import deform # import deform
from deform import compat, widget as deform_widget, field from deform import widget as deform_widget, field # compat,
from . import widget from . import widget
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
sequence_types = (
list,
tuple,
range,
)
class DeTable(field.Field): class DeTable(field.Field):
""" """
Field representing an entire form. Field representing an entire form.
...@@ -219,7 +223,7 @@ class DeTable(field.Field): ...@@ -219,7 +223,7 @@ class DeTable(field.Field):
_scripts = [] _scripts = []
# buttons = Params Buttons # buttons = Params Buttons
for button in buttons: for button in buttons:
if isinstance(button, compat.string_types): if isinstance(button, str):
button = Button(button) button = Button(button)
obj_buttons.append(button) obj_buttons.append(button)
header_buttons = [] header_buttons = []
......
...@@ -16,10 +16,10 @@ from iso8601.iso8601 import ISO8601_REGEX ...@@ -16,10 +16,10 @@ from iso8601.iso8601 import ISO8601_REGEX
from translationstring import TranslationString from translationstring import TranslationString
from deform.widget import MappingWidget from deform.widget import MappingWidget
from deform.compat import text_ # from deform.compat import text_
from .i18n import _ from .i18n import _
_BLANK = text_("") _BLANK = ""
class TableWidget(MappingWidget): class TableWidget(MappingWidget):
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!