[web2py] Re: 'list:reference', contains, Mysql, instr

2013-01-22 Thread pablo . angulo


El lunes, 21 de enero de 2013 22:47:41 UTC+1, Massimo Di Pierro escribió:

 Now I understand the problem. You want to pass an expression where a value 
 is expected. I do not believe we can support this. INSTR does not solve the 
 problem because it would not be correct to looks for substrings. In fact 
 paper.authors may contain '|12|13|' and it would incorrectly return that 
 author '2' is one of authors because it is a substring.


ok, but we can use CONCAT to append and prepend '|', that's more standard 
that instr.
 


 You have to do it in two steps:

 person = db(db.person.name='').select().first()
 papers = db.paper.authors.contains(person.id).select()


But it's not a one-time query. I'm working in something like appadmin, 
tweaking smart_query and SQLFORM.grid to help the user build compund 
querys. I'd rather normalize the database.

BTW, I will come later with some ideas/questions.

Thanks again
 


 Massimo


 On Jan 21, 2013, at 3:33 PM, pablo@uam.es javascript: wrote:



 El lunes, 21 de enero de 2013 18:56:07 UTC+1, Massimo Di Pierro escribió:

 Before we attempt to fix this. It works for me as it is with sqlite. Why 
 does doesn't it wirk with mysql? MySQL has a LIKE operator. Wat error do 
 you get?


 execution of:

 db(db.paper.authors.contains(person.id))._select()

 gives:

 SELECT  person.id, paper.id, paper.title, paper.authors FROM person, 
 paper WHERE (paper.authors LIKE '%|person.id|%');
  
 which I think tries to find those papers whose authors field contains 
 the literal person.id, instead of the pairs (paper,person) such that 
 the person is one of the authors of the paper.

 With the modification I wrote before, it gets converted into:

 'SELECT  person.id, paper.id, paper.title, paper.authors FROM person, 
 paper WHERE INSTR(paper.authors, person.id);'

 with a different meaning.

 I can see why using the INSTR operator on MySQL may be better but do we 
 know it is faster?


 I haven't made any speed test, I'd go for anything that works in sqlite 
 and mysql/mariadb.

 Thanks for your attention!
  


 Massimo

 On Monday, 21 January 2013 08:55:40 UTC-6, pablo@uam.es wrote:

   Hello:
   I was getting incorrect SQL from statements like:

 db(db.paper.authors.contains(person.id)).select()

 where

 db.define_table('paper',
 Field('title'),
 Field('authors', 'list:reference person'),
 )


   so I rewrote dal.MySQLAdapter.CONTAINS from:

 def CONTAINS(self, first, second):
 if first.type in ('string', 'text'):
 key = '%'+str(second).replace('%','%%')+'%'
 elif first.type.startswith('list:'):
 key = 
 '%|'+str(second).replace('|','||').replace('%','%%')+'|%'
 return '(%s LIKE %s)' % 
 (self.expand(first),self.expand(key,'string'))

 into:

 def CONTAINS(self, first, second):
 if first.type in ('string', 'text'):
 key = '%'+str(second).replace('%','%%')+'%'
 elif first.type.startswith('list:reference'):
 return 'INSTR(%s, %s)'%(first, str(second))
 elif first.type.startswith('list:'):
 key = 
 '%|'+str(second).replace('|','||').replace('%','%%')+'|%'
 return '(%s LIKE %s)' % 
 (self.expand(first),self.expand(key,'string'))

 now the above query works, but that's in MySQL, not SQLite, which 
 apparently does not have  a INSTR operation, despite the fact that it is 
 advertised!

 https://www.sqlite.org/lang_corefunc.html

 Can anybody think of a solution that works in more databases




-- 





[web2py] Re: Scheduler ignoring period/repeat setting.

2013-01-22 Thread Stormcrow
Hi Niphlod. Thanks so much for the reply. I suspected I had the* 
queue_task*method in the wrong place and I did.

Is there isn't any neat way of automatically checking that these tasks are 
in the database and adding them if they're not there? I don't really want 
to have to access a controller to get them going I just want them to always 
be there when I start the server.

-- 





[web2py] Re: 'truncate' broken in SQLTABLE with 'headers'.

2013-01-22 Thread Mandar Vaze
Just to revive the discussion, if SQLTABLE is passed a headers dict AND 
truncate value, then truncate isn't honored.

e.g 

mytable = SQLTABLE(somequery,
   headers={'table.field1': 'Label1', 'table.field2': 'Label2'}
   truncate=25)



On Wednesday, July 20, 2011 5:45:21 AM UTC+5:30, Anthony wrote:

 On Tuesday, July 19, 2011 7:48:35 PM UTC-4, Carlos wrote: 

 So 'truncate' is not being respected when using the previous 'headers' 
 format (simple dict of strings).

  
 Oh, I see, you're right -- that should be fixed.
  
 Anthony


This continues to be broken after 12+ months. May be not enough people are 
using SQLTABLE + truncate combination

Any plans to fix this ?

-Mandar


 

  


-- 





[web2py] Is there a way to use SQLFORMs to generate form that can update multiple records?

2013-01-22 Thread Srinath
Hi all,

As the subject states, is there a way to update multiple records in a
single form using SQLFORM?

Thanks in advance,
Srinath

-- 





[web2py] Re: Is there a way to use SQLFORMs to generate form that can update multiple records?

2013-01-22 Thread Alan Etkin


 As the subject states, is there a way to update multiple records in a 
 single form using SQLFORM?


If you don't need to use specifically SQLFORM, you can try 
contrib/spreadsheet using the data option (for viewing/updating a db)
It's intended to deal with numbers and short text, but it could be improved 
to support other field types.

-- 





[web2py] Re: 'truncate' broken in SQLTABLE with 'headers'.

2013-01-22 Thread Mandar Vaze


 On Wednesday, July 20, 2011 5:45:21 AM UTC+5:30, Anthony wrote:

 On Tuesday, July 19, 2011 7:48:35 PM UTC-4, Carlos wrote: 

 So 'truncate' is not being respected when using the previous 'headers' 
 format (simple dict of strings).

  
 Oh, I see, you're right -- that should be fixed.
  
 Anthony

  
commented lines below are potential fix. (gluon/sqlhtml.py)

elif field.type in ['string', 'text']:
r = str(field.formatter(r))
if headers != {}:  # new implement dict
if isinstance(headers[colname], dict):
if isinstance(headers[colname]['truncate'], int
):
r = truncate_string(
r, headers[colname]['truncate'])
#elif truncate is not None:
#r = truncate_string(r, truncate)
elif not truncate is None:
r = truncate_string(r, truncate)


I have tested it in 2.3.2 (2012-12-17 15:03:30) stable it works. (and 
then commented the code so that I get the out of the box behavior)

-Mandar

-- 





Re: [web2py] How I can use code tag with Markmin?

2013-01-22 Thread Alan Etkin
How about

MARKMIN(text, extra={pre_with_code: lambda text: 
precode{0}/code/pre.
format(XML(text, sanitize=True))})

-- 





[web2py] Re: Scheduler ignoring period/repeat setting.

2013-01-22 Thread Niphlod
its more of an architectural problem than a web2py one  to be sure that 
the tasks are there you may have to check for their presence on the 
scheduler_task table. There is the uuid column that is enforced as unique, 
so you can use it to query the table safely.
Now, the problem is that you generally don't want to do a query at every 
request: you may want to look at cron's @reboot or use a little trick using 
cache

lock_tasks = cache.ram('lock_tasks', lambda: request.now, time_expire=120)
if lock_tasks == request.now:
 #do your checks here

What it does? Stores request.now in cache for 120 seconds. Next, it checks 
if the value retrieved from the cache is the same one (meaning that the 
cache value has been refreshed in the same request)  the code in the 
section will be executed at most every two minutes (always assuming that 
requests come along)
Please mind that if you put this in models it works well for web requests, 
but the scheduler executes models too and every time in a fresh process, so 
cache.ram doesn't survive... to eliminate that issue, you may have to put 
this logic too

if not global_settings.cmd_options.scheduler:
#this piece of code is not running on the scheduler



-- 





[web2py] records as fields in a single form

2013-01-22 Thread Annet
I defined the following tables:

