Changeset 12721 for main


Ignore:
Timestamp:
10 Mar 2015, 16:02:49 (10 years ago)
Author:
uli
Message:

Implement a general payable finder.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/payment.py

    r12700 r12721  
    3232    IPayment, STATE_UNPAID, STATE_FAILED, STATE_PAID,
    3333    IPaymentGatewayService, IPayer, IPaymentItem, IPayee,
    34     IPaymentGatewayServicesLister,
     34    IPaymentGatewayServicesLister, IPayableFinder,
    3535    )
    3636
     
    4343    cat = getUtility(ICatalog, name='payments_catalog')
    4444    result_set = [x for x in cat.searchResults(
    45         payment_id = (payment_id, payment_id))]
     45        payment_id=(payment_id, payment_id))]
    4646    if len(result_set):
    4747        return result_set[0]
     48    return None
     49
     50
     51def find_payable_from_payable_id(payable_id):
     52    """Find a payable from its id.
     53
     54    Looks up all registered IPayableFinders and returns the first
     55    positive result found.
     56    """
     57    for name, util in getUtilitiesFor(IPayableFinder):
     58        result = util.get_payable_by_id(payable_id)
     59        if result is not None:
     60            return result
    4861    return None
    4962
Note: See TracChangeset for help on using the changeset viewer.