summaryrefslogtreecommitdiff
path: root/Mailman/database/model
Commit message (Collapse)AuthorAgeFilesLines
* Reorganize the database subpackage, primarily by removing the 'model'Barry Warsaw2007-12-0813-1469/+0
| | | | | subdirectory and updating all relevant imports. Move of the circular import problems have been eliminated in the process.
* Complete the port to Storm, at least as far as the current Mailman test suiteBarry Warsaw2007-11-172-21/+35
| | | | | is concerned. This still requires a minor patch to Storm to handle timedelta types in SQLite.
* All the simple test fixes are now in, and while there are still some failingBarry Warsaw2007-11-104-29/+29
| | | | | | tests, we're making very good progress. Just the tough ones are left. This change did modify the the schema a bit, for better naming and typing. E.g. 'type' -> 'request_type' and using a RawStr for a hash type.
* More Unicodification; fixed several more doctests.Barry Warsaw2007-11-083-13/+30
|
* More Unicodification; fixed two more doctests.Barry Warsaw2007-11-082-7/+11
|
* Two more passing tests.Barry Warsaw2007-11-081-2/+2
|
* Fix two doctests: addresses.txt and mlist-addresses.txtBarry Warsaw2007-11-072-9/+18
| | | | | Remove flush() altogether. Yee-haw! Rework queries to be Stormy. Fix doctests to be Unicode-ish.
* Fix two doctests: ack-headers and acknowledgment.Barry Warsaw2007-11-065-14/+24
| | | | | | | | | | | | | | | | | | | This hacks around an apparent bug in the email package where if you parse a unicode message string, you still end up getting 8-bit strings out of the headers, and probably payloads. The hack is to override Mailman.Message.Message.__getitem__() to force the header value returned to a Unicode. It must be ASCII but this is required anyway by RFC 2822. It's not perfect, but it lets us get farther without forcing a detour into fixing the email package. Other changes: - Fix the Address table's references, and also update the subscribe() query. - Fix the Member table's references and add a __init__(). - Fix Roster's get_member() query. - Fix the Enum class's variable_class attribute. - UserManager.create_user() has to use Unicodes for real_name.
* Target Mailman onto the Storm <http://storm.canonical.com> Python ORM. ThisBarry Warsaw2007-11-0413-222/+439
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | enables a few interesting things: 1. It makes it easier to do our "pillars of storage" idea, where list data and messages could live in one database, but user information live in a separate database. 2. It reduces the number of moving parts. SQLAlchemy and Elixir can both go away in favor of just one database layer. 3. No more Unicode/string mush hell. Somewhere along the way the upgrade to SQLAlchemy 0.4 and Elixir 0.4 made the strings coming out the database sometimes Unicode and sometimes 8-bit. This was totally unpredictable. Storm asserts that if a property is declared Unicode, it comes in and goes out as Unicode. 4. 'flush' is gone. One cost of this is that Storm does not yet currently support schema generation. So I cheat by dumping the trunk's SQLite schema and using that as a starting place for the Storm-based schema. I hope that Storm will eventually address this. Other related changes include: - SQLALCHEMY_ENGINE_URL is renamed to DEFAULT_DATABASE_URL. This may still get changed. Things I still want to fix: - Ickyness with clearing the databases. - Really implement multiple stores with better management of the Store instances. - Fix all the circular import nasties.
* Kill of another now unnecessary append(), fixing the users.txt doctest.Barry Warsaw2007-10-311-1/+0
|
* Much progress, though not perfect, on migrating to SQLAlchemy 0.4 and ElixirBarry Warsaw2007-10-3112-223/+229
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 0.4. Lots of things changes, which broke lots of our code. There are still a couple of failures in the test suite that I don't understand. It seems that for pending.txt and requests.txt, sometimes strings come back from the database as 8-bit strings and other times as unicodes. It's impossible to make these tests work both separately and together. users.txt is also failing intermittently. Lots of different behavior between running the full test suite all together and running individual tests. Sigh. Note also that actually, Elixir 0.4.0 doesn't work for us. There's a bug in that version that prevented zope.interfaces and Elixir working together. Get the latest 0.4.0 from source to fix this. Other changes include: - Remove Mailman/lockfile.py. While I haven't totally eliminated locking, I have released the lockfile as a separate Python package called locknix, which Mailman 3.0 now depends on. - Renamed Mailman/interfaces/messagestore.py and added an IMessage interface. - bin/testall raises turns on SQLALCHEMY_ECHO when the verbosity is above 3 (that's three -v's because the default verbosity is 1). - add_domain() in config files now allows url_host to be optional. If not given, it defaults to email_host. - Added a non-public interface IDatabase._reset() used by the test suite to zap the database between doctests. Added an implementation in the model which just runs through all rows in all entities, deleting them. - [I]Pending renamed to [I]Pended - Don't allow Pendings.add() to infloop. - In the model's User impelementations, we don't need to append or remove the address when linking and unlinking. By setting the address.user attribute, SQLAlchemy appears to do the right thing, though I'm not 100% sure of that (see the above mentioned failures).
* Remove the action.py module, move this to Mailman/interfaces/__init__.py.Barry Warsaw2007-10-101-4/+6
| | | | | | Convert IMailingList.personalize to a enum. Change all non-obsolete occurances of GetListEmail() to posting_address.
* Reorganize the enums so that they live in the most appropriate interface. TheBarry Warsaw2007-10-091-2/+1
| | | | only constant left in Mailman.constants is now actually a constant.
* Changes to support the Approved/Approve header with the new userBarry Warsaw2007-10-061-2/+1
| | | | | | | | | | model. Specifically, where a mailing list used to have both a password and a moderator password, both of which could be used in the Approved header, now a mailing list has only a shared moderator password. This moderator password's only purpose in life is to allow for Approved header posting. test_handlers.py is now completely ported to doctests, so it's removed.
* Removed a bunch of files that are obsolete. The interfaces are all foldedBarry Warsaw2007-09-271-8/+2
| | | | | | | | | | | | | into the IMailingList interface. OTOH, MemberAdaptor.py is completely useless now (though not entirely eradicated), as is OldStyleMemberships.py. versions.py isn't necessary any longer either because we'll have to do database migrations (and conversions from MM2.1) completely differently. New command line script 'set_members' which is used to take a CSV file and syncing that to a list's membership. Added back the DeliveryStatus.unknown item because we'll need it when we migrate MM 2.1 databases.
* OMGW00T: After over a decade, the MailList mixin class is gone! Well,Barry Warsaw2007-09-212-6/+54
| | | | | | | | | | | | mostly. It's no longer needed by anything in the test suite, and therefore the list manager returns database MailingList objects directly. The wrapper cruft has been removed. To accomplish this, a couple of hacks were added to the Mailman.app package, which will get cleaned up over time. The MailList module itself (and its few remaining mixins) aren't yet removed from the tree because some of the code is still not tested, and I want to leave this code around until I've finished converting it.
* Get bin/add_members and bin/list_members to work again (for the mostBarry Warsaw2007-09-201-0/+5
| | | | | | part). Mostly this is just updating the code to use the new APIs, but there's also some other code clean up involved. There's still more to do for sure, but this is a start.
* InitTempVars() is completely eradicated. The only bit I think weBarry Warsaw2007-09-191-1/+5
| | | | | | | | | | | | | | | | | still need temporarily is the _gui component initialization, so this has been moved into MailList.__init__(). Fixed the __getattr__() super call to properly dispatch up. Removed the _memberadaptor instance variable initialization. The whole MemberAdaptor stuff is next on the chopping block. Essentially MailList locking is gone too now, although it's not yet completely eradicated. However, the __repr__() no longer states the lock status. The full_path property is now just an attribute on the underlying MailingList database object.
* SQLAlchemy >= 0.3.10 is required.Barry Warsaw2007-09-121-4/+4
|
* ListAdmin mostly gone, but not quite.Barry Warsaw2007-09-091-1/+21
| | | | | | | | | | | | | | | | Mailman/app/moderator.py: Most of the application level interface provided by ListAdmin is moved here now, including the ability to hold messages, subscriptions, and unsubscriptions, and to handle message (defer, discard, reject, accept). More work needed. Some untested conversion of API in Mailman/Cgi/admindb.py, confirm.py, bin/checkdbs.py. messagestore.py: Don't use or require the Date: header in the global message ID calculation. As described on the mailing list, we're only going to use the Message-ID header. IListRequests: added count_of() and of_type() methods.
* Interfaces IRequests and IListRequests which are substitutes for the ListAdminBarry Warsaw2007-08-073-0/+124
| | | | | | | | | | | | mixin. This latter will go away soon. Added implementation and tests. The implementation has some cruft though -- it forces us to use a flush() in the code because I don't yet know how to get to SA's last_inserted_ids(). Note that this implementation abuses the IPendings interface in order to store arbitrary string key/value pairs. Fix the auto-discovery of interfaces by allowing Enums in interface files as well. Long term, this is how it should work anyway.
* Fixed a problem where members of a deleted mailing list were hanging around.Barry Warsaw2007-08-053-2/+23
| | | | | | | | | | | | | | | | | | | | This would cause duplicate members (e.g. owners) if you created, deleted and then recreated the mailing list. Mailman.app.create -> Mailman.app.lifecycle; Mailman/doc/create.txt -> Mailman/doc/lifecycle.txt; also added a remove_list() function. Added SubscriptionError base class, made HostileSubscriptionError inherit from that, and added a new AlreadySubscribedError. Rewrote bin/rmlist to use the new lifecycle.remove_list() function. IAddress.subscribe() must now throw an AlreadySubscribedError if the address is already subscribed to the mailing list with the given role. Added a Subscribers roster, attached to the IMailingList which gives access to all subscribers of a mailing list, regardless of their role. Added a new test for this roster.
* It all started by trying to remove MailList.Create() and use the IListManagerBarry Warsaw2007-08-051-12/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | interface to create and delete lists. Mostly that's working now, but I need unit tests for most of the new work contained in this revision. Implemented a rudimentary 'list styles' subsystem, along with interfaces, but no tests yet. Moved all of MailList.InitVars() into a DefaultStyle, which is always available at priority zero. It's used by default if there are no matching styles for a mailing list. Because of the list styles, we can now get rid of (almost) all InitVars() methods. And because of /that/ we can get rid of the mixin clases whose sole purpose was to provide an InitVars() method. Yay for code removal! Mixin modules/classes removed: Autoresponder, GatewayManager, TopicManager. Removed the Mailman/ext crufty extension mechanism. Extensions will now be done using setuptools plugins. Hopefully this will take us everywhere we need to go, but I'll add Mailman.ext back if necessary later. Mailiman.app.create module added to implement a common, higher-level list creation feature. This is used by bin/newlist now, though some of that functionality (namely, ensuring the owners exist in the database, and notifying the owners) should be moved here. The MTA plugins aren't yet integrated into this, but need to be. Mailman.app.plugins module added to generalize setuptools plugin management. Defaults.DEFAULT_REPLY_GOES_TO_LIST now gets initialized with a proper enum. Also, the duplicate DeliveryMode and DeliveryStatus enums are removed from Defaults because they're in Mailman.constants. Added Errors.DuplicateStyleError. Updated Utils.list_exists() to use the new IListManager.get() interface, which has been changed to return None if the list doesn't exist (for consistency) instead of raising an exception. Utils.list_names() also needed to be fixed to use config.db.list_manager. bin/make_instance, bin/newlist, bin/rmlist changed to use parser.error() istead of printing to sys.stderr and sys.exit(1). bin/newlist and bin/rmlist now works with the IListManager interface, so you can create and delete lists from the command line again. The CLI for newlist has been much simplified; it no longer prompts for missing positional arguments. It now uses a more traditional CLI. newlist also accepts zero to many owners, and it ensures that the owners are all in the database. It no longer asks for a list password, because this doesn't make sense any more. bin/withlist has also been fixed to work with the IListManager interface. There are lots of XXXs and FIXMEs that need to be resolved before this can land. Also, we need to test all this stuff before it can land. Configuration.load() is now taught to search in sys.argv[0] for var/etc/mailman.cfg since this is where it is for egg development layouts. Also, VAR_DIR must be abspath'd. Added an __all__ to Mailman.constants, and added an Action enum. The listmanager implementation has to set the mlist.created_at time. There's also a bit of crufty refactoring going on to instantiate the roster objects whenever the list is created or retrieved from the database. Several MailingList column types are now set to our custom TimeDeltaType, which knows how to store a datetime.timedelta. A SQLAlchemny converter type is added to Mailman.database.types. I also fixed a bug in the EnumType implementation.
* Move the pending database into the SQLAlchemy/Elixir layer. The oldBarry Warsaw2007-08-013-3/+128
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pending.py module is removed. Added an interface to this functionality such that any IPendable (essentially a key/value mapping) can be associated with a token, and that token can be confirmed and has a lifetime. Any keys and values can be stored, as long as both are unicodes. Added a doctest. Modified initialization of the database layer to support pluggability via setuptools. No longer is this layer initialized from a module, but now it's instantiated from a class that implements IDatabase. The StockDatabase class implements the SQLAchemy/Elixir layer, but this can be overridden in a setup.py. Bye bye MANAGERS_INIT_FUNCTION, we hardly knew ye. Added a package Mailman.app which will contain certain application specific functionality. Right now, the only there there is an IRegistar implementation, which didn't seem to fit anywhere else. Speaking of which, the IRegistrar interface implements all the logic related to registration and verification of email addresses. Think the equivalent of MailList.AddMember() except generalized out of a mailing list context. This latter will eventually go away. The IRegistrar sends the confirmation email. Added an IDomain interface, though the only implementation of this so far lives in the registration.txt doctest. This defines the context necessary for domain-level things, like address confirmation. A bunch of other cleanups in modules that are necessary due to the refactoring of Pending, but don't affect anything that's actually tested yet, so I won't vouch for them (except that they don't throw errors on import!). Clean up Defaults.py; also turn the functions seconds(), minutes(), hours() and days() into their datetime.timedelta equivalents. Consolidated the bogus email address exceptions. In some places where appropriate, use email 4.0 module names instead of the older brand. Switch from Mailman.Utils.unique_message_id() to email.utils.make_msgid() everywhere. This is because we need to allow sending not in the context of a mailing list (i.e. domain-wide address confirmation message). So we can't use a Message-ID generator that requires a mailing list. OTOH, this breaks Message-ID collision detection in the mail->news gateway. I'll fix that eventually. Remove the 'verified' row on the Address table. Now verification is checked by Address.verified_on not being None.
* | The start of a message store definition. Whether this will end up being usedBarry Warsaw2007-07-222-0/+32
|/ | | | | | | | | | | | | | | | | | | | for the archive or not is left to be seen. Define an interface, test, and implementation of a basic message store using globally unique identifiers of the form: archive/hash/seqno - archive is the base url of the archive, e.g. http://archives.example.com. This is available in the List-Archive header. - hash is the base32 encoded sha1 hash of the message's Message-ID and Date headers, which it must have. This is available in the X-List-ID-Hash header. - seqno is a sequence number specific to the archive which will uniquely identify the message should there be a Message-ID/Date collision. this is available in the X-List-Sequence-Number header. Added a MESSAGES_DIR variable to the config. Added a .message_store attribute to the config.
* The start of a setuptools conversion. All the Makefile.in and autoconfBarry Warsaw2007-07-131-71/+0
| | | | artifacts are removed, as is the C files which we will no longer need.
* Conversion of the ToDigest tests to doctests, along with just enough handlerBarry Warsaw2007-07-101-1/+1
| | | | | | | | | module update to make the thing pass. Much more coverage is still necessary, but this at least recreates the existing tests. Changes to the test infrastructure to make REPORT_ONLY_FIRST_FAILURE conditional on lower (default) verbosity. Increase the verbosity via 'bin/testall -v' and you get all the failure output.
* Convert TestHold to a doctest and update code as necessary. No generalBarry Warsaw2007-07-031-0/+7
| | | | modernization of Hold.py was performed.
* Support for case-preserving addresses. When an Address is given an emailBarry Warsaw2007-07-011-3/+22
| | | | | | | | | | | | | | | | | | address that is not lower cased, the original, case-preserved version is store on the '_original' attribute. The lower-cased version is always used as the key and thus always stored on the 'address' attribute. The IAddress interface is given a new 'original_address' property which returns the case-preserved version. Address's __str__() and __repr__() are similarly modified. The former always includes the case-preserved address; the latter does too, but now also includes the lower-cased 'key' email address (along with the object's id). Searching for an address always does so on the lower-cased version. Test suite is updated as necessary. Also, I'm adding the REPORT_ONLY_FIRST_FAILURE doctest flag so that it's easier to debug doctest failures without having pages of problems to scroll through.
* Convert the CookHeaders tests in test_handlers to using doctests, split upBarry Warsaw2007-06-211-1/+2
| | | | | | | | | | | | | | | | | into several sub-documents. Defaults.py.in: Removed OLD_STYLE_PREFIXING. So-called 'new style' prefixing is the default and only option now. CookHeaders.py is updated to the new API and some (but not all) of the code has been updated to more modern Python idioms. reply_goes_to_list attribute has been changed from a strict integer to a munepy enum called ReplyToMunging. RFC 2369 headers List-Subscribe and List-Unsubscribe now use the preferred -join and -leave addresses instead of the -request address with a subject value.
* Convert the tests for the CalcRecips handler to doc tests. There areBarry Warsaw2007-06-192-7/+20
| | | | | | | | | | | | | | | | | some XXX's in the doc test because digest recipients aren't tested (though those may go in a different doctest), and neither are urgent messages. This latter is for the same reason that the Approved handler is not yet tested; which password do you use in that header? The CalcRecips tests would also seem the natural place to test the receive_list_copy preference, but that actually gets processed in the AvoidDuplicates handler, so it isn't tested here. Add delivery_status (of type enum DeliveryStatus) to preferences. I'm not entirely sure that's the right place for it, but it lets me finish converting the test for now. Expose the rest of the preferences through the IMember interface.
* Convert the AfterDelivery handler test to a doctest. Also, change theBarry Warsaw2007-06-181-1/+1
| | | | | MailingList.last_post_time column to a DateTime (i.e. Python datetime object).
* Remove both the model and interface for RosterSets. These are no longer usedBarry Warsaw2007-06-184-91/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | or necessary in the current data model. Convert the test_handlers.py Python test to an acknowledge.txt doctest, and make the Acknowledge.py handler work with the new data model. There are a few XXX comments left in here due to the fact that the web stuff is a total hack in the current branch currently. Added IMailingListWeb methods and properties to the MailingList model class: web_host and script_url(). Work out how IMembers will expose the lookup-order based preferences. By getting the attribute IMember.preferences you can see exactly the preferences overridden by this member. To use the lookup order, use IMember.delivery_mode, IMember.acknowledge_posts, etc. IOW, the IMember interface now provides the properties directly and access through this mechanism supports lookup order with definitive preference values. Also added IMember.unsubscribe() which does the obvious, and IMember.options_url() which is a total hack for providing a url (but not the ultimately right one) for the user's option page. Refactor the model's roster classes. Also added IRoster.get_member() method with efficient queries to return the right results. Make AdministratorRoster.members more efficient due to a better query. Update the membership.txt doctest to eliminate a chance ordering effect, and also to test finding members with .get_member(). The clean up section uses the new .unsubscribe() method.
* profile.py -> preferences.pyBarry Warsaw2007-06-155-4/+5
| | | | | Fix the last few doctests by ensuring that other newly created Addresses have a preferences object.
* Update the IUser interface and tests, specifically as it relates toBarry Warsaw2007-06-156-33/+34
| | | | | | | | | | | | | | | | | | | | preferences. IAddresses, IUsers, and IMembers all get preferences by default, althoughthe attributes of these preferences are None by default. IMailingLists don't get preferences by default though; because these live in the user database, we can't cross-polinate them in the mailing lists. We'll figure something out later for these. IUser.register(): Add this method which registers and links an address to the user. Allow EnumType database columns to accept and return Nones. This is useful for when the columns are not defined NOT NULL. Update doctests. Removed teh hide_address preference. I can't think of a reason not to want to hide addresses for everyone.
* More test updates based on simplified data model. Rosters are gone so theBarry Warsaw2007-06-103-2/+6
| | | | | | | | | | | | | | | | | | | | mlist-rosters.txt tests are removed. Give MailingList entities a Preferences foreign key, so that they now have preferences. Member.preferences(): Watch out for unlinked addresses, i.e. which have no user and thus no user preferences. Address.controls() takes a text email address, not an IAddress. UserManager: add create_address(), delete_address(), get_address(), and 'addresses' property. Updated the address.txt and user.txt doctests as needed. Added User.register() to register an email address and immediately link it to a user.
* Repair the usermanager.txt and listmanager.txt doc tests. These repairs wereBarry Warsaw2007-06-091-1/+6
| | | | | | | | | | | | | necessary to deal with the simplified user model. Eradicate more references to rosters and roster sets. Give Users a repr. Also give them a belongs_to() link to Preferences, but change the user manager to not give a user preferences by default (the lookup schema should properly handle users with no preferences now). Also, when creating a user, set their real_name to the empty string if no real_name argument was given to create_user(). Update the IUserManager interface's create_user() method to match the implementation.
* Implement the new, simplified membership model. Rosters and RosterSets asBarry Warsaw2007-06-099-164/+277
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | they were previously known are now gone. Rosters, rather than being a database entity that collects users, is now just a filter on the member database. This way, we can use generic rosters to search for regular members, digest members, owners, or moderators. More advanced rosters can do all kinds of other membership queries. But rosters no longer need to be a database entity. Users have a name, password, optional preferences, and a set of addresses, but users are not subscribed to mailing lists. Addresses have the email address, some verification information, and optional preferences. Members tie an address to a mailing list, through a role, with optional preferences. Other changes here include: MailList.fqdn_listname() moved to the MailingList model entity. Added MemberRole enum and SystemDefaultPreferences to Mailman.constants. Profiles are renamed to Preferences (same with the interface), but the files are not yet moved. This happens later. We mostly don't need has_*() relationships on the entity classes, because we generally don't need the reverse relationship. Use belongs_to() because that creates the foreign key, even though the wording seems counter intuitive. IAddress.subscribe() added. Tell Elixir to use shortnames for all tables. Remove the OldStyleMembership fields from MailingList. Remove all the interface elements and database fields that talk about rosters and rostersets. Convert Version entity to has_field().
* Merge exp-elixir-branch to trunk. There is enough working to make me feelbwarsaw2007-05-2810-0/+723
confident the Elixir branch is ready to become mainline. Also, fewer branches makes for an easier migration to a dvcs. Don't expect much of the old test suite to work, or even for much of the old functionality to work. The changes here are disruptive enough to break higher level parts of Mailman. But that's okay because I am slowly building up a new and improved test suite, which will lead to a functional system again. For now, only the doctests in Mailman/docs (and their related test harnesses) will pass, but they all do pass. Note that Mailman/docs serve as system documentation first and unit tests second. You should be able to read the doctest files to understand the underlying data model. Other changes included in this merge: - Added the Mailman.ext extension package. - zope.interfaces uses to describe major components - SQLAlchemy/Elixir used as the database model - Top level doinstall target renamed to justinstall - 3rd-party packages are now installed in pythonlib/lib/python to be more compliant with distutils standards. This allows us to use just --home instead of all the --install-* options. - No longer need to include the email package or pysqlite, as Python 2.5 is required (and comes with both packages). - munepy package is included, for Python enums - IRosterSets are added as a way to manage a collection of IRosters. Roster sets are named so that we can maintain the indirection between mailing lists and rosters, where the two are maintained in different storages. - IMailingListRosters: remove_*_roster() -> delete_*_roster() - Remove IMember interface. - Utils.list_names() -> config.list_manager.names - fqdn_listname() takes an optional hostname argument. - Added a bunch of new exceptions used throughout the new interfaces. - Make LockFile a context manager for use with the 'with' statement.