Browse Source

maintenance changes

wangweimin 4 years ago
parent
commit
ad039bcaad
7 changed files with 13 additions and 23 deletions
  1. 0 1
      Procfile
  2. 2 2
      demos/markdown_previewer.py
  3. 5 4
      pywebio/__init__.py
  4. 0 8
      pywebio/io_ctrl.py
  5. 5 3
      pywebio/output.py
  6. 0 4
      webiojs/src/main.ts
  7. 1 1
      webiojs/src/models/output.ts

+ 0 - 1
Procfile

@@ -1 +0,0 @@
-web: python -m demos --port=$PORT

+ 2 - 2
demos/markdown_previewer.py

@@ -23,11 +23,11 @@ def main():
 
     put_buttons(['Download content'], lambda _: download('saved.md', pin.md_text.encode('utf8')), small=True)
 
-    put_markdown('## Preview', sanitize=False)
+    put_markdown('## Preview')
     while True:
         change_detail = pin_wait_change('md_text')
         with use_scope('md', clear=True):
-            put_markdown(change_detail['value'])
+            put_markdown(change_detail['value'], sanitize=False)
 
 
 if __name__ == '__main__':

+ 5 - 4
pywebio/__init__.py

@@ -21,12 +21,13 @@ logging.getLogger(__name__).addHandler(logging.NullHandler())
 
 def enable_debug(level=logging.DEBUG):
     """Output PyWebIO logging message to sys.stderr"""
+    from tornado.log import access_log, app_log, gen_log
     ch = logging.StreamHandler()
     ch.setLevel(level)
     formatter = logging.Formatter('[%(levelname)s %(asctime)s %(module)s:%(lineno)d %(funcName)s] %(message)s',
                                   datefmt='%y%m%d %H:%M:%S')
     ch.setFormatter(formatter)
-    logger = logging.getLogger(__name__)
-    logger.handlers = [ch]
-    logger.setLevel(level)
-    logger.propagate = False
+    for logger in [logging.getLogger(__name__), access_log, app_log, gen_log]:
+        logger.handlers = [ch]
+        logger.setLevel(level)
+        logger.propagate = False

+ 0 - 8
pywebio/io_ctrl.py

@@ -285,7 +285,6 @@ def check_item(name, data, valid_func, preprocess_func):
 def trigger_onchange(event_data, onchange_funcs):
     name = event_data['name']
     onchange_func = onchange_funcs[name]
-    update_input_info = None
 
     task_id = get_current_task_id()
     get_current_session().internal_save['onchange_trigger-' + task_id] = name  # used in `pywebio.input.input_update()`
@@ -296,13 +295,6 @@ def trigger_onchange(event_data, onchange_funcs):
     finally:
         del get_current_session().internal_save['onchange_trigger-' + task_id]
 
-    if update_input_info:
-        from pywebio.input import update_input
-        assert isinstance(update_input_info, Mapping), 'The onchange function must return None or a dict'
-
-        for name, spec in update_input_info:
-            update_input(name, spec)
-
 
 @chose_impl
 def input_event_handle(item_valid_funcs, form_valid_funcs, preprocess_funcs, onchange_funcs):

+ 5 - 3
pywebio/output.py

@@ -709,8 +709,7 @@ def put_buttons(buttons, onclick, small=None, link_style=False, group=False, sco
 
     def click_callback(btn_val):
         if isinstance(onclick, dict):
-            func = onclick.get(btn_val, lambda: None)
-            return func()
+            return onclick[btn_val]()
         else:
             return onclick(btn_val)
 
@@ -1400,6 +1399,9 @@ def output(*contents):
 def style(outputs, css_style) -> Union[Output, OutputList]:
     """Customize the css style of output content
 
+    .. deprecated:: 1.3
+        See `` for how to set css style for output.
+
     :param outputs: The output content can be a ``put_xxx()`` call or a list of it.
     :type outputs: list/put_xxx()
     :param str css_style: css style string
@@ -1410,7 +1412,7 @@ def style(outputs, css_style) -> Union[Output, OutputList]:
     :Example:
 
     .. exportable-codeblock::
-        :name: style
+        :name: style-deprecated
         :summary: `style()` usage
 
         style(put_text('Red'), 'color:red')

+ 0 - 4
webiojs/src/main.ts

@@ -88,9 +88,5 @@ function startWebIOClient(options: {
 window.WebIO = {
     '_state': state,
     'startWebIOClient': startWebIOClient,
-    'sendMessage': (msg: ClientEvent) => {
-        return state.CurrentSession.send_message(msg);
-    },
     'openApp': openApp,
-    'pushData': pushData,
 };

+ 1 - 1
webiojs/src/models/output.ts

@@ -257,7 +257,7 @@ export function render_tpl(tpl: string, data: { [i: string]: any }) {
                 return 'webio-' + randomid(10);
             }
         };
-    }
+    };
 
     // count the function call number
     // {{index}}