[web2py] Re: ReCaptcha and SQLForm

2011-04-12 Thread pbreit
This seems to work but you might need to play around with the layout (need 
to replace recaptcha keys).

def captcha_form():
public_key = 'xxx'
private_key = 'xxx'
form = SQLFORM(db.confession)
form[0].append(TR('',Recaptcha(request, public_key, private_key),''))
if form.accepts(request.vars, session):
response.flash = 'form accepted'
elif form.errors.has_key('captcha'):
response.flash='invalid capctha'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill the form'
return dict(form=form)


[web2py] request.args error on module

2011-04-12 Thread pbreit
I usually just put those functions in the models folder. Much easier.

I would highly recommend trying to keep things simple.


[web2py] Re: shortcut for table_is empty?

2011-04-12 Thread Massimo Di Pierro


On Apr 12, 10:06 pm, mart  wrote:
> Just tried this:
>
> test = db(db.cumulativeProperties.id>0).select(limitby=(0,1))
> print 'test: {0}'.format(test)
>
> results:
> cumulativeProperties.id,cumulativeProperties.uuid,cumulativeProperties.name 
> ,cumulativeProperties.value,cumulativeProperties.tag,cumulativeProperties.c 
> mdName
> 1,365674dc-6371-4215-ad44-c35b5f6159bf,ftp_user,nmcbuild,,None
>
> perfect :) and the bonus, makes it easy and quick to test if
> individual fields have content as well just by looping through results
> and doing dict(testItems).keys(). If a given field has value,it can
> also indicate a met or unmet condition.
>
> question: if i do the this, i get a 'update_record' in the returned
> list, does that indicate that something has in fact updated the
> record?

no the record was not touched

> and would 'isempty' be a shortcut for ...select(limitby=(0,1) and
> return the same data?
>
> thanks,
> Mart :)
>
> On Apr 12, 5:11 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > may be faster to do
>
> > db(db.tablename.id>0).select(limitby=(0,1))
>
> > perhaps we should have something like:
>
> > db(db.tablename).isempty()
>
> > On Apr 12, 12:02 pm, Marin Pranjic  wrote:
>
> > > Something like db(db.tablename.id>0).count() ?
>
> > > On Tue, Apr 12, 2011 at 5:22 PM, mart  wrote:
> > > > Hi,
>
> > > > is there a shortcut  to check if a table is empty? (not look to see
> > > > what the content is, just if it has any at all)
>
> > > > Thanks,
> > > > Mart :)


[web2py] Re: shortcut for table_is empty?

2011-04-12 Thread mart
Just tried this:

test = db(db.cumulativeProperties.id>0).select(limitby=(0,1))
print 'test: {0}'.format(test)


results:
cumulativeProperties.id,cumulativeProperties.uuid,cumulativeProperties.name,cumulativeProperties.value,cumulativeProperties.tag,cumulativeProperties.cmdName
1,365674dc-6371-4215-ad44-c35b5f6159bf,ftp_user,nmcbuild,,None

perfect :) and the bonus, makes it easy and quick to test if
individual fields have content as well just by looping through results
and doing dict(testItems).keys(). If a given field has value,it can
also indicate a met or unmet condition.

question: if i do the this, i get a 'update_record' in the returned
list, does that indicate that something has in fact updated the
record?

and would 'isempty' be a shortcut for ...select(limitby=(0,1) and
return the same data?

thanks,
Mart :)


On Apr 12, 5:11 pm, Massimo Di Pierro 
wrote:
> may be faster to do
>
> db(db.tablename.id>0).select(limitby=(0,1))
>
> perhaps we should have something like:
>
> db(db.tablename).isempty()
>
> On Apr 12, 12:02 pm, Marin Pranjic  wrote:
>
>
>
>
>
>
>
> > Something like db(db.tablename.id>0).count() ?
>
> > On Tue, Apr 12, 2011 at 5:22 PM, mart  wrote:
> > > Hi,
>
> > > is there a shortcut  to check if a table is empty? (not look to see
> > > what the content is, just if it has any at all)
>
> > > Thanks,
> > > Mart :)


[web2py] Re: powertable question about bStateSave

2011-04-12 Thread tomt
Whoops, I made a mistake. Page position is lost when:
table.showkeycolumn = False

but the "solution" is the same... fnDraw(false)

On Apr 12, 8:02 pm, tomt  wrote:
> Hi,
>
> I discovered why pagination is lost.  When table.showkeycolumn = true
> then at line 733
>
> hidekeycolumnjs = "var hidekeycolumn =
> 200;oTable.fnSetColumnVis(0,false);oTable.fnDraw();"
>
> The datatable API says that fnDraw() has the side effect of resetting
> the pagination
>
> If the call is changed to "... oTable.fnDraw(false)" then pagination
> is not lost.
>
> I don't know if this change would have any negative effects, but so
> far it has worked for me.
>
> - Tom
>
> On Apr 7, 7:54 am, Bruno Rocha  wrote:
>
> > I,m Sorry. I am without time to dedicate to powerTable now. I hope to get
> > this project back soon and I will start to fix some issues and implement the
> > TODOs. (any volunteer?)
>
> > The state saving is a Java Script issue and it is explained 
> > here:http://datatables.net/examples/basic_init/state_save.html
>
> > I will take a look in to it.
> > --
> > Bruno Rocha
> > [ About me:http://zerp.ly/rochacbruno]
>
> > On Thu, Apr 7, 2011 at 12:49 AM, tomt  wrote:
> > > Hi,
>
> > > I'm using powertable and set table.dtfeatures['bStateSave'] = True
> > > The search parameters are saved successfully, but the page position
> > > is not being restored. The cookie created by powertable saves
> > > iStart and iEnd but they don't appear to be used.
>
> > > I looked at the plugin_powertable.py code, but it was not easy to
> > > determine how bStateSave was processed.
>
> > > Is it possible to restore page position with powertable?
>
> > > Any hints or suggestions would be appreciated.
>
> > > thx, - Tom
>
>


[web2py] Re: powertable question about bStateSave

2011-04-12 Thread tomt
Hi,

I discovered why pagination is lost.  When table.showkeycolumn = true
then at line 733

hidekeycolumnjs = "var hidekeycolumn =
200;oTable.fnSetColumnVis(0,false);oTable.fnDraw();"

The datatable API says that fnDraw() has the side effect of resetting
the pagination

If the call is changed to "... oTable.fnDraw(false)" then pagination
is not lost.

I don't know if this change would have any negative effects, but so
far it has worked for me.

- Tom






On Apr 7, 7:54 am, Bruno Rocha  wrote:
> I,m Sorry. I am without time to dedicate to powerTable now. I hope to get
> this project back soon and I will start to fix some issues and implement the
> TODOs. (any volunteer?)
>
> The state saving is a Java Script issue and it is explained 
> here:http://datatables.net/examples/basic_init/state_save.html
>
> I will take a look in to it.
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]
>
> On Thu, Apr 7, 2011 at 12:49 AM, tomt  wrote:
> > Hi,
>
> > I'm using powertable and set table.dtfeatures['bStateSave'] = True
> > The search parameters are saved successfully, but the page position
> > is not being restored. The cookie created by powertable saves
> > iStart and iEnd but they don't appear to be used.
>
> > I looked at the plugin_powertable.py code, but it was not easy to
> > determine how bStateSave was processed.
>
> > Is it possible to restore page position with powertable?
>
> > Any hints or suggestions would be appreciated.
>
> > thx, - Tom
>
>


[web2py] Re: secure connection to database ¿?

2011-04-12 Thread Massimo Di Pierro
yes from the point of the web2py all and from the point of view of the
postgresql server.



On Apr 12, 5:36 pm, luis diaz  wrote:
> thanks for the reply.
>
> I had intended to use for the tunnel: autossh
>
> in the configuration of postgresql:
> allowed the ip of the vps, running the app
>
> the ideas of restricting access only to 127.0.0.1
> not thought of it.
>
> My new question:
> to making the tunnel, the connection to the db is done as if you were on
> 127.0.0.1?


[web2py] Re: ReCaptcha and SQLForm

2011-04-12 Thread Drise
Hm... I've also tried there too. Seems only to contain a method for CRUD and 
auth, which I would honestly like to avoid, but if I need to, which it seems 
I do, I'll use it.

Re: [web2py] Re: bulk insert form

2011-04-12 Thread Stifan Kristi
thank you so much villas for your share, i'll try to modify it for inserts.

best regards,

steve van christie

On Wed, Apr 13, 2011 at 8:43 AM, villas  wrote:

> I use this code for updating multiple records,  maybe you could use
> something similar for inserts.
>
>  controller --
> myrecords=db(query).select(db.table.ALL)
> if form.accepts ...
>for r in myrecords:
>if request.vars.has_key('id%i_price' % r.table.id):
>r.table.update_record(price=request.vars['id%i_price'%
> r.table.id])
>
> - view --
> 
> {{for record in myrecords:}}
>  
>{{=record.carprice.id}}
> value={{=record.table.price}}/>
>  
> {{pass}}
> ...
>
> On Apr 12, 5:31 am, 黄祥  wrote:
> > hi,
> >
> > is it possible to insert several data simultanously (bulk insert) in
> > web2py using crud or sqlform? i mean, like select several image file
> > and then upload it, or maybe using jquery add or remove form field
> > any suggestion or reference for doing that?
> >
> > thank you so much


