comparison MoinMoin/items/__init__.py @ 488:8462764f59d2

contenttype_groups structure moved under config
author Akash Sinha <akash2607@gmail.com>
date Wed, 13 Jul 2011 21:43:58 +0530
parents b6149c732926
children fa1b9282a3ac
comparison
equal deleted inserted replaced
487:bdf613f0a062 488:8462764f59d2
66 StorageError 66 StorageError
67 from MoinMoin.config import UUID, NAME, NAME_OLD, MTIME, REVERTED_TO, ACL, \ 67 from MoinMoin.config import UUID, NAME, NAME_OLD, MTIME, REVERTED_TO, ACL, \
68 IS_SYSITEM, SYSITEM_VERSION, USERGROUP, SOMEDICT, \ 68 IS_SYSITEM, SYSITEM_VERSION, USERGROUP, SOMEDICT, \
69 CONTENTTYPE, SIZE, LANGUAGE, ITEMLINKS, ITEMTRANSCLUSIONS, \ 69 CONTENTTYPE, SIZE, LANGUAGE, ITEMLINKS, ITEMTRANSCLUSIONS, \
70 TAGS, ACTION, ADDRESS, HOSTNAME, USERID, EXTRA, COMMENT, \ 70 TAGS, ACTION, ADDRESS, HOSTNAME, USERID, EXTRA, COMMENT, \
71 HASH_ALGORITHM 71 HASH_ALGORITHM, CONTENTTYPE_GROUPS
72 72
73 COLS = 80 73 COLS = 80
74 ROWS_DATA = 20 74 ROWS_DATA = 20
75 ROWS_META = 10 75 ROWS_META = 10
76 76
581 creates an top level index of sub items of this item 581 creates an top level index of sub items of this item
582 if startswith is set, filtering is done on the basis of starting letter of item name 582 if startswith is set, filtering is done on the basis of starting letter of item name
583 if selected_groups is set, items whose contentype belonging to the selected contenttype_groups, are filtered. 583 if selected_groups is set, items whose contentype belonging to the selected contenttype_groups, are filtered.
584 """ 584 """
585 index = self.get_index() 585 index = self.get_index()
586 nonexistent_item = NonExistent(self)
587 if not selected_groups: 586 if not selected_groups:
588 selected_groups = [gname for (gname, contenttypes) in nonexistent_item.contenttype_groups] 587 selected_groups = [gname for (gname, contenttypes) in CONTENTTYPE_GROUPS]
589 588
590 ctypes = [[ctype for ctype, clabel in contenttypes] 589 ctypes = [[ctype for ctype, clabel in contenttypes]
591 for gname, contenttypes in nonexistent_item.contenttype_groups 590 for gname, contenttypes in CONTENTTYPE_GROUPS
592 if gname in selected_groups] 591 if gname in selected_groups]
593 592
594 ctypes_chain = itertools.chain(*ctypes) 593 ctypes_chain = itertools.chain(*ctypes)
595 selected_contenttypes = list(ctypes_chain) 594 selected_contenttypes = list(ctypes_chain)
596 595
629 initials = [(name[1][0]) 628 initials = [(name[1][0])
630 for name in names] 629 for name in names]
631 return initials 630 return initials
632 631
633 class NonExistent(Item): 632 class NonExistent(Item):
634 contenttype_groups = [
635 ('markup text items', [
636 ('text/x.moin.wiki;charset=utf-8', 'Wiki (MoinMoin)'),
637 ('text/x.moin.creole;charset=utf-8', 'Wiki (Creole)'),
638 ('text/x-mediawiki;charset=utf-8', 'Wiki (MediaWiki)'),
639 ('text/x-rst;charset=utf-8', 'ReST'),
640 ('application/docbook+xml;charset=utf-8', 'DocBook'),
641 ('text/html;charset=utf-8', 'HTML'),
642 ]),
643 ('other text items', [
644 ('text/plain;charset=utf-8', 'plain text'),
645 ('text/x-diff;charset=utf-8', 'diff/patch'),
646 ('text/x-python;charset=utf-8', 'python code'),
647 ('text/csv;charset=utf-8', 'csv'),
648 ('text/x-irclog;charset=utf-8', 'IRC log'),
649 ]),
650 ('image items', [
651 ('image/jpeg', 'JPEG'),
652 ('image/png', 'PNG'),
653 ('image/svg+xml', 'SVG'),
654 ]),
655 ('audio items', [
656 ('audio/wave', 'WAV'),
657 ('audio/ogg', 'OGG'),
658 ('audio/mpeg', 'MP3'),
659 ('audio/webm', 'WebM'),
660 ]),
661 ('video items', [
662 ('video/ogg', 'OGG'),
663 ('video/webm', 'WebM'),
664 ('video/mp4', 'MP4'),
665 ]),
666 ('drawing items', [
667 ('application/x-twikidraw', 'TDRAW'),
668 ('application/x-anywikidraw', 'ADRAW'),
669 ('application/x-svgdraw', 'SVGDRAW'),
670 ]),
671
672 ('other items', [
673 ('application/pdf', 'PDF'),
674 ('application/zip', 'ZIP'),
675 ('application/x-tar', 'TAR'),
676 ('application/x-gtar', 'TGZ'),
677 ('application/octet-stream', 'binary file'),
678 ]),
679 ]
680
681 def do_get(self, force_attachment=False): 633 def do_get(self, force_attachment=False):
682 abort(404) 634 abort(404)
683 635
684 def _convert(self): 636 def _convert(self):
685 abort(404) 637 abort(404)
686 638
687 def do_modify(self, contenttype, template_name): 639 def do_modify(self, contenttype, template_name):
688 # XXX think about and add item template support 640 # XXX think about and add item template support
689 return render_template('modify_show_type_selection.html', 641 return render_template('modify_show_type_selection.html',
690 item_name=self.name, 642 item_name=self.name,
691 contenttype_groups=self.contenttype_groups, 643 contenttype_groups=CONTENTTYPE_GROUPS,
692 ) 644 )
693 645
694 item_registry.register(NonExistent._factory, Type('application/x-nonexistent')) 646 item_registry.register(NonExistent._factory, Type('application/x-nonexistent'))
695 647
696 class ValidJSON(Validator): 648 class ValidJSON(Validator):