[ZDP] BackTalk to Document Zope Developer's Guide (2.4 edition)/Object Publishing

webmaster@zope.org webmaster@zope.org
Fri, 15 Nov 2002 13:37:57 -0500


A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZDG/current/ObjectPublishing.stx#3-49

---------------

      This function cannot be called from the web because by default
      the publisher marshals arguments into strings, not numbers. This
      is why the publisher provides a number of converters. To signal
      an argument conversion you name your form variables with a colon
      followed by a type conversion code. For example, to call the
      above function with 66 as the argument you can use this URL
      *onethird?number:int=66* The publisher supports many
      converters:

        boolean -- Converts a variable to true or false. Variables
        that are 0, None, an empty string, or an empty sequence are
        false, all others are true.

        int -- Converts a variable to a Python integer.

        long -- Converts a variable to a Python long integer.

        float -- Converts a variable to a Python floating point
        number.

        string -- Converts a variable to a Python string.

        required -- Raises an exception if the variable is not present
        or is an empty string.

        ignore_empty -- Excludes a variable from the request if the
        variable is an empty string.

        date -- Converts a string to a *DateTime* object. The formats
        accepted are fairly flexible, for example '10/16/2000',
        '12:01:13 pm'.

        list -- Converts a variable to a Python list of values, even
        if there is only one value.

        tuple -- Converts a variable to a Python tuple of values, even
        if there is only one value.

        lines -- Converts a string to a Python list of values by
        splitting the string on line breaks.

        tokens -- Converts a string to a Python list of values by
        splitting the string on spaces.

        text -- Converts a variable to a string with normalized line
        breaks.  Different browsers on various platforms encode line
        endings differently, so this converter makes sure the line
        endings are consistent, regardless of how they were encoded by
        the browser.

        % Anonymous User - Nov. 15, 2002 1:37 pm:
         Asserting that 'This function cannot be called from the web' seems inaccurate or incomplete - especially
         considering the subsequent explanation.