db.define_table('nav',
Field('navbarID','reference 
navbar',default='',requires=IS_IN_DB(db,'navbar.id','%(name)s',zero=T('select 
a value')),notnull=True),

Field('name',length=32,default='',requires=[IS_LENGTH(32,error_message=T('length
 
exceeds 32 characters')),IS_NOT_EMPTY()],notnull=True),

Field('backendcontroller',length=32,default='',requires=IS_LENGTH(32,error_message=T('length
 
exceeds 32 characters'))),

Field('frontendcontroller',length=32,default='',requires=IS_LENGTH(32,error_message=T('length
 
exceeds 32 characters'))),

Field('function',length=32,default='',requires=[IS_LENGTH(32,error_message=T('length
 
exceeds 32 characters')),IS_NOT_EMPTY()],notnull=True),
format='%(name)s',
migrate=False)

db.define_table('nodeNav',
Field('nodeID','reference node',**isnode),
Field('navID','reference nav',default='',notnull=True'),
Field('backend',type='boolean',default=False),
Field('frontend',type='boolean',default=False),
on_define=set_requirement,
migrate=False)

Given the following records in nodeNav:

46TrueTrue
47TrueFalse
48TrueFalse
49TrueTrue

I'd like to create a form in which every record is a field, the name should 
be the navID, the label should be the name  in table nav, the field should 
be of type boolean and its value should be the value of frontend.

I thought of something like:

query=db((db.nodeNav.nodeID==4)(db.nodeNav.navID==db.nav.id)(db.nav.navbarID==3))
records=query.select(db.nodeNav.ALL,db.nav.ALL)
fields_list=[]
for r in records:

fields_list.append(Field(name=str(r.nav.id),type='boolean',default=r.nodeNav.frontend,label=r.nav.name))
form=SQLFORM.factory(*fields_list)
if form.process().accepted:
records=query.select(db.nodeNav.ALL)
for r in records:
field=r.navID
r.update_record(frontend=form.vars.field)
return dict(form=form)

Is this the way to go or is there a better way to implement this?

Kind regards,

Annet

-- 





[web2py] Compare row objects inside a for... in loop

2013-01-22 Thread Luciano Laporta Podazza
Hello, 

I've been searching a lot about this but couldn't find anything so sorry 
for this basic question.

How can I compare an actual row object with the next one inside a for...in 
loop?

Thanks in advance!

-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2013-01-22 Thread paolo.vall...@gmail.com
Hi all, I've just discovered that the regex used to retrieve the static
files doesn't work if I use languages abbreviation in urls.
How can we fix this?



2012/12/28 Richard Vézina ml.richard.vez...@gmail.com

 Hello,

 I publish a new script that allow deployment of Redmine beside web2py.

 Here :
 https://groups.google.com/forum/?fromgroups=#!searchin/web2py/redmine/web2py/ZqL7Si8Khbo/Es-wK1yXdgQJ

 Notice : After some read, I choose Unicorn over Phussion Passenger.

 Richard


 On Thu, Dec 20, 2012 at 9:57 AM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 please email me the patch of latest file when ready for inclusion.


 On Thursday, 20 December 2012 03:18:20 UTC-6, Niphlod wrote:

 perfect, Ccing Massimo on this final one.

 Il giorno giovedì 20 dicembre 2012 00:16:25 UTC+1, Paolo ha scritto:

 Hi
 I was trying with the script that comes with the stable web2py. with
 the one on dropbox I problem has gone.

 Paolo


 2012/12/19 Niphlod nip...@gmail.com


 @Simone, an other improvement to the script could be to combine into a
 single server the 80, and 443 to avoid duplicating configuration, as 
 stated
 here :
 http://nginx.org/en/docs/http/configuring_https_servers.**html**
 #single_http_https_serverhttp://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server
 I don't had test this.

 Also, here the code for permanent redirection
 server {
   server_name $hostname;
   listen  80;
   return 301 http*s*://$hostname$request_uri; # NOTE: I am not sure
 for $hostname here, because I didn't set hostname for my VM until now, as
 in the example (URL below) we can use domainName.com instead if properly
 configure in nginx
 ...
 }


 People may want separate configs for http and https. The script
 objective is to have a working copy of web2py. If we start to follow such
 requests, we'd end up installing postgresql and redis too :P

 @Paolo: try the script found at the dropbox link. If the same error
 happens I think we need the log of pip and a hand by Roberto on the
 specific error...

 --







 --
  Paolo

  --





  --







-- 
 Paolo

-- 





Re: [web2py] Re: Is there a way to use SQLFORMs to generate form that can update multiple records?

2013-01-22 Thread Srinath
Is there any guide on how I can make use of this spreadsheet module? How I
create the form and other related guides?


On Tue, Jan 22, 2013 at 4:21 PM, Alan Etkin spame...@gmail.com wrote:

 As the subject states, is there a way to update multiple records in a
 single form using SQLFORM?


 If you don't need to use specifically SQLFORM, you can try
 contrib/spreadsheet using the data option (for viewing/updating a db)
 It's intended to deal with numbers and short text, but it could be
 improved to support other field types.

 --





-- 





[web2py] Re: 'list:reference', contains, Mysql, instr

2013-01-22 Thread pablo . angulo


 person = db(db.person.name='').select().first()
 papers = db.paper.authors.contains(person.id).select()


 Sorry, I didn't read carefully enough. That's not what I need, I need to 
perform a join. My real-world query is rather like:

db.define_table('person',
Field('name', unique=True),
Field('some_field'),
)

Advisor = db.person.with_alias('advisor')
GradStudent = db.person.with_alias('grad')

db.define_table('thesis_project',
Field('advisors', 'list:reference person'),
Field('candidate', db.person),
Field('title', 'text')
)



and then:

db( db.thesis_project.advisors.contains(Advisor.id)  
   (db.thesis_project.candidate==GradStudent.id)  
   (Advisor.some_field==some_value)  
   (GradStudent.some_field==some_value)).select(...)



and it works in mysql using INSTR and CONCAT, and there are other solutions 
with other functions that don't seem to work in sqlite, even though some of 
them are advertised. That's my puzzle.


-- 





[web2py] Re: Compare row objects inside a for... in loop

2013-01-22 Thread Anthony
I suppose you could do something like:

rows = db(query).select()
for i in range(len(rows)-1):
code comparing rows[i] to rows[i+1]

Anthony

On Tuesday, January 22, 2013 8:17:10 AM UTC-5, Luciano Laporta Podazza 
wrote:

 Hello, 

 I've been searching a lot about this but couldn't find anything so sorry 
 for this basic question.

 How can I compare an actual row object with the next one inside a for...in 
 loop?

 Thanks in advance!


-- 





Re: [web2py] Re: Compare row objects inside a for... in loop

2013-01-22 Thread Luciano Laporta Podazza
Hi Anthony!,

Yes, a friend of mine just gave me the same solution and I can't believe I
didn't thought about that :P.

Thanks a lot!!!


On Tue, Jan 22, 2013 at 11:10 AM, Anthony abasta...@gmail.com wrote:

 I suppose you could do something like:

 rows = db(query).select()
 for i in range(len(rows)-1):
 code comparing rows[i] to rows[i+1]

 Anthony

 On Tuesday, January 22, 2013 8:17:10 AM UTC-5, Luciano Laporta Podazza
 wrote:

 Hello,

 I've been searching a lot about this but couldn't find anything so sorry
 for this basic question.

 How can I compare an actual row object with the next one inside a
 for...in loop?

 Thanks in advance!

  --







-- 
Atte
Luciano Laporta Podazza

-- 





Re: [web2py] Re: Book in epub format?

2013-01-22 Thread Massimo Di Pierro
my process is

markmin - html
markmin - latex - pdf - print

There is a latex - epub (http://johnmacfarlane.net/pandoc/)

On Tuesday, 22 January 2013 00:22:11 UTC-6, Johann Spies wrote:

 On 21 January 2013 22:49, Niphlod nip...@gmail.com javascript: wrote:

 rotfl. always available, but I don't know a single thing about the epub 
 format. 
 did anyone tried just converting the pdf to epub using calibre ?


 The success of converting pdf to epub using calibre depends on how the pdf 
 was created.  I had some successes and some miserable results.

 Anyhow I have sent Massimo an epub of the book.

 I used Sigil to create the epub by loading the html-files.

 Regards
 Johann

 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)


-- 





Re: [web2py] How I can use code tag with Markmin?

2013-01-22 Thread Massimo Di Pierro
This would be safe but t may mess up the output. In principe the text 
inside code/ should be allowed to contain any html including script but 
it should not be able to close the code tag. I think the right solution 
is:

MARKMIN(text, extra={pre_with_code: lambda text: 
precode{0}/code/pre.format(cgi.escape(text))})


On Tuesday, 22 January 2013 05:09:57 UTC-6, Alan Etkin wrote:

 How about

 MARKMIN(text, extra={pre_with_code: lambda text: 
 precode{0}/code/pre.
 format(XML(text, sanitize=True))})



-- 





[web2py] Re: How to redirect within a method that was invoked via Ajax?! Problem with wrong method being called.

2013-01-22 Thread c0nstin3
Excellent! 

Thanks Massimo, it worked perfectly!

On Monday, 21 January 2013 19:32:18 UTC, Massimo Di Pierro wrote:

 Assuming your ajax callback function is correctly called you just need to 
 do:

redirect(location, client_side=True)

 instead of

redirect(location)

 With client_side = True you are handling the redirect client-side and not 
 server side. This is designed to work over ajax requests.


 On Monday, 21 January 2013 12:58:03 UTC-6, c0nstin3 wrote:

 Hi everyone,


  Could someone please help me with a problem I'm having with the *amazing
 * web2py framework? 


  This is hard to explain, so please bear with me, I'm still new to web 
 development :)


  I seem to have a problem with using redirect in a function that is 
 called via ajax. I thought I could use web2py_component method to call a 
 method that returns a form (using SQLFORM or CRUD) and when the form is 
 processed OK I could redirect to another method and have the content of 
 that method returned instead.


  Everything is OK if I just add records, or edit records or delete 
 records BUT when I edit or delete a record and then try to add a record 
 something odd happens. Basically, when I delete a record I redirect back to 
 the index page (to reload the grid). The grid is rendered OK BUT when a add 
 a new record (using the form included in the index page) the WRONG METHOD 
 is called. I can see from the debug that the delete method is called. I 
 presume its all to do with me doing a redirect from within a .load file 
 that has been rendered via web2py_component.


  I have page that I load a tabbed display into using ajax 
 (web2py_component). The tabs are labelled Contacts, Documents, Widgets etc. 
 When I click on the Contacts tab I use ajax to call contacts/index and 
 display the what is returned into the tab-content div. Everything is OK at 
 this point.


  @auth.requires_login()

 def index():

 company_id = request.args[0]

  crud.settings.hideerror=True


  db.contact.company.default = company_id


  grid = create_grid(db.contact.company == company_id, company_id)

 form = crud.create(db.contact, next=URL('contacts', 'index', 
 args=company_id, user_signature=True))

 submit_btn = form.element(_type='submit')

 submit_btn['_class']='btn btn-small btn-success'

 submit_btn['_value']='Save'

  return locals()


  The create_grid function returns a grid and the links are like this:


  links = [

 lambda row: A('', _onclick=web2py_component(' + URL(contacts, edit, 
 args=[row.id, company_id], user_signature=True) + ', 'tabContent');, 
 _class='icon-pencil'),

 lambda row: A('', _onclick=web2py_component(' + URL(contacts, 
 delete, args=[row.id, company_id], user_signature=True) + ', 
 'tabContent');, _class='icon-trash')

 ]

  If a click on a Delete link within the grid, this is what is called:


  @auth.requires_login()

 def delete():

 contact_id = request.args[0]

 company_id = request.args[1]

  crud.settings.hideerror=True


  contact = db.contact[contact_id] or redirect(error_page)

 crud.delete(db.contact, contact.id, next=URL('contacts', 'index', 
 args=company_id, user_signature=True))


  The record is deleted OK and the index method is called OK and the grid 
 is re-appears. When I try to add a new record then the delete method is 
 called AGAIN rather than the index method. There is no problem adding 
 records if I don't do a delete first!


  I don't understand what where I'm going wrong :( I suspect its to with 
 using web2py_component method within a partial (.load) file that was also 
 loaded via ajax and then trying to do a redirect from a method that was 
 invoked via ajax.


  Kind Regards,

 Chris


  

-- 





[web2py] Re: records as fields in a single form

2013-01-22 Thread Massimo Di Pierro
I cannot think of any.



On Tuesday, 22 January 2013 06:34:03 UTC-6, Annet wrote:

 I defined the following tables:

 db.define_table('nav',
 Field('navbarID','reference navbar',default='',requires=IS_IN_DB(db,'
 navbar.id','%(name)s',zero=T('select a value')),notnull=True),
 
 Field('name',length=32,default='',requires=[IS_LENGTH(32,error_message=T('length
  
 exceeds 32 characters')),IS_NOT_EMPTY()],notnull=True),
 
 Field('backendcontroller',length=32,default='',requires=IS_LENGTH(32,error_message=T('length
  
 exceeds 32 characters'))),
 
 Field('frontendcontroller',length=32,default='',requires=IS_LENGTH(32,error_message=T('length
  
 exceeds 32 characters'))),
 
 Field('function',length=32,default='',requires=[IS_LENGTH(32,error_message=T('length
  
 exceeds 32 characters')),IS_NOT_EMPTY()],notnull=True),
 format='%(name)s',
 migrate=False)

 db.define_table('nodeNav',
 Field('nodeID','reference node',**isnode),
 Field('navID','reference nav',default='',notnull=True'),
 Field('backend',type='boolean',default=False),
 Field('frontend',type='boolean',default=False),
 on_define=set_requirement,
 migrate=False)

 Given the following records in nodeNav:

 46TrueTrue
 47TrueFalse
 48TrueFalse
 49TrueTrue

 I'd like to create a form in which every record is a field, the name 
 should be the navID, the label should be the name  in table nav, the field 
 should be of type boolean and its value should be the value of frontend.

 I thought of something like:

 query=db((db.nodeNav.nodeID==4)(db.nodeNav.navID==db.nav.id
 )(db.nav.navbarID==3))
 records=query.select(db.nodeNav.ALL,db.nav.ALL)
 fields_list=[]
 for r in records:
 fields_list.append(Field(name=str(r.nav.id
 ),type='boolean',default=r.nodeNav.frontend,label=r.nav.name))
 form=SQLFORM.factory(*fields_list)
 if form.process().accepted:
 records=query.select(db.nodeNav.ALL)
 for r in records:
 field=r.navID
 r.update_record(frontend=form.vars.field)
 return dict(form=form)

 Is this the way to go or is there a better way to implement this?

 Kind regards,

 Annet


-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2013-01-22 Thread Massimo Di Pierro
can you show an example?

On Tuesday, 22 January 2013 07:36:39 UTC-6, Paolo valleri wrote:

 Hi all, I've just discovered that the regex used to retrieve the static 
 files doesn't work if I use languages abbreviation in urls.
 How can we fix this?



 2012/12/28 Richard Vézina ml.richa...@gmail.com javascript:

 Hello,

 I publish a new script that allow deployment of Redmine beside web2py.

 Here : 
 https://groups.google.com/forum/?fromgroups=#!searchin/web2py/redmine/web2py/ZqL7Si8Khbo/Es-wK1yXdgQJ

 Notice : After some read, I choose Unicorn over Phussion Passenger.

 Richard


 On Thu, Dec 20, 2012 at 9:57 AM, Massimo Di Pierro 
 massimo@gmail.comjavascript:
  wrote:

 please email me the patch of latest file when ready for inclusion.


 On Thursday, 20 December 2012 03:18:20 UTC-6, Niphlod wrote:

 perfect, Ccing Massimo on this final one.

 Il giorno giovedì 20 dicembre 2012 00:16:25 UTC+1, Paolo ha scritto:

 Hi
 I was trying with the script that comes with the stable web2py. with 
 the one on dropbox I problem has gone. 

 Paolo 


 2012/12/19 Niphlod nip...@gmail.com


 @Simone, an other improvement to the script could be to combine into 
 a single server the 80, and 443 to avoid duplicating configuration, as 
 stated here :
 http://nginx.org/en/docs/http/configuring_https_servers.**html**
 #single_http_https_serverhttp://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server
 I don't had test this.

 Also, here the code for permanent redirection 
 server {
   server_name $hostname;
   listen  80;
   return 301 http*s*://$hostname$request_uri; # NOTE: I am not sure 
 for $hostname here, because I didn't set hostname for my VM until now, 
 as 
 in the example (URL below) we can use domainName.com instead if 
 properly 
 configure in nginx
 ...
 }


 People may want separate configs for http and https. The script 
 objective is to have a working copy of web2py. If we start to follow 
 such 
 requests, we'd end up installing postgresql and redis too :P 

 @Paolo: try the script found at the dropbox link. If the same error 
 happens I think we need the log of pip and a hand by Roberto on the 
 specific error...
  
 -- 
  
  
  




 -- 
  Paolo
  
  -- 
  
  
  


  -- 
  
  
  




 -- 
  Paolo 


-- 





[web2py] Re: 'list:reference', contains, Mysql, instr

2013-01-22 Thread Massimo Di Pierro
I understand the problem. Please open a ticket with a a request for 
improvement.

On Tuesday, 22 January 2013 07:53:58 UTC-6, pablo@uam.es wrote:

 person = db(db.person.name='').select().first()
 papers = db.paper.authors.contains(person.id).select()


 Sorry, I didn't read carefully enough. That's not what I need, I need to 
 perform a join. My real-world query is rather like:

 db.define_table('person',
 Field('name', unique=True),
 Field('some_field'),
 )
 
 Advisor = db.person.with_alias('advisor')
 GradStudent = db.person.with_alias('grad')

 db.define_table('thesis_project',
 Field('advisors', 'list:reference person'),
 Field('candidate', db.person),
 Field('title', 'text')
 )



 and then:

 db( db.thesis_project.advisors.contains(Advisor.id)  
(db.thesis_project.candidate==GradStudent.id)  
(Advisor.some_field==some_value)  
(GradStudent.some_field==some_value)).select(...)



 and it works in mysql using INSTR and CONCAT, and there are other 
 solutions with other functions that don't seem to work in sqlite, even 
 though some of them are advertised. That's my puzzle.




-- 





[web2py] Re: How to redirect within a method that was invoked via Ajax?! Problem with wrong method being called.

2013-01-22 Thread Massimo Di Pierro
You should thank Anthony. He wrote that code. ;-)

On Tuesday, 22 January 2013 08:47:53 UTC-6, c0nstin3 wrote:

 Excellent! 

 Thanks Massimo, it worked perfectly!

 On Monday, 21 January 2013 19:32:18 UTC, Massimo Di Pierro wrote:

 Assuming your ajax callback function is correctly called you just need to 
 do:

redirect(location, client_side=True)

 instead of

redirect(location)

 With client_side = True you are handling the redirect client-side and not 
 server side. This is designed to work over ajax requests.


 On Monday, 21 January 2013 12:58:03 UTC-6, c0nstin3 wrote:

 Hi everyone,


  Could someone please help me with a problem I'm having with the *
 amazing* web2py framework? 


  This is hard to explain, so please bear with me, I'm still new to web 
 development :)


  I seem to have a problem with using redirect in a function that is 
 called via ajax. I thought I could use web2py_component method to call a 
 method that returns a form (using SQLFORM or CRUD) and when the form is 
 processed OK I could redirect to another method and have the content of 
 that method returned instead.


  Everything is OK if I just add records, or edit records or delete 
 records BUT when I edit or delete a record and then try to add a record 
 something odd happens. Basically, when I delete a record I redirect back to 
 the index page (to reload the grid). The grid is rendered OK BUT when a add 
 a new record (using the form included in the index page) the WRONG METHOD 
 is called. I can see from the debug that the delete method is called. I 
 presume its all to do with me doing a redirect from within a .load file 
 that has been rendered via web2py_component.


  I have page that I load a tabbed display into using ajax 
 (web2py_component). The tabs are labelled Contacts, Documents, Widgets etc. 
 When I click on the Contacts tab I use ajax to call contacts/index and 
 display the what is returned into the tab-content div. Everything is OK at 
 this point.


  @auth.requires_login()

 def index():

 company_id = request.args[0]

  crud.settings.hideerror=True


  db.contact.company.default = company_id


  grid = create_grid(db.contact.company == company_id, company_id)

 form = crud.create(db.contact, next=URL('contacts', 'index', 
 args=company_id, user_signature=True))

 submit_btn = form.element(_type='submit')

 submit_btn['_class']='btn btn-small btn-success'

 submit_btn['_value']='Save'

  return locals()


  The create_grid function returns a grid and the links are like this:


  links = [

 lambda row: A('', _onclick=web2py_component(' + URL(contacts, 
 edit, args=[row.id, company_id], user_signature=True) + ', 
 'tabContent');, _class='icon-pencil'),

 lambda row: A('', _onclick=web2py_component(' + URL(contacts, 
 delete, args=[row.id, company_id], user_signature=True) + ', 
 'tabContent');, _class='icon-trash')

 ]

  If a click on a Delete link within the grid, this is what is called:


  @auth.requires_login()

 def delete():

 contact_id = request.args[0]

 company_id = request.args[1]

  crud.settings.hideerror=True


  contact = db.contact[contact_id] or redirect(error_page)

 crud.delete(db.contact, contact.id, next=URL('contacts', 'index', 
 args=company_id, user_signature=True))


  The record is deleted OK and the index method is called OK and the 
 grid is re-appears. When I try to add a new record then the delete method 
 is called AGAIN rather than the index method. There is no problem adding 
 records if I don't do a delete first!


  I don't understand what where I'm going wrong :( I suspect its to with 
 using web2py_component method within a partial (.load) file that was also 
 loaded via ajax and then trying to do a redirect from a method that was 
 invoked via ajax.


  Kind Regards,

 Chris


  

-- 





[web2py] Re: is bug? sqlform.factory

2013-01-22 Thread www.diazluis.com
thank you all for the answers.

if I am using sqlite.
field size has always been one (1) character.
that the form only allows me to store more.

My logic told me that if a user entered eg AAA
the system only stores A

-- 





[web2py] Re: Scheduler ignoring period/repeat setting.

2013-01-22 Thread Stormcrow
Hi again,
Thanks for the tips! What I ended up doing is creating a model file 
containing the following:

import datetime 
if db(db.scheduler_task).isempty():  

db.scheduler_task.update_or_insert(db.scheduler_task.task_name=='my_function',
application_name='my_app',
task_name='my_function',
function_name='my_function',
repeats =  0, 
period = 5,
retry_failed = -1
)
db.commit()

There is perhaps a less verbose way to do it, I didn't check which fields 
have defaults. I tried the same thing using the *queue_task *function but 
it seemed to cause multiple tasks to appear again,* update_or_insert*solved 
that problem.

-- 





Re: [web2py] Re: Is there a way to use SQLFORMs to generate form that can update multiple records?

2013-01-22 Thread Alan Etkin


 Is there any guide on how I can make use of this spreadsheet module? How I 
 create the form and other related guides?


The module docstring has some help and simple examples.

 See this web2py plugin also: https://bitbucket.org/rochacbruno/powertable

-- 





[web2py] How to disable deleting profile pictures...

2013-01-22 Thread sasogeek
#model
db.define_table(
auth.settings.table_user_name,
Field('profile_picture', 'upload',))

#controller
def user():
form=auth()
return dict(form=form)

#view
{{=form}}

How do I disable the delete feature? it appears like so on the page...

Profile Picture [uploaded image]   [file|*delete]


How do i make that delete feature disappear...?

-- 





[web2py] How to disable deleting profile pictures...

2013-01-22 Thread sasogeek
#model
db.define_table(
auth.settings.table_user_name,
Field('profile_picture', 'upload',))

#controller
def user():
form=auth()
return dict(form=form)

#view
{{=form}}

How do I disable the delete feature? it appears like so on the page...

Profile Picture [uploaded image]   [file|*delete]


How do i make that delete feature disappear...?

-- 





Re: [web2py] Form with fields collected from javascript

2013-01-22 Thread Christian Espinoza
Hi Bruno, now my form at the view is:

{{=form.custom.begin}}
Name: {{=form.custom.widget.name}}
input type='hidden' id=fences_type name=type
input type='hidden' id=fences_definition name=definition
input type='hidden' id=fences_customer name=customer
{{=form.custom.submit}}
{{=form.custom.end}}

I'm was testing a lot of times a insert with it, and every first time I'm 
login to app
this form doesn't insert the data and nothing else shows, after that all 
works fine, only the first time fails...
I can insert 30 times after the first time without problems..

I was checking the javascript data and all times the data is collected very 
well
My controller now is :
def fences():
form = SQLFORM(db.fences)
if form:
if form.process().accepted:
response.flash = 'Datos Ingresados'
else:
#response.flash = form.vars
  response.flash = form.errors
return(form=form))
 
I tried to debug, but at the last web2py trunk version the debugger doesn't 
work very well

Thanks in advance.
Christian.

El lunes, 21 de enero de 2013 17:12:38 UTC-3, rochacbruno escribió:

 SQLFORM expects a field named fences_customer the pattern is 
 tablename_fieldname


-- 





Re: [web2py] Redmine beside web2py with Nginx deployment script

2013-01-22 Thread Richard Vézina
On Mon, Jan 21, 2013 at 5:30 PM, Arnon Marcus a.m.mar...@gmail.com wrote:

 M array over Windows 2008R2 Hyper-V, and it has better support for
 CentOS/RHEL then for Ubuntu (something relating to virtualization
  acceleration...)


I don't know CentOS, but as long as you know a bit of bash I think it could
be easy to adapt it for CentOS... The main task will be to identified the
equivalent packages names... If you make any effort in this direction,
think to others users and publish your script here...

Richard

-- 





[web2py] Re: Scheduler ignoring period/repeat setting.

2013-01-22 Thread Niphlod
queue_task does a validate_or_insert, because its meant to be used to queue 
the tasks  
if you want to use that you should enforce your own fixed uuid and pass 
that to queue_task()... validation will fail (because the uuid is declared 
as unique, and another row with that id sits on the table yet) and so no 
new insert will be done.
PS: you don't need to put in the application_name, it's filled 
automatically.
PS2: a 5 seconds period is rather small, with the default heartbeat don't 
expect to get exactly 20 runs in one minute

if you put this in models a query is fired at every request to check if the 
table is empty: if you're fine with that than I'm glad you solved the 
problem ^_^

On Tuesday, January 22, 2013 4:01:01 PM UTC+1, Stormcrow wrote:

 Hi again,
 Thanks for the tips! What I ended up doing is creating a model file 
 containing the following:

 import datetime 
 if db(db.scheduler_task).isempty():
   
 db.scheduler_task.update_or_insert(db.scheduler_task.task_name=='my_function',
   application_name='my_app',
   task_name='my_function',
   function_name='my_function',
   repeats =  0, 
   period = 5,
   retry_failed = -1
 )
 db.commit()

 There is perhaps a less verbose way to do it, I didn't check which fields 
 have defaults. I tried the same thing using the *queue_task *function but 
 it seemed to cause multiple tasks to appear again,* update_or_insert*solved 
 that problem.


-- 





[web2py] sqlform.grid does not delete record

2013-01-22 Thread António Ramos
hello
my sqlform.grid delete button , deletes the document from the grid but if i
refresh the page the document comes back again to the grid.

mytable = SQLFORM.grid( db.t_docs.f_trab_ref==request.args(0),
csv=False,
searchable=False,
maxtextlength=32,
details=False,
editable=False,
)


I have to go to admin to delete the record







What is wrong?



Thank you

-- 





[web2py] Re: records as fields in a single form

2013-01-22 Thread Alan Etkin


 I defined the following tables:

 
- contrib.spreadsheet plus the data argument (a DAL instance), but I'm not 
sure it supports joins (see the module help)
- Or maybe plugin powertable?

-- 





[web2py] Twitter bootstrap cannot recreate popover

2013-01-22 Thread António Ramos
hello
i´m testing twitter popover efect but i have to press the button the see
the popup, instead of just hovering above the button.

jQuery(document).ready(function(){
jQuery(#example).popover();

...
...

a href=# id=example class=btn btn-success rel=popover
data-content=It's so simpleasd asd asd asd asd asd asdasd asd asd sa d asd
asd asd asd asd sd  to create a tooltop for my website!
data-original-title=Twitter Bootstrap Popoverhover for popover/a/a


Thank you

-- 





[web2py] Re: Re-enable admin interface

2013-01-22 Thread Wonton
Thanks, I will try this.

Anyway, is there any way to upload a packed project to the server without 
admin access?

El lunes, 21 de enero de 2013 22:28:41 UTC+1, Niphlod escribió:

 admin works on sessions like any other app. I think your problem will be 
 easily fixed by just deleting the applications/admin/sessions/* files.

 On Monday, January 21, 2013 7:18:01 PM UTC+1, Wonton wrote:

 Hello,

 Trying to upload my web2py project to the server I failed to enter the 
 admin password (4 times :-S) so the admin interface was automatically 
 disabled. 
 Since I have no access to my server and I have to request all things to 
 the server administrators I asked them to re-enable the admin interface. 
 But they have answer me that they don't know how to do it, so...what should 
 they do to re-enable the admin interface? The server is a typical Apache.

 Kind regards and thank you very much!



-- 





[web2py] Re: Twitter bootstrap cannot recreate popover

2013-01-22 Thread Anthony
What does this have to do with web2py?

On Tuesday, January 22, 2013 11:45:43 AM UTC-5, Ramos wrote:

 hello
 i´m testing twitter popover efect but i have to press the button the see 
 the popup, instead of just hovering above the button.

 jQuery(document).ready(function(){
 jQuery(#example).popover();
 
 ...
 ...

 a href=# id=example class=btn btn-success rel=popover 
 data-content=It's so simpleasd asd asd asd asd asd asdasd asd asd sa d asd 
 asd asd asd asd sd  to create a tooltop for my website! 
 data-original-title=Twitter Bootstrap Popoverhover for popover/a/a


 Thank you


-- 





Re: [web2py] Re: web2py best practices/patterns

2013-01-22 Thread Richard Vézina
Does Model Less approach still relevent with the new lazy table feature??

Richard


On Mon, Jan 21, 2013 at 7:15 PM, samuel bonilla pythonn...@gmail.comwrote:

 look, this is for big project :

 Model Less Apps (using data models and modules in web2py)


 http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py



 http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py



 http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py


 El miércoles, 16 de enero de 2013 07:35:21 UTC-5, H.C. v. Stockhausen
 escribió:

 Hi,

 working with web2py is fun and I've learned a lot about web development
 and Python. So 'yes', web2py is a great teaching tool and the docs are very
 good too. Small projects are a breeze to realize and MVC separates the
 concerns nicely. In larger projects however, I still manage to end up in a
 bit of a mess. What I lack is a set of w2p design principles that go beyond
 MVC.

 The type of questions I had are:

 - What should one never place into a Model, View, Controller, Module and
 why?
 - What should one always place into a Model, View, Controller, Module and
 why?
 - What known exceptions are there to these rules?
 - Should a view ideally be assembled entirely from components?
 - At what granularity should components, controllers and plugins operate?
 - Should one try to create a (Rest) API first and then consume it oneself?
 ...

 Here's how I would answer some of them today:
 - Create a distinct controller for every business function (blog,
 shopping cart, ...)
 - Keep controller actions as small as possible.
 - Move all utility functions into custom modules that don't depend on w2p
 (i.e. they don't import gluon).
 - Allow strictly no logic in views except for loops and branches.
 - If DAL is too low-level or an alternative storage backend is used
 create a ORM-type wrapper as a custom module.
 - Assemble pages from components.
 ...

 This is how I would go about my next w2p project today but I am sure that
 I would have to learn some new lessons the hard way.

 How do you structure your apps to avoid spaghetti logic and to keep them
 maintainable? I would also be interested to hear the kind of questions you
 have?

 Maybe we can collect our lessons learned and compile a nice
 document/catalogue. If there's already such a doc, please let me know.

 Best regards,
 HC










  --





-- 





[web2py] Re: sqlform.grid does not delete record

2013-01-22 Thread Niphlod
SQLFORM.grid uses args to determine what to do. you are using 
request.args(0) in your query without letting know the grid that the 
args(0) is needed by you and should be left alone .

please use SQLFORM.grid( ... args=request.args[:1]) 

On Tuesday, January 22, 2013 5:25:06 PM UTC+1, Ramos wrote:

 hello
 my sqlform.grid delete button , deletes the document from the grid but if 
 i refresh the page the document comes back again to the grid.

 mytable = SQLFORM.grid( db.t_docs.f_trab_ref==request.args(0), 
 csv=False,  
 searchable=False,
 maxtextlength=32,
 details=False,
 editable=False,
 )


 I have to go to admin to delete the record







 What is wrong?



 Thank you


-- 





Re: [web2py] Re: Twitter bootstrap cannot recreate popover

2013-01-22 Thread António Ramos
 I´l try my best to solve it myself!

This question was never posted!

:)

2013/1/22 Anthony abasta...@gmail.com

 What does this have to do with web2py?


 On Tuesday, January 22, 2013 11:45:43 AM UTC-5, Ramos wrote:

 hello
 i´m testing twitter popover efect but i have to press the button the see
 the popup, instead of just hovering above the button.

 jQuery(document).ready(**function(){
 jQuery(#example).popover();
 
 ...
 ...

 a href=# id=example class=btn btn-success rel=popover
 data-content=It's so simpleasd asd asd asd asd asd asdasd asd asd sa d asd
 asd asd asd asd sd  to create a tooltop for my website!
 data-original-title=Twitter Bootstrap Popoverhover for popover/a/a


 Thank you

  --





-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2013-01-22 Thread paolo.vall...@gmail.com
Hi Massimo, for example, if I visit this
traffic.integreen-life.bz.it/default/wiki/about  (default is the controller
and wiki is the function) it works while
traffic.integreen-life.bz.it/it/default/wiki/about the application works
very well but the static links do not.

Paolo


2013/1/22 Massimo Di Pierro massimo.dipie...@gmail.com

 can you show an example?


 On Tuesday, 22 January 2013 07:36:39 UTC-6, Paolo valleri wrote:

 Hi all, I've just discovered that the regex used to retrieve the static
 files doesn't work if I use languages abbreviation in urls.
 How can we fix this?



 2012/12/28 Richard Vézina ml.richa...@gmail.com

  Hello,

 I publish a new script that allow deployment of Redmine beside web2py.

 Here : https://groups.google.com/**forum/?fromgroups=#!searchin/**
 web2py/redmine/web2py/**ZqL7Si8Khbo/Es-wK1yXdgQJhttps://groups.google.com/forum/?fromgroups=#!searchin/web2py/redmine/web2py/ZqL7Si8Khbo/Es-wK1yXdgQJ

 Notice : After some read, I choose Unicorn over Phussion Passenger.

 Richard


 On Thu, Dec 20, 2012 at 9:57 AM, Massimo Di Pierro 
 massimo@gmail.com wrote:

 please email me the patch of latest file when ready for inclusion.


 On Thursday, 20 December 2012 03:18:20 UTC-6, Niphlod wrote:

 perfect, Ccing Massimo on this final one.

 Il giorno giovedì 20 dicembre 2012 00:16:25 UTC+1, Paolo ha scritto:

 Hi
 I was trying with the script that comes with the stable web2py. with
 the one on dropbox I problem has gone.

 Paolo


 2012/12/19 Niphlod nip...@gmail.com


 @Simone, an other improvement to the script could be to combine into
 a single server the 80, and 443 to avoid duplicating configuration, as
 stated here :
 http://nginx.org/en/docs/http/**configuring_https_servers.**
 html#single_http_https_serverhttp://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server
 I don't had test this.

 Also, here the code for permanent redirection
 server {
   server_name $hostname;
   listen  80;
   return 301 http*s*://$hostname$request_uri; # NOTE: I am not
 sure for $hostname here, because I didn't set hostname for my VM until 
 now,
 as in the example (URL below) we can use domainName.com instead if 
 properly
 configure in nginx
 ...
 }


 People may want separate configs for http and https. The script
 objective is to have a working copy of web2py. If we start to follow 
 such
 requests, we'd end up installing postgresql and redis too :P

 @Paolo: try the script found at the dropbox link. If the same error
 happens I think we need the log of pip and a hand by Roberto on the
 specific error...

 --







 --
  Paolo

  --





  --







 --
  Paolo

  --







-- 
 Paolo

-- 





Re: [web2py] Re: web2py best practices/patterns

2013-01-22 Thread Bruno Rocha
On Tue, Jan 22, 2013 at 3:09 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 Does Model Less approach still relevent with the new lazy table feature??


No need to use this module based approach (unless you want), now with
lazy_tables it is better to use the standard ways to avoid extra loads.

-- 





Re: [web2py] Re: Twitter bootstrap cannot recreate popover

2013-01-22 Thread Anthony
You might try the Bootstrap support forum.

On Tuesday, January 22, 2013 12:13:41 PM UTC-5, Ramos wrote:


  I´l try my best to solve it myself!

 This question was never posted!

 :)

 2013/1/22 Anthony abas...@gmail.com javascript:

 What does this have to do with web2py?


 On Tuesday, January 22, 2013 11:45:43 AM UTC-5, Ramos wrote:

 hello
 i´m testing twitter popover efect but i have to press the button the see 
 the popup, instead of just hovering above the button.

 jQuery(document).ready(**function(){
 jQuery(#example).popover();
 
 ...
 ...

 a href=# id=example class=btn btn-success rel=popover 
 data-content=It's so simpleasd asd asd asd asd asd asdasd asd asd sa d asd 
 asd asd asd asd sd  to create a tooltop for my website! 
 data-original-title=Twitter Bootstrap Popoverhover for popover/a/a


 Thank you

  -- 
  
  
  




-- 





Re: [web2py] Re: Twitter bootstrap cannot recreate popover

2013-01-22 Thread Richard Vézina
I think Popover is not working properly with Chromium or even Chrome, I
notice that a month or 2 ago.

Richard


On Tue, Jan 22, 2013 at 12:33 PM, Anthony abasta...@gmail.com wrote:

 You might try the Bootstrap support forum.


 On Tuesday, January 22, 2013 12:13:41 PM UTC-5, Ramos wrote:


  I´l try my best to solve it myself!

 This question was never posted!

 :)

 2013/1/22 Anthony abas...@gmail.com

 What does this have to do with web2py?


 On Tuesday, January 22, 2013 11:45:43 AM UTC-5, Ramos wrote:

 hello
 i´m testing twitter popover efect but i have to press the button the
 see the popup, instead of just hovering above the button.

 jQuery(document).ready(**functio**n(){
 jQuery(#example).popover();
 
 ...
 ...

 a href=# id=example class=btn btn-success rel=popover
 data-content=It's so simpleasd asd asd asd asd asd asdasd asd asd sa d asd
 asd asd asd asd sd  to create a tooltop for my website!
 data-original-title=Twitter Bootstrap Popoverhover for popover/a/a


 Thank you

  --





  --





-- 





[web2py] Sqlform.Factory upload file error!

2013-01-22 Thread António Ramos
hello
my sqlform.factory below

trab_id=db.trabalhador.insert(**db.trabalhador._filter_fields(form.vars))

is not uploading a file

First i got error
SQLFORM.factory - RuntimeError: you must specify a
Field(...,uploadfolder=...)

so i added in my model

Field('apt_medica','upload',
uploadfolder=os.path.join(request.folder,'uploads'),label='Ficha de aptidão
médica'),

then the upload is done( i think! because no errors)

Strangely in app admin when i click in the file link i get another error

404 not found

the url is
http://127.0.0.1:8000/EMPRE2/appadmin/download/db/*no_table.*
apt_medica.b8e824a896390be6.737061333130322e747874.txt

what does it mean  *no_table *in the url?


Thank you

-- 





[web2py] can smartgrid use a SET as a table?

2013-01-22 Thread Alex Glaros
Here is an example of a SET named purchased from the 
documentationhttp://www.web2py.com/examples/default/examples
:

purchased = \n(db.person.id==db.purchase.buyer_id)\n
(db.product.id==db.purchase.product_id)

Can Smartgrid use the SET purchased instead of a table, e.g., as in the 
example below (instead of tables person, product, purchase)?

def manage_transactions():
grid = SQLFORM 
http://www.web2py.com/examples/global/vars/SQLFORM.smartgrid(db.person,linked_tables=['product','purchase'],
 user_signature=False)
return dict(grid=grid)

What would the syntax look like?

Thanks,

Alex Glaros


-- 





[web2py] Re: can smartgrid use a SET as a table?

2013-01-22 Thread Derek
No.
The first argument of SQLFORM.grid can be a table or a query.

A SQLFORM.smartgrid looks a lot like a grid, in fact it contains a grid but 
it is designed to take as input not a query but only one table and to 
browse said table and selected referencing tables.

You can use SQLFORM.grid, but not smartgrid.

On Tuesday, January 22, 2013 12:24:23 PM UTC-7, Alex Glaros wrote:

 Here is an example of a SET named purchased from the 
 documentationhttp://www.web2py.com/examples/default/examples
 :

 purchased = \n(db.person.id==db.purchase.buyer_id)\n
 (db.product.id==db.purchase.product_id)

 Can Smartgrid use the SET purchased instead of a table, e.g., as in the 
 example below (instead of tables person, product, purchase)?

 def manage_transactions():
 grid = SQLFORM 
 http://www.web2py.com/examples/global/vars/SQLFORM.smartgrid(db.person,linked_tables=['product','purchase'],
  user_signature=False)
 return dict(grid=grid)

 What would the syntax look like?

 Thanks,

 Alex Glaros




-- 





[web2py] Share by lockerz doesn't close on an iphone

2013-01-22 Thread GeeksRule
Maybe this is an issue with the lockerz, but has anyone noticed that when 
you click on a share option in iphone, e.g. facebook etc. it launches a new 
page.
If you close that page and return back to the page you were trying to 
share, the popup is still there.

Also, even when you try to click somewhere else, that pop-up still remains..

I haven't modified the default code for the Share buttons.

Would appreciate, if anyone knows a way around this.

-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2013-01-22 Thread Niphlod
got it. can you post the routes.py you're using ?

The problem lies in the fact that routes.py is really flexible and adapting 
that logic using only rewrite or alias statements in nginx is cumbersome.
Standing on one feet (i.e. without tests) I'd say that the regex checking 
static files

location ~* /(\w+)/static/ {
root /home/www-data/web2py/applications/;
#remove next comment on production
#expires max;
}

is catching it as the app name and not the language trick . so, for a request 
going to /it/app/static/whatever.css is looking into 
/home/www-data/web2py/applications/*it/*appname/static/whatever.css instead of  
. (remove the bold part, *it/*).

If you remove those lines web2py will take charge for static files serving, 
so the issue will be temporarily fixed.

I'll try to set up some additional rules to make nginx behave like 
routes.py, but it will take some time.

PS: please mind that the script it's a template it's not meant to 
fullfill every custom installation patterns out there without further 
tuning.
language routing is probably the most difficult out there because for a 
request
/it/appname/static/whateverfile.css
web2py looks into /web2py/appname/static/it/whateverfile.css and then if 
not found into /web2py/appname/static/whateverfile.css (a nice fallback, 
but hard to map with a simple nginx statement)

On Tuesday, January 22, 2013 6:14:55 PM UTC+1, Paolo valleri wrote:

 Hi Massimo, for example, if I visit this 
 traffic.integreen-life.bz.it/default/wiki/about  (default is the 
 controller and wiki is the function) it works while 
 traffic.integreen-life.bz.it/it/default/wiki/about the application works 
 very well but the static links do not.

 Paolo


 2013/1/22 Massimo Di Pierro massimo@gmail.com javascript:

 can you show an example?


 On Tuesday, 22 January 2013 07:36:39 UTC-6, Paolo valleri wrote:

 Hi all, I've just discovered that the regex used to retrieve the static 
 files doesn't work if I use languages abbreviation in urls.
 How can we fix this?



 2012/12/28 Richard Vézina ml.richa...@gmail.com

  Hello,

 I publish a new script that allow deployment of Redmine beside web2py.

 Here : https://groups.google.com/**forum/?fromgroups=#!searchin/**
 web2py/redmine/web2py/**ZqL7Si8Khbo/Es-wK1yXdgQJhttps://groups.google.com/forum/?fromgroups=#!searchin/web2py/redmine/web2py/ZqL7Si8Khbo/Es-wK1yXdgQJ

 Notice : After some read, I choose Unicorn over Phussion Passenger.

 Richard


 On Thu, Dec 20, 2012 at 9:57 AM, Massimo Di Pierro 
 massimo@gmail.com wrote:

 please email me the patch of latest file when ready for inclusion.


 On Thursday, 20 December 2012 03:18:20 UTC-6, Niphlod wrote:

 perfect, Ccing Massimo on this final one.

 Il giorno giovedì 20 dicembre 2012 00:16:25 UTC+1, Paolo ha scritto:

 Hi
 I was trying with the script that comes with the stable web2py. with 
 the one on dropbox I problem has gone. 

 Paolo 


 2012/12/19 Niphlod nip...@gmail.com


 @Simone, an other improvement to the script could be to combine 
 into a single server the 80, and 443 to avoid duplicating 
 configuration, as 
 stated here :
 http://nginx.org/en/docs/http/**configuring_https_servers.**
 html#single_http_https_serverhttp://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server
 I don't had test this.

 Also, here the code for permanent redirection 
 server {
   server_name $hostname;
   listen  80;
   return 301 http*s*://$hostname$request_uri; # NOTE: I am not 
 sure for $hostname here, because I didn't set hostname for my VM 
 until now, 
 as in the example (URL below) we can use domainName.com instead if 
 properly 
 configure in nginx
 ...
 }


 People may want separate configs for http and https. The script 
 objective is to have a working copy of web2py. If we start to follow 
 such 
 requests, we'd end up installing postgresql and redis too :P 

 @Paolo: try the script found at the dropbox link. If the same error 
 happens I think we need the log of pip and a hand by Roberto on the 
 specific error...
  
 -- 
  
  
  




 -- 
  Paolo
  
  -- 
  
  
  


  -- 
  
  
  




 -- 
  Paolo 

  -- 
  
  
  




 -- 
  Paolo 


-- 





[web2py] Re: HOSTING FOR web2py ?

2013-01-22 Thread GeeksRule
I was using (slicehost -- now rackspace). You get a dedicated slice and it 
has worked well for me.
You get a plain-minimal linux installation and you can do what you want 
with it.
SliceHost had awesome support, but rackspace isn't that bad either.


On Friday, 18 January 2013 21:11:43 UTC-5, samuel bonilla wrote:

 I'm doing testing for my application in pythonanywhere.com, but I had 
 some problems with paypal and I could not buy a domain.

 someone can recommend another hosting web2py to not only accept paypal ?

 thank you very much.


-- 





[web2py] Re: How to disable deleting profile pictures...

2013-01-22 Thread Derek
Add:
ondelete = 'NO ACTION' to the field... that will make it not deletable. 
They may still see the checkbox though.

On Tuesday, January 22, 2013 8:08:49 AM UTC-7, sasogeek wrote:

 #model
 db.define_table(
 auth.settings.table_user_name,
 Field('profile_picture', 'upload',))

 #controller
 def user():
 form=auth()
 return dict(form=form)

 #view
 {{=form}}

 How do I disable the delete feature? it appears like so on the page...

 Profile Picture [uploaded image]   [file|*delete]


 How do i make that delete feature disappear...?


-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2013-01-22 Thread paolo.vall...@gmail.com
Hi Niphlod, once I discovered that making a symbolic link for each language
in the app directory pointing to the app directory worked well.
Namely something like that app_dir/it --- app_dir . However  it would be
better to find something cleaner but for that I have to look at nginx but
right now I don't access to the virtual machine.
I guess we can add a new directive for serving static files with language
in url. will it works?
Paolo


2013/1/22 Niphlod niph...@gmail.com

 got it. can you post the routes.py you're using ?

 The problem lies in the fact that routes.py is really flexible and
 adapting that logic using only rewrite or alias statements in nginx is
 cumbersome.
 Standing on one feet (i.e. without tests) I'd say that the regex checking
 static files

 location ~* /(\w+)/static/ {
 root /home/www-data/web2py/applications/;
 #remove next comment on production
 #expires max;
 }

 is catching it as the app name and not the language trick . so, for a 
 request going to /it/app/static/whatever.css is looking into

 /home/www-data/web2py/applications/*it/*appname/static/whatever.css instead 
 of  . (remove the bold part, *it/*).

 If you remove those lines web2py will take charge for static files
 serving, so the issue will be temporarily fixed.

 I'll try to set up some additional rules to make nginx behave like
 routes.py, but it will take some time.

 PS: please mind that the script it's a template it's not meant to
 fullfill every custom installation patterns out there without further
 tuning.
 language routing is probably the most difficult out there because for a
 request
 /it/appname/static/whateverfile.css
 web2py looks into /web2py/appname/static/it/whateverfile.css and then if
 not found into /web2py/appname/static/whateverfile.css (a nice fallback,
 but hard to map with a simple nginx statement)


 On Tuesday, January 22, 2013 6:14:55 PM UTC+1, Paolo valleri wrote:

 Hi Massimo, for example, if I visit this traffic.integreen-life.bz.it/**
 default/wiki/abouthttp://traffic.integreen-life.bz.it/default/wiki/about 
 (default is the controller and wiki is the function) it works while
 traffic.integreen-life.bz.it/**it/default/wiki/abouthttp://traffic.integreen-life.bz.it/it/default/wiki/aboutthe
  application works very well but the static links do not.

 Paolo


 2013/1/22 Massimo Di Pierro massimo@gmail.com

 can you show an example?


 On Tuesday, 22 January 2013 07:36:39 UTC-6, Paolo valleri wrote:

 Hi all, I've just discovered that the regex used to retrieve the static
 files doesn't work if I use languages abbreviation in urls.
 How can we fix this?



 2012/12/28 Richard Vézina ml.richa...@gmail.com

  Hello,

 I publish a new script that allow deployment of Redmine beside web2py.

 Here : https://groups.google.com/**fo**rum/?fromgroups=#!searchin/**
 web**2py/redmine/web2py/**ZqL7Si8Khbo**/Es-wK1yXdgQJhttps://groups.google.com/forum/?fromgroups=#!searchin/web2py/redmine/web2py/ZqL7Si8Khbo/Es-wK1yXdgQJ

 Notice : After some read, I choose Unicorn over Phussion Passenger.

 Richard


 On Thu, Dec 20, 2012 at 9:57 AM, Massimo Di Pierro 
 massimo@gmail.com wrote:

 please email me the patch of latest file when ready for inclusion.


 On Thursday, 20 December 2012 03:18:20 UTC-6, Niphlod wrote:

 perfect, Ccing Massimo on this final one.

 Il giorno giovedì 20 dicembre 2012 00:16:25 UTC+1, Paolo ha scritto:

 Hi
 I was trying with the script that comes with the stable web2py.
 with the one on dropbox I problem has gone.

 Paolo


 2012/12/19 Niphlod nip...@gmail.com


 @Simone, an other improvement to the script could be to combine
 into a single server the 80, and 443 to avoid duplicating 
 configuration, as
 stated here :
 http://nginx.org/en/docs/http/configuring_https_servers.*
 *html**#single_http_https_serverhttp://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server
 I don't had test this.

 Also, here the code for permanent redirection
 server {
   server_name $hostname;
   listen  80;
   return 301 http*s*://$hostname$request_uri; # NOTE: I am not
 sure for $hostname here, because I didn't set hostname for my VM 
 until now,
 as in the example (URL below) we can use domainName.com instead if 
 properly
 configure in nginx
 ...
 }


 People may want separate configs for http and https. The script
 objective is to have a working copy of web2py. If we start to follow 
 such
 requests, we'd end up installing postgresql and redis too :P

 @Paolo: try the script found at the dropbox link. If the same
 error happens I think we need the log of pip and a hand by Roberto on 
 the
 specific error...

 --







 --
  Paolo

  --





  --







 --
  Paolo

  --







 --
  Paolo

  --







-- 
 Paolo

-- 





Re: [web2py] Redmine beside web2py with Nginx deployment script

2013-01-22 Thread Alan Etkin


 Will the already-existing script for CentOS work for 6.3 86_64 ?


I think it's based in a 32 bit os, but I suppose it's needs just rewriting 
the parts that download libraries for that architecture. 

-- 





[web2py] Re: Help on Unit Tests

2013-01-22 Thread Israel Fermin Montilla
Thank you very much for your quick answers.

I saw that article you're saying Anthony, that was the way I was writing my 
tests, and I also tried to 
write my own test runner using unittest, os and sys and I faced the problem 
that Bruno points out, 
web2py runs on his own environment.

Are there any contributing guidelines or a mailing list like 
web2py-ideas?, or any TO-DO list?

Thank you very much

-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2013-01-22 Thread Niphlod
maybe I have a fix .
Can you please test it ?
assuming an example of routes.py like

myapp = dict(languages=['en', 'it', 'jp'], default_language='en')


this means that navigating to:
 /myapp/ -- the static files will be referenced as 
web2py_home/applications/myapp/en/static/whatever.css
 /myapp/it/ -- the static files will be referenced as 
web2py_home/applications/myapp/it/static/whatever.css

however, direct requests to /myapp/static/whatever.css should map to 
web2py_home/applications/myapp/en/static/whatever.css

additionally, if /myapp/it/static/whatever.css is requested, if not found 
web2py_home/applications/myapp/static/whatever.css should be served.

Now, I think that adding this section before the standard one will fix the 
issue

location ~* /(\w+)/(en|it|jp)/static/(.*)$ {
alias /home/www-data/web2py/applications/$1/;
try_files static/$2/$3 static/$3 =404;
}

(en|it|jp) here is the regex matching the languages list of the routes 
app's dict  This will set for the request /myapp/it/static/whatever.css 
  the alias to the web2py_home/applications/myapp/ and then try to serve 
static/it/whatever.css, if not found, it will fall back to a normal 
static/whatever.css, and if that one is not found will return a 404.

@Jonathan: please stop me if I did miss something in the routes logic
@all : seems a simple fix - maybe too simple... please help test it

On Tuesday, January 22, 2013 9:14:26 PM UTC+1, Niphlod wrote:

 got it. can you post the routes.py you're using ?

 The problem lies in the fact that routes.py is really flexible and 
 adapting that logic using only rewrite or alias statements in nginx is 
 cumbersome.
 Standing on one feet (i.e. without tests) I'd say that the regex checking 
 static files

 location ~* /(\w+)/static/ {
 root /home/www-data/web2py/applications/;
 #remove next comment on production
 #expires max;
 }

 is catching it as the app name and not the language trick . so, for a 
 request going to /it/app/static/whatever.css is looking into 
 /home/www-data/web2py/applications/*it/*appname/static/whatever.css instead 
 of  . (remove the bold part, *it/*).

 If you remove those lines web2py will take charge for static files 
 serving, so the issue will be temporarily fixed.

 I'll try to set up some additional rules to make nginx behave like 
 routes.py, but it will take some time.

 PS: please mind that the script it's a template it's not meant to 
 fullfill every custom installation patterns out there without further 
 tuning.
 language routing is probably the most difficult out there because for a 
 request
 /it/appname/static/whateverfile.css
 web2py looks into /web2py/appname/static/it/whateverfile.css and then if 
 not found into /web2py/appname/static/whateverfile.css (a nice fallback, 
 but hard to map with a simple nginx statement)

 On Tuesday, January 22, 2013 6:14:55 PM UTC+1, Paolo valleri wrote:

 Hi Massimo, for example, if I visit this 
 traffic.integreen-life.bz.it/default/wiki/about  (default is the 
 controller and wiki is the function) it works while 
 traffic.integreen-life.bz.it/it/default/wiki/about the application works 
 very well but the static links do not.

 Paolo


 2013/1/22 Massimo Di Pierro massimo@gmail.com

 can you show an example?


 On Tuesday, 22 January 2013 07:36:39 UTC-6, Paolo valleri wrote:

 Hi all, I've just discovered that the regex used to retrieve the static 
 files doesn't work if I use languages abbreviation in urls.
 How can we fix this?



 2012/12/28 Richard Vézina ml.richa...@gmail.com

  Hello,

 I publish a new script that allow deployment of Redmine beside web2py.

 Here : https://groups.google.com/**forum/?fromgroups=#!searchin/**
 web2py/redmine/web2py/**ZqL7Si8Khbo/Es-wK1yXdgQJhttps://groups.google.com/forum/?fromgroups=#!searchin/web2py/redmine/web2py/ZqL7Si8Khbo/Es-wK1yXdgQJ

 Notice : After some read, I choose Unicorn over Phussion Passenger.

 Richard


 On Thu, Dec 20, 2012 at 9:57 AM, Massimo Di Pierro 
 massimo@gmail.com wrote:

 please email me the patch of latest file when ready for inclusion.


 On Thursday, 20 December 2012 03:18:20 UTC-6, Niphlod wrote:

 perfect, Ccing Massimo on this final one.

 Il giorno giovedì 20 dicembre 2012 00:16:25 UTC+1, Paolo ha scritto:

 Hi
 I was trying with the script that comes with the stable web2py. 
 with the one on dropbox I problem has gone. 

 Paolo 


 2012/12/19 Niphlod nip...@gmail.com


 @Simone, an other improvement to the script could be to combine 
 into a single server the 80, and 443 to avoid duplicating 
 configuration, as 
 stated here :
 http://nginx.org/en/docs/http/**configuring_https_servers.**
 html#single_http_https_serverhttp://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server
 I don't had test this.

 Also, here the code for permanent redirection 
 server {
   server_name $hostname;
   listen  80;

[web2py] Re: Sqlform.Factory upload file error!

2013-01-22 Thread Derek
From the docs...

By default SQLFORM.factory generates the form using html id attributes 
generated as if the form was generated from a table called no_table. To 
change this dummy table name, use the table_name attribute for the factory:

form = SQLFORM.factory(...,table_name='other_dummy_name')

Changing the table_name is necessary if you need to place two factory 
generated forms in the same table and want to avoid CSS conflicts.

On Tuesday, January 22, 2013 11:01:59 AM UTC-7, Ramos wrote:

 hello
 my sqlform.factory below

 trab_id=db.trabalhador.insert(**db.trabalhador._filter_fields(form.vars))

 is not uploading a file

 First i got error 
 SQLFORM.factory - RuntimeError: you must specify a 
 Field(...,uploadfolder=...) 

 so i added in my model

 Field('apt_medica','upload', 
 uploadfolder=os.path.join(request.folder,'uploads'),label='Ficha de aptidão 
 médica'),

 then the upload is done( i think! because no errors)

 Strangely in app admin when i click in the file link i get another error

 404 not found

 the url is
 http://127.0.0.1:8000/EMPRE2/appadmin/download/db/*no_table.*
 apt_medica.b8e824a896390be6.737061333130322e747874.txt

 what does it mean  *no_table *in the url?


 Thank you




-- 





Re: [web2py] Re: Help on Unit Tests

2013-01-22 Thread Bruno Rocha
Issues page on google code: https://code.google.com/p/web2py (issues menu)

Develpers list: web2py-developers on google group

-- 





[web2py] Re: is bug? sqlform.factory

2013-01-22 Thread Massimo Di Pierro
The problem is that when you set a length=1 you should get a default 
IS_LENGHT(1) validator but because you specify the IS_UPPER() validator you 
override the default. This will do what you ask:

Field('name', 'string', length=1, requires=(IS_LENGTH(1),IS_UPPER()))

Without the check sqlite may allow you to store longer strings in there. 
Not sure.

On Monday, 21 January 2013 07:43:12 UTC-6, www.diazluis.com wrote:

 when implemented the following code, I notice that the system does not 
 respect
 the length of the field in the database.

 if the user enters a name of more than one (1) character the system stores 
 ..

 wonder: is this a bug?

 to the following model:

 auth_user_id = (auth.user and auth.user.id) or None

 db.define_table('table_x',
 Field('name', 'string', length=1, requires= IS_UPPER()),
 Field('auth_user', db.auth_user, default=auth_user_id, 
 writable=False, Readable=False),
 )

 using the controller:

 def index ():
 form = SQLFORM.factory(
 Field('name', 'string', length=3, requires=IS_UPPER()),
 )

  if form.accepts (request.vars):
  db(db.table_x.auth_user==auth_user_id).update(name=
 request.vars.name)

  return dict (form = form)


-- 





[web2py] Re: Sqlform.Factory upload file error!

2013-01-22 Thread Massimo Di Pierro
This is true. The fact is the SQLFORM.factory is not connect to a db 
therefore does not know where the app keeps uploads.

On Tuesday, 22 January 2013 12:01:59 UTC-6, Ramos wrote:

 hello
 my sqlform.factory below

 trab_id=db.trabalhador.insert(**db.trabalhador._filter_fields(form.vars))

 is not uploading a file

 First i got error 
 SQLFORM.factory - RuntimeError: you must specify a 
 Field(...,uploadfolder=...) 

 so i added in my model

 Field('apt_medica','upload', 
 uploadfolder=os.path.join(request.folder,'uploads'),label='Ficha de aptidão 
 médica'),

 then the upload is done( i think! because no errors)

 Strangely in app admin when i click in the file link i get another error

 404 not found

 the url is
 http://127.0.0.1:8000/EMPRE2/appadmin/download/db/*no_table.*
 apt_medica.b8e824a896390be6.737061333130322e747874.txt

 what does it mean  *no_table *in the url?


 Thank you




-- 





[web2py] Re: bug in smartgrid groupby

2013-01-22 Thread Massimo Di Pierro
This this been fixed in trunk some time ago.

On Friday, 18 January 2013 11:21:20 UTC-6, Mark wrote:

 For web2py 2.2.1.

 When I use groupby in smartgrid, the number of records found usually 
 displays a wrong number.  Often displays 1 records found even there are 
 many records in the grid. Sometime, for examples, displays 11 when there 
 are 9 records in grid, displays 2 when there are 4 records. The number will 
 be displayed correctly if I remove the groupby from grid.  

 Thanks,
 Mark


-- 





[web2py] Re: aµzing...

2013-01-22 Thread Massimo Di Pierro
Sorry for missing this issue. Are you sure the ecoding of the page is UTF8? 
Look into the generated HTML.

On Thursday, 17 January 2013 12:27:17 UTC-6, Bill Thayer wrote:

 Been searching a while now for the magic decoder ring that solves the 
 UTF-8 encoding issue.

 If I enter a mu (µ) by typing alt+0181 into my form field it looks fine. 
 Then looking at the data in SQLDeveloper (Oracle) the data is 2 little 
 boxes. NP I think the client encoding is wrong so I set my preferences to 
 UTF-8 but µ is still 2 boxes. Still not worried yet but then I refresh  or 
 re-edit the field with the µ in it then it is returned from the database as 
 two question marks. Same behavior occurs with the squared (²) sign...two 
 boxes in db, two question marks in returned value on page.

 Anyone solve this yet?

 Thank you,
 Bill


-- 





[web2py] Re: gluon.contenttype.contenttype

2013-01-22 Thread Massimo Di Pierro
No. It is to check for extensions like:

'.eps.bz2': 'image/x-bzeps'

On Saturday, 12 January 2013 14:44:40 UTC-6, Bob St John wrote:

 def contenttype(filename, default='text/plain'):
 
 Returns the Content-Type string matching extension of the given 
 filename.
 
 i = filename.rfind('.')
 if i=0:
 default = CONTENT_TYPE.get(filename[i:].lower(),default)
 j = filename.rfind('.', 0, i)
 if j=0:
 default = CONTENT_TYPE.get(filename[j:].lower(),default)
 if default.startswith('text/'):
 default += '; charset=utf-8'
 return default

 I do not understand why the line:

 default = CONTENT_TYPE.get(filename[j:].lower(), default)

 is not instead:

 default = CONTENT_TYPE.get(filename[j:i].lower(), default)

 Is the purpose of this second rfind not to check for a possible double 
 extension... filename.ext.ext ?

 I apologize in advance if I am completely missing something here in such a 
 simple function.



-- 





[web2py] Re: Web2Py compute fields not working on update

2013-01-22 Thread Massimo Di Pierro
What web2py version? I cannot reproduce this.

On Friday, 11 January 2013 14:13:04 UTC-6, palomar wrote:

 Sorry but I have the same problem; i tried with readable=true and 
 writable=true and to comment the line in DAL.py, but nothing. 
 I have this table:
 db.define_table('magazzino',
 Field('id_tipo', 'integer',default=0),
 Field('p_p','double', default=0.0),
 Field('pp_tot','double', writable=True, readable=True, compute=lambda 
 r: r['id_tipo']==0 and r['p_p']*1 or r['p_p']*r['id_tipo']*-1),
 )
 If I edit a row with a FORM the compute field works but if I edit it in a 
 function with ajax don't...

 def modArtPrice():
 newPp = 100
 articolo = db.magazzino[request.vars.id]
 articolo.update_record(p_p=newPp)  

 what's wrong?
 s.

 Il giorno martedì 21 agosto 2012 18:35:05 UTC+2, Brandon Reynolds ha 
 scritto:

 Thank you so much i got it working. I removed the readable=false and 
 writable=false and it works on update now.  Those are not needed anyway 
 because when the compute field is added on the model it hides it 
 automatically.


 Brandon

 On Thursday, August 9, 2012 2:14:42 PM UTC-6, Deidre wrote:

 If you look at issue 822 you will see an example of a thumb that works 
 on update. As the comments say, you have to not set writeable to false for 
 the thumb. If you do set writeable to false then compute only works on add 
 not edit or update.
 So my experience is that compute for images to create a thumb does work 
 on update.
 Peter

 On Thursday, August 9, 2012 5:04:28 PM UTC+1, Brandon Reynolds wrote:

 Has anyone found a way to fix this yet? Or is there a thumbnail module 
 out now? Like django's http://djangothumbnails.com/

 Brandon


 On Monday, June 18, 2012 10:24:05 AM UTC-6, Brandon Reynolds wrote:

 I have this problem when i try to generate thumbnails. If the field is 
 empty it inserts the photo thumb into the thumbnail. But when i try to 
 update that record the thumbnail doesn't change. 

 Here is my model:

 # coding: utf8
 from image import THUMBER

 db.define_table('park', 
 Field('park_name', requires=IS_NOT_EMPTY()),
 Field('park_city', requires=IS_NOT_EMPTY()),
 Field('park_state', requires=IS_NOT_EMPTY()),
 Field('park_address', requires=IS_NOT_EMPTY()),
 Field('park_zip', requires=IS_NOT_EMPTY()),
 Field('country', default=USA, notnull=True, readable=False, 
 writable=False),
 Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
 Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('park_phone_2', 'string', 
 requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('photo1', 'upload'),
 Field('photo_thumb1', 'upload', readable=False, writable=False),
 Field('photo2', 'upload'),
 Field('photo_thumb2', 'upload', readable=False, writable=False),
 Field('photo3', 'upload'),
 Field('photo_thumb3', 'upload', readable=False, writable=False),
 Field('photo4', 'upload'),
 Field('photo_thumb4', 'upload', readable=False, writable=False),
 Field('photo5', 'upload'),
 Field('photo_thumb5', 'upload', readable=False, writable=False),
 Field('manager', requires=IS_NOT_EMPTY()),
 Field('manager_email', requires=IS_EMAIL()),
 Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
 Field('vacant', 'integer'),
 Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
 Field('water', 'boolean'),
 Field('sewer', 'boolean'),
 Field('trash', 'boolean'),
 Field('pool', 'boolean'),
 Field('playground', 'boolean'),
 Field('clubhouse', 'boolean'),
 Field('laundromat', 'boolean'),
 Field('rv_spaces', 'boolean'),
 Field('storage', 'boolean'),
 Field('handicap_accessible', 'boolean'),
 Field('community_description', 'text'),
 format='%(park_name)s')

 db.define_table('home', 
 Field('pid', notnull=True, readable=False, writable=False),
 Field('lot'),
 Field('year', length=4, requires=IS_NOT_EMPTY()),
 Field('make'),
 Field('model'),
 Field('width', requires=IS_NOT_EMPTY()),
 Field('length', requires=IS_NOT_EMPTY()),
 Field('wide', requires=IS_NOT_EMPTY()),
 Field('for_sale', 'boolean', default=True),
 Field('beds', requires=IS_NOT_EMPTY()),
 Field('baths', requires=IS_NOT_EMPTY()),
 Field('fridge', 'boolean'),
 Field('stove', 'boolean'),
 Field('dishwasher', 'boolean'),
 Field('microwave', 'boolean'),
 Field('washer', 'boolean'),
 Field('dryer', 'boolean'),
 Field('photo1', 'upload'),
 Field('photo1_text'),
 Field('photo_thumb1', 'upload', readable=False, writable=False),
 Field('photo2', 'upload'),
 Field('photo2_text'),
 Field('photo_thumb2', 'upload', readable=False, writable=False),
 Field('photo3', 'upload'),
 Field('photo3_text'),
 Field('photo_thumb3', 'upload', readable=False, writable=False),
 Field('photo4', 'upload'),
 Field('photo4_text'),
 Field('photo_thumb4', 'upload', readable=False, writable=False),
 Field('photo5', 'upload'),
 Field('photo5_text'),
 Field('photo_thumb5', 'upload', readable=False, writable=False),
 Field('price',requires=IS_NOT_EMPTY()),
 Field('description', 'text', requires=IS_NOT_EMPTY()),
 Field('posted_on', 

[web2py] Re: Sqlform.Factory upload file error!

2013-01-22 Thread Derek
I believe I posted a reply, but now it shows as deleted. I didn't delete 
it. I was just quoting from the book.
You need to specify table= in your sqlform.factory.

On Tuesday, January 22, 2013 2:53:57 PM UTC-7, Massimo Di Pierro wrote:

 This is true. The fact is the SQLFORM.factory is not connect to a db 
 therefore does not know where the app keeps uploads.

 On Tuesday, 22 January 2013 12:01:59 UTC-6, Ramos wrote:

 hello
 my sqlform.factory below

 trab_id=db.trabalhador.insert(**db.trabalhador._filter_fields(form.vars))

 is not uploading a file

 First i got error 
 SQLFORM.factory - RuntimeError: you must specify a 
 Field(...,uploadfolder=...) 

 so i added in my model

 Field('apt_medica','upload', 
 uploadfolder=os.path.join(request.folder,'uploads'),label='Ficha de aptidão 
 médica'),

 then the upload is done( i think! because no errors)

 Strangely in app admin when i click in the file link i get another error

 404 not found

 the url is
 http://127.0.0.1:8000/EMPRE2/appadmin/download/db/*no_table.*
 apt_medica.b8e824a896390be6.737061333130322e747874.txt

 what does it mean  *no_table *in the url?


 Thank you




-- 





[web2py] Re: Web2Py compute fields not working on update

2013-01-22 Thread palomar
sorry, I posted a new threat about it...
https://groups.google.com/forum/?fromgroups=#!topic/web2py/8RWkVAYVG1c
s.

Il giorno martedì 22 gennaio 2013 23:14:17 UTC+1, Massimo Di Pierro ha 
scritto:

 What web2py version? I cannot reproduce this.

 On Friday, 11 January 2013 14:13:04 UTC-6, palomar wrote:

 Sorry but I have the same problem; i tried with readable=true and 
 writable=true and to comment the line in DAL.py, but nothing. 
 I have this table:
 db.define_table('magazzino',
 Field('id_tipo', 'integer',default=0),
 Field('p_p','double', default=0.0),
 Field('pp_tot','double', writable=True, readable=True, compute=lambda 
 r: r['id_tipo']==0 and r['p_p']*1 or r['p_p']*r['id_tipo']*-1),
 )
 If I edit a row with a FORM the compute field works but if I edit it in a 
 function with ajax don't...

 def modArtPrice():
 newPp = 100
 articolo = db.magazzino[request.vars.id]
 articolo.update_record(p_p=newPp)  

 what's wrong?
 s.

 Il giorno martedì 21 agosto 2012 18:35:05 UTC+2, Brandon Reynolds ha 
 scritto:

 Thank you so much i got it working. I removed the readable=false and 
 writable=false and it works on update now.  Those are not needed anyway 
 because when the compute field is added on the model it hides it 
 automatically.


 Brandon

 On Thursday, August 9, 2012 2:14:42 PM UTC-6, Deidre wrote:

 If you look at issue 822 you will see an example of a thumb that works 
 on update. As the comments say, you have to not set writeable to false for 
 the thumb. If you do set writeable to false then compute only works on add 
 not edit or update.
 So my experience is that compute for images to create a thumb does work 
 on update.
 Peter

 On Thursday, August 9, 2012 5:04:28 PM UTC+1, Brandon Reynolds wrote:

 Has anyone found a way to fix this yet? Or is there a thumbnail module 
 out now? Like django's http://djangothumbnails.com/

 Brandon


 On Monday, June 18, 2012 10:24:05 AM UTC-6, Brandon Reynolds wrote:

 I have this problem when i try to generate thumbnails. If the field 
 is empty it inserts the photo thumb into the thumbnail. But when i try 
 to 
 update that record the thumbnail doesn't change. 

 Here is my model:

 # coding: utf8
 from image import THUMBER

 db.define_table('park', 
 Field('park_name', requires=IS_NOT_EMPTY()),
 Field('park_city', requires=IS_NOT_EMPTY()),
 Field('park_state', requires=IS_NOT_EMPTY()),
 Field('park_address', requires=IS_NOT_EMPTY()),
 Field('park_zip', requires=IS_NOT_EMPTY()),
 Field('country', default=USA, notnull=True, readable=False, 
 writable=False),
 Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
 Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('park_phone_2', 'string', 
 requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('photo1', 'upload'),
 Field('photo_thumb1', 'upload', readable=False, writable=False),
 Field('photo2', 'upload'),
 Field('photo_thumb2', 'upload', readable=False, writable=False),
 Field('photo3', 'upload'),
 Field('photo_thumb3', 'upload', readable=False, writable=False),
 Field('photo4', 'upload'),
 Field('photo_thumb4', 'upload', readable=False, writable=False),
 Field('photo5', 'upload'),
 Field('photo_thumb5', 'upload', readable=False, writable=False),
 Field('manager', requires=IS_NOT_EMPTY()),
 Field('manager_email', requires=IS_EMAIL()),
 Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
 Field('vacant', 'integer'),
 Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
 Field('water', 'boolean'),
 Field('sewer', 'boolean'),
 Field('trash', 'boolean'),
 Field('pool', 'boolean'),
 Field('playground', 'boolean'),
 Field('clubhouse', 'boolean'),
 Field('laundromat', 'boolean'),
 Field('rv_spaces', 'boolean'),
 Field('storage', 'boolean'),
 Field('handicap_accessible', 'boolean'),
 Field('community_description', 'text'),
 format='%(park_name)s')

 db.define_table('home', 
 Field('pid', notnull=True, readable=False, writable=False),
 Field('lot'),
 Field('year', length=4, requires=IS_NOT_EMPTY()),
 Field('make'),
 Field('model'),
 Field('width', requires=IS_NOT_EMPTY()),
 Field('length', requires=IS_NOT_EMPTY()),
 Field('wide', requires=IS_NOT_EMPTY()),
 Field('for_sale', 'boolean', default=True),
 Field('beds', requires=IS_NOT_EMPTY()),
 Field('baths', requires=IS_NOT_EMPTY()),
 Field('fridge', 'boolean'),
 Field('stove', 'boolean'),
 Field('dishwasher', 'boolean'),
 Field('microwave', 'boolean'),
 Field('washer', 'boolean'),
 Field('dryer', 'boolean'),
 Field('photo1', 'upload'),
 Field('photo1_text'),
 Field('photo_thumb1', 'upload', readable=False, writable=False),
 Field('photo2', 'upload'),
 Field('photo2_text'),
 Field('photo_thumb2', 'upload', readable=False, writable=False),
 Field('photo3', 'upload'),
 Field('photo3_text'),
 Field('photo_thumb3', 'upload', readable=False, writable=False),
 Field('photo4', 'upload'),
 Field('photo4_text'),
 Field('photo_thumb4', 'upload', readable=False, writable=False),
 Field('photo5', 'upload'),
 

[web2py] Re: Handling unicode keys in jsonrpc calls

2013-01-22 Thread Alan Etkin


 Recently web2py changed to parse the jsonrpc parameters in 
 tools.py/Service.serve_jsonrpc. Now I have a frawework in my client 


Looks like the Service class is trying to unpack a unicode string and pass 
it as keyword arguments of a stored function, where it should not. I think 
the behavior of your web2py version is different has changed in trunk. 
Perhaps you can test the new version to check if the input is now being 
handled properly

-- 





[web2py] Help Query speed

2013-01-22 Thread FERNANDO VILLARROEL
Dear.

I have the follow problem.

If i run the follows query in PgAdminIII is very fast:

select  rutas.id,rutas.nombre,ratecltes.rate from ratecltes
joinrutas on rutas.id = ratecltes.id_rutas
where   ratecltes.id_clte=26
order by rutas.nombre

But when i run the query on Web2py is very slow


query=(db.ratecltes.id_clte==session.cliente_id)
reg=db(query).select(db.rutas.id,db.rutas.nombre,db.ratecltes.rate,
left=db.rutas.on(db.rutas.id==db.ratecltes.id_rutas),
orderby=db.rutas.nombre)

The query show 2287 tuples.

I have PostgreSQL 8.4

The explain analyse
  QUERY PLAN
   
---
 Unique  (cost=1264.00..1286.87 rows=2287 width=30) (actual 
time=135.604..145.228 rows=2251 loops=1)
   -  Sort  (cost=1264.00..1269.71 rows=2287 width=30) (actual 
time=135.592..138.590 rows=2251 loops=1)
 Sort Key: rutas.nombre, rutas.id, ratecltes.rate
 Sort Method:  quicksort  Memory: 221kB
 -  Hash Join  (cost=69.65..1136.39 rows=2287 width=30) (actual 
time=17.528..34.604 rows=2251 loops=1)
   Hash Cond: (ratecltes.id_rutas = rutas.id)
   -  Seq Scan on ratecltes  (cost=0.00..1032.44 rows=2287 
width=8) (actual time=9.888..19.838 rows=2251 loops=1)
 Filter: (id_clte = 26)
   -  Hash  (cost=41.51..41.51 rows=2251 width=26) (actual 
time=7.580..7.580 rows=2251 loops=1)
 -  Seq Scan on rutas  (cost=0.00..41.51 rows=2251 
width=26) (actual time=0.013..3.853 rows=2251 loops=1)
 Total runtime: 148.293 ms

I hope you could help me.

Fernando


-- 





Re: [web2py] Re: web2py best practices/patterns

2013-01-22 Thread samuel bonilla
I use Model Less App And it works very good
http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py

2013/1/22 Bruno Rocha rochacbr...@gmail.com


 On Tue, Jan 22, 2013 at 3:09 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Does Model Less approach still relevent with the new lazy table feature??


 No need to use this module based approach (unless you want), now with
 lazy_tables it is better to use the standard ways to avoid extra loads.


  --





-- 





Re: [web2py] Help Query speed

2013-01-22 Thread FERNANDO VILLARROEL
I think found the problem.

My problem is with powerTable plugin.

If i return rows only the show results is fast, but i try to use powertable the 
result is slow:

powerTable = plugins.powerTable
powerTable.datasource = reg

powerTable.dtfeatures['bPaginate'] =  True
powerTable.dtfeatures['bAutoWidth'] = True
powerTable.dtfeatures['bSort'] = False #Se muestra ordenado por Query
powerTable.dtfeatures['iDisplayLength'] = 50
powerTable.virtualfields = Virtual()
powerTable.headers='labels'
powerTable.showkeycolumn = False
powerTable.dtfeatures['bJQueryUI'] = request.vars.get('jqueryui',True)
powerTable.keycolumn = 'rutas.nombre'
powerTable.columns = ['rutas.nombre','ratecltes.rate','virtual.edit']
powerTable.hiddecolumns=['rutas.nombre']
table=powerTable.create()

return dict(table=table)


Any idea?

Regards

--- On Tue, 1/22/13, FERNANDO VILLARROEL fvillarr...@yahoo.com wrote:

 From: FERNANDO VILLARROEL fvillarr...@yahoo.com
 Subject: [web2py] Help Query speed
 To: web2py@googlegroups.com
 Date: Tuesday, January 22, 2013, 6:54 PM
 Dear.
 
 I have the follow problem.
 
 If i run the follows query in PgAdminIII is very fast:
 
 select  rutas.id,rutas.nombre,ratecltes.rate from
 ratecltes
 join    rutas on rutas.id = ratecltes.id_rutas
 where   ratecltes.id_clte=26
 order by rutas.nombre
 
 But when i run the query on Web2py is very slow
 
 
 query=(db.ratecltes.id_clte==session.cliente_id)
 reg=db(query).select(db.rutas.id,db.rutas.nombre,db.ratecltes.rate,
                
 left=db.rutas.on(db.rutas.id==db.ratecltes.id_rutas),
                
 orderby=db.rutas.nombre)
 
 The query show 2287 tuples.
 
 I have PostgreSQL 8.4
 
 The explain analyse
                
                
                
           QUERY PLAN   
                
                
                
        
 ---
  Unique  (cost=1264.00..1286.87 rows=2287 width=30)
 (actual time=135.604..145.228 rows=2251 loops=1)
    -  Sort 
 (cost=1264.00..1269.71 rows=2287 width=30) (actual
 time=135.592..138.590 rows=2251 loops=1)
          Sort Key:
 rutas.nombre, rutas.id, ratecltes.rate
          Sort Method: 
 quicksort  Memory: 221kB
          -  Hash
 Join  (cost=69.65..1136.39 rows=2287 width=30) (actual
 time=17.528..34.604 rows=2251 loops=1)
            
    Hash Cond: (ratecltes.id_rutas =
 rutas.id)
            
    -  Seq Scan on ratecltes 
 (cost=0.00..1032.44 rows=2287 width=8) (actual
 time=9.888..19.838 rows=2251 loops=1)
                
      Filter: (id_clte = 26)
            
    -  Hash  (cost=41.51..41.51
 rows=2251 width=26) (actual time=7.580..7.580 rows=2251
 loops=1)
                
      -  Seq Scan on rutas 
 (cost=0.00..41.51 rows=2251 width=26) (actual
 time=0.013..3.853 rows=2251 loops=1)
  Total runtime: 148.293 ms
 
 I hope you could help me.
 
 Fernando
 
 
 -- 
 
 
 
 

-- 





Re: [web2py] Help Query speed

2013-01-22 Thread Bruno Rocha
maybe the virtual fields?

-- 





Re: [web2py] Help Query speed

2013-01-22 Thread FERNANDO VILLARROEL
Ok but how i can solve?

--- On Tue, 1/22/13, Bruno Rocha rochacbr...@gmail.com wrote:

From: Bruno Rocha rochacbr...@gmail.com
Subject: Re: [web2py] Help Query speed
To: web2py@googlegroups.com
Date: Tuesday, January 22, 2013, 10:10 PM

maybe the virtual fields?




-- 

 

 

 

-- 





[web2py] Register action using info from POST

2013-01-22 Thread Mark Li
I am currently using web2py's auth to return a registration form.

However, I would also like users to be able to register RESTfully, with the 
email and password information in a POST call. How would I write a register 
action that mimics auth.register(), except the information is from a POST, 
not a form.

-- 





[web2py] Re: aµzing...

2013-01-22 Thread Joe Barnhart
I'm not sure what needs solving.  Were you expecting the greek mu character 
to be one byte in UTF-8?  It is two bytes.  See the link:

http://www.fileformat.info/info/unicode/char/3bc/index.htm

UTF-8 is actually a variable-byte encoding scheme that can encode any 
character.  It is interoperable with the 7-bit ASCII char set but 
encompasses all of the encodings of the universe... but with more than 8 
bits, of course.

-- Joe

On Thursday, January 17, 2013 10:27:17 AM UTC-8, Bill Thayer wrote:

 Been searching a while now for the magic decoder ring that solves the 
 UTF-8 encoding issue.

 If I enter a mu (µ) by typing alt+0181 into my form field it looks fine. 
 Then looking at the data in SQLDeveloper (Oracle) the data is 2 little 
 boxes. NP I think the client encoding is wrong so I set my preferences to 
 UTF-8 but µ is still 2 boxes. Still not worried yet but then I refresh  or 
 re-edit the field with the µ in it then it is returned from the database as 
 two question marks. Same behavior occurs with the squared (²) sign...two 
 boxes in db, two question marks in returned value on page.

 Anyone solve this yet?

 Thank you,
 Bill


-- 





[web2py] Re: Sqlform.Factory upload file error!

2013-01-22 Thread Massimo Di Pierro
this is a happening a lot recently. I did not delete it and I do not 
believe any of the other managers did either. It is not our policy to 
delete posts unless requested by the author. 

massimo

On Tuesday, 22 January 2013 16:20:34 UTC-6, Derek wrote:

 I believe I posted a reply, but now it shows as deleted. I didn't delete 
 it. I was just quoting from the book.
 You need to specify table= in your sqlform.factory.

 On Tuesday, January 22, 2013 2:53:57 PM UTC-7, Massimo Di Pierro wrote:

 This is true. The fact is the SQLFORM.factory is not connect to a db 
 therefore does not know where the app keeps uploads.

 On Tuesday, 22 January 2013 12:01:59 UTC-6, Ramos wrote:

 hello
 my sqlform.factory below

 trab_id=db.trabalhador.insert(**db.trabalhador._filter_fields(form.vars))

 is not uploading a file

 First i got error 
 SQLFORM.factory - RuntimeError: you must specify a 
 Field(...,uploadfolder=...) 

 so i added in my model

 Field('apt_medica','upload', 
 uploadfolder=os.path.join(request.folder,'uploads'),label='Ficha de aptidão 
 médica'),

 then the upload is done( i think! because no errors)

 Strangely in app admin when i click in the file link i get another error

 404 not found

 the url is
 http://127.0.0.1:8000/EMPRE2/appadmin/download/db/*no_table.*
 apt_medica.b8e824a896390be6.737061333130322e747874.txt

 what does it mean  *no_table *in the url?


 Thank you




-- 





[web2py] Re: aµzing...

2013-01-22 Thread Massimo Di Pierro
I think the issue here is whether a generic utf8 chars inserted in a form 
is rendered properly in a web2py table or update form. Web2py consistently 
encodes everything in utf8 but it is possible that the page encoding is in 
latin-1 or other. In this case the submitted form would contain a non-utf8 
encoding for the character. 

On Tuesday, 22 January 2013 20:53:50 UTC-6, Joe Barnhart wrote:

 I'm not sure what needs solving.  Were you expecting the greek mu 
 character to be one byte in UTF-8?  It is two bytes.  See the link:

 http://www.fileformat.info/info/unicode/char/3bc/index.htm

 UTF-8 is actually a variable-byte encoding scheme that can encode any 
 character.  It is interoperable with the 7-bit ASCII char set but 
 encompasses all of the encodings of the universe... but with more than 8 
 bits, of course.

 -- Joe

 On Thursday, January 17, 2013 10:27:17 AM UTC-8, Bill Thayer wrote:

 Been searching a while now for the magic decoder ring that solves the 
 UTF-8 encoding issue.

 If I enter a mu (µ) by typing alt+0181 into my form field it looks fine. 
 Then looking at the data in SQLDeveloper (Oracle) the data is 2 little 
 boxes. NP I think the client encoding is wrong so I set my preferences to 
 UTF-8 but µ is still 2 boxes. Still not worried yet but then I refresh  or 
 re-edit the field with the µ in it then it is returned from the database as 
 two question marks. Same behavior occurs with the squared (²) sign...two 
 boxes in db, two question marks in returned value on page.

 Anyone solve this yet?

 Thank you,
 Bill



-- 





[web2py] Querying the DAL by regex

2013-01-22 Thread Daniel Gonzalez
Hi,

I have this function to delete a user with a certain email address:

def delete_user(self, email):
my_query = self.db[self.web2py_user_table].email == email
my_set   = self.db(my_query)
my_set.delete()

Now I would like to implement a function to delete several users at once, 
based on a regex parameter:

def delete_users(self, regex):
my_query = define query using regex
my_set   = self.db(my_query)
my_set.delete()

Is it possible to do this?

Thanks,

Daniel

-- 





[web2py] Re: Scheduler ignoring period/repeat setting.

2013-01-22 Thread Stormcrow
OK, I'll try try it with my own UUID rather.

I don't need my task to run at exactly 5 second intervals, it's a simple 
task which updates only a few parameters but it needs to happen quite 
regularly. I think the scheduler works well enough for my purposes here, I 
don't expect it to be precise.  

I realise that check will occur with every request, it's not ideal but it's 
simple and it works and I don't expect my server to be *that* busy that it 
can't handle it. All the same I might actually change it to use cron 
@reboot instead, i just want to keep things as simple and as automated as 
possible.

Thanks again for all your comments, you've been extremely helpful.

-- 





[web2py] Re: Querying the DAL by regex

2013-01-22 Thread Massimo Di Pierro
You can do

db(db.table.field.regexp('your regex')).select()
db(db.table.field.regexp('your regex')).delete()

works with sqlite and postgresql only. The regex syntax may be different 
between the two.

On Wednesday, 23 January 2013 00:31:25 UTC-6, Daniel Gonzalez wrote:

 Hi,

 I have this function to delete a user with a certain email address:

 def delete_user(self, email):
 my_query = self.db[self.web2py_user_table].email == email
 my_set   = self.db(my_query)
 my_set.delete()

 Now I would like to implement a function to delete several users at once, 
 based on a regex parameter:

 def delete_users(self, regex):
 my_query = define query using regex
 my_set   = self.db(my_query)
 my_set.delete()

 Is it possible to do this?

 Thanks,

 Daniel


-- 





Re: [web2py] Re: Book in epub format?

2013-01-22 Thread Johann Spies
On 22 January 2013 16:42, Massimo Di Pierro massimo.dipie...@gmail.comwrote:

 my process is

 markmin - html
 markmin - latex - pdf - print

 There is a latex - epub (http://johnmacfarlane.net/pandoc/)


Pandoc is a great tool, but it's success in converting latex to anything
else is limited to a subset lf LaTeX.  For most of my latex files it is
unusable.

To convert multiple html-files to a single epub I thing Sigil is the
easiest way to go and the results I have seen so far are good.

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] anyserver.py not working properly for gevent

2013-01-22 Thread JimK
Since gluon.main and gluon.fileutils are being imported before 
gevent's monkey.patch_all() is run, the sessions were getting mixed up.

Here's the code I used that verified the issue (found on this forum):

def index():
import time
from gluon import current
print current.request.uuid
time.sleep(10)
print current.request.uuid
return dict(done='done!')

Load this method in 2 different browsers within 10 seconds and you'll see 
that the uuids are out of sync.

It should be:
A
B
A
B

But instead you get:
A
B
B
B

To fix this, I created a separate file that just starts the gevent server. 
 Essentially, before importing the gluon modules, I run:
from gevent import monkey
monkey.patch_all()

After running the test again, I get:
A
B
A
B

So, should we remove gevent from anyserver.py and add gevent_server.py? 
 This would save others from encountering the same issue that I did.

-- 





[web2py] Re: Scheduler ignoring period/repeat setting.

2013-01-22 Thread Stormcrow
cron doesn't seem to work on 2.3.2 running as a Windows 7 service. Not sure 
how to find the problem.

--