random ads web2py query:
unseen_ads = unseen_ads_query.select(orderby='<random>', limitby=(0,5))
return unseen_ads

update is pretty much the exact same code as provided before, with the
different it appends to the list of ads it got from the database.
today_ads = self.db((self.db.viewedads.member_id == member) &
(self.db.viewedads.date == date)).select().first()
if today_ads.adsviewed:
      ads_viewed = cPickle.loads(str(today_ads.adsviewed))
else:
      ads_viewed = []
unseen = []
ad_ids_to_skip = []
start_index = 0
if ads_viewed:
     #print ads_viewed
     for ad in ads_viewed:
         if not ad['valid']:
             unseen.append(ad)
             ad_ids_to_skip.append(ad['id'])
         start_index = int(ads_viewed[-1]['index']) + 1

random_ads = self._get_random_urls(ad_ids_to_skip)
for new_ad in random_ads:
                    ad_details = {
                        'index':start_index,
                        'id':new_ad['id'],
                        'url':new_ad['url'],
                        'valid':'',
                        'suburlcount':'',
                        'viewcanceled':'',
                        'timestart':'',
                        'timeend':'',
                        'rating':''
                    }
                    start_index += 1
                    #print "New index", start_index
                    unseen.append(ad_details)
                    ads_viewed.append(ad_details)
today_ads.update_record(adsviewed=cPickle.dumps(ads_viewed))

I have it working in both frameworks, however I needed to include gluon in
python path on the old framework. So I am just curious as to where is this
code is causing it to use a storage object.

On Sun, Apr 15, 2012 at 10:27 PM, Anthony <[email protected]> wrote:

> The code I showed you is exactly how ads are created and stored in the
>> database. It is all through that code.
>
>
> The code doesn't show how the random_ads object and the url objects it
> contains are created.
>
>
>> The code that updates the code uses cPickle.loads and treats it like a
>> python object updating the array then redumps it cPickle.dumps before
>> saving.
>>
>
> Is it web2py code that is doing this updating, or is that all in the other
> framework? If web2py, show that code too.
>
> Anthony
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

Reply via email to