[web2py] Re: bulk insert form

2011-04-12 Thread villas
I use this code for updating multiple records,  maybe you could use
something similar for inserts.

 controller --
myrecords=db(query).select(db.table.ALL)
if form.accepts ...
for r in myrecords:
if request.vars.has_key('id%i_price' % r.table.id):
r.table.update_record(price=request.vars['id%i_price'%
r.table.id])

- view --

{{for record in myrecords:}}
  
{{=record.carprice.id}}

  
{{pass}}
...

On Apr 12, 5:31 am, 黄祥  wrote:
> hi,
>
> is it possible to insert several data simultanously (bulk insert) in
> web2py using crud or sqlform? i mean, like select several image file
> and then upload it, or maybe using jquery add or remove form field
> any suggestion or reference for doing that?
>
> thank you so much


[web2py] request.args error on module

2011-04-12 Thread 黄祥
hi all,

i have a lot of code that used by another controller:
e.g.

def show():
page = db.author(request.args(0)) or redirect(URL('index'))
return dict(page = page)

so, i plan to use a module that contain repeated def function:
e.g.
module :

def show(request, db):
page = db(request.args(0)) or redirect(URL(request.application,
request.controller, 'index'))
return dict(page = page)

controller :
mymodule = local_import('module')

def show():
return mymodule.show(request, db = db.author)

an error occured, 'Field' object is not callable', is there anybody
know how to pass request.args(0) or request.args on the module please?

thank you in advance

steve van christie


[web2py] Re: ReCaptcha and SQLForm

2011-04-12 Thread DenesL

See 
http://www.web2py.com/book/default/chapter/08?search=captcha#CAPTCHA-and-reCAPTCHA


On Apr 12, 8:05 pm, Drise  wrote:
> Also, I need to have it show no matter, so I don't need to append it.
> I just need to have it display always.
>
> On Apr 12, 6:45 pm, Drise  wrote:
>
>
>
>
>
>
>
> > I've already read through that, and tried to dissect it and use it for
> > what I need, but it didn't work (and slightly confused me more).
>
> > On Apr 12, 6:42 pm, Drise  wrote:
>
> > > Traceback (most recent call last):
> > >   File "gluon/restricted.py", line 188, in restricted
> > >   File "C:/Users/Drise/Desktop/web2py/applications/MinecraftAnonymous/
> > > controllers/default.py", line 69, in 
> > >   File "gluon/globals.py", line 124, in 
> > >   File "C:/Users/Drise/Desktop/web2py/applications/MinecraftAnonymous/
> > > controllers/default.py", line 30, in submit
> > > NameError: global name 'captcha' is not defined
>
> > > On Apr 12, 6:12 pm, pbreit  wrote:
>
> > > > I see this suggestion:
> > > > form[0].append(TR('',captcha, ''))
>
> > > >https://groups.google.com/d/topic/web2py/eeMT2Bb-KYA/discussion


[web2py] Re: ReCaptcha and SQLForm

2011-04-12 Thread Drise
Also, I need to have it show no matter, so I don't need to append it.
I just need to have it display always.

On Apr 12, 6:45 pm, Drise  wrote:
> I've already read through that, and tried to dissect it and use it for
> what I need, but it didn't work (and slightly confused me more).
>
> On Apr 12, 6:42 pm, Drise  wrote:
>
>
>
>
>
>
>
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 188, in restricted
> >   File "C:/Users/Drise/Desktop/web2py/applications/MinecraftAnonymous/
> > controllers/default.py", line 69, in 
> >   File "gluon/globals.py", line 124, in 
> >   File "C:/Users/Drise/Desktop/web2py/applications/MinecraftAnonymous/
> > controllers/default.py", line 30, in submit
> > NameError: global name 'captcha' is not defined
>
> > On Apr 12, 6:12 pm, pbreit  wrote:
>
> > > I see this suggestion:
> > > form[0].append(TR('',captcha, ''))
>
> > >https://groups.google.com/d/topic/web2py/eeMT2Bb-KYA/discussion


[web2py] Re: ReCaptcha and SQLForm

2011-04-12 Thread Drise
I've already read through that, and tried to dissect it and use it for
what I need, but it didn't work (and slightly confused me more).

On Apr 12, 6:42 pm, Drise  wrote:
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 188, in restricted
>   File "C:/Users/Drise/Desktop/web2py/applications/MinecraftAnonymous/
> controllers/default.py", line 69, in 
>   File "gluon/globals.py", line 124, in 
>   File "C:/Users/Drise/Desktop/web2py/applications/MinecraftAnonymous/
> controllers/default.py", line 30, in submit
> NameError: global name 'captcha' is not defined
>
> On Apr 12, 6:12 pm, pbreit  wrote:
>
>
>
>
>
>
>
> > I see this suggestion:
> > form[0].append(TR('',captcha, ''))
>
> >https://groups.google.com/d/topic/web2py/eeMT2Bb-KYA/discussion


[web2py] Re: ReCaptcha and SQLForm

2011-04-12 Thread Drise
Traceback (most recent call last):
  File "gluon/restricted.py", line 188, in restricted
  File "C:/Users/Drise/Desktop/web2py/applications/MinecraftAnonymous/
controllers/default.py", line 69, in 
  File "gluon/globals.py", line 124, in 
  File "C:/Users/Drise/Desktop/web2py/applications/MinecraftAnonymous/
controllers/default.py", line 30, in submit
NameError: global name 'captcha' is not defined

On Apr 12, 6:12 pm, pbreit  wrote:
> I see this suggestion:
> form[0].append(TR('',captcha, ''))
>
> https://groups.google.com/d/topic/web2py/eeMT2Bb-KYA/discussion


[web2py] Re: Powerpack

2011-04-12 Thread mart
Bravo!

On Apr 12, 5:50 pm, Massimo Di Pierro 
wrote:
> wow...can we make easier for user to install? Can we add this to the
> list of wizard plugins?
>
> On Apr 12, 4:34 pm, pbreit  wrote:
>
>
>
>
>
>
>
> > Wow, great packaging! Will definitely have a look.


Re: [web2py] Re: Powerpack

2011-04-12 Thread Stifan Kristi
amazing, i'll try it...


Re: [web2py] Re: bulk insert form

2011-04-12 Thread Stifan Kristi
a, i am understand right now, thank you so much for your explaination, greg.

best regards,

steve van christie


[web2py] Re: ReCaptcha and SQLForm

2011-04-12 Thread pbreit
I see this suggestion:
form[0].append(TR('',captcha, '')) 

https://groups.google.com/d/topic/web2py/eeMT2Bb-KYA/discussion


[web2py] ReCaptcha and SQLForm

2011-04-12 Thread Drise
I know this is probably really simple, however, I'm somewhat new to
Web2py. I have

def submit():
form = SQLFORM(db.confession)

This form doesnt require a login, so to avoid spam, I would like to
implement a captcha. I'd rahter not use Crud, as I'm much more
familiar with sqlform, and it seems more customizable. Unless I'm
mistaken, how can I do this? And if I am mistaken, how qwould I
implement it with CRUD?


[web2py] Re: secure connection to database ¿?

2011-04-12 Thread luis diaz
thanks for the reply.

I had intended to use for the tunnel: autossh

in the configuration of postgresql:
allowed the ip of the vps, running the app


the ideas of restricting access only to 127.0.0.1
not thought of it.


My new question:
to making the tunnel, the connection to the db is done as if you were on 
127.0.0.1?


[web2py] Re: Powerpack

2011-04-12 Thread Massimo Di Pierro
wow...can we make easier for user to install? Can we add this to the
list of wizard plugins?

On Apr 12, 4:34 pm, pbreit  wrote:
> Wow, great packaging! Will definitely have a look.


[web2py] Re: bulk insert form

2011-04-12 Thread Gregory Hellings
It probably isn't helpful for multiple file uploads, but you can do
bulk insert with the CSV interface. You might need to write a little
JavaScript magic to convert multiple forms into a CSV format, but it
shouldn't be terribly difficult.

For multiple uploads, you could just put multiple forms on a page,
hidden, and just unhide them with JavaScript when requested. Then use
the standard SQLFORM and CRUD validation tools to handle multiple
forms on a single page, but allow them to be optional instead of
producing page errors when they are not filled in.  There is a section
in the web2py book about multiple forms on a single page.  Of course,
that necessitates setting a predetermined limit on the number of
simultaneous bulk creations.

--Greg

On Apr 11, 11:31 pm, 黄祥  wrote:
> hi,
>
> is it possible to insert several data simultanously (bulk insert) in
> web2py using crud or sqlform? i mean, like select several image file
> and then upload it, or maybe using jquery add or remove form field
> any suggestion or reference for doing that?
>
> thank you so much


[web2py] Re: plugins

2011-04-12 Thread Anthony
Let's add Martin's Powerpack to the list: 
https://bitbucket.org/mulonemartin/powerpack/wiki/Home
 

On Friday, March 11, 2011 9:48:26 AM UTC-5, Massimo Di Pierro wrote: 
>
> I did a very poor job at keeping track of community created plugins. 
>
> If you are aware of a plugin for web2py that is not listed on 
> http://web2py.com/plugins can please add a link to this thread with a 
> small description? 
>
> Massimo



