WOW not a good idea:
for row in db( db.file_properties.id > 0 ).select(

If you have a lot of records that is going to kill your memory.

On Thu, May 10, 2012 at 12:10 AM, szimszon <szims...@gmail.com> wrote:

> I wonder if somebody could help me.
>
> The following code has eaten up ~1,5GB ram and after ended successfully it
> is not released :(
>
> file_properties table has 137314 rows.
>
> Model:
> db.define_table( 'files_store',
>                                 Field( 'name', 'string',
>                                             label = 'Fájlnév' ,
>                                             ),
>                                 Field( 'content', 'upload',
>                                             uploadseparate = True,
>                                             autodelete = True,
>                                             label = 'Aláírt fájl',
>                                             ),
>                                 Field( 'status', 'string',
>                                             label = 'Állapot',
>                                             requires = IS_IN_SET( ['empty'
> , 'notsigned', 'senttosign', 'signed'],
>
>               [ 'Üres', 'Aláiratlan', 'Aláírásra elküldve', 'Aláírt'] ),
>                                             represent = lambda r, row:T(r
> )
>                                             ),
>                                 Field( 'state', 'string',
>                                             label = 'Státusz',
>                                             requires = IS_IN_SET( ['ok',
> 'error'],
>
>               [ 'Rendben', 'Hiba'] ),
>                                             represent = lambda r, row:T(r
> )
>                                             ),
>                                 Field( 'data_count', 'integer',
>                                             label = 'Adat bejegyzések',
>                                             requires = IS_NOT_EMPTY(),
>                                             default = 0,
>                                             ),
>                                 Field( 'dirname', 'string',
>                                             label = 'Könyvtár név' ,
>                                             requires = IS_NOT_EMPTY(),
>                                             ),
>                                 Field( 'md5sum', 'string',
>                                             label = T( 'MD5 Sum' ),
>                                             represent = lambda md5sum,junk
> : '[%s]' % md5sum,
>                                             writable = False ),
>                             auth.signature,
>                             format = '%(dirname)s/%(name)s (%(id)s)'
>  )
> db.files_store.created_on.readable = True
> db.define_table( 'file_properties',
>                                 Field( 'files_store_id', db.files_store,
>                                             label = 'Aláírt fájl' ,
>                                             ),
>                                 Field( 'kezdo_oldal', 'integer',
>                                             label = 'Számla kezdő oldal',
>                                             requires = IS_NOT_EMPTY(),
>                                             ),
>                                 Field( 'oldalszam', 'integer',
>                                             label = 'Számla oldalainak
> száma',
>                                             requires = IS_NOT_EMPTY(),
>                                             ),
>                                 Field( 'szamla_sorszama', 'string',
>                                             label = 'Számla sorszáma',
>                                             #requires = IS_NOT_IN_DB( db,
> 'file_properties' ),
>                                             unique = True,
>                                             ),
>                                 Field( 'ugyfel_azonosito', 'string',
>                                             label = 'Ügyfél azonosító',
>                                             requires = IS_NOT_EMPTY(),
>                                             ),
>                                 Field( 'folyoszamla_azonosito', 'string',
>                                             label = 'Folyószámla
> azonosító',
>                                             requires = IS_NOT_EMPTY(),
>                                             ),
>                                 Field( 'teljesites_idopontja', 'date',
>                                             label = 'Teljesítés időpontja'
> ,
>                                             requires = IS_DATE(
> '%Y.%m.%d.' ) ),
>                                 auth.signature,
>                                 ),
>
>
>
>
> Controller:
>
> def autoadjust():
>     lista = list()
>     last_row = None
>     next_page_number = 0
>     for row in db( db.file_properties.id > 0 ).select(
>
>                   orderby = ( db.file_properties.files_store_id,
>
>                                       db.file_properties.id )
>
>                   ):
>         if last_row:
>             if last_row.files_store_id == row.files_store_id:
>                 if next_page_number > row.kezdo_oldal:
>                     row.update_record( kezdo_oldal = next_page_number )
>
>             else:
>                 last_row = row
>         else:
>             last_row = row
>         next_page_number = row.kezdo_oldal + row.oldalszam
>
>         lista.append( TR(
>                                         TD( row.id ),
>                                         TD( row.files_store_id.name ),
>                                         TD( row.kezdo_oldal ),
>                                         TD( row.oldalszam )
>                                         ) )
>     lista = TABLE( *lista )
>     return dict( lista = lista )
>
>
> View:
> {{extend 'layout.html'}}
> {{block statusbar}}
> <h4>Admin felület</h4>
> {{end}}
>
> <h2>AdjustPage</h2>
>
> {{=lista}}
>
>
>
>
>


-- 
-- 
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