Thanks Davis, On Sat, Apr 10, 2010 at 9:28 AM, davis <[email protected]> wrote: > Hi Darryl, > > I don't know how others are doing it, but I use a listener for the > payment_methods_query signal to conditionally reduce payment choices > like this: > > def adjust_payment_choices(sender, contact, methods, **kwargs): > if should_reduce: # whatever your condition is > for method in methods: > if method[0] == 'PAYMENT_PMTKEY': > methods.remove(method) > > It would be nice if methods were a dict rather than a list of tuples.
You can make a dict out of a list of tuple pairs: dict(methods) Best, Darryl > > On Apr 8, 8:34 pm, Darryl Cousins <[email protected]> wrote: >> Hi, >> >> Thanks to the Satchmo team for a fine application. >> >> I want to edit the payment_choices list using the >> payment_methods_query signal. I've set up a listener which is getting >> called ok. But simply changing the 'methods' list does not make any >> effect. >> >> The comment in PaymentMethodForm says that our listener can modify the >> methods list if necessary however modifying it from the listener does >> not change the payment_choices list. I don't think that it would be >> possible to alter the list from the listener? >> >> # Send a signal to perform additional filtering of available >> payment methods. >> # Receivers have cart/order passed in variables to check the >> contents and modify methods >> # list if neccessary. >> payment_choices = labelled_gateway_choices() >> print 'SATCHMO 1', payment_choices >> signals.payment_methods_query.send( >> PaymentMethodForm, >> methods=payment_choices, >> cart=cart, >> order=order, >> contact=self._contact >> ) >> print 'SATCHMO 2', payment_choices # same as above >> >> My listener: >> >> def virtual_payment_options(sender, signal=None, contact=None, >> cart=None, order=None, >> methods=[]): >> # change the methods list here >> print methods # changed >> >> However, I've managed to achieve the desired result using the >> `form_init` listener of PaymentContactInfoForm. >> >> Thanks, >> Darryl > > -- > You received this message because you are subscribed to the Google Groups > "Satchmo users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/satchmo-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Satchmo users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/satchmo-users?hl=en.