[web2py] Re: Powerpack

2011-04-12 Thread pbreit
Wow, great packaging! Will definitely have a look.

[web2py] Re: Powerpack

2011-04-12 Thread Anthony
Awesome! Thanks a lot, Martin. :)

On Tuesday, April 12, 2011 5:19:51 PM UTC-4, Martin.Mulone wrote:

> Powerpack App = Plugin Instant Press + Plugins Comments + Plugins
>
> Intro: http://www.youtube.com/watch?v=nvvWE2rVnR0
>
> https://bitbucket.org/mulonemartin/powerpack/wiki/Home
>
> -- 
>  My blog: http://martin.tecnodoc.com.ar
> Expert4Solution: http://www.experts4solutions.com/e4s/default/expert/6 
> http://www.cvstash.com/profile/Xzi5bWCdD
>
>
>

[web2py] Re: Bookings Manager

2011-04-12 Thread pbreit
I almost never advise an Ajax solution first but this might be a reasonable 
way to go. This will work for 10s of rooms but probably not 100s since you 
have to click once to verify each room. You can choose whatever statuses you 
want. I have it so that it becomes "verified" when you click the link.

=== db.py ===
db.define_table('room',
Field('name'), 
Field('status'))

=== default.py ===
def index():
rooms = db(db.room.id>0).select()
return dict(rooms=rooms)

def update_status():
room = db(db.room.id==request.vars.id).select().first()
room.update_record(status='verified')
return room.status

=== index.html ===
{{extend 'layout.html'}}


{{for room in rooms:}}
{{=room.name}} - {{=room.status}}
{{pass}}





[web2py] Re: Web2Py and IntelliJ Idea

2011-04-12 Thread mikech
We are voting for PyCharm to support Web2Py  see this 
thread: https://groups.google.com/d/topic/web2py/JN7PLI93Vp0/discussion



[web2py] Powerpack

2011-04-12 Thread Martín Mulone
Powerpack App = Plugin Instant Press + Plugins Comments + Plugins

Intro: http://www.youtube.com/watch?v=nvvWE2rVnR0

https://bitbucket.org/mulonemartin/powerpack/wiki/Home

-- 
My blog: http://martin.tecnodoc.com.ar
Expert4Solution: http://www.experts4solutions.com/e4s/default/expert/6
http://www.cvstash.com/profile/Xzi5bWCdD


[web2py] Re: Bookings Manager

2011-04-12 Thread b00m_chef
You need to add a db Boolean field for "validated". You will need to
set default to False. Then simply have the admin validate page return
all records in db that have validation=False.



On Apr 11, 6:27 pm, Ialejandro  wrote:
> Hi everybody!! Again with my booking example, but now I'm really
> stucked.
>
> I have this model:
>
> ***
>
> if auth.is_logged_in():
>     me = auth.user.id
> else:
>     me = None
>
> db.define_table('room'
>     Field('name','string'),
>     Field('ubication','string'),
>     Field('comment','string'))
>
> db.define_table('booking',
>     Field('room',db.room),
>
> Field('createdby',db.auth_user,default=me,writable=False,readable=False),
>     Field('comments','string'))
>
> Then I have this logic:
>
> Any logged user can make a booking via:
>
> crud.create(db.booking)
>
> I need an admin page where an admin can view ALL the made bookings,
> and he NEEDS to validate them, so I imagine a list of check boxes like
> this:
>
> Room1     [ ]
> Room2     [ ]
> Room3     [ ]
> Room4     [ ]
>
> [SUBMIT]
>
> And then the users can see if their booking has been approved.
>
> How could I do this???
>
> No matter how, could be checkboxes, a list, but what I need is to have
> every booking validated.
>
> Thanks! I really appreciate your help because that's for my final
> school project.
>
> Thanks!


[web2py] Re: shortcut for table_is empty?

2011-04-12 Thread Massimo Di Pierro
may be faster to do

db(db.tablename.id>0).select(limitby=(0,1))

perhaps we should have something like:

db(db.tablename).isempty()






On Apr 12, 12:02 pm, Marin Pranjic  wrote:
> Something like db(db.tablename.id>0).count() ?
>
>
>
>
>
>
>
> On Tue, Apr 12, 2011 at 5:22 PM, mart  wrote:
> > Hi,
>
> > is there a shortcut  to check if a table is empty? (not look to see
> > what the content is, just if it has any at all)
>
> > Thanks,
> > Mart :)


[web2py] Re: shortcut for table_is empty?

2011-04-12 Thread mart
Yeah, that's what I ended up using... was really looking for a
boolean, so I faked it (def isEmpty(tb): returns True if empty, False
if not).

Was just looking to see if there was one already.
Thanks for the reply
Mart :)


On Apr 12, 1:02 pm, Marin Pranjic  wrote:
> Something like db(db.tablename.id>0).count() ?
>
>
>
>
>
>
>
> On Tue, Apr 12, 2011 at 5:22 PM, mart  wrote:
> > Hi,
>
> > is there a shortcut  to check if a table is empty? (not look to see
> > what the content is, just if it has any at all)
>
> > Thanks,
> > Mart :)


Re: [web2py] Bookings Manager

2011-04-12 Thread Ismael Alejandro


On Mon, Apr 11, 2011 at 8:27 PM, Ialejandro  wrote:

> Hi everybody!! Again with my booking example, but now I'm really
> stucked.
>
>
> I have this model:
>
>
> ***
>
> if auth.is_logged_in():
>me = auth.user.id
> else:
>me = None
>
> db.define_table('room'
>Field('name','string'),
>Field('ubication','string'),
>Field('comment','string'))
>
> db.define_table('booking',
>Field('room',db.room),
>
> Field('createdby',db.auth_user,default=me,writable=False,readable=False),
>Field('comments','string'))
>
>
>
> Then I have this logic:
>
>
> Any logged user can make a booking via:
>
> crud.create(db.booking)
>
>
> I need an admin page where an admin can view ALL the made bookings,
> and he NEEDS to validate them, so I imagine a list of check boxes like
> this:
>
>
>
> Room1 [ ]
> Room2 [ ]
> Room3 [ ]
> Room4 [ ]
>
> [SUBMIT]
>
>
> And then the users can see if their booking has been approved.
>
> How could I do this???
>
> No matter how, could be checkboxes, a list, but what I need is to have
> every booking validated.
>
> Thanks! I really appreciate your help because that's for my final
> school project.
>
> Thanks!


[web2py] Re: Interactive Fiction App

2011-04-12 Thread Jonathan Dobson
Right on - thanks.

[web2py] Re: Redirect & response.flash

2011-04-12 Thread Drise
Sorry to dig something old up, but is there a way to time it? like the
auth login?

On Feb 28, 7:11 am, puercoespin 
wrote:
> Very useful information.
>
> Thanks Jonathan
>
> On 25 feb, 17:11, Jonathan Lundell  wrote:
>
>
>
>
>
>
>
> > On Feb 25, 2011, at 2:02 AM, SergeyPo wrote:
>
> > > Hello everyone!
>
> > > I want to do something like:
>
> > > def selector():
> > >    try:
> > >        x = db.headers[request.vars.ID]
> > >        if x is None:
> > >            response.flash = T('ID incorrect')
> > >            redirect(URL(r=request, f='index', args=(request.args[1])))
> > >    except:
> > >        response.flash = T('ID incorrect')
> > >        redirect(URL(r=request, f='headers', args=(request.args[1])))
>
> > > response.flash does not keep its value when you redirect. Is it
> > > possible to fix or workaround?
>
> > As others have already said, you want to use session.flash here. It's 
> > useful to understand why.
>
> > Redirect is itself a response, sending a redirection code and the new URL 
> > to the requesting browser. When that happens, everything in response, 
> > including response.flash, is discarded--the redirection becomes the entire 
> > response.
>
> > On every request from the browser, web2py initializes a new response 
> > dictionary (along with request and some other stuff). It sets 
> > response.flash = session.flash, and then sets session.flash = None. So 
> > anything you store in session.flash is used as response.flash for the 
> > *next* request/response, which is exactly what you want when you're calling 
> > redirect.


[web2py] Re: mod_wsgi and import error under apache

2011-04-12 Thread Arun K.Rajeevan
well I was looking into mercurial.py in admin/controllers and mercurial's 
python api
I can see ui.quiet is set in our mercurial.py implementation.
That should be fixed this issue.

But we know it doesn't

See http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions
and search for "Why do I get the error 'IOError: sys.stdout access 
restricted by mod_wsgi'?" some possible workarounds at apache level.

@whoever in charge of mercurial support:

Also, from what I've read in the mercurial api,
if ui.quiet set then mercurial.ui.status() method (called inside 
mercurial.cmdutils) will suppress writing to output, if --quiet is passed 
in. (like "hg addremove --quite")
Can we pass this argument to mercurial.cmdutils.addremove()? 
If yes, I think, it'll fix the problem.
I don't know who's in charge of mercurial support, (so if anyone know, 
please forward a copy to him/her for quick attention)

