# HG changeset patch # User Paul Boddie # Date 1276122861 -7200 # Node ID 407f7373d8ea89098d43fd29c527d72b5a646075 # Parent 318a5cc8ddd14b49bcd874659a1b3838949cbfb8 Introduced convenience functionality in order to work around API breakage introduced in MoinMoin 1.9.x. diff -r 318a5cc8ddd1 -r 407f7373d8ea EventAggregatorSupport.py --- a/EventAggregatorSupport.py Wed Jun 02 22:27:43 2010 +0200 +++ b/EventAggregatorSupport.py Thu Jun 10 00:34:21 2010 +0200 @@ -26,7 +26,7 @@ except ImportError: pytz = None -__version__ = "0.6" +__version__ = "0.7" # Date labels. @@ -97,6 +97,49 @@ else: return int(x) +# Utility classes and associated functions. + +Undefined = object() + +class Form: + + """ + A wrapper preserving MoinMoin 1.8.x (and earlier) behaviour in a 1.9.x + environment. + """ + + def __init__(self, form): + self.form = form + + def get(self, name, default=Undefined): + values = self.form.getlist(name) + if not values: + if default is Undefined: + return [] + else: + return default + else: + return values + + def __getitem__(self, name): + return self.form.getlist(name) + +class ActionSupport: + + "Work around disruptive MoinMoin changes in 1.9." + + def get_form(self): + return get_form(self.request) + +def get_form(request): + + "Work around disruptive MoinMoin changes in 1.9." + + if hasattr(request, "values"): + return Form(request.values) + else: + return request.form + # Textual representations. def getHTTPTimeString(tmtuple): diff -r 318a5cc8ddd1 -r 407f7373d8ea PKG-INFO --- a/PKG-INFO Wed Jun 02 22:27:43 2010 +0200 +++ b/PKG-INFO Thu Jun 10 00:34:21 2010 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: EventAggregator -Version: 0.6 +Version: 0.7 Author: Paul Boddie Author-email: paul at boddie org uk Maintainer: Paul Boddie diff -r 318a5cc8ddd1 -r 407f7373d8ea README.txt --- a/README.txt Wed Jun 02 22:27:43 2010 +0200 +++ b/README.txt Thu Jun 10 00:34:21 2010 +0200 @@ -224,6 +224,15 @@ time zone information for the correct interpretation of time information in those summaries. Thus, it is highly recommended that pytz be installed. +New in EventAggregator 0.7 (Changes since EventAggregator 0.6) +-------------------------------------------------------------- + + * Fixed form handling to be compatible with MoinMoin 1.9.x, since that + particular release series introduced an incompatible request API that + breaks existing code (no longer providing access to query string + parameters via the form attribute, and only returning single values + unless the new getlist method on form-like objects is used). + New in EventAggregator 0.6 (Changes since EventAggregator 0.5) -------------------------------------------------------------- diff -r 318a5cc8ddd1 -r 407f7373d8ea actions/EventAggregatorNewEvent.py --- a/actions/EventAggregatorNewEvent.py Wed Jun 02 22:27:43 2010 +0200 +++ b/actions/EventAggregatorNewEvent.py Thu Jun 10 00:34:21 2010 +0200 @@ -24,7 +24,7 @@ # Action class and supporting functions. -class EventAggregatorNewEvent(ActionBase): +class EventAggregatorNewEvent(ActionBase, EventAggregatorSupport.ActionSupport): "An event creation dialogue requesting various parameters." @@ -44,7 +44,7 @@ def get_form_html(self, buttons_html): _ = self._ request = self.request - form = request.form + form = self.get_form() # Handle advanced and basic forms, and enable/disable certain fields. @@ -465,7 +465,7 @@ "Create the new event." _ = self._ - form = self.request.form + form = self.get_form() # If no title exists in the request, an error message is returned. @@ -495,7 +495,7 @@ "Create an event page using the 'request'." _ = request.getText - form = request.form + form = self.get_form() category_pagenames = form.get("category", []) description = form.get("description", [None])[0] diff -r 318a5cc8ddd1 -r 407f7373d8ea actions/EventAggregatorSummary.py --- a/actions/EventAggregatorSummary.py Wed Jun 02 22:27:43 2010 +0200 +++ b/actions/EventAggregatorSummary.py Thu Jun 10 00:34:21 2010 +0200 @@ -22,14 +22,14 @@ # Action class and supporting functions. -class EventAggregatorSummary(ActionBase): +class EventAggregatorSummary(ActionBase, EventAggregatorSupport.ActionSupport): "A summary dialogue requesting various parameters." def get_form_html(self, buttons_html): _ = self._ request = self.request - form = request.form + form = self.get_form() category_list = [] @@ -138,7 +138,7 @@ "Write the iCalendar resource." _ = self._ - form = self.request.form + form = self.get_form() # If no category names exist in the request, an error message is # returned. @@ -176,7 +176,7 @@ can be specified. """ - form = request.form + form = EventAggregatorSupport.get_form(request) category_names = form.get("category", []) format = form.get("format", ["iCalendar"])[0] diff -r 318a5cc8ddd1 -r 407f7373d8ea setup.py --- a/setup.py Wed Jun 02 22:27:43 2010 +0200 +++ b/setup.py Thu Jun 10 00:34:21 2010 +0200 @@ -8,6 +8,6 @@ author = "Paul Boddie", author_email = "paul@boddie.org.uk", url = "http://moinmo.in/MacroMarket/EventAggregator", - version = "0.6", + version = "0.7", py_modules = ["EventAggregatorSupport", "MoinMoin.script.import.eventfeed"] )