This file is indexed.

/usr/share/pyshared/zope.file-0.6.2.egg-info/PKG-INFO is in python-zope.file 0.6.2-0ubuntu1.

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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
Metadata-Version: 1.1
Name: zope.file
Version: 0.6.2
Summary: Efficient File Implementation for Zope Applications
Home-page: http://cheeseshop.python.org/pypi/zope.file
Author: Zope Corporation and Contributors
Author-email: zope-dev@zope.org
License: ZPL 2.1
Description: The `zope.file` package provides a content object used to store a
        file. The interface supports efficient upload and download.
        
        
        .. contents::
        
        ===========
        File Object
        ===========
        
        The `zope.file` package provides a content object used to store a
        file.  The interface supports efficient upload and download.  Let's
        create an instance:
        
          >>> from zope.file.file import File
          >>> f = File()
        
        The object provides a limited number of data attributes.  The
        `mimeType` attribute is used to store the preferred MIME
        content-type value for the data:
        
          >>> f.mimeType
        
          >>> f.mimeType = "text/plain"
          >>> f.mimeType
          'text/plain'
        
          >>> f.mimeType = "application/postscript"
          >>> f.mimeType
          'application/postscript'
        
        The `parameters` attribute is a mapping used to store the content-type
        parameters.  This is where encoding information can be found when
        applicable (and available):
        
          >>> f.parameters
          {}
          >>> f.parameters["charset"] = "us-ascii"
          >>> f.parameters["charset"]
          'us-ascii'
        
        Both, `parameters` and `mimeType` can optionally also be set when
        creating a `File` object:
        
          >>> f2 = File(mimeType = "application/octet-stream",
          ...           parameters = dict(charset = "utf-8"))
          >>> f2.mimeType
          'application/octet-stream'
        
          >>> f2.parameters["charset"]
          'utf-8'
        
        File objects also sport a `size` attribute that provides the number of
        bytes in the file:
        
          >>> f.size
          0
        
        The object supports efficient upload and download by providing all
        access to content data through accessor objects that provide (subsets
        of) Python's file API.
        
        A file that hasn't been written to is empty.  We can get a reader by calling
        `open()`. Note that all blobs are binary, thus the mode always contains a
        'b':
        
          >>> r = f.open("r")
          >>> r.mode
          'rb'
        
        The `read()` method can be called with a non-negative integer argument
        to specify how many bytes to read, or with a negative or omitted
        argument to read to the end of the file:
        
          >>> r.read(10)
          ''
          >>> r.read()
          ''
          >>> r.read(-1)
          ''
        
        Once the accessor has been closed, we can no longer read from it:
        
          >>> r.close()
          >>> r.read()
          Traceback (most recent call last):
          ValueError: I/O operation on closed file
        
        We'll see that readers are more interesting once there's data in the
        file object.
        
        Data is added by using a writer, which is also created using the
        `open()` method on the file, but requesting a write file mode:
        
          >>> w = f.open("w")
          >>> w.mode
          'wb'
        
        The `write()` method is used to add data to the file, but note that
        the data may be buffered in the writer:
        
          >>> w.write("some text ")
          >>> w.write("more text")
        
        The `flush()` method ensure that the data written so far is written to
        the file object:
        
          >>> w.flush()
        
        We need to close the file first before determining its file size
        
          >>> w.close()
          >>> f.size
          19
        
        We can now use a reader to see that the data has been written to the
        file:
        
          >>> w = f.open("w")
          >>> w.write('some text more text')
          >>> w.write(" still more")
          >>> w.close()
          >>> f.size
          30
        
        
        Now create a new reader and let's perform some seek operations.
        
          >>> r = f.open()
        
        The reader also has a `seek()` method that can be used to back up or
        skip forward in the data stream.  Simply passing an offset argument,
        we see that the current position is moved to that offset from the
        start of the file:
        
          >>> r.seek(20)
          >>> r.read()
          'still more'
        
        That's equivalent to passing 0 as the `whence` argument:
        
          >>> r.seek(20, 0)
          >>> r.read()
          'still more'
        
        We can skip backward and forward relative to the current position by
        passing 1 for `whence`:
        
          >>> r.seek(-10, 1)
          >>> r.read(5)
          'still'
          >>> r.seek(2, 1)
          >>> r.read()
          'ore'
        
        We can skip to some position backward from the end of the file using
        the value 2 for `whence`:
        
          >>> r.seek(-10, 2)
          >>> r.read()
          'still more'
        
          >>> r.seek(0)
          >>> r.seek(-4, 2)
          >>> r.read()
          'more'
        
          >>> r.close()
        
        
        Attempting to write to a closed writer raises an exception:
        
        
          >>> w = f.open('w')
          >>> w.close()
        
          >>> w.write('foobar')
          Traceback (most recent call last):
          ValueError: I/O operation on closed file
        
        Similarly, using `seek()` or `tell()` on a closed reader raises an
        exception:
        
          >>> r.close()
          >>> r.seek(0)
          Traceback (most recent call last):
          ValueError: I/O operation on closed file
        
          >>> r.tell()
          Traceback (most recent call last):
          ValueError: I/O operation on closed file
        
        
        
        ========================
        Downloading File Objects
        ========================
        
        The file content type provides a view used to download the file,
        regardless of the browser's default behavior for the content type.
        This relies on browser support for the Content-Disposition header.
        
        The download support is provided by two distinct objects:  A view that
        provides the download support using the information in the content
        object, and a result object that can be used to implement a file
        download by other views.  The view can override the content-type or the
        filename suggested to the browser using the standard IResponse.setHeader
        method.
        
        Note that result objects are intended to be used once and then
        discarded.
        
        Let's start by creating a file object we can use to demonstrate the
        download support:
        
          >>> import transaction
          >>> from zope.file.file import File
          >>> f = File()
          >>> getRootFolder()['file'] = f
          >>> transaction.commit()
        
        Headers
        -------
        
        Now, let's get the headers for this file.  We use a utility function called
        ``getHeaders``:
        
          >>> from zope.file.download import getHeaders
          >>> headers = getHeaders(f, contentDisposition='attachment')
        
        Since there's no suggested download filename on the file, the
        Content-Disposition header doesn't specify one, but does indicate that
        the response body be treated as a file to save rather than to apply
        the default handler for the content type:
        
          >>> sorted(headers)
          [('Content-Disposition', 'attachment; filename="file"'),
           ('Content-Length', '0'),
           ('Content-Type', 'application/octet-stream')]
        
        
        Note that a default content type of 'application/octet-stream' is
        used.
        
        If the file object specifies a content type, that's used in the headers
        by default:
        
          >>> f.mimeType = "text/plain"
          >>> headers = getHeaders(f, contentDisposition='attachment')
          >>> sorted(headers)
          [('Content-Disposition', 'attachment; filename="file"'),
           ('Content-Length', '0'),
           ('Content-Type', 'text/plain')]
        
        Alternatively, a content type can be specified to ``getHeaders``:
        
          >>> headers = getHeaders(f, contentType="text/xml",
          ...                      contentDisposition='attachment')
          >>> sorted(headers)
          [('Content-Disposition', 'attachment; filename="file"'),
           ('Content-Length', '0'),
           ('Content-Type', 'text/xml')]
        
        The filename provided to the browser can be controlled similarly.  If
        the content object provides one, it will be used by default:
        
          >>> headers = getHeaders(f, contentDisposition='attachment')
          >>> sorted(headers)
          [('Content-Disposition', 'attachment; filename="file"'),
           ('Content-Length', '0'),
           ('Content-Type', 'text/plain')]
        
        Providing an alternate name to ``getHeaders`` overrides the download
        name from the file:
        
          >>> headers = getHeaders(f, downloadName="foo.txt",
          ...                      contentDisposition='attachment')
          >>> sorted(headers)
          [('Content-Disposition', 'attachment; filename="foo.txt"'),
           ('Content-Length', '0'),
           ('Content-Type', 'text/plain')]
        
        The default Content-Disposition header can be overridden by providing
        an argument to ``getHeaders``:
        
          >>> headers = getHeaders(f, contentDisposition="inline")
          >>> sorted(headers)
          [('Content-Disposition', 'inline; filename="file"'),
           ('Content-Length', '0'),
           ('Content-Type', 'text/plain')]
        
        If the `contentDisposition` argument is not provided, none will be
        included in the headers:
        
          >>> headers = getHeaders(f)
          >>> sorted(headers)
          [('Content-Length', '0'),
           ('Content-Type', 'text/plain')]
        
        
        Body
        ----
        
        We use DownloadResult to deliver the content to the browser.  Since
        there's no data in this file, there are no body chunks:
            
          >>> transaction.commit()
          >>> from zope.file.download import DownloadResult
          >>> result = DownloadResult(f)
          >>> list(result)
          []
        
        We still need to see how non-empty files are handled.  Let's write
        some data to our file object:
        
          >>> w = f.open("w")
          >>> w.write("some text")
          >>> w.flush()
          >>> w.close()
          >>> transaction.commit()
        
        Now we can create a result object and see if we get the data we
        expect:
        
          >>> result = DownloadResult(f)
          >>> L = list(result)
          >>> "".join(L)
          'some text'
        
        If the body content is really large, the iterator may provide more
        than one chunk of data:
        
          >>> w = f.open("w")
          >>> w.write("*" * 1024 * 1024)
          >>> w.flush()
          >>> w.close()
          >>> transaction.commit()
        
          >>> result = DownloadResult(f)
          >>> L = list(result)
          >>> len(L) > 1
          True
        
        Once iteration over the body has completed, further iteration will not
        yield additional data:
        
          >>> list(result)
          []
        
        
        The Download View
        -----------------
        
        Now that we've seen the ``getHeaders`` function and the result object,
        let's take a look at the basic download view that uses them.  We'll need
        to add a file object where we can get to it using a browser:
        
          >>> f = File()
          >>> f.mimeType = "text/plain"
          >>> w = f.open("w")
          >>> w.write("some text")
          >>> w.close()
          >>> transaction.commit()
        
          >>> getRootFolder()["abcdefg"] = f
        
          >>> transaction.commit()
        
        Now, let's request the download view of the file object and check the
        result:
        
          >>> print http("""
          ... GET /abcdefg/@@download HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, handle_errors=False)
          HTTP/1.1 200 Ok
          Content-Disposition: attachment; filename="abcdefg"
          Content-Length: 9
          Content-Type: text/plain
          <BLANKLINE>
          some text
        
        
        The Inline View
        ---------------
        
        In addition, it is sometimes useful to view the data inline instead of
        downloading it.  A basic inline view is provided for this use case.
        Note that browsers may decide not to display the image when this view
        is used and there is not page that it's being loaded into: if this
        view is being referenced directly via the URL, the browser may show
        nothing:
        
          >>> print http("""
          ... GET /abcdefg/@@inline HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, handle_errors=False)
          HTTP/1.1 200 Ok
          Content-Disposition: inline; filename="abcdefg"
          Content-Length: 9
          Content-Type: text/plain
          <BLANKLINE>
          some text
        
        
        The Default Display View
        ------------------------
        
        This view is similar to the download and inline views, but no content
        disposition is specified at all.  This lets the browser's default
        handling of the data in the current context to be applied:
        
          >>> print http("""
          ... GET /abcdefg/@@display HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, handle_errors=False)
          HTTP/1.1 200 Ok
          Content-Length: 9
          Content-Type: text/plain
          <BLANKLINE>
          some text
        
        
        ====================
        Uploading a new file
        ====================
        
        There's a simple view for uploading a new file.  Let's try it:
        
          >>> from StringIO import StringIO
        
          >>> sio = StringIO("some text")
          >>> sio.filename = "plain.txt"
          >>> sio.headers = {"Content-Type": "text/plain; charset=utf-8",
          ...                "Content-Disposition": 'attachment; filename="plain.txt"'}
        
          >>> print http("""
          ... POST /@@+/zope.file.File HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, form={"form.data": sio,
          ...            "form.actions.add": "Add"}, handle_errors=False)
          HTTP/1.1 303 ...
        
        Now, let's request the download view of the file object and check the
        result:
        
          >>> print http("""
          ... GET /plain.txt/@@download HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, handle_errors=False)
          HTTP/1.1 200 Ok
          Content-Disposition: attachment; filename="plain.txt"
          Content-Length: 9
          Content-Type: text/plain;charset=utf-8
          <BLANKLINE>
          some text
        
        We'll peek into the database to make sure the object implements the
        expected MIME type interface:
        
          >>> from zope.mimetype import types
          >>> ob = getRootFolder()["plain.txt"]
          >>> types.IContentTypeTextPlain.providedBy(ob)
          True
        
        We can upload new data into our file object as well:
        
          >>> sio = StringIO("new text")
          >>> sio.filename = "stuff.txt"
          >>> sio.headers = {"Content-Type": "text/plain; charset=utf-8",
          ...                "Content-Disposition": 'attachment; filename="stuff.txt"'}
        
          >>> print http("""
          ... POST /plain.txt/@@edit.html HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, form={"form.data": sio,
          ...            "form.actions.edit": "Edit"}, handle_errors=False)
          HTTP/1.1 200 ...
        
        Now, let's request the download view of the file object and check the
        result:
        
          >>> print http("""
          ... GET /plain.txt/@@download HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, handle_errors=False)
          HTTP/1.1 200 Ok
          Content-Disposition: attachment; filename="plain.txt"
          Content-Length: 8
          Content-Type: text/plain;charset=utf-8
          <BLANKLINE>
          new text
        
        If we upload a file that has imprecise content type information (as we
        expect from browsers generally, and MSIE most significantly), we can
        see that the MIME type machinery will improve the information where
        possible:
        
          >>> sio = StringIO("<?xml version='1.0' encoding='utf-8'?>\n"
          ...                "<html>...</html>\n")
          >>> sio.filename = "simple.html"
          >>> sio.headers = {
          ...     "Content-Type": "text/html; charset=utf-8",
          ...     "Content-Disposition": 'attachment; filename="simple.html"',
          ...     }
        
          >>> print http("""
          ... POST /@@+/zope.file.File HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, form={"form.data": sio,
          ...            "form.actions.add": "Add"}, handle_errors=False)
          HTTP/1.1 303 ...
        
        Again, we'll request the download view of the file object and check
        the result:
        
          >>> print http("""
          ... GET /simple.html/@@download HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, handle_errors=False)
          HTTP/1.1 200 Ok
          Content-Disposition: attachment; filename="simple.html"
          Content-Length: 56
          Content-Type: application/xhtml+xml;charset=utf-8
          <BLANKLINE>
          <?xml version='1.0' encoding='utf-8'?>
          <html>...</html>
          <BLANKLINE>
        
        Further, if a browser is bad and sends a full path as the file name (as
        sometimes happens in many browsers, apparently), the name is correctly
        truncated and changed.
        
          >>> sio = StringIO("<?xml version='1.0' encoding='utf-8'?>\n"
          ...                "<html>...</html>\n")
          >>> sio.filename = r"C:\Documents and Settings\Joe\naughty name.html"
          >>> sio.headers = {
          ...     "Content-Type": "text/html; charset=utf-8",
          ...     "Content-Disposition": 'attachment; filename=%s' % sio.filename,
          ...     }
        
          >>> print http("""
          ... POST /@@+/zope.file.File HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, form={"form.data": sio,
          ...            "form.actions.add": "Add"}, handle_errors=False)
          HTTP/1.1 303 ...
        
        Again, we'll request the download view of the file object and check
        the result:
        
          >>> print http("""
          ... GET /naughty%20name.html/@@download HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, handle_errors=False)
          HTTP/1.1 200 Ok
          Content-Disposition: attachment; filename="naughty name.html"
          Content-Length: 56
          Content-Type: application/xhtml+xml;charset=utf-8
          <BLANKLINE>
          <?xml version='1.0' encoding='utf-8'?>
          <html>...</html>
          <BLANKLINE>
        
        In zope.file <= 0.5.0, a redundant ObjectCreatedEvent was fired in the
        Upload view.  We'll demonstrate that this is no longer the case.
        
          >>> import zope.component
          >>> from zope.file.interfaces import IFile
          >>> from zope.lifecycleevent import IObjectCreatedEvent
        
        We'll register a subscriber for IObjectCreatedEvent that simply increments
        a counter.
        
          >>> count = 0
          >>> def inc(*args):
          ...   global count; count += 1
          >>> zope.component.provideHandler(inc, (IFile, IObjectCreatedEvent))
        
          >>> print http("""
          ... POST /@@+/zope.file.File HTTP/1.1
          ... Authorization: Basic mgr:mgrpw
          ... """, form={"form.data": sio,
          ...            "form.actions.add": "Add"}, handle_errors=False)
          HTTP/1.1 303 ...
        
        The subscriber was called only once.
        
          >>> print count
          1
        
        
        ==================================
        Content type and encoding controls
        ==================================
        
        Files provide a view that supports controlling the MIME content type
        and, where applicable, the content encoding.  Content encoding is
        applicable based on the specific content type of the file.
        
        Let's demonstrate the behavior of the form with a simple bit of
        content.  We'll upload a bit of HTML as a sample document:
        
          >>> import StringIO
          >>> sio = StringIO.StringIO("A <sub>little</sub> HTML."
          ...                         "  There's one 8-bit Latin-1 character: \xd8.")
        
          >>> from zope.testbrowser.testing import Browser
          >>> browser = Browser()
          >>> browser.addHeader("Authorization", "Basic mgr:mgrpw")
          >>> browser.addHeader("Accept-Language", "en-US")
          >>> browser.open("http://localhost/@@+/zope.file.File")
        
          >>> ctrl = browser.getControl(name="form.data")
          >>> ctrl.mech_control.add_file(
          ...     sio, "text/html", "sample.html")
          >>> browser.getControl("Add").click()
        
        We can see that the MIME handlers have marked this as HTML content:
        
          >>> import zope.mimetype.interfaces
          >>> import zope.mimetype.types
        
          >>> file = getRootFolder()["sample.html"]
          >>> zope.mimetype.types.IContentTypeTextHtml.providedBy(file)
          True
        
        It's important to note that this also means the content is encoded
        text:
        
          >>> zope.mimetype.interfaces.IContentTypeEncoded.providedBy(file)
          True
        
        The "Content Type" page will show us the MIME type and encoding that
        have been selected:
        
          >>> browser.getLink("sample.html").click()
          >>> browser.getLink("Content Type").click()
        
          >>> browser.getControl(name="form.mimeType").value
          ['zope.mimetype.types.IContentTypeTextHtml']
        
        The empty string value indicates that we have no encoding
        information:
        
          >>> ctrl = browser.getControl(name="form.encoding")
          >>> print ctrl.value
          ['']
        
        Let's now set the encoding value to an old favorite, Latin-1:
        
          >>> ctrl.value = ["iso-8859-1"]
          >>> browser.handleErrors = False
          >>> browser.getControl("Save").click()
        
        We now see the updated value in the form, and can check the value in
        the MIME content-type parameters on the object:
        
          >>> ctrl = browser.getControl(name="form.encoding")
          >>> print ctrl.value
          ['iso-8859-1']
        
          >>> file = getRootFolder()["sample.html"]
          >>> file.parameters
          {'charset': 'iso-8859-1'}
        
        Something more interesting is that we can now use a non-encoded
        content type, and the encoding field will be removed from the form:
        
          >>> ctrl = browser.getControl(name="form.mimeType")
          >>> ctrl.value = ["zope.mimetype.types.IContentTypeImageTiff"]
          >>> browser.getControl("Save").click()
        
          >>> browser.getControl(name="form.encoding")
          Traceback (most recent call last):
            ...
          LookupError: name 'form.encoding'
        
        If we switch back to an encoded type, we see that our encoding wasn't
        lost:
        
          >>> ctrl = browser.getControl(name="form.mimeType")
          >>> ctrl.value = ["zope.mimetype.types.IContentTypeTextHtml"]
          >>> browser.getControl("Save").click()
        
          >>> browser.getControl(name="form.encoding").value
          ['iso-8859-1']
        
        On the other hand, if we try setting the encoding to something which
        simply cannot decode the input data, we get an error message saying
        that's not going to work, and no changes are saved:
        
          >>> ctrl = browser.getControl(name="form.encoding")
          >>> ctrl.value = ["utf-8"]
        
          >>> browser.getControl("Save").click()
        
          >>> print browser.contents
          <...Selected encoding cannot decode document...
        
        
        =====================
        Presentation Adapters
        =====================
        
        Object size
        -----------
        
        The size of the file as presented in the contents view of a container is
        provided using an adapter implementing the `zope.size.interfaces.ISized`
        interface. Such an adapter is available for the file object.
        
        Let's do some imports and create a new file object:
        
          >>> from zope.file.file import File
          >>> from zope.file.browser import Sized
          >>> from zope.size.interfaces import ISized
        
          >>> f = File()
          >>> f.size
          0
        
          >>> s = Sized(f)
          >>> ISized.providedBy(s)
          True
          >>> s.sizeForSorting()
          ('byte', 0)
          >>> s.sizeForDisplay()
          u'0 KB'
        
        Let's add some content to the file:
        
          >>> w = f.open('w')
          >>> w.write("some text")
          >>> w.close()
        
        The sized adapter now reflects the updated size:
        
          >>> s.sizeForSorting()
          ('byte', 9)
          >>> s.sizeForDisplay()
          u'1 KB'
        
        Let's try again with a larger file size:
        
          >>> w = f.open('w')
          >>> w.write("x" * (1024*1024+10))
          >>> w.close()
        
          >>> s.sizeForSorting()
          ('byte', 1048586)
          >>> m = s.sizeForDisplay()
          >>> m
          u'${size} MB'
          >>> m.mapping
          {'size': '1.00'}
        
        And still a bigger size:
        
          >>> w = f.open('w')
          >>> w.write("x" * 3*512*1024)
          >>> w.close()
        
          >>> s.sizeForSorting()
          ('byte', 1572864)
          >>> m = s.sizeForDisplay()
          >>> m
          u'${size} MB'
          >>> m.mapping
          {'size': '1.50'}
        
        
        =======
        CHANGES
        =======
        
        0.6.2 (2012-06-04)
        ------------------
        
        - Moved menu-oriented registrations into new menus.zcml. This is now
          loaded if zope.app.zcmlfiles is available only.
        
        - Increase test coverage.
        
        0.6.1 (2012-01-26)
        ------------------
        
        - Declared more dependencies.
        
        
        0.6.0 (2010-09-16)
        ------------------
        
        - Bug fix: remove duplicate firing of ObjectCreatedEvent in
          zope.file.upload.Upload (the event is already fired in its base class,
          zope.formlib.form.AddForm).
        
        - Move browser-related zcml to `browser.zcml` so that it easier for
          applications to exclude it.
        
        - Import content-type parser from zope.contenttype, adding a dependency on
          that package.
        
        - Removed undeclared dependency on zope.app.container, depend on zope.browser.
        
        - Using Python's ``doctest`` module instead of deprecated
          ``zope.testing.doctest``.
        
        0.5.0 (2009-07-23)
        ------------------
        
        - Change package's mailing list address to zope-dev at zope.org instead
          of the retired one.
        
        - Made tests compatible with ZODB 3.9.
        
        - Removed not needed install requirement declarations.
        
        
        0.4.0 (2009-01-31)
        ------------------
        
        - `openDetached` is now protected by zope.View instead of zope.ManageContent.
        
        - Use zope.container instead of zope.app.container.
        
        0.3.0 (2007-11-01)
        ------------------
        
        - Package data update.
        
        0.2.0 (2007-04-18)
        ------------------
        
        - Fix code for Publisher version 3.4.
        
        0.1.0 (2007-04-18)
        ------------------
        
        - Initial release.
        
Keywords: zope3 web html ui file pattern
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Zope Public License
Classifier: Programming Language :: Python
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Framework :: Zope3