@Manuele: in meanwhile, try the link provided and also try add following to 
your global .hgrc file (actually it's done with api in 
admin/conttrollers/mercurial.py but trying will not hurt :) )
[ui]
quiet=True




[web2py] Re: Performance Considerations

2011-04-12 Thread VP
Hi, do you have controller methods that take a relatively long time?
For example, at least 0.5 second?

I made a point previously that because session is locked at the
beginning of a controller function and is released only at the finish
of that function, requests will have to wait one after each other.  So
unless you explicitly release the lock (via session.forget(response)),
there might be a performance penalty.

I think so, but I don't know enough to be certain.



On Apr 12, 12:52 pm, Ross Peoples  wrote:
> I've been developing my application for 6 weeks now and I stay updated with
> the trunk version of web2py. I know that Massimo, Johnathan, and others have
> been working to increase performance of web2py, but I had to make a Django
> app for someone that was similar to one of the web2py applications I built
> while teaching myself web2py about a month ago. Running the Django app, I
> noticed that the Django app responds around 50 to 100ms faster in some
> cases. My app still checks for migrations because I'm still developing it,
> so I know that will slow it down a bit.
>
> Are there some areas where performance can be further improved to squeeze a
> little more speed out of web2py applications? Also, is there a good way to
> profile applications to find the slowest methods? Web2py is pretty fast
> already, but I'm wondering if there are any known areas of slowness (besides
> the obvious latency caused by database queries) within web2py that I can
> play around with?


Re: [web2py] Performance Considerations

2011-04-12 Thread Jason Brower

ooohhh, nice!
On 04/12/2011 09:31 PM, Anthony wrote:

On Tuesday, April 12, 2011 2:14:30 PM UTC-4, encompass wrote:

I wish there was a way to make a query that could be read easily
by all
users. And it updates at a rate I can set in my default.py or
something
similar. :D
That way I can have comon queries for all users in one area and it
doesn't smack the database needlessly.
But maybe this is memcaching :D
BR,
Jason

Are you looking for something like this: 
http://web2py.com/book/default/chapter/06#Caching-Selects

Anthony




[web2py] Re: mod_wsgi and import error under apache

2011-04-12 Thread Arun K.Rajeevan
It's not matplotlib but mercurial that prints into stdout.

>File"/usr/lib/pymodules/python2.6/mercurial/ui.py",line232,inwrite
>  sys.stdout.write(str(a))
> IOError:sys.stdout access restricted by mod_wsgi

About matplotlib,
in case there's still problem, 
can you try to enter plot.py's contents one by one into a python prompt and 
see whether that works.
May be some installation problem of matplotlib.

I installed matplotlib for testing your problem 
$> sudo apt-get install python-matplotlib
$> ipython
>>>import matplotlib
>>>matplotlib.__version__
 '0.99.3'
>>>import matplotlib
>>>import matplotlib.cbook
>>>from matplotlib.backends.backend_agg import FigureCanvasAgg as 
FigureCanvas
>>>from matplotlib.backend_bases import RendererBase

And I got no errors about imports, or attribut error as you got

>   
 
File"/usr/lib/pymodules/python2.6/matplotlib/backend_bases.py",line29,in
>  importmatplotlib.cbook as cbook
> AttributeError:'module'object has no attribute'cbook'

In case you got this same error while trying this on python prompt, try 
reinstalling the library.


[web2py] Error ticket and path problem

2011-04-12 Thread Arun K.Rajeevan
Hi,

today I tried to put all my web2py projects under a common directory called
web2py_projects with a "application" directory within it, in which I kept
all my web2py projects.
I cloned web2py trunk at web2py_projects/web2py
Then soft linked admin, welcome and example applications from within cloned
repo to web2py_projects/applications.

I started web2py with "--folder" argument.
It all wen't well, until an error occurred in one of my projects.
I can't view error tickets, when I click on ticket link, I'll get another
ticket on "admin" app.


Reason is an error in calculating ticket path in gluon/restricted.py
Which doesn't take into account, --folder option and possibility of soft
linking applications.

I don't know about any such problems in other parts of the framework, but
herewith I'm attaching a patch for this problem.
Apply to gluon/restricted.py


@massimo: Is there anybody else with write access to the repository?

Arun.K.R
_
{ Man can be Destroyed but cannot be Defeated.}
{ As you live your days, so you craft your life. }
{ In this world of no walls or fences, we don't need windows or gates! }
http://www.google.com/profiles/ *the1.arun*
Registered Gnu\Linux User: #470196
Registered Ubuntu User: #25827
_
65c65
< errors_folder = os.path.join(root, 'errors') #.replace('\\', '/')
---
> errors_folder = os.path.abspath(os.path.join(root, 'errors'))#.replace('\\', '/')


[web2py] Re: Performance Considerations

2011-04-12 Thread pbreit
pool_size

Re: [web2py] Performance Considerations

2011-04-12 Thread Anthony
On Tuesday, April 12, 2011 2:14:30 PM UTC-4, encompass wrote: 
>
> I wish there was a way to make a query that could be read easily by all 
> users. And it updates at a rate I can set in my default.py or something 
> similar. :D
> That way I can have comon queries for all users in one area and it 
> doesn't smack the database needlessly.
> But maybe this is memcaching :D
> BR,
> Jason

 
Are you looking for something like this: 
http://web2py.com/book/default/chapter/06#Caching-Selects
 
Anthony


[web2py] Re: secure connection to database ¿?

2011-04-12 Thread Massimo Di Pierro
restrict postgresql access to 127.0.0.1 and make a ssh tunnel between
machines.

On Apr 12, 10:38 am, Luis Díaz  wrote:
> Greetings
>
> pose the scenario:
>
> I have 2 VPS:
>
> the first where web2py run the app I'm developing.
> the second that I have for postgresql database
>
> Now the question ..
> as the database is not on the same server
> I require to connect securely?
>
> Díaz Luishttp://www.facebook.com/diazluis2007
> User Linux 532223
> progjuegos.com
> TSU Analisis de Sistemas
> Universidad de Carabobo
> Facultad de 
> Odontología


[web2py] Re: Performance Considerations

2011-04-12 Thread Massimo Di Pierro
Migrations do affect time at al, in particular if you use an rdbms
other than sqlite.

Try switch migrations off, click on the button "bytecode compile"/,
and set cool_size=20.

Let us know what you get. We can still do better but these three
changes should give you a big boost.


On Apr 12, 12:52 pm, Ross Peoples  wrote:
> I've been developing my application for 6 weeks now and I stay updated with
> the trunk version of web2py. I know that Massimo, Johnathan, and others have
> been working to increase performance of web2py, but I had to make a Django
> app for someone that was similar to one of the web2py applications I built
> while teaching myself web2py about a month ago. Running the Django app, I
> noticed that the Django app responds around 50 to 100ms faster in some
> cases. My app still checks for migrations because I'm still developing it,
> so I know that will slow it down a bit.
>
> Are there some areas where performance can be further improved to squeeze a
> little more speed out of web2py applications? Also, is there a good way to
> profile applications to find the slowest methods? Web2py is pretty fast
> already, but I'm wondering if there are any known areas of slowness (besides
> the obvious latency caused by database queries) within web2py that I can
> play around with?


Re: [web2py] Performance Considerations

2011-04-12 Thread Jason Brower

On 04/12/2011 08:52 PM, Ross Peoples wrote:
I've been developing my application for 6 weeks now and I stay updated 
with the trunk version of web2py. I know that Massimo, Johnathan, and 
others have been working to increase performance of web2py, but I had 
to make a Django app for someone that was similar to one of the web2py 
applications I built while teaching myself web2py about a month ago. 
Running the Django app, I noticed that the Django app responds around 
50 to 100ms faster in some cases. My app still checks for migrations 
because I'm still developing it, so I know that will slow it down a bit.


Are there some areas where performance can be further improved to 
squeeze a little more speed out of web2py applications? Also, is there 
a good way to profile applications to find the slowest methods? Web2py 
is pretty fast already, but I'm wondering if there are any known areas 
of slowness (besides the obvious latency caused by database queries) 
within web2py that I can play around with?
I wish there was a way to make a query that could be read easily by all 
users. And it updates at a rate I can set in my default.py or something 
similar. :D
That way I can have comon queries for all users in one area and it 
doesn't smack the database needlessly.

But maybe this is memcaching :D
BR,
Jason


[web2py] Re: LAMP like frameworks are dying. Time for the javascript age

2011-04-12 Thread Massimo Di Pierro
http://blog.mysyncpad.com/post/2073441622/node-js-vs-erlang-syncpads-experience

On Apr 12, 12:45 pm, Albert Abril  wrote:
> Just a question... is erlang a direct competitor to javascript with this
> paradigm?
>
> 2011/4/12 JmiXIII 
>
>
>
>
>
>
>
> > "Expect the growth of more full-blown desktop-like
> > apps hosted in the browser (like the Ext JS desktop demo).  Expect
> > people to begin to hate refreshing the page. " => +1
>
> > I really agree with this and I wish so much webbrowser could use
> > python as javascript
>
> > On 12 avr, 00:46, cjrh  wrote:
> > > On Apr 9, 10:35 am, Luther Goh Lu Feng  wrote:
>
> > > > I hope to learn from everyone's opinion on this.
>
> > > It is pretty clear that the future belongs to javascript, as long as
> > > that is the language that all browsers support.  Expect javascript
> > > JITs to improve.  Expect the growth of more full-blown desktop-like
> > > apps hosted in the browser (like the Ext JS desktop demo).  Expect
> > > people to begin to hate refreshing the page.
>
> > > By including jQuery, web2py is ahead of the curve, or at least on par
> > > with the other "traditional" frameworks.  We could probably make AJAX
> > > even easier if we tried.  We probably should try.  More support for
> > > reducing page refreshes.


