This file is indexed.

/usr/share/pyshared/zc/datetimewidget/datetimewidget.txt is in python-zc.datetimewidget 0.7.0-0ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
===============
Calendar Widget
===============


Configuration
-------------

    >>> from zope.interface.verify import verifyObject
    >>> from zc.datetimewidget.datetimewidget import (
    ...     CalendarWidgetConfiguration, ICalendarWidgetConfiguration)

Let's create a standard configuration object:

    >>> conf = CalendarWidgetConfiguration('field.x')
    >>> verifyObject(ICalendarWidgetConfiguration, conf)
    True

Fields have their default values:

    >>> conf.daFormat
    u'%Y/%m/%d'
    >>> conf.singleClick
    True
    >>> print conf.flat
    None

We can customize some attributes during instantiation:

    >>> import datetime
    >>> conf = CalendarWidgetConfiguration('x', date=datetime.date(2006, 8, 25))
    >>> conf.date
    datetime.date(2006, 8, 25)


Dumping JavaScript
------------------

Configuration can be dumped as JavaScript.  First an empty configuration:

    >>> print CalendarWidgetConfiguration('field.x').dumpJS()
    Calendar.setup({
    <BLANKLINE>
    });

Now let's add a few customizations:

    >>> conf = CalendarWidgetConfiguration('x', daFormat=u'%m-%d',
    ...     inputField='inp', eventName=None, date=conf.date)
    >>> print conf.dumpJS()
    Calendar.setup({
      inputField: 'inp',
      eventName: null,
      daFormat: '%m-%d',
      date: new Date(2006, 7, 25)
    });

Invalid arguments are not accepted:

    >>> conf = CalendarWidgetConfiguration('x', foo='bar')
    Traceback (most recent call last):
        ...
    ValueError: unknown arguments: foo


Date set widget
---------------

    >>> from zc.datetimewidget.datetimewidget import DateSetWidget
    >>> from zope.schema import Set
    >>> from zope.publisher.browser import TestRequest

    >>> class Context(object):
    ...     somedates = set()
    >>> context = Context()

    >>> request = TestRequest()
    >>> field = Set(__name__='somedates')
    >>> field.set(context, set([datetime.date(2006, 12, 6),
    ...                         datetime.date(2006, 12, 7)]))
    >>> field = field.bind(context)
    >>> widget = DateSetWidget(field, object(), request)

    >>> print widget() # doctest: +REPORT_NDIFF
    <BLANKLINE>
    <input class="textType" id="field.somedates" name="field.somedates" size="30" type="text" value=""  />
    <input type="button" value="..." id="field.somedates_trigger">
    <script type="text/javascript">
    <BLANKLINE>
      var multi_field_somedates = [new Date(2006, 11, 6), new Date(2006, 11, 7)];
      Calendar.setup({
      inputField: 'field.somedates',
      button: 'field.somedates_trigger',
      ifFormat: '%Y-%m-%d',
      onClose: getMultipleDateClosedHandler("field.somedates", multi_field_somedates),
      multiple: multi_field_somedates
    });
    <BLANKLINE>
    </script>
    <BLANKLINE>

    >>> print widget.hidden() # doctest: +REPORT_NDIFF
    <input class="hiddenType" id="field.somedates" name="field.somedates" type="hidden" value=""  />
    <input type="button" value="..." id="field.somedates_trigger">
    <script type="text/javascript">
    <BLANKLINE>
      var multi_field_somedates = [new Date(2006, 11, 6), new Date(2006, 11, 7)];
      Calendar.setup({
      inputField: 'field.somedates',
      button: 'field.somedates_trigger',
      ifFormat: '%Y-%m-%d',
      onClose: getMultipleDateClosedHandler("field.somedates", multi_field_somedates),
      multiple: multi_field_somedates
    });
    <BLANKLINE>
    </script>