Logo Search packages:      
Sourcecode: zope-emarket version File versions

def EMarket::EMarket::EMarket::addNewShopper (   self,
  REQUEST = None,
  RESPONSE = None,
  PATH_INFO = None,
  PARENTS = None 
)

addNewShopper handles a special situation. We have a temporary user with
no passwd, name etc. etc. etc.... We need to extract the name etc from
the REQUEST, but *not* aqcuire the bogus values from the temporary user.
This means we need to explicity get the from the REQUEST object.

Definition at line 584 of file EMarket.py.

00584                                                                                               :
        """
        addNewShopper handles a special situation. We have a temporary user with
        no passwd, name etc. etc. etc.... We need to extract the name etc from
        the REQUEST, but *not* aqcuire the bogus values from the temporary user.
        This means we need to explicity get the from the REQUEST object.
        """
        #

        ShopperError = ShopperManager.ShopperError

        checkList = ['id','email']

        missingList = []

        for item in checkList:
            if not REQUEST.has_key(item): 
                missingList.append(item)

        if len(missingList) > 0:
            raise "Bad Request", "Missing Data..."

        clientCookie = REQUEST.cookies.get('clientCookie',None)
        origURL = REQUEST.get('origURL',None)
        validateUser = REQUEST.get('validateUser',0)
        
        id = REQUEST['id']
        email = REQUEST['email']

        if not hasattr(self,'randWords'):
            self.randWords = randWords
            self.FixupClassProperties()

        randPass = random.choice(self.randWords) + random.choice(randSymbs) + random.choice(self.randWords)

        passwd = REQUEST.get('passwd',randPass)
        passwd2 = REQUEST.get('passwd2',randPass)

        if passwd == '':
            passwd = passwd2 = randPass
        
        try:
            
            msg = self.addShopper(id, passwd, passwd2, email, REQUEST)

            if (clientCookie is not None) and (clientCookie != id) and clientCookie[:4] == 'temp':

                # we need to copy the temp shopper here and then delete the
                # temporary shopper info....

                oldShopper = self.shopperFolder.getItem( clientCookie )
                newShopper = self.shopperFolder.getItem(id)
                
                if oldShopper is not None:
                    theOldBasket = self.basketManager.getItem(clientCookie)
                    if theOldBasket:
                        oldBasketItemIds = getattr(theOldBasket,'basketItemIds',[])
                        theNewBasket = self.basketManager.newShoppingBasket(id)
                        theNewBasket.basketItemIds = oldBasketItemIds
                        theOldBasket.manage_delete()

                        if origURL is not None:
                            origURL = string.replace(origURL, clientCookie, id)

            if RESPONSE is not None:
                if not self.requireLogin:
                    self.set_cookie(REQUEST = REQUEST, RESPONSE = RESPONSE, path=PATH_INFO, parents=PARENTS, clientCookie=id)
                result = "OK! Successfully added new Shopper."

        except ShopperError, msg:
            result = "ERR Sorry... %s" % msg

        return result


    def constructAbsURL(self, meta_type, parents, path, base, rel):


Generated by  Doxygen 1.6.0   Back to index