[web2py] Performance Considerations

2011-04-12 Thread Ross Peoples
I've been developing my application for 6 weeks now and I stay updated with 
the trunk version of web2py. I know that Massimo, Johnathan, and others have 
been working to increase performance of web2py, but I had to make a Django 
app for someone that was similar to one of the web2py applications I built 
while teaching myself web2py about a month ago. Running the Django app, I 
noticed that the Django app responds around 50 to 100ms faster in some 
cases. My app still checks for migrations because I'm still developing it, 
so I know that will slow it down a bit. 

Are there some areas where performance can be further improved to squeeze a 
little more speed out of web2py applications? Also, is there a good way to 
profile applications to find the slowest methods? Web2py is pretty fast 
already, but I'm wondering if there are any known areas of slowness (besides 
the obvious latency caused by database queries) within web2py that I can 
play around with?


Re: [web2py] Re: LAMP like frameworks are dying. Time for the javascript age

2011-04-12 Thread Albert Abril
Just a question... is erlang a direct competitor to javascript with this
paradigm?

2011/4/12 JmiXIII 

> "Expect the growth of more full-blown desktop-like
> apps hosted in the browser (like the Ext JS desktop demo).  Expect
> people to begin to hate refreshing the page. " => +1
>
> I really agree with this and I wish so much webbrowser could use
> python as javascript
>
>
>
> On 12 avr, 00:46, cjrh  wrote:
> > On Apr 9, 10:35 am, Luther Goh Lu Feng  wrote:
> >
> > > I hope to learn from everyone's opinion on this.
> >
> > It is pretty clear that the future belongs to javascript, as long as
> > that is the language that all browsers support.  Expect javascript
> > JITs to improve.  Expect the growth of more full-blown desktop-like
> > apps hosted in the browser (like the Ext JS desktop demo).  Expect
> > people to begin to hate refreshing the page.
> >
> > By including jQuery, web2py is ahead of the curve, or at least on par
> > with the other "traditional" frameworks.  We could probably make AJAX
> > even easier if we tried.  We probably should try.  More support for
> > reducing page refreshes.
>


Re: [web2py] Re: Use bpython with web2py

2011-04-12 Thread Albert Abril
OMG! My favourite python interpeter in my favourite (all-languages)
framework.
You are fantastic people.

2011/4/12 Arun K.Rajeevan 

> For those who don't use repo but web2py packages from download page,
> here is conventional patch files from diff. use patch to apply them.
> you have to apply patches to gluon/shell.py and gluon/widget.py
>
>
> A screen shot of bython console with web2py auto-completion is
> also attached.
>
>
>


[web2py] Re: auth_user manually insert/update the password

