[web2py] Re: fluxflex

2011-08-21 Thread David Marko
How did you upload the existing web2py app there? I tried several times but 
it fails after upload finished with some bad URL redirection and my app is 
not there. :-(




Re: [web2py] Nesting functions inside functions in controllers

2011-08-21 Thread Bruno Rocha
I guess it is not wrong, but I do not recommend too much code in
controllers, controllers should be for decide the app flow.

I reccomend you to create a module in /modules

# modules/myobjects.py
from gluon import *
request = current.request
class Myobjects(object):
def showsearch(self, db):
search
= db(db.listing.title==request.args(0)).select(db.listing.ALL)
items = []
for person in search:
items.append(DIV(A(person.first_name, _href=URL('listing',args=
person.id

   return TAG[''](*items)
# modules/myobjects.py

then in controller you do:

# controllers/default.py

def search():
from myobjects import Myobjects
return dict(showsearch=Myobjects.showsearch(db))

# controllers/deafault.py

Note that you need to pass 'db' instance to the module

I think the controller code looks much better in this way, needs web2py
1.97+







On Mon, Aug 22, 2011 at 2:10 AM, Jarrod Cugley  wrote:

> Is there anything wrong with doing this inside default.py controller?:
>
> def search():
>def showsearch():
>search =
> db(db.listing.title==request.args(0)).select(db.listing.ALL)
>items = []
>for person in search:
>items.append(DIV(A(person.first_name, _href=URL('listing',
> args=person.id
>
>return TAG[''](*items)
>return dict(showsearch=showsearch())
>
> That is, nesting functions inside functions, I'm not getting an error,
> it's working as intended but is this a horrible practice to get into?
> Is there an ideal way?




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


[web2py] Re: Sample code for new scheduler

2011-08-21 Thread Adi
Also another possible typo in the documentation:

> For any existing app
>
> Create File: app/models/scheduler.py ==
> from gluon.scheduler import Scheduler
>
> ## run worker nodes with:
>
>   python web2py.py -S app -M -N -R applications/app/modules/scheduler.py

modules should be models or vice versa (in the path)?

On Aug 22, 11:26 am, Adi  wrote:
> Hi Massimo,
>
> Is there some sample code (a sample tasks.py) which we can look at
> while testing the new gluon/scheduler.py as an alternate to cron jobs?
>
> Also, in scheduler.py, I spotted a typo:
> id = scheduler.db.tast_scheduler.insert()
>
> tast should be task?


[web2py] Sample code for new scheduler

2011-08-21 Thread Adi
Hi Massimo,

Is there some sample code (a sample tasks.py) which we can look at
while testing the new gluon/scheduler.py as an alternate to cron jobs?

Also, in scheduler.py, I spotted a typo:
id = scheduler.db.tast_scheduler.insert()

tast should be task?


[web2py] Re: fluxflex

2011-08-21 Thread guruyaya
Super awsome!

On Aug 21, 3:37 pm, Omi Chiba  wrote:
> Ichino who is a member of web2py Japan created a library on fluxflex
> and it works great !
>
> http://www.fluxflex.com/library/47
>
> 1. Sign up fluxflex
> 2. Create new project (e.g. ochiba)
> 3. Install the library (It will be done in one second!)
> 4. Access to your project with HTTPS not HTTP 
> (e.g.https://ochiba.fluxflex.com)
> 5. Access Administrative Interface with /admin 
> (e.g.https://ochiba.fluxflex.com/admin
> )
> 5. Admin password is the same as your MySQL database on fluxflex
> project.
>
> Enjoy :)


[web2py] Re: web2py app give "Application not responding" in MAC, when provide -a password

2011-08-21 Thread xzhang
Thank you for your reply, but my problem is happen on a mac computer.
Is there anyway to solve this on mac ?


On Aug 18, 1:20 am, Massimo Di Pierro 
wrote:
> on windows I suggest you use a windows binary (so not python
> conflicts) and create your own .bat file for starting it up on click
> with the command line options you need
>
> On Aug 17, 6:36 pm, xzhang  wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I am using web2py mac version.
> > Because I don't need my user know anything about the server and
> > password,
> > So I add "-a password" argument in web2py.py.
>
> > This working fine if I start it from command line by: ./web2py
> > But not working when start it from double click the app.
>
> > Because the app doesn't provide the gui anymore, it go into a
> > "Application not responding" status.
>
> > The web server is actually works fine, I still can browser my pages.
> > but when I try to quit the server,  I have to use force quit, this
> > will give me report window back.
>
> > I am worry about this "Application not responding" and "force quit"
> > will scare my user.
>
> > So I want to know is there any other way to running the server without
> > password and command line?
>
> > Ideally, I hope after user double click the app, an icon will show in
> > dock just like an application, without any console or gui window, and
> > they can quick it by click quit from dock.
>
> > Thanks for reading my question.
> > xzhang


[web2py] Nesting functions inside functions in controllers

2011-08-21 Thread Jarrod Cugley
Is there anything wrong with doing this inside default.py controller?:

def search():
def showsearch():
search =
db(db.listing.title==request.args(0)).select(db.listing.ALL)
items = []
for person in search:
items.append(DIV(A(person.first_name, _href=URL('listing',
args=person.id

return TAG[''](*items)
return dict(showsearch=showsearch())

That is, nesting functions inside functions, I'm not getting an error,
it's working as intended but is this a horrible practice to get into?
Is there an ideal way?


Re: [web2py] Re: An issue with trunk changes to password rules

2011-08-21 Thread Jonathan Lundell
On Aug 21, 2011, at 8:17 PM, Massimo Di Pierro wrote:

> Do you suggest reverting the patch?

It does break existing installations.

The real fix is to enforce password-strength rules when passwords are being 
generated, but not when they're being checked. 

> 
> On Aug 21, 3:14 pm, Jonathan Lundell  wrote:
>> On Aug 21, 2011, at 11:20 AM, Anthony wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> On Sunday, August 21, 2011 1:56:00 PM UTC-4, Jonathan Lundell wrote:
>>> On Aug 21, 2011, at 9:27 AM, Jonathan Lundell wrote:
 On Aug 21, 2011, at 8:33 AM, Jonathan Lundell wrote:
>> 
> I do something like this. Your details might vary.
>> 
> #  invoke IS_STRONG only for password creation, not password checking
> if "login" not in request.args:
>   auth.settings.table_user.password.requires.insert(0, IS_STRONG(min=8, 
> max=0, special=1))
>> 
> ...but I also define the entire auth table, so Massimo's method is 
> handier if you're using the default.
>> 
> I think it'd be good if auth worked this way by default. There's no 
> reason to enforce IS_STRONG on login, and actually there's good reason 
> *not* to, since it enables an attacker to learn things about the actual 
> password.
>> 
 Actually, as I review the source, the only place I see IS_STRONG being 
 invoked by default is in the admin app. So if you're adding IS_STRONG to 
 your auth forms, just make it conditional as above.
>> 
>>> ...and if that's right, perhaps we could put something like that (but with 
>>> a default IS_STRONG call?) into the scaffolding app, as an example.
>> 
>>> Looks like the recent change in trunk was to CRYPT, not IS_STRONG. CRYPT 
>>> now checks for a minimum password length, which defaults to 4. If you're 
>>> already using IS_STRONG, then I suppose you could just set the min_length 
>>> argument of CRYPT to 1.
>> 
>> Except that CRYPT is invoked inside Auth.
>> 
>> 1) I don't see a good reason for enforcing password length in CRPYT, and 2) 
>> password length (or strength) should never be enforced while checking.




[web2py] Re: An issue with trunk changes to password rules

2011-08-21 Thread Massimo Di Pierro
Do you suggest reverting the patch?

On Aug 21, 3:14 pm, Jonathan Lundell  wrote:
> On Aug 21, 2011, at 11:20 AM, Anthony wrote:
>
>
>
>
>
>
>
>
>
> > On Sunday, August 21, 2011 1:56:00 PM UTC-4, Jonathan Lundell wrote:
> > On Aug 21, 2011, at 9:27 AM, Jonathan Lundell wrote:
> > > On Aug 21, 2011, at 8:33 AM, Jonathan Lundell wrote:
>
> > >> I do something like this. Your details might vary.
>
> > >> #  invoke IS_STRONG only for password creation, not password checking
> > >> if "login" not in request.args:
> > >>   auth.settings.table_user.password.requires.insert(0, IS_STRONG(min=8, 
> > >> max=0, special=1))
>
> > >> ...but I also define the entire auth table, so Massimo's method is 
> > >> handier if you're using the default.
>
> > >> I think it'd be good if auth worked this way by default. There's no 
> > >> reason to enforce IS_STRONG on login, and actually there's good reason 
> > >> *not* to, since it enables an attacker to learn things about the actual 
> > >> password.
>
> > > Actually, as I review the source, the only place I see IS_STRONG being 
> > > invoked by default is in the admin app. So if you're adding IS_STRONG to 
> > > your auth forms, just make it conditional as above.
>
> > ...and if that's right, perhaps we could put something like that (but with 
> > a default IS_STRONG call?) into the scaffolding app, as an example.
>
> > Looks like the recent change in trunk was to CRYPT, not IS_STRONG. CRYPT 
> > now checks for a minimum password length, which defaults to 4. If you're 
> > already using IS_STRONG, then I suppose you could just set the min_length 
> > argument of CRYPT to 1.
>
> Except that CRYPT is invoked inside Auth.
>
> 1) I don't see a good reason for enforcing password length in CRPYT, and 2) 
> password length (or strength) should never be enforced while checking.


Re: [web2py] Re: table, grid, smartgrid, getting better

2011-08-21 Thread pbreit
That seems unnecessary to me. Easy enough to command-click a link to open in 
a new tab/window. And you might not want to reload the table window since it 
could add unnecessary activity on the DB.

[web2py] Re: Calender / datetime picker - localization

2011-08-21 Thread Iceberg
Hi Martin,

About the translation, have you checked out its official package?
http://www.dynarch.com/projects/calendar/old/

It contains lots of different language files. Just include one of
them, and you are good to go. It works for me, for years!

Regards,
Ray (a.k.a. Iceberg)


On Aug 17, 10:24 pm, Martin Weissenboeck  wrote:
> Thx. But how can I translate the names of the months and the days and how
> can I make the calendar start at Monday (and not at Sunday)?
>
> By the way: I wanted to get a timepicker and I have tried to use "...
> _class='time'...". The datepicker works (_class='date') and also
> _class='datetime', but not 'time'.
>
> Regards, Martin
>
> 2011/8/17 Anthony 
>
>
>
>
>
>
>
> > If you want to localize the date format in particular, in
> > /views/web2py_ajax.html, you'll notice variables w2p_ajax_date_format and
> > w2p_ajax_datetime_format. Both of those are translated via the web2py
> > translation system, so you can simply add translations for those two formats
> > to your language files.
>
> > Anthony
>
> > On Wednesday, August 17, 2011 5:53:07 AM UTC-4, mweissen wrote:
>
> >> Who knows where to find details about the localization (and other
> >> customization) of the built-in calender?
> >> In calendar.js I have found the link
> >>http://www.dynarch.com/projects/calendar, but I could only find there
> >> something about a (new) version JSCal2
>
> >> Regards, Martin


[web2py] Re: jqgrid-module import problem

2011-08-21 Thread Iceberg
Hi Johann,

It is not about local_import() vs the new "from jqgrid import JqGrid"
syntax.
It is because you install your jqgrid app with a name other than
"jqgrid".
And this bug is fixed in latest trunk of jqgrid app already.

Regards,
Ray

On Aug 17, 7:28 pm, Bruno Rocha  wrote:
> No more need to use lical_import it is deprecated. Newest web2py has a
> custom importer which works much better.
>
> Em 17/08/2011 08:20, "Johann Spies"  escreveu:
>
> > On 17 August 2011 12:55, Bruno Rocha  wrote:
>
> >> try changing this:
>
> >> JqGrid = local_import('jqgrid', app='jqgrid', reload=True).JqGrid
>
> >> to this:
>
> >> from jqgrid import JqGrid
>
> > Thanks. That solved the problem but not the mystery (because my lack of
> > understanding).
>
> > When is it better to use the first version?
>
> > Regards
> > Johann
> > --


Re: [web2py] Re: table, grid, smartgrid, getting better

2011-08-21 Thread Roberto Perdomo
and new link too

2011/8/21 Roberto Perdomo 

> Great work, thanks
>
> I just wanted to make a suggestion, you can place the links to to view and
> edit as modal windows , and when close it, reload the table page?
>
>
>
> 2011/8/21 mart 
>
>> Hi Massimo,
>>
>> So all is working great! I just have one question :)
>>
>> i think I am making a real mess of things while trying to add an xtra
>> link.
>>
>> this is in my test controller function:
>>
>> def test()
>>table=SQLFORM.grid(db.buildSpec,links=[lambda
>> r:A('build',_href=(f=queue_it ...   --> the rest is way to ugly to
>> show ;)
>>
>>return dict(table=table)
>>
>>
>> which should call this function when the link is clicked:
>>
>> def queue_it():
>>Q=os.path.abspath('../../../Q')
>>id=request.args(2)
>>
>>name=db(db[request.args(1)].id==id).select()\
>> .last().name
>>
>>content=db(db[request.args(1)].id==id).select()\
>> .last().content
>>
>>client_system=db(db[request.args(1)].id==id).select()\
>> .last().client_system
>>
>>change=db(db[request.args(1)].id==id).select()\
>> .last().change
>>
>>changed_by=db(db[request.args(1)].id==id).select()\
>> .last().changed_by
>>
>>date=db(db[request.args(1)].id==id).select()\
>> .last().date
>>
>>description=db(db[request.args(1)].id==id).select()\
>> .last().description
>>
>>is_head=db(db[request.args(1)].id==id).select()\
>> .last().is_head
>>
>>if os.path.exists(Q):
>>bsPath='{0}/{1}'.format(Q,name)
>>if os.path.exists(bsPath):
>>try:
>>os.remove(bsPath)
>>except Exception as err:
>>print('could not remove existing file
>> {0}\n{1}'.format(bsPath,err))
>>
>>oFile=open(bsPath,'a')
>>for cItem in content.split('\n'):
>>if '>cItem='{0}\n\t\tbuildSpec_id="{1}"'.format(cItem,id)
>>oFile.write('{0}\n'.format(cItem))
>>oFile.close()
>>
>>response.flash='{0} has been dropped in the blueLite Q'\
>> .format(name)
>>
>>return dict(form=crud()\
>>,name=name\
>>,client_system=client_system\
>>,change=change\
>>,changed_by=changed_by\
>>,date=date\
>>,description=description\
>>,is_head=is_head)
>>
>>
>> any help would be appreciated (and sorry for the dumb question :) ),
>> Thanks,
>> Mart :)
>>
>> On Aug 19, 12:28 pm, Richard Vézina 
>> wrote:
>> > ;-D
>> >
>> > Think we will be needing a recent advance briefing email througth the
>> > list...
>> >
>> > Richard
>> >
>> > On Fri, Aug 19, 2011 at 5:57 AM, Martín Mulone > >wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > The web2py is advancing so fast, that the documentation get deprecated
>> > > before get published. :)
>> >
>> > > 2011/8/18 Massimo Di Pierro 
>> >
>> > >> Actually I just killed myself in the foot... I am writing a packt
>> book
>> > >> with some other members of the list. Have to deliver it in 5 days.
>> > >> Today 10-20% of the book recipes become obsolete and I have to
>> rewrite
>> > >> them. At the same time I am not ready to commit to the API of the new
>> > >> SQLFORM.grid.  :-(
>> >
>> > >> On Aug 18, 6:32 pm, mart  wrote:
>> > >> > WOW! Thank you! this is awesome! :)
>> >
>> > >> > Mart :)
>> >
>> > >> > On Aug 18, 5:03 pm, Massimo Di Pierro 
>> > >> > wrote:
>> >
>> > >> > > This is a new API so it expects a new syntax for represent that
>> takes
>> > >> > > two arguments. The second argument is the record.
>> >
>> > >> > > On Aug 18, 2:47 pm, pbreit  wrote:
>> >
>> > >> > > > I'm getting errors on my tables. auth_user works OK but I get
>> these
>> > >> errors
>> > >> > > > on three of my other tables.
>> >
>> > >> > > > Traceback (most recent call last):
>> > >> > > >   File "/Users/pbreit/web2py/gluon/restricted.py", line 194, in
>> > >> restricted
>> > >> > > > exec ccode in environment
>> > >> > > >   File
>> > >> "/Users/pbreit/web2py/applications/init/controllers/default.py" <
>> > >>
>> http://pb-dev.pricetack.com:8001/admin/edit/init/controllers/default.py>,
>> > >> line 107, in 
>> > >> > > >   File "/Users/pbreit/web2py/gluon/globals.py", line 145, in
>> > >> 
>> > >> > > > self._caller = lambda f: f()
>> > >> > > >   File
>> > >> "/Users/pbreit/web2py/applications/init/controllers/default.py" <
>> > >>
>> http://pb-dev.pricetack.com:8001/admin/edit/init/controllers/default.py>,
>> > >> line 12, in grid
>> > >> > > > table = SQLFORM.grid(db.purchase)
>> > >> > > >   File "/Users/pbreit/web2py/gluon/sqlhtml.py", line 1408, in
>> grid
>> > >> > > > value=field.represent(value,row)
>> > >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3730, in
>> repr_ref
>> > >> > > > def repr_ref(id, r=referenced, f=ff): return f(r, id)
>> > >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3699, in ff
>> > >> > > > row=r(id)
>> > >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3805, in
>> 

Re: [web2py] Re: table, grid, smartgrid, getting better

2011-08-21 Thread Roberto Perdomo
Great work, thanks

I just wanted to make a suggestion, you can place the links to to view and
edit as modal windows , and when close it, reload the table page?


2011/8/21 mart 

> Hi Massimo,
>
> So all is working great! I just have one question :)
>
> i think I am making a real mess of things while trying to add an xtra
> link.
>
> this is in my test controller function:
>
> def test()
>table=SQLFORM.grid(db.buildSpec,links=[lambda
> r:A('build',_href=(f=queue_it ...   --> the rest is way to ugly to
> show ;)
>
>return dict(table=table)
>
>
> which should call this function when the link is clicked:
>
> def queue_it():
>Q=os.path.abspath('../../../Q')
>id=request.args(2)
>
>name=db(db[request.args(1)].id==id).select()\
> .last().name
>
>content=db(db[request.args(1)].id==id).select()\
> .last().content
>
>client_system=db(db[request.args(1)].id==id).select()\
> .last().client_system
>
>change=db(db[request.args(1)].id==id).select()\
> .last().change
>
>changed_by=db(db[request.args(1)].id==id).select()\
> .last().changed_by
>
>date=db(db[request.args(1)].id==id).select()\
> .last().date
>
>description=db(db[request.args(1)].id==id).select()\
> .last().description
>
>is_head=db(db[request.args(1)].id==id).select()\
> .last().is_head
>
>if os.path.exists(Q):
>bsPath='{0}/{1}'.format(Q,name)
>if os.path.exists(bsPath):
>try:
>os.remove(bsPath)
>except Exception as err:
>print('could not remove existing file
> {0}\n{1}'.format(bsPath,err))
>
>oFile=open(bsPath,'a')
>for cItem in content.split('\n'):
>if 'cItem='{0}\n\t\tbuildSpec_id="{1}"'.format(cItem,id)
>oFile.write('{0}\n'.format(cItem))
>oFile.close()
>
>response.flash='{0} has been dropped in the blueLite Q'\
> .format(name)
>
>return dict(form=crud()\
>,name=name\
>,client_system=client_system\
>,change=change\
>,changed_by=changed_by\
>,date=date\
>,description=description\
>,is_head=is_head)
>
>
> any help would be appreciated (and sorry for the dumb question :) ),
> Thanks,
> Mart :)
>
> On Aug 19, 12:28 pm, Richard Vézina 
> wrote:
> > ;-D
> >
> > Think we will be needing a recent advance briefing email througth the
> > list...
> >
> > Richard
> >
> > On Fri, Aug 19, 2011 at 5:57 AM, Martín Mulone  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > The web2py is advancing so fast, that the documentation get deprecated
> > > before get published. :)
> >
> > > 2011/8/18 Massimo Di Pierro 
> >
> > >> Actually I just killed myself in the foot... I am writing a packt book
> > >> with some other members of the list. Have to deliver it in 5 days.
> > >> Today 10-20% of the book recipes become obsolete and I have to rewrite
> > >> them. At the same time I am not ready to commit to the API of the new
> > >> SQLFORM.grid.  :-(
> >
> > >> On Aug 18, 6:32 pm, mart  wrote:
> > >> > WOW! Thank you! this is awesome! :)
> >
> > >> > Mart :)
> >
> > >> > On Aug 18, 5:03 pm, Massimo Di Pierro 
> > >> > wrote:
> >
> > >> > > This is a new API so it expects a new syntax for represent that
> takes
> > >> > > two arguments. The second argument is the record.
> >
> > >> > > On Aug 18, 2:47 pm, pbreit  wrote:
> >
> > >> > > > I'm getting errors on my tables. auth_user works OK but I get
> these
> > >> errors
> > >> > > > on three of my other tables.
> >
> > >> > > > Traceback (most recent call last):
> > >> > > >   File "/Users/pbreit/web2py/gluon/restricted.py", line 194, in
> > >> restricted
> > >> > > > exec ccode in environment
> > >> > > >   File
> > >> "/Users/pbreit/web2py/applications/init/controllers/default.py" <
> > >>
> http://pb-dev.pricetack.com:8001/admin/edit/init/controllers/default.py>,
> > >> line 107, in 
> > >> > > >   File "/Users/pbreit/web2py/gluon/globals.py", line 145, in
> > >> 
> > >> > > > self._caller = lambda f: f()
> > >> > > >   File
> > >> "/Users/pbreit/web2py/applications/init/controllers/default.py" <
> > >>
> http://pb-dev.pricetack.com:8001/admin/edit/init/controllers/default.py>,
> > >> line 12, in grid
> > >> > > > table = SQLFORM.grid(db.purchase)
> > >> > > >   File "/Users/pbreit/web2py/gluon/sqlhtml.py", line 1408, in
> grid
> > >> > > > value=field.represent(value,row)
> > >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3730, in
> repr_ref
> > >> > > > def repr_ref(id, r=referenced, f=ff): return f(r, id)
> > >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3699, in ff
> > >> > > > row=r(id)
> > >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3805, in
> __call__
> > >> > > > return self.__getitem__(key)
> > >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3802, in
> > >> __getitem__
> > >> > > > return dict.__getitem__(self, key)
> > >> > > > KeyError: '1

[web2py] Re: query quest

2011-08-21 Thread Niphlod
Actually, there is a "hackier" way, but I advise strongly not to
follow this path.

Psyco-maniac query that returns the same result (this is working on
Postgresql, on MSSQL || must be replaced with +, on mysql there is the
CONCAT function for that, but I don't have mysql installed to test it)

Postgre
select curve.*, site.*
from curve
inner join
site
on site.id = curve.site
where cast(start as varchar) || '$$$' || site IN (select
cast(max("start") as varchar) || '$$$' || site from curve
group by site)

mssql
select curve.*, site.*
from curve
inner join
site
on site.id = curve.site
where cast(start as varchar) + '$$$' + site IN (select
cast(max("start") as varchar) + '$$$' + site from curve
group by site)

mysql
select curve.*, site.*
from curve
inner join
site
on site.id = curve.site
where CONCAT(start, '$$$', site) IN (select concat(max("start"),'$$
$',site from curve
group by site)


So, to explain, what are we doing ?
We are constructing a "composed" column concatenating start and site
(the '$$$' in the middle is there to avoid potential collision). Start
and site are chosen because they are: the max() we want to filter for
and the external key we must join to.
We can use that to avoid the inner join and placing the group by in
the IN () construct.

Seems maybe a smart idea but here the database is forced to do a full
scan on the table because the IN condition is evaluated on a function,
not on a native field. This is the reason why I'm not recommending it,
execution time is greater than with the solution from the above post.
Anyway, time for big hacks :D

The way to reproduce the query using DAL is the following (only
postgresql example given)

concatted = "cast(start as varchar) || '$$$' || site IN (%s)"
max_concatted = "cast(max(start) as varchar) || '$$$' || site as
start"
q1 = db(db.curve.id>0)._select(max_concatted, groupby=db.curve.site)
query = db((db.site.id == db.curve.site) & (concatted %
(q1[:-1]))).select(db.curve.ALL, db.site.ALL)

It works, but again, I prefer the method from the previous post, both
for "hackiness", code maintenance and lower execution times.


[web2py] Re: query quest

2011-08-21 Thread Niphlod
Once defined that you want a recordset that is the result of a join
between the two tables, with all the fields of the two tables and
containing only the records having the maximum start date, I think
that the right query for the job is

select curve.*, site.*
from curve
inner join
(
select max("start") as start, site from curve
group by site
) b
on b.start = curve.start
and
b.site = curve.site
inner join
site
on site.id = curve.site

[antimysql mode on]
That blowing query on the first post should have never been written,
and if I managed to see it working in anything calling itself
relational database I'll be erasing all database's instances from my
pc
[antimysql mode off]

I don't think that DAL allows inner join on a constructed str... so no
tricks come to my mind :D

but maybe Massimo or heavy DAL devs can help on that (DAL.py, lines
1116-1123).

For the time being you can define a view e.g.

create view curve_max as
select 1 as id, max("start") as start, site from curve
group by site

and define a "fake" model e.g.

db.define_table('curve_max', #I swear I'll never do insert or update
on this one
Field('start', 'date'),
Field('site', db.site),
migrate=False,
fake_migrate=False
)

you will have to swear to observe a strict "only read" policy on that,
but you can do

query = db((db.curve.start == db.curve_max.start) & (db.curve.site ==
db.curve_max.site) & (db.site.id ==
db.curve.site)).select(db.curve.ALL, db.site.ALL)

and live happily (until someone smarter thinks how to do that NOT
using an intermediate view with a "fake" model)

Can you live with that ?


Re: [web2py] Re: fluxflex

2011-08-21 Thread Bruno Rocha
and PLANS

 PlanProjects TrafficProcessed Time Transfer InTransfer Out Disk SpaceDB
Space *super geek*
($9.0/month)100 unlimited 10.0GB/day3.0GB/day 3.0GB/day4.0GB
0.5GBChange
*standard*
($1.0/month)15 5.0/day 5.0GB/day1.0GB/day 1.0GB/day1.0GB
0.1GBChange
*free*
($0.0/month) 31.0/day 0.25GB/day0.25GB/day 0.25GB/day0.25GB 0.025GBYour
Plan


Re: [web2py] Re: fluxflex

2011-08-21 Thread Bruno Rocha
Found about the QUOTA

Processed Time 19 / 1 Requests Processed Time 5.25 / 900.0 seconds (0.25
Hours) Transfer In 14646 / 268435456.0 Bytes (0.25 GB) Transfer Out 106990 /
268435456.0 Bytes (0.25 GB) Storage Size 0.0 / 256.0 MBytes (0.25
GB)Database Size0.0 / 25.6 MBytes (0.025 GB)


Re: [web2py] Re: fluxflex

2011-08-21 Thread Bruno Rocha
Very good!

And admin works perfectly! I am already running an app with MySQL and web2py
Trunk.

We can create our instalations on github by forking this;
https://github.com/nus/web2py-for-fluxflex and customizing to our project
needs, so deployment will be very very easy.

I didt find any information about terms, plans & prices


Re: [web2py] Re: GAE questions...

2011-08-21 Thread Anthony
On Sunday, August 21, 2011 5:06:11 AM UTC-4, sebastian wrote:
>
> thanks cfh,
>
> that's great... web2py now supports GAE native lists !!!
>
> any idea if it is possible to use Expanto and PolyModel classes  ?
>  
>
 
PolyModel: https://groups.google.com/d/msg/web2py/OsNUPL9IwH4/CmsuUIuX34kJ
 


[web2py] Re: Google datastore concepts - denormalising and list:reference fields

2011-08-21 Thread howesc
the 30 second timeout can be hit if you are doing something that triggers a 
few hundred "sub-queries".

contains is very nice.  yes it's then a pain to add/remove items from the 
list, but GAE is all about query efficiency at the expense of write 
efficiency.

cfh


[web2py] Re: How to get the referenced objects from a list:reference

2011-08-21 Thread howesc
the challenge is that you are thinking about a normalized referential DB.  
GAE does not provide that at this time.  so you have warp your mind to get 
it to work.  flat schemas work best, but they are hard to manage and very 
ugly, so it's all about finding that middle ground.

at the same time, GAE is not right for every problem.  i too am eagerly 
awaiting the long promised SQL support on GAE!

cfh


Re: [web2py] Re: GAE questions...

2011-08-21 Thread howesc
i can't remember for sure, but i thought the DAL made them all as expando 
classes

given that web2py supports multiple db backends where expando and polymodel 
would not be supported there is no direct support for that.  you can always 
redefine the table though and the no-op migration will happen and away you 
go

cfh


Re: [web2py] Re: fluxflex

2011-08-21 Thread Stef Mientki

really fantastic,
despite the server 500 errors during sign up,
web2py running within 2 minutes.
cheers,
Stef

On 21-08-2011 22:11, Martín Mulone wrote:

bye bye gae (?)

2011/8/21 Massimo Di Pierro mailto:massimo.dipie...@gmail.com>>

This is fantastic. I will be travelling in the next few hours but I
look forward to try it. I have been looking for something like this
for long time!

Massimo

On Aug 21, 7:37 am, Omi Chiba mailto:ochib...@gmail.com>> wrote:
> Ichino who is a member of web2py Japan created a library on fluxflex
> and it works great !
>
> http://www.fluxflex.com/library/47
>
> 1. Sign up fluxflex
> 2. Create new project (e.g. ochiba)
> 3. Install the library (It will be done in one second!)
> 4. Access to your project with HTTPS not HTTP 
(e.g.https://ochiba.fluxflex.com)
> 5. Access Administrative Interface with /admin 
(e.g.https://ochiba.fluxflex.com/admin
> )
> 5. Admin password is the same as your MySQL database on fluxflex
> project.
>
> Enjoy :)




--
http://martin.tecnodoc.com.ar





Re: [web2py] An issue with trunk changes to password rules

2011-08-21 Thread Anthony
On Sunday, August 21, 2011 4:14:09 PM UTC-4, Jonathan Lundell wrote:
>
>  
> Except that CRYPT is invoked inside Auth.
>  
>
Good point, forgot about that.


Re: [web2py] An issue with trunk changes to password rules

2011-08-21 Thread Jonathan Lundell
On Aug 21, 2011, at 11:20 AM, Anthony wrote:

> On Sunday, August 21, 2011 1:56:00 PM UTC-4, Jonathan Lundell wrote:
> On Aug 21, 2011, at 9:27 AM, Jonathan Lundell wrote:
> > On Aug 21, 2011, at 8:33 AM, Jonathan Lundell wrote:
> > 
> >> I do something like this. Your details might vary.
> >> 
> >> #  invoke IS_STRONG only for password creation, not password checking
> >> if "login" not in request.args:
> >>   auth.settings.table_user.password.requires.insert(0, IS_STRONG(min=8, 
> >> max=0, special=1))
> >> 
> >> ...but I also define the entire auth table, so Massimo's method is handier 
> >> if you're using the default.
> >> 
> >> I think it'd be good if auth worked this way by default. There's no reason 
> >> to enforce IS_STRONG on login, and actually there's good reason *not* to, 
> >> since it enables an attacker to learn things about the actual password.
> > 
> > Actually, as I review the source, the only place I see IS_STRONG being 
> > invoked by default is in the admin app. So if you're adding IS_STRONG to 
> > your auth forms, just make it conditional as above.
> 
> ...and if that's right, perhaps we could put something like that (but with a 
> default IS_STRONG call?) into the scaffolding app, as an example.
> 
> Looks like the recent change in trunk was to CRYPT, not IS_STRONG. CRYPT now 
> checks for a minimum password length, which defaults to 4. If you're already 
> using IS_STRONG, then I suppose you could just set the min_length argument of 
> CRYPT to 1.
> 

Except that CRYPT is invoked inside Auth. 

1) I don't see a good reason for enforcing password length in CRPYT, and 2) 
password length (or strength) should never be enforced while checking.



Re: [web2py] Re: fluxflex

2011-08-21 Thread Martín Mulone
bye bye gae (?)

2011/8/21 Massimo Di Pierro 

> This is fantastic. I will be travelling in the next few hours but I
> look forward to try it. I have been looking for something like this
> for long time!
>
> Massimo
>
> On Aug 21, 7:37 am, Omi Chiba  wrote:
> > Ichino who is a member of web2py Japan created a library on fluxflex
> > and it works great !
> >
> > http://www.fluxflex.com/library/47
> >
> > 1. Sign up fluxflex
> > 2. Create new project (e.g. ochiba)
> > 3. Install the library (It will be done in one second!)
> > 4. Access to your project with HTTPS not HTTP (e.g.
> https://ochiba.fluxflex.com)
> > 5. Access Administrative Interface with /admin (e.g.
> https://ochiba.fluxflex.com/admin
> > )
> > 5. Admin password is the same as your MySQL database on fluxflex
> > project.
> >
> > Enjoy :)
>



-- 
 http://martin.tecnodoc.com.ar


[web2py] Re: cache.shelv problem

2011-08-21 Thread frasse
I think I fix the problem by change access permission for cache.lock
to 777.

On 21 Aug, 12:00, frasse  wrote:
> I hade a working application for some time now. now it stop working
> and it give the following error.
> the cache directory is exist and access permission is 775 to it .
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/main.py", line 485, in wsgibase
>     serve_controller(request, response, session)
>   File "/home/www-data/web2py/gluon/main.py", line 188, in
> serve_controller
>     environment = build_environment(request, response, session)
>   File "/home/www-data/web2py/gluon/compileapp.py", line 257, in
> build_environment
>     c = environment['cache'] = Cache(request)
>   File "/home/www-data/web2py/gluon/cache.py", line 376, in __init__
>     self.disk = CacheOnDisk(request)
>   File "/home/www-data/web2py/gluon/cache.py", line 261, in __init__
>     os.unlink(self.shelve_name)
> OSError: [Errno 2] No such file or directory: '/home/www-data/web2py/
> applications/myapp/cache/cache.shelve'
>
> Thanx
> Frasse


[web2py] Re: table, grid, smartgrid, getting better

2011-08-21 Thread mart
Hi Massimo,

So all is working great! I just have one question :)

i think I am making a real mess of things while trying to add an xtra
link.

this is in my test controller function:

def test()
table=SQLFORM.grid(db.buildSpec,links=[lambda
r:A('build',_href=(f=queue_it ...   --> the rest is way to ugly to
show ;)

return dict(table=table)


which should call this function when the link is clicked:

def queue_it():
Q=os.path.abspath('../../../Q')
id=request.args(2)

name=db(db[request.args(1)].id==id).select()\
.last().name

content=db(db[request.args(1)].id==id).select()\
.last().content

client_system=db(db[request.args(1)].id==id).select()\
.last().client_system

change=db(db[request.args(1)].id==id).select()\
.last().change

changed_by=db(db[request.args(1)].id==id).select()\
.last().changed_by

date=db(db[request.args(1)].id==id).select()\
.last().date

description=db(db[request.args(1)].id==id).select()\
.last().description

is_head=db(db[request.args(1)].id==id).select()\
.last().is_head

if os.path.exists(Q):
bsPath='{0}/{1}'.format(Q,name)
if os.path.exists(bsPath):
try:
os.remove(bsPath)
except Exception as err:
print('could not remove existing file
{0}\n{1}'.format(bsPath,err))

oFile=open(bsPath,'a')
for cItem in content.split('\n'):
if '
wrote:
> ;-D
>
> Think we will be needing a recent advance briefing email througth the
> list...
>
> Richard
>
> On Fri, Aug 19, 2011 at 5:57 AM, Martín Mulone wrote:
>
>
>
>
>
>
>
> > The web2py is advancing so fast, that the documentation get deprecated
> > before get published. :)
>
> > 2011/8/18 Massimo Di Pierro 
>
> >> Actually I just killed myself in the foot... I am writing a packt book
> >> with some other members of the list. Have to deliver it in 5 days.
> >> Today 10-20% of the book recipes become obsolete and I have to rewrite
> >> them. At the same time I am not ready to commit to the API of the new
> >> SQLFORM.grid.  :-(
>
> >> On Aug 18, 6:32 pm, mart  wrote:
> >> > WOW! Thank you! this is awesome! :)
>
> >> > Mart :)
>
> >> > On Aug 18, 5:03 pm, Massimo Di Pierro 
> >> > wrote:
>
> >> > > This is a new API so it expects a new syntax for represent that takes
> >> > > two arguments. The second argument is the record.
>
> >> > > On Aug 18, 2:47 pm, pbreit  wrote:
>
> >> > > > I'm getting errors on my tables. auth_user works OK but I get these
> >> errors
> >> > > > on three of my other tables.
>
> >> > > > Traceback (most recent call last):
> >> > > >   File "/Users/pbreit/web2py/gluon/restricted.py", line 194, in
> >> restricted
> >> > > >     exec ccode in environment
> >> > > >   File
> >> "/Users/pbreit/web2py/applications/init/controllers/default.py" <
> >>http://pb-dev.pricetack.com:8001/admin/edit/init/controllers/default.py>,
> >> line 107, in 
> >> > > >   File "/Users/pbreit/web2py/gluon/globals.py", line 145, in
> >> 
> >> > > >     self._caller = lambda f: f()
> >> > > >   File
> >> "/Users/pbreit/web2py/applications/init/controllers/default.py" <
> >>http://pb-dev.pricetack.com:8001/admin/edit/init/controllers/default.py>,
> >> line 12, in grid
> >> > > >     table = SQLFORM.grid(db.purchase)
> >> > > >   File "/Users/pbreit/web2py/gluon/sqlhtml.py", line 1408, in grid
> >> > > >     value=field.represent(value,row)
> >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3730, in repr_ref
> >> > > >     def repr_ref(id, r=referenced, f=ff): return f(r, id)
> >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3699, in ff
> >> > > >     row=r(id)
> >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3805, in __call__
> >> > > >     return self.__getitem__(key)
> >> > > >   File "/Users/pbreit/web2py/gluon/dal.py", line 3802, in
> >> __getitem__
> >> > > >     return dict.__getitem__(self, key)
> >> > > > KeyError: '1'
>
> >> > > > Traceback (most recent call last):
> >> > > >   File "/Users/pbreit/web2py/gluon/restricted.py", line 194, in
> >> restricted
> >> > > >     exec ccode in environment
> >> > > >   File
> >> "/Users/pbreit/web2py/applications/init/controllers/default.py" <
> >>http://pb-dev.pricetack.com:8001/admin/edit/init/controllers/default.py>,
> >> line 107, in 
> >> > > >   File "/Users/pbreit/web2py/gluon/globals.py", line 145, in
> >> 
> >> > > >     self._caller = lambda f: f()
> >> > > >   File
> >> "/Users/pbreit/web2py/applications/init/controllers/default.py" <
> >>http://pb-dev.pricetack.com:8001/admin/edit/init/controllers/default.py>,
> >> line 12, in grid
> >> > > >     table = SQLFORM.grid(db.item)
> >> > > >   File "/Users/pbreit/web2py/gluon/sqlhtml.py", line 1408, in grid
> >> > > >     value=field.represent(value,row)
> >> > > > TypeError: () takes exactly 1 argument (2 given)
>
> > --
> >  http://martin.tecnodoc.com.ar


Re: [web2py] An issue with trunk changes to password rules

2011-08-21 Thread Anthony
On Sunday, August 21, 2011 1:56:00 PM UTC-4, Jonathan Lundell wrote:
>
> On Aug 21, 2011, at 9:27 AM, Jonathan Lundell wrote:
>
> > On Aug 21, 2011, at 8:33 AM, Jonathan Lundell wrote:
> > 
> >> I do something like this. Your details might vary.
> >> 
> >> #  invoke IS_STRONG only for password creation, not password checking
> >> if "login" not in request.args:
> >>   auth.settings.table_user.password.requires.insert(0, IS_STRONG(min=8, 
> max=0, special=1))
> >> 
> >> ...but I also define the entire auth table, so Massimo's method is 
> handier if you're using the default.
> >> 
> >> I think it'd be good if auth worked this way by default. There's no 
> reason to enforce IS_STRONG on login, and actually there's good reason *not* 
> to, since it enables an attacker to learn things about the actual password.
> > 
> > Actually, as I review the source, the only place I see IS_STRONG being 
> invoked by default is in the admin app. So if you're adding IS_STRONG to 
> your auth forms, just make it conditional as above.
>
> ...and if that's right, perhaps we could put something like that (but with 
> a default IS_STRONG call?) into the scaffolding app, as an example.
>
Looks like the recent change in trunk was to CRYPT, not IS_STRONG. CRYPT now 
checks for a minimum password length, which defaults to 4. If you're already 
using IS_STRONG, then I suppose you could just set the min_length argument 
of CRYPT to 1.
 
Anthony 


Re: [web2py] An issue with trunk changes to password rules

2011-08-21 Thread Jonathan Lundell
On Aug 21, 2011, at 9:27 AM, Jonathan Lundell wrote:

> On Aug 21, 2011, at 8:33 AM, Jonathan Lundell wrote:
> 
>> I do something like this. Your details might vary.
>> 
>> #  invoke IS_STRONG only for password creation, not password checking
>> if "login" not in request.args:
>>   auth.settings.table_user.password.requires.insert(0, IS_STRONG(min=8, 
>> max=0, special=1))
>> 
>> ...but I also define the entire auth table, so Massimo's method is handier 
>> if you're using the default.
>> 
>> I think it'd be good if auth worked this way by default. There's no reason 
>> to enforce IS_STRONG on login, and actually there's good reason *not* to, 
>> since it enables an attacker to learn things about the actual password.
> 
> Actually, as I review the source, the only place I see IS_STRONG being 
> invoked by default is in the admin app. So if you're adding IS_STRONG to your 
> auth forms, just make it conditional as above.

...and if that's right, perhaps we could put something like that (but with a 
default IS_STRONG call?) into the scaffolding app, as an example.

[web2py] A Chinese website developed with web2py and Blueprint

2011-08-21 Thread chinakr
I recently rebuilt a website about Car Driving School with web2py and
Blueprint. The url of the website is as follow:

http://www.haijia.org/

I thought the default layout of web2py web development framework is a
little too complicated and less flexible, and the compatible problem
of IE 6 also annoyed me a lot. So I picked up the most popular
Blueprint CSS framework instead.

I wrote the layout_haijia.html to replace layout.html. The skeleton is
as follow, which is SEO optimized:





{{=response.title}} | {{=response.keywords}}







{{block head}}{{end}}





{{include}}



Then the new index.html can be wrote this way:

{{extend 'layout_haijia.html'}}


{{include request.controller+'/header.html'}}



The main content of the page.


The right sidebar of the page.



{{include request.controller+'/footer.html'}}


{{block head}}
http://ajax.googleapis.com/ajax/
libs/jquery/1.6.2/jquery.min.js">
{{end}}

The final things we have to do are writing static/css/haijia.css,
default/header.html, and default/footer.html.

The whole procedure is productive and painless. I recommend all of you
to try it -- the gold combination of web2py and Blueprint.


Re: [web2py] An issue with trunk changes to password rules

2011-08-21 Thread Jonathan Lundell
On Aug 21, 2011, at 8:33 AM, Jonathan Lundell wrote:

> I do something like this. Your details might vary.
> 
> #  invoke IS_STRONG only for password creation, not password checking
> if "login" not in request.args:
>auth.settings.table_user.password.requires.insert(0, IS_STRONG(min=8, 
> max=0, special=1))
> 
> ...but I also define the entire auth table, so Massimo's method is handier if 
> you're using the default.
> 
> I think it'd be good if auth worked this way by default. There's no reason to 
> enforce IS_STRONG on login, and actually there's good reason *not* to, since 
> it enables an attacker to learn things about the actual password.

Actually, as I review the source, the only place I see IS_STRONG being invoked 
by default is in the admin app. So if you're adding IS_STRONG to your auth 
forms, just make it conditional as above.

[web2py] Re: table, grid, smartgrid, getting better

2011-08-21 Thread JaapP
Thanks a lot; this works like a charm!!

On Aug 21, 4:59 pm, Massimo Di Pierro 
wrote:
> SQLFORM.grid(db.locatie,query=db.locatie.mutatie_user_id==auth.user.id)
>
> should be
>
> SQLFORM.grid(query=db.locatie.mutatie_user_id==auth.user.id)
>
> it will figure out the table automatically
>
> On Aug 21, 7:19 am, JaapP  wrote:
>
>
>
>
>
>
>
> > Hi Massimo,
>
> > i tried to play a little bit with the 'query=...' part but i can't get
> > it working;
>
> > #CONTROLLER
> > def locaties():
> >     locaties =
> > SQLFORM.grid(db.locatie,query=db.locatie.mutatie_user_id==auth.user.id)
> >     return dict(locaties=locaties)
>
> > Error:
> >    locaties =
> > SQLFORM.grid(db.locatie,query=db.locatie.mutatie_user_id==auth.user.id)
> > TypeError: grid() got multiple values for keyword argument 'query'
>
> > i tried to simplify the query, put () around the query but still the
> > same error message.
> > Do you have any idea what i'm doing wrong?
>
> > thanks for the great framework!!
>
> > Jaap


Re: [web2py] An issue with trunk changes to password rules

2011-08-21 Thread Jonathan Lundell
On Aug 21, 2011, at 7:45 AM, apple wrote:

> On trunk the password has to be over a certain length. If I try to
> login to an existing application with an existing user then it says my
> password is not long enough. However there is no way of changing it
> without logging in!

I do something like this. Your details might vary.

#  invoke IS_STRONG only for password creation, not password checking
if "login" not in request.args:
auth.settings.table_user.password.requires.insert(0, IS_STRONG(min=8, 
max=0, special=1))

...but I also define the entire auth table, so Massimo's method is handier if 
you're using the default.

I think it'd be good if auth worked this way by default. There's no reason to 
enforce IS_STRONG on login, and actually there's good reason *not* to, since it 
enables an attacker to learn things about the actual password.



[web2py] Re: An issue with trunk changes to password rules

2011-08-21 Thread apple
I can also just go into the admin interface and change the password to
meet the new rules.

However I thought it worth pointing out that changing the default
could cause issues for live systems running on web2py with a lot of
users.

On Aug 21, 4:02 pm, Massimo Di Pierro 
wrote:
> If you have the power to upgrade you have the power to do
>
> db.auth_user.password.requires[0].length=0
>
> You can also call "user/request_server_password".
>
> Massimo
>
> On Aug 21, 9:45 am, apple  wrote:
>
>
>
>
>
>
>
> > On trunk the password has to be over a certain length. If I try to
> > login to an existing application with an existing user then it says my
> > password is not long enough. However there is no way of changing it
> > without logging in!


[web2py] Re: fluxflex

2011-08-21 Thread Massimo Di Pierro
This is fantastic. I will be travelling in the next few hours but I
look forward to try it. I have been looking for something like this
for long time!

Massimo

On Aug 21, 7:37 am, Omi Chiba  wrote:
> Ichino who is a member of web2py Japan created a library on fluxflex
> and it works great !
>
> http://www.fluxflex.com/library/47
>
> 1. Sign up fluxflex
> 2. Create new project (e.g. ochiba)
> 3. Install the library (It will be done in one second!)
> 4. Access to your project with HTTPS not HTTP 
> (e.g.https://ochiba.fluxflex.com)
> 5. Access Administrative Interface with /admin 
> (e.g.https://ochiba.fluxflex.com/admin
> )
> 5. Admin password is the same as your MySQL database on fluxflex
> project.
>
> Enjoy :)


[web2py] Re: An issue with trunk changes to password rules

2011-08-21 Thread Massimo Di Pierro
If you have the power to upgrade you have the power to do

db.auth_user.password.requires[0].length=0

You can also call "user/request_server_password".

Massimo

On Aug 21, 9:45 am, apple  wrote:
> On trunk the password has to be over a certain length. If I try to
> login to an existing application with an existing user then it says my
> password is not long enough. However there is no way of changing it
> without logging in!


[web2py] Re: table, grid, smartgrid, getting better

2011-08-21 Thread Massimo Di Pierro
SQLFORM.grid(db.locatie,query=db.locatie.mutatie_user_id==auth.user.id)

should be

SQLFORM.grid(query=db.locatie.mutatie_user_id==auth.user.id)

it will figure out the table automatically

On Aug 21, 7:19 am, JaapP  wrote:
> Hi Massimo,
>
> i tried to play a little bit with the 'query=...' part but i can't get
> it working;
>
> #CONTROLLER
> def locaties():
>     locaties =
> SQLFORM.grid(db.locatie,query=db.locatie.mutatie_user_id==auth.user.id)
>     return dict(locaties=locaties)
>
> Error:
>    locaties =
> SQLFORM.grid(db.locatie,query=db.locatie.mutatie_user_id==auth.user.id)
> TypeError: grid() got multiple values for keyword argument 'query'
>
> i tried to simplify the query, put () around the query but still the
> same error message.
> Do you have any idea what i'm doing wrong?
>
> thanks for the great framework!!
>
> Jaap


[web2py] An issue with trunk changes to password rules

2011-08-21 Thread apple
On trunk the password has to be over a certain length. If I try to
login to an existing application with an existing user then it says my
password is not long enough. However there is no way of changing it
without logging in!


[web2py] Re: built-in lazy virtual fields

2011-08-21 Thread Carlos
Hi Massimo,

Not in my case, I only want to have the same fake/virtual/lazy fields (not 
rows) in all my rows, but using 'self' to access the direct rows (instead of 
via their table names), therefore my proposal above.

It would also be great to have 'access' (subclass / extend) to all other DAL 
objects (e.g. Set, Rows), but that's another topic.

Please let me know if what I explain is not clear - thanks!,

   Carlos



[web2py] fluxflex

2011-08-21 Thread Omi Chiba
Ichino who is a member of web2py Japan created a library on fluxflex
and it works great !

http://www.fluxflex.com/library/47

1. Sign up fluxflex
2. Create new project (e.g. ochiba)
3. Install the library (It will be done in one second!)
4. Access to your project with HTTPS not HTTP (e.g. https://ochiba.fluxflex.com)
5. Access Administrative Interface with /admin (e.g. 
https://ochiba.fluxflex.com/admin
)
5. Admin password is the same as your MySQL database on fluxflex
project.

Enjoy :)




[web2py] Re: table, grid, smartgrid, getting better

2011-08-21 Thread JaapP
Hi Massimo,

i tried to play a little bit with the 'query=...' part but i can't get
it working;

#CONTROLLER
def locaties():
locaties =
SQLFORM.grid(db.locatie,query=db.locatie.mutatie_user_id==auth.user.id)
return dict(locaties=locaties)

Error:
   locaties =
SQLFORM.grid(db.locatie,query=db.locatie.mutatie_user_id==auth.user.id)
TypeError: grid() got multiple values for keyword argument 'query'

i tried to simplify the query, put () around the query but still the
same error message.
Do you have any idea what i'm doing wrong?

thanks for the great framework!!

Jaap


[web2py] Re: Google datastore concepts - denormalising and list:reference fields

2011-08-21 Thread fishwebby
Ah ok, that makes sense. Is it really that easy to come up with a web
request that takes more than thirty seconds? I'll have to watch out
for that...

I'm thinking now that I'm going about this the wrong way as regards
the design for the datastore - from what I've read, "contains" is an
efficient way to query based on a list:reference field, so I'm
considering having a field on the course model for people, so I can
say something like

courses = db(db.course.people.contains(person.id)).select()

This would make it more complicated in the controller when I'm
updating and inserting rows, but the queries would be efficient. As
far as sorting goes, if there is a risk of the request timing out I
could even do it in the browser (using a YUI datatable or something to
display the data).

Thank you for your help!


On Aug 20, 8:15 pm, howesc  wrote:
> right, so when i need to do a belongs query for more than 30 items:
>
>     items=db(db.my_table.end_user.belongs(id_list[0:30])).select()
>     for i in range(30, len(id_list)+30, 30):
>         items = items & \
>                   db(db.my_table.end_user.belongs(id_list[i-30:i])).select()
>
> i'd say that web2py should just do that for you, but on GAE you want to be
> aware that this is happening because it can easily eat up all 30 seconds
> that you have to service a web request, so i like that i have to do it
> explicitly (i only try to do queries like this in taskqueue tasks where i
> know i can process more data per request)
>
> for one to many relationship you can use the list:reference property that
> maps to the GAE list property.  then when you get a row you have a property
> that has all the IDs of the records that 'belong' to it, and you can query
> for them (perhaps using the above if there is more than 30 in the list)
>
> hope that helps a little!
>
> christian
>
> while it takes more queries, there is nothing stopping you from:
>
>   item_refs = db(db.join_table.sidea=ref_a).select()
>   items = db(db.sideb_table.id.belongs(item_refs.as_dict().keys()).select()
>
> it feels yucky by comparison to SQL but it works.  i do try and avoid it
> because it is inefficient.


[web2py] cache.shelv problem

2011-08-21 Thread frasse
I hade a working application for some time now. now it stop working
and it give the following error.
the cache directory is exist and access permission is 775 to it .

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/main.py", line 485, in wsgibase
serve_controller(request, response, session)
  File "/home/www-data/web2py/gluon/main.py", line 188, in
serve_controller
environment = build_environment(request, response, session)
  File "/home/www-data/web2py/gluon/compileapp.py", line 257, in
build_environment
c = environment['cache'] = Cache(request)
  File "/home/www-data/web2py/gluon/cache.py", line 376, in __init__
self.disk = CacheOnDisk(request)
  File "/home/www-data/web2py/gluon/cache.py", line 261, in __init__
os.unlink(self.shelve_name)
OSError: [Errno 2] No such file or directory: '/home/www-data/web2py/
applications/myapp/cache/cache.shelve'


Thanx
Frasse


[web2py] Re: How to get the referenced objects from a list:reference

2011-08-21 Thread fishwebby
Just tried that, and all that does is return a comma separated list of
the course titles - a bit closer but I need the objects really as I
want to access other properties of them.

I'm beginning to think that either I don't understand GAE enough or
it's not useful for the app I'm developing (which would be a shame, as
I really like the idea of hassle-free deployment and scaleability)

Dave


On Aug 20, 11:42 pm, Anthony  wrote:
> Does db.person.courses.represent(person.coures) work? 
> Seehttp://web2py.com/book/default/chapter/06#Many-to-Many,-list:,-and-contains
> .
>
> Anthony
>
>
>
>
>
>
>
> On Saturday, August 20, 2011 1:58:04 PM UTC-4, fishwebby wrote:
> > Hi, I'm trying to do something quite straightforward but can't seem to
> > work out how to do it: for a list:reference field, get all the items
> > in the reference field (not just their IDs).
>
> > For example, a person with many courses:
>
> > db.define_table('course', Field('title'))
>
> > db.define_table('person',
> >   Field('name'),
> >   Field('courses', 'list:reference course'))
>
> > First I'm finding a person by ID:
>
> > person = db(db.person.id==id).select().first()
>
> > Then I want to get a list of courses - "person.courses" just returns a
> > list of IDs. I could use "belongs" with those IDs but I believe that
> > has a limit of 30 on GAE so I can't use that.
>
> > Is there some way of selecting the objects in the reference, something
> > like
>
> > db(person.courses).select() ?


Re: [web2py] Re: GAE questions...

2011-08-21 Thread Sebastian E. Ovide
thanks cfh,

that's great... web2py now supports GAE native lists !!!

any idea if it is possible to use Expanto and PolyModel classes  ?

On Sat, Aug 20, 2011 at 7:07 PM, howesc  wrote:

> i use list fields (which now implemented using the GAE native list property
> and string list property) liberally.
>
> in places where i wish i had a join, i tend to use the web2py syntax that
> does the subquery for me:
>   item.user.name
> where item is a Row, with a field user that is a reference to the user
> table, and name is a field on the user.  keep in mind that this does the
> query, just under the covers.
>
> cfh
>



-- 
Sebastian E. Ovide


[web2py] Re: UserGroups: Extend Auth_Group or Table Inheritance?

2011-08-21 Thread Massimo Di Pierro
The question is: do you use a auth_groups to manage internal working
of the app or not? For example to you have user roles like "manager"
or "admin" etc. If so you may want to expose a different mechanism to
users. If you can use auth_groups (because you are not using it
already or you you plan to add checks to avoid conflicts, by all
means, you should use that, as it will save work later.

Massimo

On Aug 21, 12:20 am, Anaconda  wrote:
> I am looking to allow users to create their own groups and have
> members. Which is more effecient:
>
> Table Inheritance:
> db.define_table('user_groups', db.auth_group,
> Field('name') ...ect...))
>
> or
> Extend auth_group:
>
> db.define_table(
>    auth.settings.table_user_group,
>   Field('role', length=512, default='',
> label=auth.messages.label_role),
>   Field('description', 'text',
> label=auth.messages.label_description),
>   Field('name', length=128, default='', unique=True))
>
> custom_auth_group = db[auth.settings.table_user_group]
>
> # auth.define_tables()
>
> Thanks in advance for any help!!


[web2py] Re: built-in lazy virtual fields

2011-08-21 Thread Massimo Di Pierro
Is the goal to append fake (virtual) rows to the result of a
select(...)

Massimo

On Aug 20, 11:33 am, Carlos  wrote:
> Hi Massimo,
>
> So far this is great !
>
> But, while we're on the lazy fields topic, can you implement the following
> specialized VirtualCommand (maybe named Virtual*Row*Command)?:
>
>     class VirtualRowCommand(object):
>         def __init__(self, method, row):
>             self.method = method
>             if len(row) != 1:
>                 a + b # raise an error.
>             self.row = *row.values()[0]*
>         def __call__(self, *args, **kwargs):
>             return self.method(self.row, *args, **kwargs)
>
> In my case, all my rows are a single item (whith is the table name), so it
> would be much better and simpler to use 'self' for the direct row (see
> "row.values()[0]" above).
>
> This way I can use virtual fields as follow:
>
>     class VirtualTest(object):
>         def x_id(vv, self):
>             return *self*.id
>
> Note that 'vv' (or any other name) is the VirtualTest instance (which I
> don't really care about), and 'self' is the actual specific row.
>
> Can you please consider this approach or something similar that accomplishes
> the same thing?.
>
> Thanks!,
>
>    Carlos