I'm not sure. That would be handy though.
On Oct 28, 3:38 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> Yes, but for virtualfields.
>
> -Thadeus
>
> On Wed, Oct 28, 2009 at 3:36 PM, mr.freeze <nat...@freezable.com> wrote:
>
> > Like sum/avg/min/max?
>
> > On Oct 28, 3:13 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> > > Is expressions that get applied to all rows for a column on hold? I still
> > > would like a way to sum an integer virtualfield.
>
> > > -Thadeus
>
> > > On Wed, Oct 28, 2009 at 3:10 PM, mr.freeze <nat...@freezable.com> wrote:
>
> > > > I wanted to do an 'each' to process all rows in place but it got too
> > > > complicated trying to convert the DALStorage back into a Rows object.
> > > > Nothing else from me.
>
> > > > On Oct 28, 3:03 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> > > > > Thanks. I just implemented. I guess we had the same idea.
>
> > > > > page = rows[pagenum*pagesize:pagenum*pagesize+pagesize]
>
> > > > > I am about to release 1.69.1 in 5 minutes. Any more ideas to hold on
> > > > > for?
>
> > > > > Massimo
>
> > > > > On Oct 28, 2:59 pm, "mr.freeze" <nat...@freezable.com> wrote:
>
> > > > > > Interested in these? Handy for paging through stuff you've already
> > > > > > pulled from the db (otherwise limitby is best):
>
> > > > > > rows = db().select(db.things.ALL)
>
> > > > > > skip - bypass the specified number of elements and return the rest
> > > > > > take - return the specified number of elements from the beginning
>
> > > > > > >page = rows.skip(pagenum * pagesize).take((pagesize+1)
>
> > > > > > On Oct 28, 12:50 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > > > deal! uploading.
>
> > > > > > > On Oct 28, 12:42 pm, Alex Fanjul <alex.fan...@gmail.com> wrote:
>
> > > > > > > > I agree with Jonathan, (find) and (exclude) are the best.
> > > > > > > > Filter is like "let me this in the result" (just the opposite
> > > > sense),
> > > > > > > > and remove is like "real remove this from my database"
>
> > > > > > > > So... '*Find*' this in my rows, BUT also *Exclude *this from my
> > > > results!
>
> > > > > > > > Alex F
>
> > > > > > > > El 28/10/2009 18:23, Jonathan Lundell escribió:
>
> > > > > > > > > On Oct 28, 2009, at 9:58 AM, mdipierro wrote:
>
> > > > > > > > >> On a third thougth. Mr Freeze original names are better
> > (find
> > > > and
> > > > > > > > >> filter it is).
>
> > > > > > > > > Your use of 'filter' (or my confusion about it) for both
> > cases
> > > > > > > > > illustrates its ambiguity. How about 'find' and 'exclude'?
>
> > > > > > > > >> I added slices too. Here is an example:
>
> > > > > > > > >> b=DAL('sqlite://storage')
> > > > > > > > >> db.define_table('a',Field('b'))
> > > > > > > > >> db.a.insert(b='aaa')
> > > > > > > > >> db.a.insert(b='aab')
> > > > > > > > >> db.a.insert(b='abb')
> > > > > > > > >> db.a.insert(b='bbb')
>
> > > > > > > > >> ### return rows that match condition
> > > > > > > > >> rows=db(db.a.id>0).select().find(lambda row: row.b>0)
>
> > > > > > > > >> #### sort rows
> > > > > > > > >> rows0 = rows.sort(lambda row: row.b.upper()):
>
> > > > > > > > >> rows1=db(db.a.id>0).select()
> > > > > > > > >> ### move matching rows from rows1 to rows2
> > > > > > > > >> rows2=rows1.filter(lambda row: row.b>'b')
>
> > > > > > > > >> ### get a slice of the rows
> > > > > > > > >> rows3=rows[1:3]
>
> > > > > > > > >> They can be mixed and matched
>
> > > > > > > > >> rows=(rows1|rows2|rows3).find(..)[:].filter(..).sort(..)
>
> > > > > > > > >> Now one implement at DAL level most functions missing on GAE
> > > > like OR,
> > > > > > > > >> LIKE, BELONGS.
>
> > > > > > > > >> Massimo
>
> > > > > > > > >> On Oct 28, 11:17 am, mdipierro<mdipie...@cs.depaul.edu>
> > wrote:
>
> > > > > > > > >>> Ok, I am going with filter (same as your find) and extract
> > > > (same as
> > > > > > > > >>> your filter with some changes to make it faster and issue
> > that
> > > > caused
> > > > > > > > >>> it to skip some rows). In trunk now.
>
> > > > > > > > >>> Massimo
>
> > > > > > > > >>> On Oct 28, 10:51 am, "mr.freeze"<nat...@freezable.com>
> > wrote:
>
> > > > > > > > >>>> Now I'm confused :) What if you just changed the 'where'
> > to
> > > > 'find'
> > > > > > > > >>>> and kept both. Filter should reduce the actual set,
> > returning
> > > > the
> > > > > > > > >>>> removed rows. Find should just return the matched rows.
>
> > > > > > > > >>>> On Oct 28, 10:15 am, mdipierro<mdipie...@cs.depaul.edu>
> > > > wrote:
>
> > > > > > > > >>>>> OK I just put the where function in trunk but renamed it
> > > > filter
> > > > > > > > >>>>> (sorry
> > > > > > > > >>>>> for the confusion).
>
> > > > > > > > >>>>> On Oct 28, 10:11 am, Joe Barnhart<joe.barnh...@gmail.com
>
> > > > wrote:
>
> > > > > > > > >>>>>> I know, that's what I'm saying.... the word "where"
> > suggests
> > > > it
> > > > > > > > >>>>>> is an SQL
> > > > > > > > >>>>>> verb but it has nothing to do with SQL. I was just
> > thinking
> > > > it
> > > > > > > > >>>>>> might be
> > > > > > > > >>>>>> confusing to new users of w2p.
>
> > > > > > > > >>>>>> On Wed, Oct 28, 2009 at 6:32 AM, mr.freeze
> > > > > > > > >>>>>> <nat...@freezable.com> wrote:
>
> > > > > > > > >>>>>>> No, anything post 'select' is done after the db call,
> > > > including
> > > > > > > > >>>>>>> first
> > > > > > > > >>>>>>> () and last().
>
> > > > > > > > >>>>>>> On Oct 28, 2:51 am, Joe Barnhart<
> > joe.barnh...@gmail.com>
> > > > wrote:
>
> > > > > > > > >>>>>>>> I love the functionality, but doesn't calling the
> > function
> > > > > > > > >>>>>>>> "where"
> > > > > > > > >>>>>>>> conjure up the SQL WHERE clause? I might think it was
> > > > doing
> > > > > > > > >>>>>>>> something
> > > > > > > > >>>>>>>> with SELECT...WHERE in the underlying DB.
>
> > > > > > > > >>>>>>>> -- Joe B.
>
> > > > > > > > >>>>>>>> On Oct 27, 10:11 pm, "mr.freeze"<nat...@freezable.com
>
> > > > wrote:
>
> > > > > > > > >>>>>>>>> Works! Would you be interested in these for sql.py
> > Rows
> > > > class?:
>
> > > > > > > > >>>>>>>>> def where(self,f):
> > > > > > > > >>>>>>>>> if not self.response:
> > > > > > > > >>>>>>>>> return None
> > > > > > > > >>>>>>>>> rows = []
> > > > > > > > >>>>>>>>> for i in range(0,len(self)):
> > > > > > > > >>>>>>>>> row = self[i]
> > > > > > > > >>>>>>>>> if f(row): rows.append(self.response[i])
> > > > > > > > >>>>>>>>> return Rows(self._db,rows,*self.colnames)
>
> > > > > > > > >>>>>>>>> def filter(self,f):
> > > > > > > > >>>>>>>>> if not self.response:
> > > > > > > > >>>>>>>>> return None
> > > > > > > > >>>>>>>>> rows = self.response
> > > > > > > > >>>>>>>>> removed = []
> > > > > > > > >>>>>>>>> for i in range(0,len(self)):
> > > > > > > > >>>>>>>>> row = self[i]
> > > > > > > > >>>>>>>>> if f(row):
> > > > > > > > >>>>>>>>> removed.append(rows[i])
> > > > > > > > >>>>>>>>> rows.remove(rows[i])
> > > > > > > > >>>>>>>>> return Rows(self._db,removed,*self.colnames)
>
> > > > > > > > >>>>>>>>> Example:
> > > > > > > > >>>>>>>>> db.define_table('things',Field('category'))
> > > > > > > > >>>>>>>>> rows = db(db.things.id>0).select()
> > > > > > > > >>>>>>>>> tests = rows.where(lamdba row: row.category=="test")
> > #
> > > > > > > > >>>>>>>>> returns matches
> > > > > > > > >>>>>>>>> rows.filter(lamdba row: row.category=="test")#
> > removes
> > > > and
> > > > > > > > >>>>>>>>> returns
> > > > > > > > >>>>>>>>> removed
>
> > > > > > > > >>>>>>>>> On Oct 27, 10:49 pm, mdipierro<
> > mdipie...@cs.depaul.edu>
> > > > wrote:
>
> > > > > > > > >>>>>>>>>> Thanks. Just fixed in trunk!
>
> > > > > > > > >>>>>>>>>> On Oct 27, 10:35 pm, "mr.freeze"<
> > nat...@freezable.com>
> > > > wrote:
>
> > > > > > > > >>>>>>>>>>> I get a syntax error when using this. I believe
> > line
> > > > 2926 of
> > > > > > > > >>>>>>>>>>> Rows.__getitem__ needs to be changed from:
>
> > > > > > > > >>>>>>>>>>> if i>= len(self.response) or i< 0:
>
> > > > > > > > >>>>>>>>>>> ...to...
>
> > > > > > > > >>>>>>>>>>> if i>= len(self.response):
>
> > > > > > > > >>>>>>>>>>> since Rows.last() returns self[-1]
>
> > > > > > > > --
> > > > > > > > Alejandro Fanjul Fdez.
> > > > > > > > alex.fan...@gmail.comwww.mhproject.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to
web2py+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---