2011-04-12 Thread Anthony
On Tuesday, April 12, 2011 12:01:26 PM UTC-4, Bob wrote: 
>
> Thanks Anthony 
>
> Hiding with javascript will not work because it will get submitted 
> with javascript.

 
If you use an update form, the hidden password field should be 
pre-populated, so when you submit, it shouldn't replace the password with a 
blank (at least it doesn't when I try it).
 
Anthony


[web2py] Re: 2 field unique validator

2011-04-12 Thread Mike
Thanks DenesL! That was definitely the issue.

On Apr 12, 12:21 pm, DenesL  wrote:
> Move the requires from inside the field definition to after the table
> definition.
> web2py will not allow a reference to a field that has not been
> created.
>
> On Apr 12, 12:01 pm, Mike  wrote:
>
>
>
>
>
>
>
> > I know this question has been asked and answered before, but I am
> > having errors in implementation and I feel like it's something really
> > silly. If anyone can point anything obvious out that I am missing,
> > please let me know. Basically I am trying to implement so that two
> > rows can not have the same combination of Invoice + SKU. Now when I
> > just got to the web2py admin database editor I am getting these
> > errors.
>
> > Thanks in Advance!
>
> > Error message:
>
> > Traceback (most recent call last):
> >   File "/home/msheiny/Dropbox/web2py/gluon/restricted.py", line 188,
> > in restricted
> >     exec ccode in environment
> >   File "/home/msheiny/Dropbox/web2py/applications/mycybersoft/models/
> > mycyber_model.py", line 5, in 
> >     Field('Invoice',
> > type='integer',requires=(IS_NOT_EMPTY(),IS_INT_IN_RANGE(1,
> > 999,error_message=T('Needs to be between 1 -
> > 999')),IS_NOT_IN_DB(db(db.software_database.SKU==request.vars.SKU),'sof 
> > tware_database.Invoice')),
> >   File "/home/msheiny/Dropbox/web2py/gluon/dal.py", line 3904, in
> > __getattr__
> >     return self[key]
> >   File "/home/msheiny/Dropbox/web2py/gluon/dal.py", line 3898, in
> > __getitem__
> >     return dict.__getitem__(self, str(key))
> > KeyError: 'software_database'
>
> > Database in question with validator on Invoice field:
>
> > db.define_table('software_database',
> >     Field('Invoice',
> > type='integer',requires=(IS_NOT_EMPTY(),IS_INT_IN_RANGE(1,
> > 999,error_message=T('Needs to be between 1 -
> > 999')),IS_NOT_IN_DB(db(db.software_database.SKU==request.vars.SKU),'sof 
> > tware_database.Invoice')),
> >           label=T('Invoice Number')),
> >     Field('Company_Name',
> > type='string',requires=(IS_NOT_EMPTY(),IS_IN_DB(db,'auth_user.Company','',z 
> > ero=T('choose
> > one'))),
> >           label=T('Company Name')),
>
> > Field('Start_Date','date',default=now,writable=False,requires=(IS_NOT_EMPTY 
> > (),IS_DATE()),label=T('Start
> > Date')),
>
> > Field('Expire_Date','date',default=thirtydaysout,requires=(IS_NOT_EMPTY(),I 
> > S_DATE()),label=T('Expiration
> > Date')),
> >     Field('SKU', requires=IS_IN_DB(db,'cyber_skus.SKU','%
> > (SKU)s',zero=T('CyberSoft Product')),label=T('SKU')),
> >     Field('NumOfCopies',
> > type='integer',requires=IS_NOT_EMPTY(),label=T('Number of Copies')),
> >     Field('Comments', type='string',label=T('Optional Comments')),
> >     Field('Assoc_Usernames', 'list:reference auth_user'),
> >     format='%(username)s',
> >     migrate=settings.migrate)


Re: [web2py] shortcut for table_is empty?

2011-04-12 Thread Marin Pranjic
Something like db(db.tablename.id>0).count() ?

On Tue, Apr 12, 2011 at 5:22 PM, mart  wrote:

> Hi,
>
> is there a shortcut  to check if a table is empty? (not look to see
> what the content is, just if it has any at all)
>
> Thanks,
> Mart :)


[web2py] Re: extract get_records from build_set in IS_IN_DB

2011-04-12 Thread DenesL

An alternative would be to load you records in a table defined in a
DAL('SQLITE:memory') database, then you can use the regular validators
and DB commands.


On Apr 12, 11:00 am, Carlos  wrote:
> Hi,
>
> For now, I've implemented a tricky work-around that seems to work properly
> for the special cases I describe, and without repeating any code.
>
> In case anyone is interested:
>
> class tmp_dbset(object):
>     def __init__(self, owner):
>         self.db = db
>         self.owner = owner
>     def select(self, *args, **kwargs):
>         return self.owner.rows
>
> class x_IS_IN_DB(IS_IN_DB):
>     def __init__(self, *args, **kwargs):
>         self.rows = None
>         super(x_IS_IN_DB, self).__init__(*args, **kwargs)
>     def build_set(self):
>         # print 'x_IS_IN_DB.build_set > rows', _rowids(self.rows)
>         usetmp = not self.rows is None
>         if usetmp:
>             backup = self.dbset
>             self.dbset = tmp_dbset(self)
>         result = super(x_IS_IN_DB, self).build_set()
>         if usetmp:
>             self.dbset = backup
>         return result
>
> Take care,
>
>    Carlos


[web2py] Re: extract get_records from build_set in IS_IN_DB

2011-04-12 Thread Carlos
Hi DenesL,

Thanks, but I just needed this change in IS_IN_DB validator in order to 
support direct rows/records instead of selectable dbsets, and without 
requiring extra database access (therefore without an extra db / table).

Best regards,

   Carlos



[web2py] Re: 2 field unique validator

2011-04-12 Thread DenesL

Move the requires from inside the field definition to after the table
definition.
web2py will not allow a reference to a field that has not been
created.


On Apr 12, 12:01 pm, Mike  wrote:
> I know this question has been asked and answered before, but I am
> having errors in implementation and I feel like it's something really
> silly. If anyone can point anything obvious out that I am missing,
> please let me know. Basically I am trying to implement so that two
> rows can not have the same combination of Invoice + SKU. Now when I
> just got to the web2py admin database editor I am getting these
> errors.
>
> Thanks in Advance!
>
> Error message:
>
> Traceback (most recent call last):
>   File "/home/msheiny/Dropbox/web2py/gluon/restricted.py", line 188,
> in restricted
>     exec ccode in environment
>   File "/home/msheiny/Dropbox/web2py/applications/mycybersoft/models/
> mycyber_model.py", line 5, in 
>     Field('Invoice',
> type='integer',requires=(IS_NOT_EMPTY(),IS_INT_IN_RANGE(1,
> 999,error_message=T('Needs to be between 1 -
> 999')),IS_NOT_IN_DB(db(db.software_database.SKU==request.vars.SKU),'software_database.Invoice')),
>   File "/home/msheiny/Dropbox/web2py/gluon/dal.py", line 3904, in
> __getattr__
>     return self[key]
>   File "/home/msheiny/Dropbox/web2py/gluon/dal.py", line 3898, in
> __getitem__
>     return dict.__getitem__(self, str(key))
> KeyError: 'software_database'
>
> Database in question with validator on Invoice field:
>
> db.define_table('software_database',
>     Field('Invoice',
> type='integer',requires=(IS_NOT_EMPTY(),IS_INT_IN_RANGE(1,
> 999,error_message=T('Needs to be between 1 -
> 999')),IS_NOT_IN_DB(db(db.software_database.SKU==request.vars.SKU),'software_database.Invoice')),
>           label=T('Invoice Number')),
>     Field('Company_Name',
> type='string',requires=(IS_NOT_EMPTY(),IS_IN_DB(db,'auth_user.Company','',zero=T('choose
> one'))),
>           label=T('Company Name')),
>
> Field('Start_Date','date',default=now,writable=False,requires=(IS_NOT_EMPTY(),IS_DATE()),label=T('Start
> Date')),
>
> Field('Expire_Date','date',default=thirtydaysout,requires=(IS_NOT_EMPTY(),IS_DATE()),label=T('Expiration
> Date')),
>     Field('SKU', requires=IS_IN_DB(db,'cyber_skus.SKU','%
> (SKU)s',zero=T('CyberSoft Product')),label=T('SKU')),
>     Field('NumOfCopies',
> type='integer',requires=IS_NOT_EMPTY(),label=T('Number of Copies')),
>     Field('Comments', type='string',label=T('Optional Comments')),
>     Field('Assoc_Usernames', 'list:reference auth_user'),
>     format='%(username)s',
>     migrate=settings.migrate)


[web2py] 2 field unique validator

2011-04-12 Thread pbreit
Not sure if this is the problem but the book always shows multiple validators 
enclosed in square brackets [].


[web2py] Re: auth_user manually insert/update the password

2011-04-12 Thread Bob
Thanks Anthony

Hiding with javascript will not work because it will get submitted
with javascript. But I will try the readable/writable trick, thanks

Bob


[web2py] 2 field unique validator

2011-04-12 Thread Mike
I know this question has been asked and answered before, but I am
having errors in implementation and I feel like it's something really
silly. If anyone can point anything obvious out that I am missing,
please let me know. Basically I am trying to implement so that two
rows can not have the same combination of Invoice + SKU. Now when I
just got to the web2py admin database editor I am getting these
errors.

Thanks in Advance!


Error message:

Traceback (most recent call last):
  File "/home/msheiny/Dropbox/web2py/gluon/restricted.py", line 188,
in restricted
exec ccode in environment
  File "/home/msheiny/Dropbox/web2py/applications/mycybersoft/models/
mycyber_model.py", line 5, in 
Field('Invoice',
type='integer',requires=(IS_NOT_EMPTY(),IS_INT_IN_RANGE(1,
999,error_message=T('Needs to be between 1 -
999')),IS_NOT_IN_DB(db(db.software_database.SKU==request.vars.SKU),'software_database.Invoice')),
  File "/home/msheiny/Dropbox/web2py/gluon/dal.py", line 3904, in
__getattr__
return self[key]
  File "/home/msheiny/Dropbox/web2py/gluon/dal.py", line 3898, in
__getitem__
return dict.__getitem__(self, str(key))
KeyError: 'software_database'

Database in question with validator on Invoice field:

db.define_table('software_database',
Field('Invoice',
type='integer',requires=(IS_NOT_EMPTY(),IS_INT_IN_RANGE(1,
999,error_message=T('Needs to be between 1 -
999')),IS_NOT_IN_DB(db(db.software_database.SKU==request.vars.SKU),'software_database.Invoice')),
  label=T('Invoice Number')),
Field('Company_Name',
type='string',requires=(IS_NOT_EMPTY(),IS_IN_DB(db,'auth_user.Company','',zero=T('choose
one'))),
  label=T('Company Name')),
 
Field('Start_Date','date',default=now,writable=False,requires=(IS_NOT_EMPTY(),IS_DATE()),label=T('Start
Date')),
 
Field('Expire_Date','date',default=thirtydaysout,requires=(IS_NOT_EMPTY(),IS_DATE()),label=T('Expiration
Date')),
Field('SKU', requires=IS_IN_DB(db,'cyber_skus.SKU','%
(SKU)s',zero=T('CyberSoft Product')),label=T('SKU')),
Field('NumOfCopies',
type='integer',requires=IS_NOT_EMPTY(),label=T('Number of Copies')),
Field('Comments', type='string',label=T('Optional Comments')),
Field('Assoc_Usernames', 'list:reference auth_user'),
format='%(username)s',
migrate=settings.migrate)


[web2py] secure connection to database ¿?

2011-04-12 Thread Luis Díaz
Greetings

pose the scenario:

I have 2 VPS:

the first where web2py run the app I'm developing.
the second that I have for postgresql database


Now the question ..
as the database is not on the same server
I require to connect securely?


Díaz Luis
http://www.facebook.com/diazluis2007
User Linux 532223
progjuegos.com
TSU Analisis de Sistemas
Universidad de Carabobo
Facultad de 
Odontología


[web2py] Re: LAMP like frameworks are dying. Time for the javascript age

2011-04-12 Thread JmiXIII
"Expect the growth of more full-blown desktop-like
apps hosted in the browser (like the Ext JS desktop demo).  Expect
people to begin to hate refreshing the page. " => +1

I really agree with this and I wish so much webbrowser could use
python as javascript



On 12 avr, 00:46, cjrh  wrote:
> On Apr 9, 10:35 am, Luther Goh Lu Feng  wrote:
>
> > I hope to learn from everyone's opinion on this.
>
> It is pretty clear that the future belongs to javascript, as long as
> that is the language that all browsers support.  Expect javascript
> JITs to improve.  Expect the growth of more full-blown desktop-like
> apps hosted in the browser (like the Ext JS desktop demo).  Expect
> people to begin to hate refreshing the page.
>
> By including jQuery, web2py is ahead of the curve, or at least on par
> with the other "traditional" frameworks.  We could probably make AJAX
> even easier if we tried.  We probably should try.  More support for
> reducing page refreshes.


[web2py] shortcut for table_is empty?

2011-04-12 Thread mart
Hi,

is there a shortcut  to check if a table is empty? (not look to see
what the content is, just if it has any at all)

Thanks,
Mart :)


[web2py] Re: Web2Py and IntelliJ Idea

2011-04-12 Thread luckysmack
Idea has all the same features and options as the pycharm version.
Pycharm (as well as phpstorm, webstorm, et.al.) are all based on
limited versions of Idea, targeted for a specific purpose. In this
case, python. I just has the python plugin installed by default.

On Apr 12, 2:34 am, kuokon  wrote:
> You can try the Python version of their IDE, PyCharm:
>
>          http://www.jetbrains.com/pycharm/
>
> Best,
> kuokon
>
> On Apr 12, 12:25 pm, luckysmack  wrote:
>
>
>
>
>
>
>
> > Im wondering if anyone is using IntelliJ's Idea editor for their
> > web2py projects. I used it for php before coming here and is hands
> > down my favorite IDE. It works well will intellij but for some reason
> > I feel like I should have some better integration. I know it doesnt
> > officially support it, but im curious as to any special steps or
> > settings a user has done to get it to work nicely with the editor. One
> > of the things that doesnt work, is in .html files, the code is not
> > properly highlighted inside of the {{ }} brackets. I also remember
> > hearing about a setting where I could test/debug vs different versions
> > of python. Such as writing for 2.6+ with warnings/info markers showing
> > where its not compatible for 3.x (i know its going to be a while for
> > that but it's still nice to attempt to be future proof if possible).
>
> > Anyways, if anyone uses Idea and has any tips on getting it setup
> > better im all eyes. If not, no worries. Thanks
>
> > -- Shawn


[web2py] Re: Use bpython with web2py

2011-04-12 Thread Arun K.Rajeevan
as simple as issuing "hg import " once inside web2py repo.

[web2py] Re: extract get_records from build_set in IS_IN_DB

2011-04-12 Thread Carlos
Hi,

For now, I've implemented a tricky work-around that seems to work properly 
for the special cases I describe, and without repeating any code.

In case anyone is interested:

class tmp_dbset(object):
def __init__(self, owner):
self.db = db
self.owner = owner
def select(self, *args, **kwargs):
return self.owner.rows

class x_IS_IN_DB(IS_IN_DB):
def __init__(self, *args, **kwargs):
self.rows = None
super(x_IS_IN_DB, self).__init__(*args, **kwargs)
def build_set(self):
# print 'x_IS_IN_DB.build_set > rows', _rowids(self.rows)
usetmp = not self.rows is None
if usetmp:
backup = self.dbset
self.dbset = tmp_dbset(self)
result = super(x_IS_IN_DB, self).build_set()
if usetmp:
self.dbset = backup
return result

Take care,

   Carlos



Re: [web2py] Asking advice for a special architecture

2011-04-12 Thread Sebastian E. Ovide
2011/4/11 José Luis Redrejo 

>  My intention is using
> GAE for this
>

Are you sure about that ? working with GAE requires much more effort !...
you need to spend more time designingand it is much more difficult for
refactoring (it is very difficult to predict what your customer is going
to need... because he generally doesn'.t know... and the application needs
could change a lot of times)

-- 
Sebastian E. Ovide


Re: [web2py] Re: Asking advice for a special architecture

2011-04-12 Thread Vasile Ermicioi
that solves only the part of synchronizing local and remote databases,
but not the offline work

for offline you need a desktop solution (adobe air , other solution),
or if you need to work in browser, I don't see other solution than google
gears

Google Gears is in fact a javascript interface to sqlite databases


[web2py] Re: auth_user manually insert/update the password

2011-04-12 Thread Anthony
On Tuesday, April 12, 2011 9:59:00 AM UTC-4, Bob wrote: 
>
> 2. In similar situation using SQLFORM. When updating the user it's 
> logical to leave the password blank in case you don't want to change 
> it. But SQLFORM crypts the blank and changes the password in the DB

 
If you pass the record id to SQLFORM via the 'record' argument, you'll get 
an update form with the password field pre-populated, so it won't get 
replaced with a blank. Or you can completely prevent the password field from 
being displayed by temporarily setting its 'readable' and 'writable' 
attributes to False. You could also initially hide the (pre-populated) 
password field in the view, and then use javascript to show the field if the 
user decides to change the password.
 
Anthony


[web2py] Re: auth_user manually insert/update the password

2011-04-12 Thread Anthony
On Tuesday, April 12, 2011 9:59:00 AM UTC-4, Bob wrote: 
>
> Hello, could someone answer a couple of questions: 
>
> 1. Is it possible to manually crypt the password in the same way that 
> crud() does it? 
> The reason is that I need to manually update the user with 
> db().update() and can't use crud

 
I think you can get a hashed password with:
 
CRYPT()('yourpassword')[0]
 
Anthony


[web2py] Re: extra text in forms

2011-04-12 Thread Anthony
On Tuesday, April 12, 2011 1:34:01 AM UTC-4, niknok wrote: 
>
> This is how I use it right now.. Looking for a way to change 
> 'instruction' field. 
>
> form=SQLFORM.factory( 
> Field('instruction','text', writable=False, default='Extra text to 
> display'), 
> Field('f1', 'string'))

 
Are you using 'instruction' as a dummy field just to display an instruction 
right above the form? If so, you can instead manipulate the form on the 
server side to insert an instruction. See 
http://web2py.com/book/default/chapter/07#Adding-extra-form-elements-to-SQLFORM,
 
http://www.web2pyslices.com/main/slices/take_slice/43, and 
http://web2py.com/book/default/chapter/05#Server-side-DOM-and-Parsing. For 
example, you could do:
 
form=SQLFORM.factory(Field('f1', 'string'), Field('f2', 'string'))
form.element('table').insert(0, TR(TD(T('Instruction text centered above 
the form'),
_style='text-align:center', _colspan='2')))
 
Or, instead of inserting the instruction in a table row, you could just wrap 
the form in a DIV and add the instruction above the form:
 
form=DIV(SPAN(T('Instruction text above the form')), form)
 
Anthony
 


[web2py] auth_user manually insert/update the password

2011-04-12 Thread Bob
Hello, could someone answer a couple of questions:

1. Is it possible to manually crypt the password in the same way that
crud() does it?
The reason is that I need to manually update the user with
db().update() and can't use crud

2. In similar situation using SQLFORM. When updating the user it's
logical to leave the password blank in case you don't want to change
it. But SQLFORM crypts the blank and changes the password in the DB

Any ideas?

Thanks


[web2py] Re: Creating a many-to-many form with arbitrary number of fields

2011-04-12 Thread spiffytech
On Apr 11, 11:49 pm, JorgeRpo  wrote:
> what is ingredient_num for?

It's to keep track of what order the ingredients are in- recipes
usually list ingredients in the order you will use them.


On Apr 12, 1:14 am, pbreit  wrote:
> I'd suggest something like this:

That's essentially what I planned to do to display recipes, although
you removed the "units" table, which I require to do unit conversion
later.

The part I'm stuck on is making a form to enter a recipe into the
database. Web2py's FORM/SQLFORM/SQLFORM.factory functions all assume
your form is static, but mine is not. I need to show a set of fields
to the user (ingredient, quantity, and unit of measure), and allow the
user to click a button labeled "Add another ingredient" and have an
additional set of those same fields appear on the same form. I've
gotten close to this using FORM and JavaScript, but I keep running
into a few problems:

1) Some of Web2py's validators (e.g. IS_MATCH) don't like receiving
lists in the "value" argument instead of strings, which is what
happens when you have a bunch of fields all named "ingredient_name".

2) When I create the FORM object in my controller, it only has one set
of fields for a single ingredient. If I add more fields in JavaScript,
then the user fills out the form incorrectly, my controller gets the
form, says "oh, look, errors!", and sends the form back to the user
with only a single set of fields, instead of fields for all of the
ingredients the user typed in.

3) I need validators to work conditionally. If the user puts something
into the "ingredient_name" field, they must also put something into
the "quantity" field. However, if the user clicks "Add another
ingredient", but doesn't fill out any of those fields, the form should
be accepted.


[web2py] Re: mod_wsgi and import error under apache

2011-04-12 Thread Massimo Di Pierro
Try run web2py with matplotlib without mod_wsgi. Perhaps matplotlib is
printing something.

On Apr 12, 8:16 am, Manuele Pesenti  wrote:
> Il 11/04/2011 19:42, Arun K.Rajeevan ha scritto:> Seems your second problem 
> is a circular import problem in matplotlib
> > here is a reference
> >https://groups.google.com/forum/#!topic/modwsgi/97bnQk9ojtY
> > 
>
> > And here goes gist of it,
> > Try adding as first import, before other matplotlib imports:
> >   import matplotlib
> >   import matplotlib.cbook
>
> no it doesn't fix the problem :(
> the strange thing is that the problem is still at the line of my code in
> wich I call>   frommatplotlib.backends.backend_aggimportFigureCanvasAgg as 
> FigureCanvas
>
> that comes after the two import you suggest that do not give errors.
>
> Cheers
>      Manuele


[web2py] Re: Interactive Fiction App

2011-04-12 Thread Anthony
On Tuesday, April 12, 2011 7:52:24 AM UTC-4, Jonathan Dobson wrote: 
>
> Great - thanks for the info Anthony.  WebSockets seem more straightforward 
> to me.  They appeal to my low-level sensibilities.  Too bad they're not 
> ubiquitous.  Yet?

 
For browsers that don't yet support WebSockets, there's also 
http://socket.io/ (and https://github.com/MrJoes/tornadio).


Re: [web2py] Re: mod_wsgi and import error under apache

2011-04-12 Thread Manuele Pesenti

Il 11/04/2011 19:42, Arun K.Rajeevan ha scritto:

Seems your second problem is a circular import problem in matplotlib
here is a reference 
https://groups.google.com/forum/#!topic/modwsgi/97bnQk9ojtY 



And here goes gist of it,
Try adding as first import, before other matplotlib imports:
  import matplotlib
  import matplotlib.cbook

no it doesn't fix the problem :(
the strange thing is that the problem is still at the line of my code in 
wich I call

  frommatplotlib.backends.backend_aggimportFigureCanvasAgg as FigureCanvas

that comes after the two import you suggest that do not give errors.

Cheers
Manuele



[web2py] Re: contains in selecting rows

2011-04-12 Thread DenesL

You might be able to use belongs.

On Apr 12, 6:44 am, Kenneth Lundström 
wrote:
> I d like to create a form with a list of members in a select/option tag
> and have the user select one or more of the members.
>
> In form.accepts I d like to pull all rows of the selected members. In
> request.vars.members I have a list of selected members but what should
> the query look like?
>
> Kenneth


[web2py] Re: extra text in forms

2011-04-12 Thread DenesL


On Apr 12, 1:34 am, niknok  wrote:
> This is how I use it right now.. Looking for a way to change
> 'instruction' field.

Change the field how? Be specific.

> form=SQLFORM.factory(
>     Field('instruction','text', writable=False, default='Extra text to
> display'),
>     Field('f1', 'string'))
>
> On Apr 12, 10:00 am, DenesL  wrote:
>
>
>
>
>
>
>
> > Can you provide an example of what you want?.
>
> > On Apr 11, 8:57 pm, niknok  wrote:
>
> > > Yes, I know it can be done in Views. What I was wondering about is how
> > > to do so from the controller.
>
> > > On Apr 11, 10:07 pm, Johann Spies  wrote:
>
> > > > On 10 April 2011 23:42, niknok  wrote:
>
> > > > >  This might sound too basic, but I couldn't find out how to display 
> > > > > extra
> > > > > text in across the width of the whole form table.
>
> > > > > Right now, I do it this way (which only displays in the input column) 
> > > > > but I
> > > > > wonder what's the web2py way?
>
> > > > > form=SQLFORM.factory(
> > > > >     Field('instruction','text', writable=False, default='Extra text to
> > > > > display'),
> > > > >     Field('f1', 'string'))
>
> > > > What I do is to use a custom form layout and handle the extra text in 
> > > > the
> > > > view.  Check the 
> > > > Book:http://web2py.com/book/default/chapter/07?search=custom+form#Custom-f
>
> > > > Regards
> > > > Johann
>
> > > > --
> > > >  May grace and peace be yours in abundance through the full knowledge 
> > > > of God
> > > > and of Jesus our Lord!  His divine power has given us everything we 
> > > > need for
> > > > life and godliness through the full knowledge of the one who called us 
> > > > by
> > > > his own glory and excellence.
> > > >                                                     2 Pet. 1:2b,3a


[web2py] Re: Pagination in web2py

2011-04-12 Thread David Marko
Hello, see web2py util project here: 
http://packages.python.org/web2py_utils/paginate.html I have a good 
experinece with this.
For more advanced solutions you an use this: 
http://www.web2pyslices.com/main/slices/take_slice/39

David


[web2py] Re: Interactive Fiction App

2011-04-12 Thread Jonathan Dobson
Great - thanks for the info Anthony.  WebSockets seem more straightforward 
to me.  They appeal to my low-level sensibilities.  Too bad they're not 
ubiquitous.  Yet?

[web2py] Re: 502 Bad Gateway in web2py

2011-04-12 Thread Jose


On 11 abr, 10:39, "contatogilson...@gmail.com"
 wrote:
> Hello guys,
>
> I hosted a system webfaction.com and its plan has 80MB of memory. But
> the strange
> thing is that only has two people accessing the system and the usage time 
> gives
> thefollowing error:
>
> 502 Bad Gateway
>
> What do I resolve this problem? Has anyone experienced this?

Hi,

tried to lower the number of processes from the configuration file.

Jose


[web2py] Re: Pagination in web2py

2011-04-12 Thread Francisco Costa
The thing is that I use paginations on a lot of different controllers,
and I would love to have a more generic solution


On Apr 12, 11:29 am, Tom Atkins  wrote:
> This worked for me:
>
> http://www.web2py.com/book/default/chapter/12#Pagination
>
> On 12 April 2011 11:16, Francisco Costa  wrote:
>
>
>
>
>
>
>
> > Hi!
> > What is the ideal pagination method in web2py?
> > Are there any plugins or examples?


[web2py] contains in selecting rows

2011-04-12 Thread Kenneth Lundström
I´d like to create a form with a list of members in a select/option tag 
and have the user select one or more of the members.


In form.accepts I´d like to pull all rows of the selected members. In 
request.vars.members I have a list of selected members but what should 
the query look like?



Kenneth



Re: [web2py] Pagination in web2py

2011-04-12 Thread Tom Atkins
This worked for me:

http://www.web2py.com/book/default/chapter/12#Pagination

On 12 April 2011 11:16, Francisco Costa  wrote:

> Hi!
> What is the ideal pagination method in web2py?
> Are there any plugins or examples?


[web2py] Pagination in web2py

2011-04-12 Thread Francisco Costa
Hi!
What is the ideal pagination method in web2py?
Are there any plugins or examples?


Re: [web2py] Re: extra text in forms

2011-04-12 Thread Martín Mulone
pass comment value to field definition?

,comment="This is my instruction on how to fill this field"

Field('author_name', 'string', length=255, default="", label=("Your
name"), comment=T("Your name")),


2011/4/12 niknok 

> This is how I use it right now.. Looking for a way to change
> 'instruction' field.
>
> form=SQLFORM.factory(
>Field('instruction','text', writable=False, default='Extra text to
> display'),
>Field('f1', 'string'))
>
> On Apr 12, 10:00 am, DenesL  wrote:
> > Can you provide an example of what you want?.
> >
> > On Apr 11, 8:57 pm, niknok  wrote:
> >
> >
> >
> > > Yes, I know it can be done in Views. What I was wondering about is how
> > > to do so from the controller.
> >
> > > On Apr 11, 10:07 pm, Johann Spies  wrote:
> >
> > > > On 10 April 2011 23:42, niknok  wrote:
> >
> > > > >  This might sound too basic, but I couldn't find out how to display
> extra
> > > > > text in across the width of the whole form table.
> >
> > > > > Right now, I do it this way (which only displays in the input
> column) but I
> > > > > wonder what's the web2py way?
> >
> > > > > form=SQLFORM.factory(
> > > > > Field('instruction','text', writable=False, default='Extra text
> to
> > > > > display'),
> > > > > Field('f1', 'string'))
> >
> > > > What I do is to use a custom form layout and handle the extra text in
> the
> > > > view.  Check the Book:
> http://web2py.com/book/default/chapter/07?search=custom+form#Custom-f
> >
> > > > Regards
> > > > Johann
> >
> > > > --
> > > >  May grace and peace be yours in abundance through the full knowledge
> of God
> > > > and of Jesus our Lord!  His divine power has given us everything we
> need for
> > > > life and godliness through the full knowledge of the one who called
> us by
> > > > his own glory and excellence.
> > > > 2 Pet. 1:2b,3a
>



-- 
My blog: http://martin.tecnodoc.com.ar
Expert4Solution: http://www.experts4solutions.com/e4s/default/expert/6
http://www.cvstash.com/profile/Xzi5bWCdD


[web2py] Re: Web2Py and IntelliJ Idea

2011-04-12 Thread kuokon

You can try the Python version of their IDE, PyCharm:

 http://www.jetbrains.com/pycharm/

Best,
kuokon



On Apr 12, 12:25 pm, luckysmack  wrote:
> Im wondering if anyone is using IntelliJ's Idea editor for their
> web2py projects. I used it for php before coming here and is hands
> down my favorite IDE. It works well will intellij but for some reason
> I feel like I should have some better integration. I know it doesnt
> officially support it, but im curious as to any special steps or
> settings a user has done to get it to work nicely with the editor. One
> of the things that doesnt work, is in .html files, the code is not
> properly highlighted inside of the {{ }} brackets. I also remember
> hearing about a setting where I could test/debug vs different versions
> of python. Such as writing for 2.6+ with warnings/info markers showing
> where its not compatible for 3.x (i know its going to be a while for
> that but it's still nice to attempt to be future proof if possible).
>
> Anyways, if anyone uses Idea and has any tips on getting it setup
> better im all eyes. If not, no worries. Thanks
>
> -- Shawn


[web2py] Re: shameless advertisement - web2py course

2011-04-12 Thread kuokon

You can try it's Python version of their Intellij IDE, PyCharm:

http://www.jetbrains.com/pycharm/

Best,
kuokon



On Apr 12, 12:13 pm, Massimo Di Pierro 
wrote:
> Hello everybody,
>
> tomorrow is the first day of my online class on web development with python 
> using web2py:
>
> http://www.cdm.depaul.edu/ipd/Programs/Pages/WebDevelopmentwithPython...
>
> If you are interested, you may still be able to sign up. I cover some of the 
> stuff you know and some un-published examples.
> I know it is expensive and it makes no difference to me financially whether 
> you sign or not (since the university pays me a fixed salary).
>
> Yet I thought some of you may be interested.
>
> Massimo


Re: [web2py] Re: Asking advice for a special architecture

2011-04-12 Thread José Luis Redrejo Rodríguez
2011/4/12 Christopher Steel :
> We have an app for that. (Sorry could not resist...)

Thanks for not resisting :)


>
> here:
>
> http://www.web2py.com/appliances/default/show/18
>
> It is getting pretty old but should outline the basics using xmlrpc
>
> Cheers,
>

I'll take a look at it, as it looks like the most doable solution.

Thanks



> Chris
>
> On Apr 11, 8:44 am, José Luis Redrejo  wrote:
>> Hi,
>> I've volunteered to develop an application a NGO needs.
>> This organization has volunteers that will go to different places that
>> have a workstation or laptop without Internet connection. There, they
>> will fill some forms using the application.
>> When a laptop is available they'll return home with the laptops and
>> will connect to Internet.
>>
>> The NGO needs to have a centralized database. My intention is using
>> GAE for this. So the laptops must be able to sync with the central
>> database:
>> sending the data they have collected and recovering the data other
>> users have sent.
>>
>> I've thought of doing exactly the same application, running locally
>> with sqlite, and syncing with GAE when an Internet connection is
>> available. I will have to replace the database id fields with uids to
>> avoid duplication of keys between the volunteers.  I would not like to
>> reinvent the wheel for the syncronization, and I do think that someone
>> else have had to deal with the same kind of problem before.
>>
>> So, what can  you recommend me?
>> Any advice is very welcome.
>>
>> José L.