comparison roundup/hyperdb.py @ 1085:04a6b3bfbf23

instance_config -> config, and other related cleanups
author Richard Jones <richard@users.sourceforge.net>
date Mon, 09 Sep 2002 23:55:29 +0000
parents 07f88a837450
children 8dd4f736370b
comparison
equal deleted inserted replaced
1084:a625adcd6254 1085:04a6b3bfbf23
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: hyperdb.py,v 1.81 2002-08-30 08:37:16 richard Exp $ 18 # $Id: hyperdb.py,v 1.82 2002-09-09 23:55:19 richard Exp $
19 19
20 __doc__ = """ 20 __doc__ = """
21 Hyperdatabase implementation, especially field types. 21 Hyperdatabase implementation, especially field types.
22 """ 22 """
23 23
605 cl = Class(db, name, name=String(), order=String()) 605 cl = Class(db, name, name=String(), order=String())
606 for i in range(len(options)): 606 for i in range(len(options)):
607 cl.create(name=options[i], order=i) 607 cl.create(name=options[i], order=i)
608 return hyperdb.Link(name) 608 return hyperdb.Link(name)
609 609
610 #
611 # $Log: not supported by cvs2svn $
612 # Revision 1.80 2002/08/16 04:28:13 richard
613 # added is_retired query to Class
614 #
615 # Revision 1.79 2002/07/29 23:30:14 richard
616 # documentation reorg post-new-security
617 #
618 # Revision 1.78 2002/07/21 03:26:37 richard
619 # Gordon, does this help?
620 #
621 # Revision 1.77 2002/07/18 11:27:47 richard
622 # ws
623 #
624 # Revision 1.76 2002/07/18 11:17:30 gmcm
625 # Add Number and Boolean types to hyperdb.
626 # Add conversion cases to web, mail & admin interfaces.
627 # Add storage/serialization cases to back_anydbm & back_metakit.
628 #
629 # Revision 1.75 2002/07/14 02:05:53 richard
630 # . all storage-specific code (ie. backend) is now implemented by the backends
631 #
632 # Revision 1.74 2002/07/10 00:24:10 richard
633 # braino
634 #
635 # Revision 1.73 2002/07/10 00:19:48 richard
636 # Added explicit closing of backend database handles.
637 #
638 # Revision 1.72 2002/07/09 21:53:38 gmcm
639 # Optimize Class.find so that the propspec can contain a set of ids to match.
640 # This is used by indexer.search so it can do just one find for all the index matches.
641 # This was already confusing code, but for common terms (lots of index matches),
642 # it is enormously faster.
643 #
644 # Revision 1.71 2002/07/09 03:02:52 richard
645 # More indexer work:
646 # - all String properties may now be indexed too. Currently there's a bit of
647 # "issue" specific code in the actual searching which needs to be
648 # addressed. In a nutshell:
649 # + pass 'indexme="yes"' as a String() property initialisation arg, eg:
650 # file = FileClass(db, "file", name=String(), type=String(),
651 # comment=String(indexme="yes"))
652 # + the comment will then be indexed and be searchable, with the results
653 # related back to the issue that the file is linked to
654 # - as a result of this work, the FileClass has a default MIME type that may
655 # be overridden in a subclass, or by the use of a "type" property as is
656 # done in the default templates.
657 # - the regeneration of the indexes (if necessary) is done once the schema is
658 # set up in the dbinit.
659 #
660 # Revision 1.70 2002/06/27 12:06:20 gmcm
661 # Improve an error message.
662 #
663 # Revision 1.69 2002/06/17 23:15:29 richard
664 # Can debug to stdout now
665 #
666 # Revision 1.68 2002/06/11 06:52:03 richard
667 # . #564271 ] find() and new properties
668 #
669 # Revision 1.67 2002/06/11 05:02:37 richard
670 # . #565979 ] code error in hyperdb.Class.find
671 #
672 # Revision 1.66 2002/05/25 07:16:24 rochecompaan
673 # Merged search_indexing-branch with HEAD
674 #
675 # Revision 1.65 2002/05/22 04:12:05 richard
676 # . applied patch #558876 ] cgi client customization
677 # ... with significant additions and modifications ;)
678 # - extended handling of ML assignedto to all places it's handled
679 # - added more NotFound info
680 #
681 # Revision 1.64 2002/05/15 06:21:21 richard
682 # . node caching now works, and gives a small boost in performance
683 #
684 # As a part of this, I cleaned up the DEBUG output and implemented TRACE
685 # output (HYPERDBTRACE='file to trace to') with checkpoints at the start of
686 # CGI requests. Run roundup with python -O to skip all the DEBUG/TRACE stuff
687 # (using if __debug__ which is compiled out with -O)
688 #
689 # Revision 1.63 2002/04/15 23:25:15 richard
690 # . node ids are now generated from a lockable store - no more race conditions
691 #
692 # We're using the portalocker code by Jonathan Feinberg that was contributed
693 # to the ASPN Python cookbook. This gives us locking across Unix and Windows.
694 #
695 # Revision 1.62 2002/04/03 07:05:50 richard
696 # d'oh! killed retirement of nodes :(
697 # all better now...
698 #
699 # Revision 1.61 2002/04/03 06:11:51 richard
700 # Fix for old databases that contain properties that don't exist any more.
701 #
702 # Revision 1.60 2002/04/03 05:54:31 richard
703 # Fixed serialisation problem by moving the serialisation step out of the
704 # hyperdb.Class (get, set) into the hyperdb.Database.
705 #
706 # Also fixed htmltemplate after the showid changes I made yesterday.
707 #
708 # Unit tests for all of the above written.
709 #
710 # Revision 1.59.2.2 2002/04/20 13:23:33 rochecompaan
711 # We now have a separate search page for nodes. Search links for
712 # different classes can be customized in instance_config similar to
713 # index links.
714 #
715 # Revision 1.59.2.1 2002/04/19 19:54:42 rochecompaan
716 # cgi_client.py
717 # removed search link for the time being
718 # moved rendering of matches to htmltemplate
719 # hyperdb.py
720 # filtering of nodes on full text search incorporated in filter method
721 # roundupdb.py
722 # added paramater to call of filter method
723 # roundup_indexer.py
724 # added search method to RoundupIndexer class
725 #
726 # Revision 1.59 2002/03/12 22:52:26 richard
727 # more pychecker warnings removed
728 #
729 # Revision 1.58 2002/02/27 03:23:16 richard
730 # Ran it through pychecker, made fixes
731 #
732 # Revision 1.57 2002/02/20 05:23:24 richard
733 # Didn't accomodate new values for new properties
734 #
735 # Revision 1.56 2002/02/20 05:05:28 richard
736 # . Added simple editing for classes that don't define a templated interface.
737 # - access using the admin "class list" interface
738 # - limited to admin-only
739 # - requires the csv module from object-craft (url given if it's missing)
740 #
741 # Revision 1.55 2002/02/15 07:27:12 richard
742 # Oops, precedences around the way w0rng.
743 #
744 # Revision 1.54 2002/02/15 07:08:44 richard
745 # . Alternate email addresses are now available for users. See the MIGRATION
746 # file for info on how to activate the feature.
747 #
748 # Revision 1.53 2002/01/22 07:21:13 richard
749 # . fixed back_bsddb so it passed the journal tests
750 #
751 # ... it didn't seem happy using the back_anydbm _open method, which is odd.
752 # Yet another occurrance of whichdb not being able to recognise older bsddb
753 # databases. Yadda yadda. Made the HYPERDBDEBUG stuff more sane in the
754 # process.
755 #
756 # Revision 1.52 2002/01/21 16:33:19 rochecompaan
757 # You can now use the roundup-admin tool to pack the database
758 #
759 # Revision 1.51 2002/01/21 03:01:29 richard
760 # brief docco on the do_journal argument
761 #
762 # Revision 1.50 2002/01/19 13:16:04 rochecompaan
763 # Journal entries for link and multilink properties can now be switched on
764 # or off.
765 #
766 # Revision 1.49 2002/01/16 07:02:57 richard
767 # . lots of date/interval related changes:
768 # - more relaxed date format for input
769 #
770 # Revision 1.48 2002/01/14 06:32:34 richard
771 # . #502951 ] adding new properties to old database
772 #
773 # Revision 1.47 2002/01/14 02:20:15 richard
774 # . changed all config accesses so they access either the instance or the
775 # config attriubute on the db. This means that all config is obtained from
776 # instance_config instead of the mish-mash of classes. This will make
777 # switching to a ConfigParser setup easier too, I hope.
778 #
779 # At a minimum, this makes migration a _little_ easier (a lot easier in the
780 # 0.5.0 switch, I hope!)
781 #
782 # Revision 1.46 2002/01/07 10:42:23 richard
783 # oops
784 #
785 # Revision 1.45 2002/01/02 04:18:17 richard
786 # hyperdb docstrings
787 #
788 # Revision 1.44 2002/01/02 02:31:38 richard
789 # Sorry for the huge checkin message - I was only intending to implement #496356
790 # but I found a number of places where things had been broken by transactions:
791 # . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
792 # for _all_ roundup-generated smtp messages to be sent to.
793 # . the transaction cache had broken the roundupdb.Class set() reactors
794 # . newly-created author users in the mailgw weren't being committed to the db
795 #
796 # Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
797 # on when I found that stuff :):
798 # . #496356 ] Use threading in messages
799 # . detectors were being registered multiple times
800 # . added tests for mailgw
801 # . much better attaching of erroneous messages in the mail gateway
802 #
803 # Revision 1.43 2001/12/20 06:13:24 rochecompaan
804 # Bugs fixed:
805 # . Exception handling in hyperdb for strings-that-look-like numbers got
806 # lost somewhere
807 # . Internet Explorer submits full path for filename - we now strip away
808 # the path
809 # Features added:
810 # . Link and multilink properties are now displayed sorted in the cgi
811 # interface
812 #
813 # Revision 1.42 2001/12/16 10:53:37 richard
814 # take a copy of the node dict so that the subsequent set
815 # operation doesn't modify the oldvalues structure
816 #
817 # Revision 1.41 2001/12/15 23:47:47 richard
818 # Cleaned up some bare except statements
819 #
820 # Revision 1.40 2001/12/14 23:42:57 richard
821 # yuck, a gdbm instance tests false :(
822 # I've left the debugging code in - it should be removed one day if we're ever
823 # _really_ anal about performace :)
824 #
825 # Revision 1.39 2001/12/02 05:06:16 richard
826 # . We now use weakrefs in the Classes to keep the database reference, so
827 # the close() method on the database is no longer needed.
828 # I bumped the minimum python requirement up to 2.1 accordingly.
829 # . #487480 ] roundup-server
830 # . #487476 ] INSTALL.txt
831 #
832 # I also cleaned up the change message / post-edit stuff in the cgi client.
833 # There's now a clearly marked "TODO: append the change note" where I believe
834 # the change note should be added there. The "changes" list will obviously
835 # have to be modified to be a dict of the changes, or somesuch.
836 #
837 # More testing needed.
838 #
839 # Revision 1.38 2001/12/01 07:17:50 richard
840 # . We now have basic transaction support! Information is only written to
841 # the database when the commit() method is called. Only the anydbm
842 # backend is modified in this way - neither of the bsddb backends have been.
843 # The mail, admin and cgi interfaces all use commit (except the admin tool
844 # doesn't have a commit command, so interactive users can't commit...)
845 # . Fixed login/registration forwarding the user to the right page (or not,
846 # on a failure)
847 #
848 # Revision 1.37 2001/11/28 21:55:35 richard
849 # . login_action and newuser_action return values were being ignored
850 # . Woohoo! Found that bloody re-login bug that was killing the mail
851 # gateway.
852 # (also a minor cleanup in hyperdb)
853 #
854 # Revision 1.36 2001/11/27 03:16:09 richard
855 # Another place that wasn't handling missing properties.
856 #
857 # Revision 1.35 2001/11/22 15:46:42 jhermann
858 # Added module docstrings to all modules.
859 #
860 # Revision 1.34 2001/11/21 04:04:43 richard
861 # *sigh* more missing value handling
862 #
863 # Revision 1.33 2001/11/21 03:40:54 richard
864 # more new property handling
865 #
866 # Revision 1.32 2001/11/21 03:11:28 richard
867 # Better handling of new properties.
868 #
869 # Revision 1.31 2001/11/12 22:01:06 richard
870 # Fixed issues with nosy reaction and author copies.
871 #
872 # Revision 1.30 2001/11/09 10:11:08 richard
873 # . roundup-admin now handles all hyperdb exceptions
874 #
875 # Revision 1.29 2001/10/27 00:17:41 richard
876 # Made Class.stringFind() do caseless matching.
877 #
878 # Revision 1.28 2001/10/21 04:44:50 richard
879 # bug #473124: UI inconsistency with Link fields.
880 # This also prompted me to fix a fairly long-standing usability issue -
881 # that of being able to turn off certain filters.
882 #
883 # Revision 1.27 2001/10/20 23:44:27 richard
884 # Hyperdatabase sorts strings-that-look-like-numbers as numbers now.
885 #
886 # Revision 1.26 2001/10/16 03:48:01 richard
887 # admin tool now complains if a "find" is attempted with a non-link property.
888 #
889 # Revision 1.25 2001/10/11 00:17:51 richard
890 # Reverted a change in hyperdb so the default value for missing property
891 # values in a create() is None and not '' (the empty string.) This obviously
892 # breaks CSV import/export - the string 'None' will be created in an
893 # export/import operation.
894 #
895 # Revision 1.24 2001/10/10 03:54:57 richard
896 # Added database importing and exporting through CSV files.
897 # Uses the csv module from object-craft for exporting if it's available.
898 # Requires the csv module for importing.
899 #
900 # Revision 1.23 2001/10/09 23:58:10 richard
901 # Moved the data stringification up into the hyperdb.Class class' get, set
902 # and create methods. This means that the data is also stringified for the
903 # journal call, and removes duplication of code from the backends. The
904 # backend code now only sees strings.
905 #
906 # Revision 1.22 2001/10/09 07:25:59 richard
907 # Added the Password property type. See "pydoc roundup.password" for
908 # implementation details. Have updated some of the documentation too.
909 #
910 # Revision 1.21 2001/10/05 02:23:24 richard
911 # . roundup-admin create now prompts for property info if none is supplied
912 # on the command-line.
913 # . hyperdb Class getprops() method may now return only the mutable
914 # properties.
915 # . Login now uses cookies, which makes it a whole lot more flexible. We can
916 # now support anonymous user access (read-only, unless there's an
917 # "anonymous" user, in which case write access is permitted). Login
918 # handling has been moved into cgi_client.Client.main()
919 # . The "extended" schema is now the default in roundup init.
920 # . The schemas have had their page headings modified to cope with the new
921 # login handling. Existing installations should copy the interfaces.py
922 # file from the roundup lib directory to their instance home.
923 # . Incorrectly had a Bizar Software copyright on the cgitb.py module from
924 # Ping - has been removed.
925 # . Fixed a whole bunch of places in the CGI interface where we should have
926 # been returning Not Found instead of throwing an exception.
927 # . Fixed a deviation from the spec: trying to modify the 'id' property of
928 # an item now throws an exception.
929 #
930 # Revision 1.20 2001/10/04 02:12:42 richard
931 # Added nicer command-line item adding: passing no arguments will enter an
932 # interactive more which asks for each property in turn. While I was at it, I
933 # fixed an implementation problem WRT the spec - I wasn't raising a
934 # ValueError if the key property was missing from a create(). Also added a
935 # protected=boolean argument to getprops() so we can list only the mutable
936 # properties (defaults to yes, which lists the immutables).
937 #
938 # Revision 1.19 2001/08/29 04:47:18 richard
939 # Fixed CGI client change messages so they actually include the properties
940 # changed (again).
941 #
942 # Revision 1.18 2001/08/16 07:34:59 richard
943 # better CGI text searching - but hidden filter fields are disappearing...
944 #
945 # Revision 1.17 2001/08/16 06:59:58 richard
946 # all searches use re now - and they're all case insensitive
947 #
948 # Revision 1.16 2001/08/15 23:43:18 richard
949 # Fixed some isFooTypes that I missed.
950 # Refactored some code in the CGI code.
951 #
952 # Revision 1.15 2001/08/12 06:32:36 richard
953 # using isinstance(blah, Foo) now instead of isFooType
954 #
955 # Revision 1.14 2001/08/07 00:24:42 richard
956 # stupid typo
957 #
958 # Revision 1.13 2001/08/07 00:15:51 richard
959 # Added the copyright/license notice to (nearly) all files at request of
960 # Bizar Software.
961 #
962 # Revision 1.12 2001/08/02 06:38:17 richard
963 # Roundupdb now appends "mailing list" information to its messages which
964 # include the e-mail address and web interface address. Templates may
965 # override this in their db classes to include specific information (support
966 # instructions, etc).
967 #
968 # Revision 1.11 2001/08/01 04:24:21 richard
969 # mailgw was assuming certain properties existed on the issues being created.
970 #
971 # Revision 1.10 2001/07/30 02:38:31 richard
972 # get() now has a default arg - for migration only.
973 #
974 # Revision 1.9 2001/07/29 09:28:23 richard
975 # Fixed sorting by clicking on column headings.
976 #
977 # Revision 1.8 2001/07/29 08:27:40 richard
978 # Fixed handling of passed-in values in form elements (ie. during a
979 # drill-down)
980 #
981 # Revision 1.7 2001/07/29 07:01:39 richard
982 # Added vim command to all source so that we don't get no steenkin' tabs :)
983 #
984 # Revision 1.6 2001/07/29 05:36:14 richard
985 # Cleanup of the link label generation.
986 #
987 # Revision 1.5 2001/07/29 04:05:37 richard
988 # Added the fabricated property "id".
989 #
990 # Revision 1.4 2001/07/27 06:25:35 richard
991 # Fixed some of the exceptions so they're the right type.
992 # Removed the str()-ification of node ids so we don't mask oopsy errors any
993 # more.
994 #
995 # Revision 1.3 2001/07/27 05:17:14 richard
996 # just some comments
997 #
998 # Revision 1.2 2001/07/22 12:09:32 richard
999 # Final commit of Grande Splite
1000 #
1001 # Revision 1.1 2001/07/22 11:58:35 richard
1002 # More Grande Splite
1003 #
1004 #
1005 # vim: set filetype=python ts=4 sw=4 et si 610 # vim: set filetype=python ts=4 sw=4 et si

Roundup Issue Tracker: http://roundup-tracker.org/