Beispiel #1
0
def SearchWishListByEmail(repView, emailAddr=None, countryCode=None):
    """
    Retrieves an amazon wishlist by email address and creates an
    AmazonCollection containing AmazonItem's for each product in
    the wishlist (only retrieves first 10 products found). If an
    AmazonCollection already exists for the search criteria the
    method creates AmazonItem's for new products and adds them to
    the existing collection.

    The method can be used programatically or via user input. If no
    emailAddr and countryCode variables are passed in, an Amazon
    WishList By Email dialog is displayed for the user to input the
    emailAddr and countryCode.

    The method contacts the Amazon site specified by the countryCode
    and retrieves the products for the wishlist.

    @type repView: A Repository.view
    @param repView: The repository view in which to create the AmazonItems'
                    and AmazonCollection

    @type emailAddr: unicode
    @param emailAddr: The email address for the user wishlist

    @type countryCode: unicode
    @param countryCode: The countryCode of the amazon site to contact.
                        If the value is None a dialog is displayed for
                        the user to enter the information.

    @rtype: AmazonCollection or None
    @return: An AmazonCollection containing AmazonItem's for each product or
             None if no products found or an error occurs.
    """

    if emailAddr is None or countryCode is None:
        emailAddr, countryCode = AmazonDialog.promptEmail()

    if _isEmpty(emailAddr):
        return None

    while True:
        try:
            customerName, bags = \
                amazon.searchWishListByEmail(emailAddr, locale=countryCode)
            return _AddToCollection(repView, customerName, countryCode, bags) 
        except amazon.NoLicenseKey:
            if AmazonDialog.promptLicense():
                continue
            return None
        except (amazon.AmazonError, AttributeError), e:
            dt = {'emailAddress': emailAddr}
            _showError(_(u"No Amazon Wishlist was found for email address '%(emailAddress)s'") % dt)
            return None
Beispiel #2
0
 def __init__(self,keywords=None,email=None, name=None, parent=None, kind=None, view=None):
     super(AmazonCollection, self).__init__(name, parent, kind, view)
     if keywords:
         bags = amazon.searchByKeyword(keywords)
         self.displayName = 'Amzn: ' + keywords
     elif email:
         results = amazon.searchWishListByEmail(email)
         customerName = results[0]
         bags = results[1]
         self.displayName = 'Amzn: ' + customerName
     else:
         bags = {}
     for aBag in bags:
         self.add(AmazonItem(aBag, view=view))
Beispiel #3
0
 def __init__(self,
              keywords=None,
              email=None,
              name=None,
              parent=None,
              kind=None,
              view=None):
     super(AmazonCollection, self).__init__(name, parent, kind, view)
     if keywords:
         bags = amazon.searchByKeyword(keywords)
         self.displayName = 'Amzn: ' + keywords
     elif email:
         results = amazon.searchWishListByEmail(email)
         customerName = results[0]
         bags = results[1]
         self.displayName = 'Amzn: ' + customerName
     else:
         bags = {}
     for aBag in bags:
         self.add(AmazonItem(aBag, view=view))