[web2py] Re: How to - using DAL for "Between"

2013-04-08 Thread Rahul
Hi Annet,
 Thanks for getting back. However I got a ticket as below for my 
code as shown below. I am but passing a simple query you suggested. Note , 
dayseven is = sevendays 

*def view_demo():*
db.issues.id.readable=False
query = db(db.issues.date_today >= dayseven)
fields = (db.issues.ticket_no, db.issues.description,)
headers = {'issues.ticket_no': 'Ticket No' , 'issues.description': 
'Description'  }

default_sort_order = [db.issues.ticket_no ] 
links = [
 lambda row: A(SPAN(_class='icon 
magnifier'),'View',_class='button', _title='View 
Issue',_href=URL("default","view_cmgr",args=[row.id])),
 lambda row: A(SPAN(_class='icon 
downarrow'),'Edit',_class='button', _title='Edit 
Issue',_href=URL("default","update_cmgr",args=[row.id])),
 lambda row: A(SPAN(_class='icon 
cross'),'Delete',_class='negative button', _title='Delete 
Issue',_href=URL("default","delete_cmgr",args=[row.id])),
 ]
grid = SQLFORM.grid( query=query, fields=fields, headers=headers, 
links=links, orderby=default_sort_order, user_signature=False, #details = 
auth.has_permission('read', db.projects_posts),
 create=False, deletable=False, details=False, 
editable=False,  csv=False, maxtextlength=64, paginate=15, ui='jquery-ui' )

return dict(grid = grid, counter = session.counter)


*Ticket ID*

127.0.0.1.2013-04-09.12-06-04.0cfff98e-43c5-4479-9849-e26ffe837d55
 list index out of rangeVersionweb2py™Version 
2.4.5-stable+timestamp.2013.03.18.22.46.22PythonPython 2.7.2: 
C:\Python27\python.exe (prefix: C:\Python27)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

Traceback (most recent call last):
  File "D:\Web2py\web2py\gluon\restricted.py", line 212, in restricted
exec ccode in environment
  File "D:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
, line 3961, in 
  File "D:\Web2py\web2py\gluon\globals.py", line 194, in 
self._caller = lambda f: f()
  File "D:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
, line 808, in 
view_tickets_pa
create=False, deletable=False, details=False, editable=False,  csv=False, 
maxtextlength=64, paginate=15, ui='jquery-ui' )
  File "D:\Web2py\web2py\gluon\sqlhtml.py", line 1885, in grid
field_id = tables[0]._id
IndexError: list index out of range


Rahul


On Tuesday, April 9, 2013 11:27:26 AM UTC+5:30, Annet wrote:
>
> Hi Rahul,
>
> > Of course, you could omit the db.issues.date_today <= request.now if you 
> know for a fact there are no time travelers opening tickets in the future.
>
> :-)
>
> What Derek means, if db.issues.date_today is the date the issues was 
> created, than you can leave db.issues.date_today <= today out, because 
> there won't be any issues in the database where db.issues.date_today > today
>
> > You are passing rows/records where you are supposed to pass a query.
>
> What Massimo means, you should pass db(db.issues.date_today >= sevendays) 
> so, without .select()
>
>
> I hope these remarks help you solve the issue.
>
> Annet
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to - using DAL for "Between"

2013-04-08 Thread Annet
Hi Rahul,

> Of course, you could omit the db.issues.date_today <= request.now if you 
know for a fact there are no time travelers opening tickets in the future.

:-)

What Derek means, if db.issues.date_today is the date the issues was 
created, than you can leave db.issues.date_today <= today out, because 
there won't be any issues in the database where db.issues.date_today > today

> You are passing rows/records where you are supposed to pass a query.

What Massimo means, you should pass db(db.issues.date_today >= sevendays) 
so, without .select()


I hope these remarks help you solve the issue.

Annet

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to - using DAL for "Between"

2013-04-08 Thread Rahul
Hi Massimo,
Here is the code I used for SQLForm.grid(). Also db.executesql() 
does not work with SQLForm.gird I guess due to some data incompatibilites...

def new_tickets_created():
db.issues.id.readable=False

query = db((db.issues.date_today >= sevendays) &  (db.issues.date_today 
<= today)
).select()
#Note sevendays and today is equivalent to what Niphlod has suggested 
below
   
fields = (db.issues.ticket_no, db.issues.description,)
headers = {'issues.ticket_no': 'Ticket #' , 'issues.description': 
'Description', }

links = [
 lambda row: A(SPAN(_class='icon 
magnifier'),'View',_class='button', _title='View 
Issue',_href=URL("default","view_issue",args=[row.id])),
 ]
grid_new_issues = SQLFORM.grid( query=query, fields=fields, 
headers=headers, links=links, user_signature=False, #details = 
auth.has_permission('read', db.projects_posts),
 create=False, deletable=False, details=False, 
editable=False,  csv=False, maxtextlength=64, paginate=15, ui='jquery-ui' )
   
return dict( grid_new_issues = grid_new_issues, counter = 
session.counter) 

and the table is called issues with ticket_no, description and a few more 
fields.

View  --- is new_tickets_created.html with { {=grid_new_issues}} serialized

Sincerely, Rahul

On Tuesday, April 9, 2013 12:50:50 AM UTC+5:30, Massimo Di Pierro wrote:
>
> what's the code? You are passing rows/records where you are supposed to 
> pass a query.
>
> On Monday, 8 April 2013 13:46:03 UTC-5, Rahul wrote:
>>
>>
>> Thanks Niphlod, :-)
>>This code works with webgrid component. But I get an error when I 
>> try to use it with SQLForm.grid. Something like below -
>> ---
>> Ticket ID
>>
>> 127.0.0.1.2013-04-08.22-09-49.ef6e6a56-089a-4c50-87fa-2099255002de
>>  'Rows' object has no attribute '_db'
>> Versionweb2py™Version 2.4.5-stable+timestamp.2013.03.18.22.46.22PythonPython 
>> 2.7.2: C:\Python27\python.exe (prefix: C:\Python27)Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>>
>> Traceback (most recent call last):
>>   File "E:\Web2py\web2py\gluon\restricted.py", line 212, in restricted
>> exec ccode in environment
>>   File "E:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
>> , 
>> line 3882, in 
>>   File "E:\Web2py\web2py\gluon\globals.py", line 194, in 
>> self._caller = lambda f: f()
>>   File "E:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
>> , 
>> line 729, in bug_new_tickets_created
>> create=False, deletable=False, details=True, editable=False,  csv=False, 
>> maxtextlength=64, paginate=15, ui='jquery-ui' )
>>   File "E:\Web2py\web2py\gluon\sqlhtml.py", line 1808, in grid
>> db = query._db
>> AttributeError: 'Rows' object has no attribute '_db'
>>
>> Error snapshot [image: help] Detailed traceback description 
>> 
>>  
>>
>> ('Rows' object has no attribute '_db') 
>>
>> 
>>
>> However - for now I can use the above code with the workaround I have. 
>> Thanks again. Web2py has all the good folks!! 
>>
>> Cheers, Rahul.
>>
>>
>> On Monday, April 8, 2013 6:57:18 PM UTC+5:30, Niphlod wrote:
>>>
>>> from datetime import timedelta
>>> now = request.now
>>> six_days_back = now - timedelta(days=6)
>>> db(
>>> (db.issues.date_today >= six_days_back) &
>>> (db.issues.date_today <= request.now)
>>> ).select(whateverfieldyouneed)
>>>
>>>
>>>
>>> On Monday, April 8, 2013 3:07:57 PM UTC+2, Rahul wrote:

 Hi All,
  I am working on a query in SQLite  - Where I can search on some 
 data for last 7 days - 

 SQLite raw sql query  is as follows: 
 query = db.executesql("SELECT ticket_no, description FROM issues where 
 date_today between datetime ('now', '-6 days') AND datetime ('now', 
 'localtime')")

 I need to know the equivalent DAL version of it. Any help would be much 
 appreciated. 

 Rahul

>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to - using DAL for "Between"

2013-04-08 Thread Rahul


def bug_new_tickets_created():
db.issues.id.readable=False
query = db((db.issues.date_today>=('now', '-6 days')) & 
(db.issues.workspace==user_workspace)).select()
fields = (db.issues.ticket_no, db.issues.description,)
headers = {'issues.ticket_no': 'Ticket #' , 'issues.description': 
'Description', }
links = [ lambda row: A(SPAN(_class='icon 
magnifier'),'View',_class='button', _title='View 
Issue',_href=URL("default","view_issue",args=[row.id])),
 ]
grid_new_issues = SQLFORM.grid( query=query, fields=fields, 
headers=headers, links=links, user_signature=False, #details = 
auth.has_permission('read', db.projects_posts),
 create=False, deletable=False, details=False, 
editable=False,  csv=False, maxtextlength=64, paginate=15, ui='jquery-ui' )
   
return dict( grid_new_issues = grid_new_issues, counter = 
session.counter) 



On Tuesday, April 9, 2013 12:50:50 AM UTC+5:30, Massimo Di Pierro wrote:
>
> what's the code? You are passing rows/records where you are supposed to 
> pass a query.
>
> On Monday, 8 April 2013 13:46:03 UTC-5, Rahul wrote:
>>
>>
>> Thanks Niphlod, :-)
>>This code works with webgrid component. But I get an error when I 
>> try to use it with SQLForm.grid. Something like below -
>> ---
>> Ticket ID
>>
>> 127.0.0.1.2013-04-08.22-09-49.ef6e6a56-089a-4c50-87fa-2099255002de
>>  'Rows' object has no attribute '_db'
>> Versionweb2py™Version 2.4.5-stable+timestamp.2013.03.18.22.46.22PythonPython 
>> 2.7.2: C:\Python27\python.exe (prefix: C:\Python27)Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>>
>> Traceback (most recent call last):
>>   File "E:\Web2py\web2py\gluon\restricted.py", line 212, in restricted
>> exec ccode in environment
>>   File "E:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
>> , 
>> line 3882, in 
>>   File "E:\Web2py\web2py\gluon\globals.py", line 194, in 
>> self._caller = lambda f: f()
>>   File "E:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
>> , 
>> line 729, in bug_new_tickets_created
>> create=False, deletable=False, details=True, editable=False,  csv=False, 
>> maxtextlength=64, paginate=15, ui='jquery-ui' )
>>   File "E:\Web2py\web2py\gluon\sqlhtml.py", line 1808, in grid
>> db = query._db
>> AttributeError: 'Rows' object has no attribute '_db'
>>
>> Error snapshot [image: help] Detailed traceback description 
>> 
>>  
>>
>> ('Rows' object has no attribute '_db') 
>>
>> 
>>
>> However - for now I can use the above code with the workaround I have. 
>> Thanks again. Web2py has all the good folks!! 
>>
>> Cheers, Rahul.
>>
>>
>> On Monday, April 8, 2013 6:57:18 PM UTC+5:30, Niphlod wrote:
>>>
>>> from datetime import timedelta
>>> now = request.now
>>> six_days_back = now - timedelta(days=6)
>>> db(
>>> (db.issues.date_today >= six_days_back) &
>>> (db.issues.date_today <= request.now)
>>> ).select(whateverfieldyouneed)
>>>
>>>
>>>
>>> On Monday, April 8, 2013 3:07:57 PM UTC+2, Rahul wrote:

 Hi All,
  I am working on a query in SQLite  - Where I can search on some 
 data for last 7 days - 

 SQLite raw sql query  is as follows: 
 query = db.executesql("SELECT ticket_no, description FROM issues where 
 date_today between datetime ('now', '-6 days') AND datetime ('now', 
 'localtime')")

 I need to know the equivalent DAL version of it. Any help would be much 
 appreciated. 

 Rahul

>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: calling custom_store and custom_retrieve using parameters

2013-04-08 Thread James Burke
Came up with a workaround.
def store_file(file, filename=None, path=None):
 try:
  client_id = int(request.args[2])
  client_dir = db(db.client.id == client_id).select(db.client.
client_dir_name).first().client_dir_name
 except:
  client_dir = 'Default'
 
 path = "applications/init/uploads/%s" % (client_dir)
 if not os.path.exists(path):
 os.makedirs(path)
 pathfilename = os.path.join(path, filename)
 dest_file = open(pathfilename, 'wb')
 try:
 shutil.copyfileobj(file, dest_file)
 finally:
 dest_file.close()


 return filename

I'm using a smartgrid so the client id is passed as an argument when I 
client on the files link.

On Tuesday, April 9, 2013 2:34:35 PM UTC+12, James Burke wrote:
>
> Thanks for your swift response.
>
> I kind of understand that, but how do you get the value rather than the 
> field name?
>
> db.define_table('file',
>  Field('client', 'reference client'),
>  Field('type', requires=IS_IN_SET(['Clipper','Workbench', 'Terramatch',
> 'Supply']), default='Workbench'),
>  Field('file', type='upload', 
>  custom_store=lambda file,filename,path: store_file(file, filename, path,db
> .file.client._id), 
>  custom_retrieve=lambda filename, path: retrieve_file(filename, path, db.
> file.client)),
> format='%(file)s')
>
> I'm trying to retrieve the clients name and use it to generate the folder.
>
> Cheers,
>
> -James
>
>
> On Tuesday, April 9, 2013 2:06:54 PM UTC+12, Anthony wrote:
>>
>> The fourth argument passed to store_file() is db.table.new_filename, 
>> which is a DAL Field object. Your code is treating it as a string, and 
>> "table.new_filename" is the string representation of a Field object. If you 
>> want to include an actual filename string, then that's what you have to 
>> pass to the function.
>>
>> Anthony
>>
>> On Monday, April 8, 2013 9:34:45 PM UTC-4, James Burke wrote:
>>>
>>> Hi Anthony,
>>>
>>> I've tried the solution you've posted below:
>>> Field('file', 'upload',
>>> custom_store=lambda file, filename, path: store_file(file, filename,path
>>> , db.table.new_filename),
>>> ...)
>>>
>>> But when my additional parameter gets sent to store_file it sends 
>>> 'table.new_filename'
>>>
>>> def store_file(file, filename=None, path=None, new_filename=None):
>>>  path = "applications/init/uploads/%s" % (new_filename)
>>>  if not os.path.exists(path):
>>>  os.makedirs(path)
>>>  pathfilename = os.path.join(path, filename)
>>>  dest_file = open(pathfilename, 'wb')
>>>  try:
>>>  shutil.copyfileobj(file, dest_file)
>>>  finally:
>>>  dest_file.close()
>>>
>>>
>>>  return filename
>>>
>>> Results in a new folder in uploads called 'table.new_filename'
>>>
>>> Cheers 
>>> -James
>>>
>>> On Wednesday, August 8, 2012 11:51:44 PM UTC+12, Anthony wrote:

 On Wednesday, August 8, 2012 7:09:37 AM UTC-4, Jim Gregory wrote:
>
> Can custom_store and custom_retrieve take parameters when they are 
> called using Field, e.g.:
> db.define_table('table',
> Field('file', 'upload', custom_store=store_file(file, 
> db.table.new_filename), 
> custom_retrieve=retrieve_file(db.table.new_filename))?
> Field('new_filename','string')
> )
>

 These attributes have to be callables, so you can't call them yourself. 
 To pass additional custom arguments to a callable, just turn it into a 
 lambda that takes the standard arguments and pass the additional arguments 
 to your function within the lambda:

 Field('file', 'upload',
 custom_store=lambda file, filename, path: store_file(file, filename
 , path, db.table.new_filename),
 ...)

 When web2py calls the custom_store callable, it will pass three 
 arguments (file, filename, and path), so your lambda must take three 
 arguments. Within the lambda, you can then do whatever you want. You can 
 pass any or all of the standard three arguments to your custom function, 
 and you can pass additional arguments. In the example above, I passed the 
 three standard arguments followed by a fourth custom argument, though it 
 doesn't have to look like that (presumably you will at least want to pass 
 the file as an argument).

 custom_retrieve takes two standard arguments, "name" and "path".

 Anthony



-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] CSV import design advice

2013-04-08 Thread David
Hello,

I am working on an app where leads can be generated from several different 
sources via CSV files. These sources conatian information that 
will ultimately end up in the same model. I am looking for some advice on 
getting the information into the model. Should I:

1 - Write a function for each different source

2 - Write a function that creates a staging file that will use the same 
import function for each file.

or 

3 - Do something completely different that I am not thinking of?


Thanks for the help. I am just getting back into programming but love 
web2py.

David

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: calling custom_store and custom_retrieve using parameters

2013-04-08 Thread James Burke
Thanks for your swift response.

I kind of understand that, but how do you get the value rather than the 
field name?

db.define_table('file',
 Field('client', 'reference client'),
 Field('type', requires=IS_IN_SET(['Clipper','Workbench', 'Terramatch',
'Supply']), default='Workbench'),
 Field('file', type='upload', 
 custom_store=lambda file,filename,path: store_file(file, filename, path, db
.file.client._id), 
 custom_retrieve=lambda filename, path: retrieve_file(filename, path, db.
file.client)),
format='%(file)s')

I'm trying to retrieve the clients name and use it to generate the folder.

Cheers,

-James


On Tuesday, April 9, 2013 2:06:54 PM UTC+12, Anthony wrote:
>
> The fourth argument passed to store_file() is db.table.new_filename, which 
> is a DAL Field object. Your code is treating it as a string, and 
> "table.new_filename" is the string representation of a Field object. If you 
> want to include an actual filename string, then that's what you have to 
> pass to the function.
>
> Anthony
>
> On Monday, April 8, 2013 9:34:45 PM UTC-4, James Burke wrote:
>>
>> Hi Anthony,
>>
>> I've tried the solution you've posted below:
>> Field('file', 'upload',
>> custom_store=lambda file, filename, path: store_file(file, filename,path
>> , db.table.new_filename),
>> ...)
>>
>> But when my additional parameter gets sent to store_file it sends 
>> 'table.new_filename'
>>
>> def store_file(file, filename=None, path=None, new_filename=None):
>>  path = "applications/init/uploads/%s" % (new_filename)
>>  if not os.path.exists(path):
>>  os.makedirs(path)
>>  pathfilename = os.path.join(path, filename)
>>  dest_file = open(pathfilename, 'wb')
>>  try:
>>  shutil.copyfileobj(file, dest_file)
>>  finally:
>>  dest_file.close()
>>
>>
>>  return filename
>>
>> Results in a new folder in uploads called 'table.new_filename'
>>
>> Cheers 
>> -James
>>
>> On Wednesday, August 8, 2012 11:51:44 PM UTC+12, Anthony wrote:
>>>
>>> On Wednesday, August 8, 2012 7:09:37 AM UTC-4, Jim Gregory wrote:

 Can custom_store and custom_retrieve take parameters when they are 
 called using Field, e.g.:
 db.define_table('table',
 Field('file', 'upload', custom_store=store_file(file, 
 db.table.new_filename), 
 custom_retrieve=retrieve_file(db.table.new_filename))?
 Field('new_filename','string')
 )

>>>
>>> These attributes have to be callables, so you can't call them yourself. 
>>> To pass additional custom arguments to a callable, just turn it into a 
>>> lambda that takes the standard arguments and pass the additional arguments 
>>> to your function within the lambda:
>>>
>>> Field('file', 'upload',
>>> custom_store=lambda file, filename, path: store_file(file, filename,path
>>> , db.table.new_filename),
>>> ...)
>>>
>>> When web2py calls the custom_store callable, it will pass three 
>>> arguments (file, filename, and path), so your lambda must take three 
>>> arguments. Within the lambda, you can then do whatever you want. You can 
>>> pass any or all of the standard three arguments to your custom function, 
>>> and you can pass additional arguments. In the example above, I passed the 
>>> three standard arguments followed by a fourth custom argument, though it 
>>> doesn't have to look like that (presumably you will at least want to pass 
>>> the file as an argument).
>>>
>>> custom_retrieve takes two standard arguments, "name" and "path".
>>>
>>> Anthony
>>>
>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: calling custom_store and custom_retrieve using parameters

2013-04-08 Thread Anthony
The fourth argument passed to store_file() is db.table.new_filename, which 
is a DAL Field object. Your code is treating it as a string, and 
"table.new_filename" is the string representation of a Field object. If you 
want to include an actual filename string, then that's what you have to 
pass to the function.

Anthony

On Monday, April 8, 2013 9:34:45 PM UTC-4, James Burke wrote:
>
> Hi Anthony,
>
> I've tried the solution you've posted below:
> Field('file', 'upload',
> custom_store=lambda file, filename, path: store_file(file, filename,path
> , db.table.new_filename),
> ...)
>
> But when my additional parameter gets sent to store_file it sends 
> 'table.new_filename'
>
> def store_file(file, filename=None, path=None, new_filename=None):
>  path = "applications/init/uploads/%s" % (new_filename)
>  if not os.path.exists(path):
>  os.makedirs(path)
>  pathfilename = os.path.join(path, filename)
>  dest_file = open(pathfilename, 'wb')
>  try:
>  shutil.copyfileobj(file, dest_file)
>  finally:
>  dest_file.close()
>
>
>  return filename
>
> Results in a new folder in uploads called 'table.new_filename'
>
> Cheers 
> -James
>
> On Wednesday, August 8, 2012 11:51:44 PM UTC+12, Anthony wrote:
>>
>> On Wednesday, August 8, 2012 7:09:37 AM UTC-4, Jim Gregory wrote:
>>>
>>> Can custom_store and custom_retrieve take parameters when they are 
>>> called using Field, e.g.:
>>> db.define_table('table',
>>> Field('file', 'upload', custom_store=store_file(file, 
>>> db.table.new_filename), 
>>> custom_retrieve=retrieve_file(db.table.new_filename))?
>>> Field('new_filename','string')
>>> )
>>>
>>
>> These attributes have to be callables, so you can't call them yourself. 
>> To pass additional custom arguments to a callable, just turn it into a 
>> lambda that takes the standard arguments and pass the additional arguments 
>> to your function within the lambda:
>>
>> Field('file', 'upload',
>> custom_store=lambda file, filename, path: store_file(file, filename,path
>> , db.table.new_filename),
>> ...)
>>
>> When web2py calls the custom_store callable, it will pass three arguments 
>> (file, filename, and path), so your lambda must take three arguments. 
>> Within the lambda, you can then do whatever you want. You can pass any or 
>> all of the standard three arguments to your custom function, and you can 
>> pass additional arguments. In the example above, I passed the three 
>> standard arguments followed by a fourth custom argument, though it doesn't 
>> have to look like that (presumably you will at least want to pass the file 
>> as an argument).
>>
>> custom_retrieve takes two standard arguments, "name" and "path".
>>
>> Anthony
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Code changes not honored (by web2py?)

2013-04-08 Thread vince
i am running web2py 2.4.6  on apache with mod_wsgi, track_changes seems to 
always work for the first modify after i restart apache. 2nd changes and so 
on to the module will not always trigger module reload.


On Monday, December 10, 2012 6:55:06 AM UTC+8, Massimo Di Pierro wrote:
>
> This has come up before.
>
> from gluon.custom_import import track_changes; track_changes()
>
> must be a model file, before the modules are imported, not in the modules 
> themselves which are otherwise cached and therefore the line may or may not 
> be executed.
>
> Massimo
>
> On Sunday, 9 December 2012 15:34:09 UTC-6, Chr_M wrote:
>>
>> Sometimes the changes in the code of a module (in the modules directory) 
>> are not working when requesting the url that uses these modules. in the 
>> modules directory I have a subdirectory with python files that form a 
>> package (__init__.py file in this subdirectory). I have added 
>>
>> from gluon.custom_import import track_changes
>> track_changes()
>>
>> in the first model that gets called, but still sometimes code changes are 
>> not working. I noticed that the py-files in the modules dir get compiled to 
>> pyc-files. But at one point (it looks to be randomly) these are not 
>> compiled anymore when I change code in the py-files. But even when I remove 
>> these pyc-files, the code changes are still not working when requesting the 
>> url. 
>>
>> Am I missing something? Is there a cache I can clear or something? I now 
>> have to restart web2py to make the code changes work...
>>
>> Thanks.
>>
>> Regards, Chris
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: calling custom_store and custom_retrieve using parameters

2013-04-08 Thread James Burke
Hi Anthony,

I've tried the solution you've posted below:
Field('file', 'upload',
custom_store=lambda file, filename, path: store_file(file, filename,path
, db.table.new_filename),
...)

But when my additional parameter gets sent to store_file it sends 
'table.new_filename'

def store_file(file, filename=None, path=None, new_filename=None):
 path = "applications/init/uploads/%s" % (new_filename)
 if not os.path.exists(path):
 os.makedirs(path)
 pathfilename = os.path.join(path, filename)
 dest_file = open(pathfilename, 'wb')
 try:
 shutil.copyfileobj(file, dest_file)
 finally:
 dest_file.close()


 return filename

Results in a new folder in uploads called 'table.new_filename'

Cheers 
-James

On Wednesday, August 8, 2012 11:51:44 PM UTC+12, Anthony wrote:
>
> On Wednesday, August 8, 2012 7:09:37 AM UTC-4, Jim Gregory wrote:
>>
>> Can custom_store and custom_retrieve take parameters when they are called 
>> using Field, e.g.:
>> db.define_table('table',
>> Field('file', 'upload', custom_store=store_file(file, 
>> db.table.new_filename), 
>> custom_retrieve=retrieve_file(db.table.new_filename))?
>> Field('new_filename','string')
>> )
>>
>
> These attributes have to be callables, so you can't call them yourself. To 
> pass additional custom arguments to a callable, just turn it into a lambda 
> that takes the standard arguments and pass the additional arguments to your 
> function within the lambda:
>
> Field('file', 'upload',
> custom_store=lambda file, filename, path: store_file(file, filename,path
> , db.table.new_filename),
> ...)
>
> When web2py calls the custom_store callable, it will pass three arguments 
> (file, filename, and path), so your lambda must take three arguments. 
> Within the lambda, you can then do whatever you want. You can pass any or 
> all of the standard three arguments to your custom function, and you can 
> pass additional arguments. In the example above, I passed the three 
> standard arguments followed by a fourth custom argument, though it doesn't 
> have to look like that (presumably you will at least want to pass the file 
> as an argument).
>
> custom_retrieve takes two standard arguments, "name" and "path".
>
> Anthony
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] running a script without the opening lines

2013-04-08 Thread Ricardo Pedroso
On Mon, Apr 8, 2013 at 7:57 AM, guruyaya  wrote:

> I have some script I'm running via linux cron, using web2py panel, like so
> web2py.py -S app -M -R application/app/scripts/myscript.py
> When It starts, it shows these lines:
>
> No handlers could be found for logger "web2py"
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2013
> Version 2.3.2 (2012-12-17 15:03:30) stable
> Database drivers available: SQLite(sqlite3), MySQL(pymysql),
> PostgreSQL(pg8000),
>  IMAP(imaplib)
>
> Is there a way to run this script without those lines? They show up in my
> email box.
> 10x in advance
>
> Try:
$ python web2py.py --no-banner ...

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: pre populated SQLFORM.FACTORY does not submit because of upload field

2013-04-08 Thread António Ramos
Thank you Massimo for your patience.

I change factory to just sqlform and it works even with default values to
upload fields.

Thank you

António


2013/4/8 Massimo Di Pierro 

> It took me a while to isolate the problem. Here is a simple code to
> reproduce it:
>
> def index():
>
> db.define_table('thing',Field('image','upload',requires=IS_NOT_EMPTY()))
> db.thing.image.default = 'xxx.png'
> form = SQLFORM.factory(db.thing,upload=URL('download')).process()
> return locals()
>
> It is a bin can of worms and I opened a ticket about this. For now I will
> just say that giving a default to an upload field is not a good idea. You
> can try do the following:
> def index():
>
> db.define_table('thing',Field('image','upload',requires=IS_NOT_EMPTY()))
> form = SQLFORM.factory(db.thing,upload=URL('download')).process()
> db.thing.image.default = 'xxx.png'
> if form.errors['image'] == '':
> del form.errors['image']
>insert  'xxx.png' where needed
> return locals()
>
> On Sunday, 7 April 2013 06:54:41 UTC-5, Ramos wrote:
>
>> Can you check again Massimo in the app i posted? controller default -
>> Action trabalhador
>>
>> Thank you
>>
>> António
>>
>>
>> 2013/4/6 António Ramos 
>>
>>> Sorry i meant trabalhador
>>>
>>> Action trabalhador
>>> Thank you
>>> No dia 06/04/2013 17:31, "Massimo Di Pierro" 
>>> escreveu:
>>>
>>>  Sorry I cannot find action "empreiteiro"

 On Friday, 5 April 2013 16:45:39 UTC-5, Ramos wrote:
>
> I post here my app.
>
> Sorry about the quality of my code. I´m learning as i go along the way.
>
> The problem is in controller default, action empreiteiro
>
> The upload field is required but when i edit a record i see the link
> to the uploaded file and if i do nothing and just save it complains that i
> have to upload a file.
> It is there!!
>
> Thank you
>
> António
>
>
>
> 2013/4/5 Massimo Di Pierro 
>
>> Can you post a simpler example (including mode) to reproduce the
>> problem? Looks like the field in the table has a validator which requires
>> an upload.
>>
>>
>> On Friday, 5 April 2013 11:06:52 UTC-5, Ramos wrote:
>>>
>>> hello, i´m using a sqlform.factory to edit a record.
>>>
>>> The form is prepopulated using this code
>>>
>>>
>>> row=db((db.trabalhador.id==**request.args(0))).select().**first(
>>> )
>>>
>>> if row:
>>> for field in row:
>>> if field in db.trabalhador.fields:
>>>
>>> print "setting -",row[field] ," on ",field
>>> db.trabalhador[field].default=**row[field]
>>>
>>>
>>> one of the fields is a required upload field.
>>>
>>> The rest of the code
>>> form=SQLFORM.factory(db.**trabalhador,db.t_docs,
>>> submit_button="Gravar",
>>> fields=['nome','bi','ncart','**n
>>> cartval','rfid','apt_medica',**'apt_medicaval','val_formacao'**,
>>> 'f_doc'],
>>> table_name='trabalhador',
>>> upload=URL('download')
>>> )
>>> empresa=request.vars['id'] or empresa
>>> extra_but = TR(DIV(A(I(_name='but',_class=**'icon-camera
>>> icon-white'),' Tirar foto',_class="btn btn-primary",_id ="but")))
>>> extra_fp_url = TR(DIV(INPUT(_name='fp_url',_**t
>>> ype='hidden',_id='fpurl')))
>>> extra_Aptidao = TR(DIV(A(I(_name='but',_class=**'icon-file
>>> icon-white'),' ',_class="btn btn-primary"),_onclick="**locati
>>> on.href='"+URL(f='**download', args=form.vars.apt_medica)+"'"**
>>> ))
>>> form[0].insert(-4,extra_**Aptidao)
>>> form[0].insert(-1,extra_but)
>>> form[0].insert(-1,extra_fp_**url)
>>>
>>>  if form.process().accepted:
>>> print "accepted form to save or update"
>>> print form.vars
>>>
>>>
>>>
>>> When i edit a record i see the upload file. But if i do not change
>>> the upload and save the record i get the error asking me to add the 
>>> upload
>>> file.
>>>
>>> I need some help on this.
>>> Thank you
>>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to web2py+un...@**googlegroups.com.
>> For more options, visit 
>> https://groups.google.com/**grou**ps/opt_out
>> .
>>
>>
>>
>
>  --

 ---
 You received this message because you are subscribed to the Google
 Groups "web2py-users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to web2py+un...@**googlegroups.com.
 For more options, visit 
 ht

[web2py] How to implement PostgreSQL "ts_rank" function for full text search?

2013-04-08 Thread Lisandro
I've succesfully implemented postgresql fulltext search (or at least a 
basic implementation).
In the model I have:

from gluon.dal import SQLCustomType
tsv = SQLCustomType(type='text', native='tsvector')
db.define_table('anuncios', Field('titulo', 'string'), Field('tsv', tsv))

Then I manually created a before update trigger on the table to keep "tsv" 
field updated (when the row is updated, the new tsv value is calculated and 
stored).
In the controller, this example of searching by a given query:

resultados = db("tsv @@ plainto_tsquery('%s')" %request.vars.q).select()

where request.vars.q has a simple text query. This is working perfectly. 

Now, I want to order the results of the query by "relevance", that is, I 
want to show first those results that are more relevant with the query.. 
For that, PostgreSQL full text search comes with everything I apparently 
need:
http://www.postgresql.org/docs/9.1/static/textsearch-controls.html#TEXTSEARCH-RANKING

But now I'm stucked in making the query via DAL sintax. The SQL sentence I 
want to execute is this:

SELECT titulo, ts_rank_cd(tsv, query) AS rank 
FROM anuncios, plainto_tsquery('my search words') query 
WHERE query @@ tsv 
ORDER BY rank DESC;

¿Could somebody help me to translate this SQL sentence to DAL sintax? 
Thanks in advance!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Niphlod
ok, we are getting closer! ^__^

Thanks for clearing it out - I get it now. It is still disappointing that 
> the only way to do that is by "polling"... It's not solving the problem, 
> just moving it around. It's fundamentally (in terms of execution-model), 
> not different than using "long-polling" in the client instead of SSE... In 
> both cases you got this scenario:
>

Polling has to be done if your backend doesn't notify you that there is a 
new message. 
Between a long-polling ajax and SSE stands all the difference 
(traffic-wise) that is added by a new http connection: dns resolving, 
socket opening, proxies, headers (client-side) and permission checking, 
session inspecting, validation (server-side). 
The point is not short-circuting the execution model, but short-circuiting 
the need to establish a new connection. 
That being said, if you choose a backend that notifies you when a new 
message arrives, you can also short-circuit the "polling part".
 

> The whole point of SSE is to avoid that execution model...
> You alluded to Redi's "push" mechanism - I've read your link on Redis's 
> Pub/Sub protocol, but couldn't find how the push is being done.
>

The pubsub pattern basically does:
- publish a new message
- all the subscribers receive that message
on redis, the publish part is a method that returns as soon as you sent 
that message

publish(channel, message)

the subscribe part is a method that listens "blocking" and "resumes" as 
soon as a message is received (so, it blocks if there are no new messages 
until there is a new one)
so, in your SSE action you should do something like (pseudo-code)

a = pubsub.subscribe(channel)
while True:
  yield a.listen()

 

> I'm currently looking into the Python-client implementation options there, 
> but let's assume that there is a way to listen from Python to Redis - where 
> do I put that? Inside the while-loop?
> And how does this "generator-instance-yield in a return statement" work 
> from an execution-model perspective? What happens when it's sleeping? Isn't 
> the python-run-time blocked? I mean, the controller-action "itself" is NOT 
> a generator - it "returns" a generator-instance. It is returning an object. 
> That object has a ".next()" method.. Great. Now what happens? Is web2py 
> recognizing it as a generator-instance by it's type/methods ? Then it does 
> a ".next()" call and issues the result within a response with the response 
> headers? What happens then? It sleeps, right? What happens during that 
> sleep? And after it finishes sleeping, it does not yield another values by 
> itself - a generator is not a self-activating-agency - it needs to be 
> called explicitly  - only then will it replay the loop and yield another 
> result.
>

In a gevent environment the coroutine "context switching" happens when you 
put that thread to sleep. This is done in several standard libs where an IO 
is done. Additionally, if you monkey_patched web2py (as anyserver.py does), 
every sleep() call effectively calls gevent.sleep() that is 
"coroutine-friendly": while that coroutine sleeps the execution of other 
coroutines can go forward, so yes, a sleep() blocks the execution, but only 
of that greenlet, letting other greenlets to pick up from where they were 
put to sleep. 

As per wsgi specs if the body is an iterator the body is returned in a 
chunked-like manner to the client: this enables the yielding loop to 
"stream" pieces of information while keeping the connection open. 
You can yield with the default threaded webserver, but the way it's 
implemented is a pool of threads, that has a maximum vale: as soon as there 
are n connections = n of threads of the webserver replying to a connection, 
no other connection can be established.
 
On gevent, on the other end, a new greenlet is spawned at every request and 
given that they are lighter, there's (virtually) no upper bound: that's why 
an evented environment is recommended (not required, but 
"highly-appreciated" nonetheless) while doing long-standing connections.


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Tree view, Rendering

2013-04-08 Thread Jurgis Pralgauskis
I stumbled upon this post as I am having a bit similar issue
but I try to represent stuf with nested-grid (if can call so)

https://groups.google.com/forum/?fromgroups=#!topic/web2py/fmyLPCsaoIo

maybe You'll have suggestions from your experience (better post in my 
thread, Thanks : )

2012 m. balandis 3 d., antradienis 03:21:12 UTC+3, Simon Ashley rašė:
>
> Pretty new to this and stumbling a little. 
> We need to generate a Treeview structure with the bottom node ending with 
> some links to other pages (graphs etc)
>
> Have a 7 level deep structure (each level in a different table) with each 
> level have a table format simple to the following: 
>   db.define_table('node', Field('parent',db.parent), Field('node_name'))
>   Tables will be maintained using smartgrid
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: representing nested subqueries results in one page (grid)

2013-04-08 Thread Jurgis Pralgauskis

>
> grid and smartgrid are not the best way to achieve what you are trying to 
> do.


Well,  this is really a tree structure, but grid gives me rough & easy way 
 to achieve this :)
http://galvosukykla.lt/failai//tmp/nested_tables_grid.png

For my app this kind of view is OK for workflow...

***
Smartgrid follows nesting logic as well (but needs click'ing)
there are two downsides, I see:

1) DB requests are made per branch (not per table) 

2) columns are not aligned the same for same depth but separate branch rows
(could be alligned with some jquery?)

3) the crud methods give duplicated/triplicated forms -- probably for each 
level 
http://galvosukykla.lt/failai//tmp/nested_tables_grid_viewdetails.png
(could be fixed with some option mangling I guess - any suggestions?)


any other thoughts...?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Paolo Caruccio
When I wrote the small app "SSE_clock" I was searching a replacement for a 
"long polling javascript code" that I was using in order to push db's table 
update notifications to clients. I abandoned the project by lack of 
browser's support.
Anyway, the application is a simple translation from php to python. 
Original demo target is to show that SSEs reconnect automatically and that 
it possible send multiple events on a single connection. Here attached 
you'll find original code in php to compare with python version.
However SSE has other features not discussed in the clock example. 
Below some links that I collected during my research:

http://blog.samshull.com/2010/10/ajax-push-in-ios-safari-and-chrome-with.html
http://my.opera.com/WebApplications/blog/show.dml/438711
http://dev.w3.org/html5/eventsource/
http://www.html5rocks.com/en/tutorials/eventsource/basics/
https://github.com/rwldrn/jquery.eventsource
http://www.igvita.com/2011/08/26/server-sent-event-notifications-with-html5/
http://dsheiko.com/weblog/html5-and-server-sent-events
http://blog.abourget.net/2010/6/16/html5-eventsource-in-pylons-read-comet-ajax-polling/
http://en.wikipedia.org/wiki/Server-sent_events
https://msmvps.com/blogs/theproblemsolver/archive/2011/11/07/html-5-server-sent-events.aspx
http://peter.sh/examples/?/javascript/event-source.html
http://weblog.bocoup.com/chrome-6-server-sent-events-with-new-eventsource
https://developer.mozilla.org/en/Server-sent_events/Using_server-sent_events
http://stevenhollidge.blogspot.com/2011/10/html5-server-side-events.html
http://www.dotnetage.com/publishing/home/2011/09/23/6932/html5-server-sent-events.html
http://moshhard.wordpress.com/2011/10/11/html5-server-sent-event-combine-with-web-notification/
http://www.codeproject.com/Questions/405117/Sending-Html5-SSE-to-specific-clients


Il giorno lunedì 8 aprile 2013 17:48:31 UTC+2, Arnon Marcus ha scritto:
>
> Look, I appreciate you're trying to help-out, but it seems you are 
> answering the questions you know the answers to, instead of the questions I 
> ask.
> It's OK to say that you don't know the answer. You are not alone in this 
> user-group, perhaps someone else does.
>
> We all got that. it's an external process, but it's implemented already, 
>> it "just works", has a simple yet powerful routing algo and its secure. 
>> With SSE you have to do it yourself.
>>  
>>
>
> I know that there is a "somewhat-working" solution for web-sockets, using 
> Tornado.
> I know it would be better to use it, instead of trying to make SSE work in 
> web2py by myself.
> In the long-term I'll probably do something like that.
>
> But as you said, not in all scenarios, a web-socket is requited - 
> sometimes an SSE does what I need.
> And as it is HTTP-based, I thought it should have been easy to implement 
> in web2py.
>
> This is exactly the example shown on the videos about 
>> websocket_messaging.py . the user receives updates through the ws, and he 
>> sends to the default web2py installation with a simple ajax post its 
>> message. web2py then queues that message to tornado, that informs all 
>> connected users of the new message on the ws channel.
>>
>>
> Again, that is not an answer to my questions. My questions where referring 
> to how web2py can implement SSE, not how Tornado can implement web-sockets 
> and have web2py push stuff into it.
>
>>
>> On the SSE side, you'd have some controller that basically does:
>>
>> def events():
>>   initialization_of_sse
>>   while True:
>>  yield send_a_message
>>
>> you have to think to security, routing, etc by yourself.
>>
>> Basically in that while True loop you'd likely want to inspect your 
>> "storage" (redis, ram, dict, database, whatever) if there's a new message 
>> for the user.
>> You can't "exit" from there and resume itall the logic needs to 
>> happen inside that yield(ing) loop.
>>
>
> That is answering the question : "How does web2py keep a long-lasting 
> connection".
> That is NOT answering the question: "How can a different controller-action 
> activate this"
>
> I found a way to extract the web2py-SSE example, here are the relevant 
> parts (I *bold*'ed the important stuff):
>
> *Controller:*
>
>
> # -*- coding: utf-8 -*-
> import time
> from gluon.contenttype import contenttype
>
> ### required - do no delete
> def user(): return dict(form=auth())
> def download(): return response.download(request,db)
> def call(): return service()
> ### end requires
>
> def index():
> return dict()
>
> def error():
> return dict()
>
> def sse():
> return dict()
>
> def buildMsg(eid , msg):
> mmsg = "id: %s\n" %eid
> mmsg += "data: {\n"
> mmsg += "data: \"msg\": \"%s\", \n" %msg
> mmsg += "data: \"id\": %s\n" %eid
> mmsg += "data: }\n\n"
> return mmsg
>
> *def sent_server_event():*
> response.headers['Content-Type'] = 'text/event-stream'
> response.headers['Cache-Control'] = 'no-cache'
> * def sendMsg():*
> startedAt = time.time(); #http://www.epochconverter.com/
> * while True:*

[web2py] Re: Server-Sent Events

2013-04-08 Thread Arnon Marcus
I think a picture is worth "more" than a thousand words... ;)

Thanks for clearing it out - I get it now. It is still disappointing that 
the only way to do that is by "polling"... It's not solving the problem, 
just moving it around. It's fundamentally (in terms of execution-model), 
not different than using "long-polling" in the client instead of SSE... In 
both cases you got this scenario:

Side A : Are we there yet?
Side B : No
Side A : Are we there yet?
Side B : No
Side A : Are we there yet?
Side B : No
Side A : Are we there yet?
Side B : No
Side A : Are we there yet?
Side B : No
Side A : Are we there yet?
Side B : Yes, here you go...
Side A : Are we there yet?
Side B : No
Side A : Are we there yet?
Side B : No
Side A : Are we there yet?
Side B : No


The whole point of SSE is to avoid that execution model...
You alluded to Redi's "push" mechanism - I've read your link on Redis's 
Pub/Sub protocol, but couldn't find how the push is being done.
I'm currently looking into the Python-client implementation options there, 
but let's assume that there is a way to listen from Python to Redis - where 
do I put that? Inside the while-loop?
And how does this "generator-instance-yield in a return statement" work 
from an execution-model perspective? What happens when it's sleeping? Isn't 
the python-run-time blocked? I mean, the controller-action "itself" is NOT 
a generator - it "returns" a generator-instance. It is returning an object. 
That object has a ".next()" method.. Great. Now what happens? Is web2py 
recognizing it as a generator-instance by it's type/methods ? Then it does 
a ".next()" call and issues the result within a response with the response 
headers? What happens then? It sleeps, right? What happens during that 
sleep? And after it finishes sleeping, it does not yield another values by 
itself - a generator is not a self-activating-agency - it needs to be 
called explicitly  - only then will it replay the loop and yield another 
result.
This part is still unclear...

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: /admin/design/MyApp very slow over 12 seconds

2013-04-08 Thread BlueShadow
the new version 2.4.6 is great it dropped the time to about 2-3 seconds

On Monday, April 1, 2013 9:50:32 PM UTC+2, BlueShadow wrote:
>
> Thats exactly what I'm saying.
> main site about 2sec admin/design/MyApp about 12 sec
>
>
> On Monday, April 1, 2013 9:39:00 PM UTC+2, Derek wrote:
>>
>> So you're saying your admin is slow but your main site isn't?
>>
>> On Saturday, March 30, 2013 12:29:48 AM UTC-7, BlueShadow wrote:
>>>
>>> Hi,
>>> my admin/design is very slow (over 12 seconds) and my app isn't that 
>>> big. 
>>> 9Models,
>>> 2 Controllers (1 with 33 functions, 1 with 11),
>>> 44 views,
>>> I don't use the language files but all from the welcome app are there.
>>> Static(no subfolders has 5 files) 
>>> css 14(including *.bak)
>>> images: 27
>>> js: 27 plus ckeditor which are a bunch of files
>>> no moduls(except __init__.py) plugins
>>> one private file (ssl)
>>>
>>> any Idea? this loading time is driving me nuts. 
>>> I got no clue how to provide more informations since I can only stop the 
>>> time with a stopwatch.
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: spoiler (show hidden content without reloading the page)

2013-04-08 Thread BlueShadow

I did something similar to the code Niphlod suggested. thanks for the ideas

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: can't open the admin edit function for the view of my default controller.

2013-04-08 Thread BlueShadow
the new version 2.4.6 fixed it thanks guys

On Saturday, March 30, 2013 1:28:32 PM UTC+1, BlueShadow wrote:
>
> /admin/edit/MyApp/views/default/index.html?id=views__default__index__html
> this URL gives me a 404 error. the file is on my server and I can edit 
> them with vim for example.
> All other files can be opened.
> Any ideas? Thanks
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to merge two tables

2013-04-08 Thread Cliff Kachinske
db(db.table1.col1 == db.table2.col1).select(
  db.table1.col2, 
  db.table1.col3, 
  db.table1.col4,
  db.table1.col5,
  db.table2.col6,
  db.table2.col7
  )

What's the purpose of the uuid?  If they are identical between 
corresponding rows of the two tables, it defeats the purpose of uuid.

uuid = Universally Unique IDentifier.  Each instance should be unique.

If you want to guarantee that each record in a table a primary key is 
sufficient for that.

Answers to these questions and many more can be found in the Web2py Manual 
here: http://web2py.com/books/default/chapter/29/06.

On Monday, April 8, 2013 4:29:35 PM UTC-4, David S wrote:
>
> I have three tables, db.table1 db.table2 and db.table3. They are identical 
> except for the information stored in each. table3 is blank and after 
> running some code should contain the combination of the values in table1 
> and table2. 
>
> An example ( is generated by web2py_uuid()):
>
> db.table1:
> col1 col2 col3 col4 col5 col6 col7 col8
> 1AZxx  
> 2BYxx  
> 3CXxx  
> 4DWxx  
>
> db.table2:
> col1 col2 col3 col4 col5 col6 col7 col8
> 1AZ  yy
> 2BY  yy
> 3CX  yy
> 4DW  yy
>
> After merging, db.table3 should look like this:
>
> db.table3:
> col1 col2 col3 col4 col5 col6 col7 col8
> 1AZxxyy
> 2BYxxyy
> 3CXxxyy
> 4DWxxyy
>
> After some research, I found that exporting table1 and table2 to separate 
> .csv files and then importing them into table3 should be an easy way to do 
> this, however it does not seem to be working for me. Below is the code I've 
> tried to use:
>
> rows = db(db.table1).select()
> rows.export_to_csv_file(open('table1.csv','wb'))
> db.table3.import_from_csv_file(open('table1.csv','rb'),unique='col1')
> 
> rows = db(db.table2).select()
> rows.export_to_csv_file(open('table2.csv','wb'))
> db.table3.import_from_csv_file(open('table2.csv','rb'),unique='col1')
>
> The problem I'm having is only the values from table2 are showing in 
> table3.
>
> I've also tried using a join like this:
>
> db(db.table1.col1 == db.table2.col1).select()
>
> But it creates something which looks like this:
>
> col1 col2 col3 col4 col5 col6 col7 col8   col1 col2 col3 col4 col5 col6 
> col7 col8
> 1AZxx   1AZ  y
> y
> 2BYxx   2BY  y
> y
> 3CXxx   3CX  y
> y
> 4DWxx   4DW  y
> y
>
> Is there another way of doing the join which would produce table3 how I'd 
> like it formatted?
>
> Anyone have a suggestion or better way to do this?
>
> Thanks,
> David
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: legacy database with reserved word field name

2013-04-08 Thread Martin Barnard
After tinkering with dal.py & separating out the check, the issue is with *
hasattr*(Table,fieldname). I'm assuming that self.drop exists as part of
the object creation. A possible solution would be to have a legacy flag on
a field so that internally it could map to the right field, but externally
it would have a safe name. Something like this would be good:

Field('drop' ,'integer', alias_name=True, alias='d_value')

Then it could be accessed via *db.table_name.d_value*

Martin

(and yes, I've found at least 5 tables with a "drop" field so far, sigh.)



On 8 April 2013 23:25, Martin Barnard  wrote:

> I had already done that. The error generated is in the Field class and is
> matching against REGEX_PYTHON_KEYWORDS, here:
>
>   File "/home/www-data/web2py/gluon/dal.py", line 9139, in __init__
> raise SyntaxError('Field: invalid field name: %s' % fieldname)
> SyntaxError: Field: invalid field name: drop
>
>
> code at line 9139 in dal.py is:
>   if not isinstance(fieldname, str) or hasattr(Table,fieldname) or \
> fieldname[0] =='_' or REGEX_PYTHON_KEYWORDS.match(fieldname):
> raise SyntaxError('Field: invalid field name: %s' % fieldname)
>
>
> Would there be a simple way of forcing it to not check, at the field level
> maybe? It would be beneficial for the field definition to have a
> check_reserved flag or even a *force_name=False* by default flag for us
> poor souls wrestling with legacy applications. I could bypass this, but
> then I'd need to keep doing it every time I update web2py.
>
>
>
> Martin
>
>
> On 8 April 2013 22:48, Massimo Di Pierro wrote:
>
>> You can simply set DAL(..., check_reserved=None)
>>
>> the problem is, will Oracle accept the SQL generated by DAL? You need to
>> try. I do not know.
>>
>>
>> On Sunday, 7 April 2013 21:32:03 UTC-5, Martin Barnard wrote:
>>>
>>> Continuing on my Oracle adventures, I have found a table which I need to
>>> access, which has an integer field called '*drop*'.  For *obvious*reasons, 
>>> it is disallowed. Is there any way to force this field name
>>> through the DAL (my account is read-only, so I know that I *probably*can't 
>>> actually drop the table).
>>>
>>> I think that the reserved_sql_keywords is a good thing, but it would be
>>> nice if we could occasionally 'force' a table or field name for legacy
>>> database access.
>>>
>>> *Can anybody think of ways of bypassing reserved words checking for
>>> legacy dbs tablenames?*
>>>
>>>
>>> Martin Barnard
>>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/gHOkeBz3_yA/unsubscribe?hl=en.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How to merge two tables

2013-04-08 Thread David S
I have three tables, db.table1 db.table2 and db.table3. They are identical 
except for the information stored in each. table3 is blank and after 
running some code should contain the combination of the values in table1 
and table2. 

An example ( is generated by web2py_uuid()):

db.table1:
col1 col2 col3 col4 col5 col6 col7 col8
1AZxx  
2BYxx  
3CXxx  
4DWxx  

db.table2:
col1 col2 col3 col4 col5 col6 col7 col8
1AZ  yy
2BY  yy
3CX  yy
4DW  yy

After merging, db.table3 should look like this:

db.table3:
col1 col2 col3 col4 col5 col6 col7 col8
1AZxxyy
2BYxxyy
3CXxxyy
4DWxxyy

After some research, I found that exporting table1 and table2 to separate 
.csv files and then importing them into table3 should be an easy way to do 
this, however it does not seem to be working for me. Below is the code I've 
tried to use:

rows = db(db.table1).select()
rows.export_to_csv_file(open('table1.csv','wb'))
db.table3.import_from_csv_file(open('table1.csv','rb'),unique='col1')

rows = db(db.table2).select()
rows.export_to_csv_file(open('table2.csv','wb'))
db.table3.import_from_csv_file(open('table2.csv','rb'),unique='col1')

The problem I'm having is only the values from table2 are showing in table3.

I've also tried using a join like this:

db(db.table1.col1 == db.table2.col1).select()

But it creates something which looks like this:

col1 col2 col3 col4 col5 col6 col7 col8   col1 col2 col3 col4 col5 col6 
col7 col8
1AZxx   1AZ  y
y
2BYxx   2BY  y
y
3CXxx   3CX  y
y
4DWxx   4DW  y
y

Is there another way of doing the join which would produce table3 how I'd 
like it formatted?

Anyone have a suggestion or better way to do this?

Thanks,
David

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: legacy database with reserved word field name

2013-04-08 Thread Martin Barnard
I had already done that. The error generated is in the Field class and is
matching against REGEX_PYTHON_KEYWORDS, here:

  File "/home/www-data/web2py/gluon/dal.py", line 9139, in __init__
raise SyntaxError('Field: invalid field name: %s' % fieldname)
SyntaxError: Field: invalid field name: drop


code at line 9139 in dal.py is:
  if not isinstance(fieldname, str) or hasattr(Table,fieldname) or \
fieldname[0] =='_' or REGEX_PYTHON_KEYWORDS.match(fieldname):
raise SyntaxError('Field: invalid field name: %s' % fieldname)


Would there be a simple way of forcing it to not check, at the field level
maybe? It would be beneficial for the field definition to have a
check_reserved flag or even a *force_name=False* by default flag for us
poor souls wrestling with legacy applications. I could bypass this, but
then I'd need to keep doing it every time I update web2py.



Martin


On 8 April 2013 22:48, Massimo Di Pierro  wrote:

> You can simply set DAL(..., check_reserved=None)
>
> the problem is, will Oracle accept the SQL generated by DAL? You need to
> try. I do not know.
>
>
> On Sunday, 7 April 2013 21:32:03 UTC-5, Martin Barnard wrote:
>>
>> Continuing on my Oracle adventures, I have found a table which I need to
>> access, which has an integer field called '*drop*'.  For *obvious*reasons, 
>> it is disallowed. Is there any way to force this field name
>> through the DAL (my account is read-only, so I know that I *probably*can't 
>> actually drop the table).
>>
>> I think that the reserved_sql_keywords is a good thing, but it would be
>> nice if we could occasionally 'force' a table or field name for legacy
>> database access.
>>
>> *Can anybody think of ways of bypassing reserved words checking for
>> legacy dbs tablenames?*
>>
>>
>> Martin Barnard
>>
>  --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/gHOkeBz3_yA/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How can I grab the parent ID from this record?

2013-04-08 Thread Alex Glaros
I want to grab the ID of parent file SharedService during a search.

What is the best way to get it?  Can it be obtained using factory or 
sqlform?

## 
-
## Here's the model:

db.define_table('SharedService',
Field('shortSharedServiceDescription', 'string',label='Description'),
Field('shortSharedServiceTitle', 'string', label='Title'))

db.define_table('Organization',
Field('organizationFullName','string')) ## e.g., Oracle Corporation

db.define_table('SharedServicePartnerIntersection',
Field('sharedServiceID', 'reference SharedService',
  writable=False,readable=False), 
Field('organizationID','reference Organization'))
db.SharedServicePartnerIntersection['_plural'] = 'Partner List' ## here's 
where I want to say "View or Add Partners"

## 
-
## Here's the controller that does the searching.  When user chooses "View 
or Add Partners", it selects this parent record.  I want to grab parent ID. 
 How?

def search_shared_services():
grid = SQLFORM.smartgrid(db.SharedService, 
linked_tables=['SharedServicePartnerIntersection'],
maxtextlength={'SharedServicePartnerIntersection.sharedServiceID':140, 
 
'SharedService.shortSharedServiceTitle':140,'SharedService.shortSharedServiceDescription':140})
return dict(grid=grid)

## 
-

Instead of displaying "Partner List" I would like to display "View or Add 
Partners", and give user ability to view or add partners. To do this, I 
need to be able to grab the parent ID of the selected record (they select 
it by clicking on "View or Add Partners"). 

Can someone please type syntax for that?

Thanks,

Alex Glaros

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: legacy database with reserved word field name

2013-04-08 Thread Massimo Di Pierro
You can simply set DAL(..., check_reserved=None)

the problem is, will Oracle accept the SQL generated by DAL? You need to 
try. I do not know.

On Sunday, 7 April 2013 21:32:03 UTC-5, Martin Barnard wrote:
>
> Continuing on my Oracle adventures, I have found a table which I need to 
> access, which has an integer field called '*drop*'.  For *obvious*reasons, it 
> is disallowed. Is there any way to force this field name 
> through the DAL (my account is read-only, so I know that I *probably*can't 
> actually drop the table).
>
> I think that the reserved_sql_keywords is a good thing, but it would be 
> nice if we could occasionally 'force' a table or field name for legacy 
> database access.
>
> *Can anybody think of ways of bypassing reserved words checking for 
> legacy dbs tablenames?* 
>
>
> Martin Barnard
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Niphlod


On Monday, April 8, 2013 7:11:57 PM UTC+2, Arnon Marcus wrote:
>
>
>> oh my SSE are unidirectional, so of course the example shows you just 
>> the server --> client part and not the client-->server one.
>> you can do the client--> server part as usual with an ajax post.
>>
>> (I would appreciate you refrain from using expressions with 
> condescending implications such as "oh my...")
>

Sorry, it wasn't my intention I'm not a native English speaker and 
writing does not always explain "emotions" like a face to face discussion. 
By all means, feel free to put a :-) everywhere  
it's just that seeing web2py "bashed" with expression like "the example is 
half-assed" or "something crucial is missing" for something that clearly 
its not a problem of web2py itself "sounds bad", I'm trying to follow you 
and explain/give-an-alternative to the problem(s) you're pointing to.
 

>
>
>> EDIT: you don't need to have one-and-only sse capable controller. 
>> You just need to code into a single one of them what is required by the 
>> view who will call it (i.e. you can have a page for a chat that will "call" 
>> the sse that deals with the chat,  the page of the calendar that listens to 
>> the calendar sse and so on)
>>
>
> Now you are getting closer... Of course I understand that I can have more 
> then a single SSE-enabled controller-action, but as you said - this would 
> mean that, say, a "chat" view, may ONLY invoke a "chat" 
> SSE-enabled-controller-action, and a "calendar" view, may ONLY invoke a 
> "calendar" SSE-enabled-controller-action...
> What if I want 2 users to collaborate on the same data, using different 
> views, and still get real-updates?
> Let's say we have 2 views, a calendar, and a scheduling-run-chart - 
> Different views of the same (or partially-shared) data, for different 
> use-cases.
> How can I have one updating the calendar, and getting live-updates from 
> another user updating the schedule (and vice-versa) ?
> If it is not clear verbally, perhaps a picture is in order...
>


Picture definitely helps.

What needs to be cleared is this (sorry if this repeats something that is 
yet clear): you can have as many SSE "hooks" defined in a single page as 
you want, but **usually**  you'd want to have a single one for each page 
and send different events (on the SSE specs, it's different "event:" key) 
through the same connection, cause doing so you can "allocate" a single 
connection per user. That being said, if your machine can hold 1000 
connections and you have no more that 50 users, use as many "hooks" as you 
wish.

Every SSE "hook" will at all effects "hold a greenlet captive" for all the 
duration of the "streaming" of responses. 
Not to stress out on the core concept, but in the end you choose SSE over a 
recurring poll with ajax just to "spare" the reconnection times.
Given that a new "greenlet" will be costantly active to send events to the 
client (a greenlet per page per user), you can't "expect" the normal 
request/response cycle: the "method" to hold a connection open is not to 
return something, it's yielding "small blocks" in a never-ending loop. 
This "requires" that the logic, e.g., to check for new messages, "happens" 
in that while loop.

Whatever you choose to implement that logic is up to you: when I said 
"database, redis, cache, etc" I just pointed out some of the possible 
implementations:
- a messages table on a database
- a key in the cache.ram
- a list in redis
but it may be as well leveraging the pubsub features of redis.

So, let's take a messages table: you define topics, type of events, content 
of the event, recipients
user 1 opens the page /app/default/index.html that has a piece of 
javascript to hook to the sse on /app/sse/index . 
user 2 opens /app/default/index.html and you want him to book an 
appointment. 
When he books it, web2py receives the booking (a normal ajax post in 
response to a click on a button) and stores it into the messages table. 
Inside your "yielding" loop on /app/sse/index you check for new 
appointments every 3 seconds and user 1 receives the update.

Let's take instead a pubsub redis topic: 
user 1 opens the page /app/default/index.html that has a piece of 
javascript to hook to the sse on /app/sse/index . 
user 2 opens /app/default/index.html and you want him to book an 
appointment. When he books it, web2py receives the booking and stores it 
into the  
redis topic. Inside your "yielding" loop on /app/sse/index you subscribe to 
the topic and wait for redis to send you a payload that user 1 receives.

As stated before, you "need" to build your own routing mechanism: if you 
leverage redis pubsub some things can be easier than a database table, but 
you could as well store each message in a flat file and read from that 
The yielding loop can very well "subscribe" to different redis topics as 
watching for differen

Re: [web2py] Re: legacy database with reserved word field name

2013-04-08 Thread Martin Barnard
Tried. Didn't work.


On 8 April 2013 19:57, Derek  wrote:

> try putting it in [brackets] or "quotes".
>
>
> On Sunday, April 7, 2013 7:32:03 PM UTC-7, Martin Barnard wrote:
>>
>> Continuing on my Oracle adventures, I have found a table which I need to
>> access, which has an integer field called '*drop*'.  For *obvious*reasons, 
>> it is disallowed. Is there any way to force this field name
>> through the DAL (my account is read-only, so I know that I *probably*can't 
>> actually drop the table).
>>
>> I think that the reserved_sql_keywords is a good thing, but it would be
>> nice if we could occasionally 'force' a table or field name for legacy
>> database access.
>>
>> *Can anybody think of ways of bypassing reserved words checking for
>> legacy dbs tablenames?*
>>
>>
>> Martin Barnard
>>
>  --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/gHOkeBz3_yA/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to - using DAL for "Between"

2013-04-08 Thread Massimo Di Pierro
what's the code? You are passing rows/records where you are supposed to 
pass a query.

On Monday, 8 April 2013 13:46:03 UTC-5, Rahul wrote:
>
>
> Thanks Niphlod, :-)
>This code works with webgrid component. But I get an error when I 
> try to use it with SQLForm.grid. Something like below -
> ---
> Ticket ID
>
> 127.0.0.1.2013-04-08.22-09-49.ef6e6a56-089a-4c50-87fa-2099255002de
>  'Rows' object has no attribute '_db'
> Versionweb2py™Version 2.4.5-stable+timestamp.2013.03.18.22.46.22PythonPython 
> 2.7.2: C:\Python27\python.exe (prefix: C:\Python27)Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
>
> Traceback (most recent call last):
>   File "E:\Web2py\web2py\gluon\restricted.py", line 212, in restricted
> exec ccode in environment
>   File "E:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
> , 
> line 3882, in 
>   File "E:\Web2py\web2py\gluon\globals.py", line 194, in 
> self._caller = lambda f: f()
>   File "E:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
> , 
> line 729, in bug_new_tickets_created
> create=False, deletable=False, details=True, editable=False,  csv=False, 
> maxtextlength=64, paginate=15, ui='jquery-ui' )
>   File "E:\Web2py\web2py\gluon\sqlhtml.py", line 1808, in grid
> db = query._db
> AttributeError: 'Rows' object has no attribute '_db'
>
> Error snapshot [image: help] Detailed traceback description 
> 
>  
>
> ('Rows' object has no attribute '_db') 
>
> 
>
> However - for now I can use the above code with the workaround I have. 
> Thanks again. Web2py has all the good folks!! 
>
> Cheers, Rahul.
>
>
> On Monday, April 8, 2013 6:57:18 PM UTC+5:30, Niphlod wrote:
>>
>> from datetime import timedelta
>> now = request.now
>> six_days_back = now - timedelta(days=6)
>> db(
>> (db.issues.date_today >= six_days_back) &
>> (db.issues.date_today <= request.now)
>> ).select(whateverfieldyouneed)
>>
>>
>>
>> On Monday, April 8, 2013 3:07:57 PM UTC+2, Rahul wrote:
>>>
>>> Hi All,
>>>  I am working on a query in SQLite  - Where I can search on some 
>>> data for last 7 days - 
>>>
>>> SQLite raw sql query  is as follows: 
>>> query = db.executesql("SELECT ticket_no, description FROM issues where 
>>> date_today between datetime ('now', '-6 days') AND datetime ('now', 
>>> 'localtime')")
>>>
>>> I need to know the equivalent DAL version of it. Any help would be much 
>>> appreciated. 
>>>
>>> Rahul
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Arnon Marcus
That's what I'm talking about... :)

http://vimeo.com/41410528

And this is from 2011...

When will web2py support 0MQ ???

Ach...

Can web2py subscribe to Redis publishing?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to - using DAL for "Between"

2013-04-08 Thread Rahul

Thanks Niphlod, :-)
   This code works with webgrid component. But I get an error when I 
try to use it with SQLForm.grid. Something like below -
---
Ticket ID

127.0.0.1.2013-04-08.22-09-49.ef6e6a56-089a-4c50-87fa-2099255002de
 'Rows' object has no attribute '_db'
Versionweb2py™Version 2.4.5-stable+timestamp.2013.03.18.22.46.22PythonPython 
2.7.2: C:\Python27\python.exe (prefix: C:\Python27)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

Traceback (most recent call last):
  File "E:\Web2py\web2py\gluon\restricted.py", line 212, in restricted
exec ccode in environment
  File "E:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
, 
line 3882, in 
  File "E:\Web2py\web2py\gluon\globals.py", line 194, in 
self._caller = lambda f: f()
  File "E:/Web2py/web2py/applications/BBOnline/controllers/default.py" 
, 
line 729, in bug_new_tickets_created
create=False, deletable=False, details=True, editable=False,  csv=False, 
maxtextlength=64, paginate=15, ui='jquery-ui' )
  File "E:\Web2py\web2py\gluon\sqlhtml.py", line 1808, in grid
db = query._db
AttributeError: 'Rows' object has no attribute '_db'

Error snapshot [image: help] Detailed traceback description 

 

('Rows' object has no attribute '_db') 



However - for now I can use the above code with the workaround I have. 
Thanks again. Web2py has all the good folks!! 

Cheers, Rahul.


On Monday, April 8, 2013 6:57:18 PM UTC+5:30, Niphlod wrote:
>
> from datetime import timedelta
> now = request.now
> six_days_back = now - timedelta(days=6)
> db(
> (db.issues.date_today >= six_days_back) &
> (db.issues.date_today <= request.now)
> ).select(whateverfieldyouneed)
>
>
>
> On Monday, April 8, 2013 3:07:57 PM UTC+2, Rahul wrote:
>>
>> Hi All,
>>  I am working on a query in SQLite  - Where I can search on some data 
>> for last 7 days - 
>>
>> SQLite raw sql query  is as follows: 
>> query = db.executesql("SELECT ticket_no, description FROM issues where 
>> date_today between datetime ('now', '-6 days') AND datetime ('now', 
>> 'localtime')")
>>
>> I need to know the equivalent DAL version of it. Any help would be much 
>> appreciated. 
>>
>> Rahul
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] help debugging this

2013-04-08 Thread Massimo Di Pierro
I cannot think of any change that would cause this:

https://code.google.com/p/web2py/issues/detail?start=100&id=1435

*What steps will reproduce the problem?*
1. Openshift - start account, install web2py using the github stem, once 
installed, upgrade - fails
2. dotcloud - start account, install web2py, then upgrade (either local and 
push or on dotcloud) - never returns
3. pythonanywhere same, use the button to install web2py 2.4.2, upgrade, then 
it start to fail with bad gateway, and messages like headers already sent errors
*What is the expected output? What do you see instead?*
Web2py screen, and instead you get a nginx bad gateway error, after a long wait.
*What version of the product are you using? On what operating system?*
2.4.2 works, 2.4.6 works on my local machine, however once pushed or upgraded 
on these cloud services it stops working
*Please provide any additional information below.*
My application is extremely simple, so I don't think that it could be causing 
the issue, either way it works on 2.4.2 fine on these cloud providers


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.factory does not update record with upload field

2013-04-08 Thread Massimo Di Pierro
The workflow is ambiguous. You are not editing a record therefore it is not 
clear whether an empty submission means you want to keep or remove the 
default.
It thinks you want to remove it.

If you want to keep it, still, it is not a proper default for the input 
(since it is no a fieldstorage to be processed). You can do (for now):

def tab1():
if request.args(0): 
print "editing record"
row=db(db.tab1.id==request.args(0)).select()[0]
db.tab1['f1'].default = row.f1
db.tab1['f2'].default = row.f2
form=SQLFORM.factory(db.tab1,upload=URL('download'))
if form.process():
if 'f2 in form.errors: del form.errors['f2']
if not form.errors:
form.vars['f2'] = db.tab1['f2'].default 
print "updating or creating record"
return dict(form=form)


On Monday, 8 April 2013 04:44:36 UTC-5, Ramos wrote:
>
> Hello
>
> my db.py
>
> db.define_table('tab1',
> Field('f1'),
> 
> Field('f2','upload',uploadfolder=os.path.join(request.folder,'uploads'))
> )
> db.tab1.f2.requires=IS_NOT_EMPTY()
>
> my controller
> def tab1():
> if request.args(0): 
> print "editing record"
> row=db(db.tab1.id==request.args(0)).select()[0]
> db.tab1['f1'].default = row.f1
> db.tab1['f2'].default = row.f2
> form=SQLFORM.factory(db.tab1,upload=URL('download'))
> if form.process().accepted: #update or create
> print "updating or creating record"
> return dict(form=form)
> first i create a record with some text in f1 and a file in f2.
> then i edit this record with myapp/default/tab1/*1*
> If i submit without changing f1 or f2 field, i get the error about field 
> f2 not having a file to upload.
>
>
> Can someone help me to understand how to edit a record with 
> sqlform.factory and upload fields?
>
> *This is just a demo of my problem. *
> *In my project i´m using sqlform.factory to edit records from more than 
> one table.*
>
> Thank you
> António
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: UnicodeEncodeError on GAE

2013-04-08 Thread Massimo Di Pierro
Can you please give me more details and a simple example to reproduce it? 
Is this on GAE only? Still a problem with 2.4.6?

On Monday, 8 April 2013 00:57:17 UTC-5, Spring wrote:
>
> Encountered the same issue, removing 'str()' and it worked. Thanks
>
> 在 2012年2月16日星期四UTC+8下午10时59分28秒,sherdim写道:
>>
>> I Think it is a bug  as for 1.99.4
>> When a form "tries" to keep values w/ non ascii characters
>>
>> if form.accepts(request.vars,session, formname=sP, keepvalues=True):
>>   File "C:\a\w2p\gluon\html.py", line 1801, in accepts
>> status = self._traverse(status,hideerror)
>>   File "C:\a\w2p\gluon\html.py", line 743, in _traverse
>> newstatus = c._traverse(status,hideerror) and newstatus
>>   File "C:\a\w2p\gluon\html.py", line 751, in _traverse
>> self._postprocessing()
>>   File "C:\a\w2p\gluon\html.py", line 1585, in _postprocessing
>> _value = str(self['_value'])
>> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-8: 
>> ordinal not in range(128)
>>
>>
>> Is str instruction ever needed? If yes -  additional check for unicodes 
>> with proper utf-8 conversion  is needed just before.
>>
>> IMHO str at 1585 is excessive - all is fine  when deleted 
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: list:string type field is empty value on edit page

2013-04-08 Thread Massimo Di Pierro
db.define_table('gender',
Field('gender', 'list:string'),
format='%(gender)s')

db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])

should be

db.define_table('gender',
Field('gender', 'list:string'),
format='%(gender)s')
db.gender.gender.requires=IS_IN_SET(['Male', 'Female'],mutliple=True)

if you have a list of strings, you must allows multiple options. It does 
not make much sense in the Male/Female case (or perhaps it does, not sure).

On Monday, 8 April 2013 00:00:28 UTC-5, 黄祥 wrote:
>
> i've already start testing using the simple table (start from scratch) but 
> got the same result. here is my conclusion, please correct me if i'm wrong :
> - if you combine list:string field with IS_IN_SET validator, in form edit 
> you will receive blank value in drop down, not the existing value that 
> stored in database. 
> - if you want to use IS_IN_SET validator and in form edit will show the 
> existing value that store in database, please use string type field in your 
> define table.
>
> *e.g. in form edit receive blank value in drop down field, not the 
> existing value that stored in database*
> *db.py*
> db.define_table('gender',
> Field('gender', 'list:string'),
> format='%(gender)s')
>
> db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])
>
> *default.py*
> def gender():
> grid=SQLFORM.grid(db.gender, user_signature=False)
> return locals()
>
> *default/gender.html*
> {{extend 'layout.html'}}
>
> {{=grid}}
>
> *e.g. in form edit will show the existing value that store in database*
> *db.py*
> db.define_table('gender',
> Field('gender'),
> format='%(gender)s')
>
> db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])
>
> *default.py*
> def gender():
> grid=SQLFORM.grid(db.gender, user_signature=False)
> return locals()
>
> *default/gender.html*
> {{extend 'layout.html'}}
>
> {{=grid}}
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Arnon Marcus

>
>
> oh my SSE are unidirectional, so of course the example shows you just 
> the server --> client part and not the client-->server one.
> you can do the client--> server part as usual with an ajax post.
>
> (I would appreciate you refrain from using expressions with 
condescending implications such as "oh my...")
I know it's uni-directional... It's not the point...
I mean that another view from another controller, would invoke, say, an 
ajax call, to IT'S OWN CONTROLLER's action, which will THEN invoke the 
SSE-enabled-action in the other controller.


> EDIT: you don't need to have one-and-only sse capable controller. 
> You just need to code into a single one of them what is required by the 
> view who will call it (i.e. you can have a page for a chat that will "call" 
> the sse that deals with the chat,  the page of the calendar that listens to 
> the calendar sse and so on)
>

Now you are getting closer... Of course I understand that I can have more 
then a single SSE-enabled controller-action, but as you said - this would 
mean that, say, a "chat" view, may ONLY invoke a "chat" 
SSE-enabled-controller-action, and a "calendar" view, may ONLY invoke a 
"calendar" SSE-enabled-controller-action...
What if I want 2 users to collaborate on the same data, using different 
views, and still get real-updates?
Let's say we have 2 views, a calendar, and a scheduling-run-chart - 
Different views of the same (or partially-shared) data, for different 
use-cases.
How can I have one updating the calendar, and getting live-updates from 
another user updating the schedule (and vice-versa) ?
If it is not clear verbally, perhaps a picture is in order...


I'm attaching a picture - the "missing-part" in web2py from this 
stand-point, are the "green arrows"...

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: pre populated SQLFORM.FACTORY does not submit because of upload field

2013-04-08 Thread Massimo Di Pierro
It took me a while to isolate the problem. Here is a simple code to 
reproduce it:

def index():
db.define_table('thing',Field('image','upload',requires=IS_NOT_EMPTY()))
db.thing.image.default = 'xxx.png'
form = SQLFORM.factory(db.thing,upload=URL('download')).process()
return locals()

It is a bin can of worms and I opened a ticket about this. For now I will 
just say that giving a default to an upload field is not a good idea. You 
can try do the following:
def index():
db.define_table('thing',Field('image','upload',requires=IS_NOT_EMPTY()))
form = SQLFORM.factory(db.thing,upload=URL('download')).process()
db.thing.image.default = 'xxx.png'
if form.errors['image'] == '':
del form.errors['image']
   insert  'xxx.png' where needed
return locals()

On Sunday, 7 April 2013 06:54:41 UTC-5, Ramos wrote:
>
> Can you check again Massimo in the app i posted? controller default - 
> Action trabalhador
>
> Thank you
>
> António
>
>
> 2013/4/6 António Ramos >
>
>> Sorry i meant trabalhador
>>
>> Action trabalhador
>> Thank you
>> No dia 06/04/2013 17:31, "Massimo Di Pierro" 
>> > 
>> escreveu:
>>
>>  Sorry I cannot find action "empreiteiro"
>>>
>>> On Friday, 5 April 2013 16:45:39 UTC-5, Ramos wrote:

 I post here my app.

 Sorry about the quality of my code. I´m learning as i go along the way.

 The problem is in controller default, action empreiteiro 

 The upload field is required but when i edit a record i see the link to 
 the uploaded file and if i do nothing and just save it complains that i 
 have to upload a file.
 It is there!!

 Thank you

 António



 2013/4/5 Massimo Di Pierro 

> Can you post a simpler example (including mode) to reproduce the 
> problem? Looks like the field in the table has a validator which requires 
> an upload.
>
>
> On Friday, 5 April 2013 11:06:52 UTC-5, Ramos wrote:
>>
>> hello, i´m using a sqlform.factory to edit a record.
>>
>> The form is prepopulated using this code
>>
>>
>> row=db((db.trabalhador.id==**req**uest.args(0))).select().**first(**)
>>
>> if row:
>> for field in row:
>> if field in db.trabalhador.fields:
>>
>> print "setting -",row[field] ," on ",field 
>> db.trabalhador[field].default=row[field]
>>
>>
>> one of the fields is a required upload field.
>>
>> The rest of the code
>> form=SQLFORM.factory(db.**trabal**hador,db.t_docs,
>> submit_button="Gravar",
>> fields=['nome','bi','ncart','**n**
>> cartval','rfid','apt_medica',**'**apt_medicaval','val_formacao'**,**
>> 'f_doc'],
>> table_name='trabalhador',
>> upload=URL('download')
>> )
>> empresa=request.vars['id'] or empresa
>> extra_but = TR(DIV(A(I(_name='but',_class='icon-camera 
>> icon-white'),' Tirar foto',_class="btn btn-primary",_id ="but")))
>> extra_fp_url = TR(DIV(INPUT(_name='fp_url',_**t**
>> ype='hidden',_id='fpurl')))
>> extra_Aptidao = TR(DIV(A(I(_name='but',_class='icon-file 
>> icon-white'),' ',_class="btn btn-primary"),_onclick="**locati**
>> on.href='"+URL(f='**download', args=form.vars.apt_medica)+"'"))
>> form[0].insert(-4,extra_**Aptida**o) 
>> form[0].insert(-1,extra_but)
>> form[0].insert(-1,extra_fp_**url**)
>>
>>  if form.process().accepted: 
>> print "accepted form to save or update"
>> print form.vars 
>>
>>
>>
>> When i edit a record i see the upload file. But if i do not change 
>> the upload and save the record i get the error asking me to add the 
>> upload 
>> file.
>>
>> I need some help on this.
>> Thank you
>>
>  -- 
>  
> --- 
> You received this message because you are subscribed to the Google 
> Groups "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to web2py+un...@**googlegroups.com.
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>  
>  
>

  -- 
>>>  
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to web2py+un...@googlegroups.com .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com

[web2py] Re: legacy database with reserved word field name

2013-04-08 Thread Derek
try putting it in [brackets] or "quotes".

On Sunday, April 7, 2013 7:32:03 PM UTC-7, Martin Barnard wrote:
>
> Continuing on my Oracle adventures, I have found a table which I need to 
> access, which has an integer field called '*drop*'.  For *obvious*reasons, it 
> is disallowed. Is there any way to force this field name 
> through the DAL (my account is read-only, so I know that I *probably*can't 
> actually drop the table).
>
> I think that the reserved_sql_keywords is a good thing, but it would be 
> nice if we could occasionally 'force' a table or field name for legacy 
> database access.
>
> *Can anybody think of ways of bypassing reserved words checking for 
> legacy dbs tablenames?* 
>
>
> Martin Barnard
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to - using DAL for "Between"

2013-04-08 Thread Derek
Of course, you could omit the db.issues.date_today <= request.now if you 
know for a fact there are no time travelers opening tickets in the future.
;)


On Monday, April 8, 2013 6:27:18 AM UTC-7, Niphlod wrote:
>
> from datetime import timedelta
> now = request.now
> six_days_back = now - timedelta(days=6)
> db(
> (db.issues.date_today >= six_days_back) &
> (db.issues.date_today <= request.now)
> ).select(whateverfieldyouneed)
>
>
>
> On Monday, April 8, 2013 3:07:57 PM UTC+2, Rahul wrote:
>>
>> Hi All,
>>  I am working on a query in SQLite  - Where I can search on some data 
>> for last 7 days - 
>>
>> SQLite raw sql query  is as follows: 
>> query = db.executesql("SELECT ticket_no, description FROM issues where 
>> date_today between datetime ('now', '-6 days') AND datetime ('now', 
>> 'localtime')")
>>
>> I need to know the equivalent DAL version of it. Any help would be much 
>> appreciated. 
>>
>> Rahul
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Replicated Databases and fail over

2013-04-08 Thread Srinath
Hi,

We have been trying to get this thing right.

REF: http://web2py.com/books/default/chapter/29/06

There is a note about Replicated databases in the given link.

The first argument of DAL(...) can be a list of URIs. In this case web2py
tries to connect to each of them. In this case the DAL tries to connect to
the first and, on failure, it will try the second and the third.

But when we tried to do this by giving a random IP address for the first
string, and the right URI for the second connection string, it didn't seem
to be working. We were getting an nginx 504 Gateway Timeout everytime.

Is there any work around? We also know that the Round Robin way exists. But
that would also raise the same 504.

Is there any way other than this?

http://about.me/srinathgs
I write code @ Alamut
Srinath G S

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: contribute in indonesian language translate

2013-04-08 Thread Massimo Di Pierro
Thank you. This is now in trunk. Mind that the translation files contain 
some string from your app that do not belong to the welcome app. Perhaps 
they should be removed.

On Sunday, 7 April 2013 23:30:13 UTC-5, 黄祥 wrote:
>
> yes, me too, i can't find it. although when i checked the log it said 
> already commited.
> btw, please find attached file (id.py for indonesian and my.py for malay)
> thank you very much
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Niphlod


On Monday, April 8, 2013 5:48:31 PM UTC+2, Arnon Marcus wrote:
>
> Look, I appreciate you're trying to help-out, but it seems you are 
> answering the questions you know the answers to, instead of the questions I 
> ask.
> It's OK to say that you don't know the answer. You are not alone in this 
> user-group, perhaps someone else does.
>
>  
ok, back to the "sse only" discussion. 

>
>
> That is answering the question : "How does web2py keep a long-lasting 
> connection".
> That is NOT answering the question: "How can a different controller-action 
> activate this"
>

Why does this have to be activated in another controller-action ?
The point of SSE is that as soon as your page does the eventsource(url) 
stuff, the connection is istantiated and (reconnections aside) never closed.
Sure, you can have your js code attaching/detaching to different urls, but 
you're going to increase the overall implementation weight.
Inside that loop you can do, e.g.

   msg = db(db.messages.recipient == auth.user_id).select().first()
   yield msg

it's just a simple example that shows that you how in the same loop you can 
be "influenced" by other actions (i.e. that have submitted a record to the 
messages table)
 

>  But it answers NONE of the questions I asked...
>

> There is *no inter-controller/action communication* in here, there is no 
> way to *POST* something *from the client to the server*, that will *call 
> a different action* in web2py, which will *then invoke another yield* of 
> the SSE action, thus* intentionally-spawning another response over the 
> existing connection*
>
oh my SSE are unidirectional, so of course the example shows you just 
the server --> client part and not the client-->server one.
you can do the client--> server part as usual with an ajax post.

 

> And what if there are multiple connections to multiple clients? the only 
> way to differentiate between them would be via their sessions.
> Now, the way I understand this, it's a *fundamental "executional" * 
> limitation 
> of web2py - it has no concurrency, so each invocation of web2py's 
> wsgi-handler, is in fact a single-process-single-thread type of scenario, 
> so that there could never exist multiple sessions that are handled at the 
> same time 
>
>  
No framework supports multiple connections in the same 
thread/coroutine/process.  Every different implementation either spawns a 
process, or a thread, or a greenlet to do the work . Of course the more 
lightweight the better, so greenlets win hands down.
That being said, web2py is obviously concurrent: no site will be deployed 
with web2py if that was in fact happening.
Concurrency is achieved with threads with the default webserver, but anyone 
is posing a limit on what you want to run web2py into.
I really don't see what's the missing component on web2py (aside not being 
able with rocket to support a lot of users with SSE). As soon as you run it 
in a gevent wsgiserver (or the usual gevented gunicorn) you can do whatever 
you want.
In the loop you have to build your own routing, that is all is needed.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: auth.user.id in restful api

2013-04-08 Thread Massimo Di Pierro
Does this help:

patterns = [
"/friends[person]", 

"/{person.name}/:field",   
 
...
("/dogs[pet]", db.pet.info=='dog'), 

("/mydogs[pet]/{pet.name.startswith}", 
db.pet.owner==auth.user.id),#<
] 

On Sunday, 7 April 2013 08:28:10 UTC-5, Philipp Müller wrote:
>
> Hello,
>
> yes, all the methods are decorated with @requires_login(). The login 
> itself is not the problem, that works fine.
> The issue is, that I want to return user-specific results in my api. 
> Exposing one table by writing something along the lines of:
>
> @request.restful()
> @auth.requires_login()
> def v1():
> response.view = 'api.json'# +request.extension
> def GET(*args, **vars):
> 
> patterns = [
> "/stores[store]" ]
>
> parser = db.parse_as_rest(patterns, args, vars)
> if parser.status == 200:
> return dict(content=parser.response)
> else:
> raise HTTP(parser.status, parser.error)
>
> works fine.
>
> When I write "normal" database queries, that I want to return (logged in) 
> user-specific data, I can do it like this, i.e. to return the pets of a 
> user:
>
> def petsForOwnerQuery():
> pets = (db.pets.owner == db.owner.auth)
> return selectedStores
>
> then i can go on and retrieve the currently logged in owner like this:
>
> def ownerFromAuthUserQuery():
> loggedInOwner = (db.owner.auth == auth.user.id)
> return loggedInCustomer
>
> Combining these queries, I can retrieve the pets for the currently logged 
> in user.
>
> My question now is, how I can accomplish this, using the 
> @require_restful() decorator in my API.
>
> Thank you & regards,
> Philipp
>
>
> Am Samstag, 6. April 2013 19:40:39 UTC+2 schrieb Christian Foster Howes:
>>
>> have you tried decorating your GET/PUT/POST/DELETE methods with the 
>> @requires_login()?
>>
>> @request.restful()
>> def user():
>> @requires_login()
>> def GET(*args, **kwargs):
>>  
>>
>> i'm doing something similar to that...but with a custom decorator rather 
>> than requires_login.
>>
>> cfh
>>
>>
>> On Friday, April 5, 2013 2:58:17 PM UTC-7, Philipp Müller wrote:
>>>
>>> Hello,
>>>
>>> I have written a restful API in web2py using @request_restful() and then 
>>> specified the patterns and tables that I wanted to expose in the API.
>>> The whole API uses basic auth, which is fine. I'm used to retrieving the 
>>> user, that currently uses a service by calling auth.user.id. If I 
>>> wanted to check what items in the database are associated with the 
>>> currently logged in user, I could do that with a db query. 
>>>
>>> Using @request_restful, I would like to do the exact thing, i.e. return 
>>> only values, that are associated with the user, that is currently using my 
>>> API. I have been able to figure out how to do this, any help regarding this 
>>> problem would be highly appreciated.
>>>
>>> Kind regards,
>>> Philipp
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: PAM + Kerberos + LDAP Problem

2013-04-08 Thread Massimo Di Pierro
I have no idea but I would sugget adding some debug statements in 
ldap_auth.py and see why it fails for some users. There are many 
configuration options in ldap therefore it probably is a settings issue.

Can you try authenticate them from python-ldap from python shell?

Can you try identify what is in common among those who cannot login?

Massimo

On Sunday, 7 April 2013 05:25:12 UTC-5, Apoorve Mohan wrote:
>
> Hi All
>  
> I am using PAM to login into my website. I have configured my system PAM 
> with LDAP and KERBEROS.
>
> Now the problem I am facing is that not all my users are able to login 
> using that service. 
> I also checked my KERBEROS setting using KINIT command and I was able to 
> successfully authenticate all the users.
>
> I am unable to figure it out that why the application is showing such a 
> behavior and I am stuck at this point. 
> I'll really appreciate any help on this.
>
> --
> Thanks and Regards
>
> Apoorve
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Arnon Marcus
The reason this capability is useless, is that it limits the usage of SSE 
connection way too much...
There is no reason I would have to stick my entire code for dealing with 
updates to a section of my app, within a single action...
It makes no sense at all...

If I have an action that updates some data for a "related" section of my 
application, then using this mechanism I would have to copy it in 
it's entirety into the while-loop...
This is unacceptable... I could have docents of such actions, spread across 
my application, each dealing with a different "aspect" within the component 
that is presented in the SSE-enabled view... There is a relational-database 
in the back - the entire application is segregated in accordance with these 
relations. I can have many views that deal with related pieces of 
information, each belonging to a different controller, and has it's own 
dedicated update-action within that controller. Then I might have a view, 
that I wan't to make SSE-enabled, which I want to be updated "in reaction 
to" changes in "other views" I am not talking about "chat" only... We 
have a complex business-logic and a varied business-application views. We 
need more than a simple stand-alone controller that can only be called by 
the client, and can talk to (and be called from) no one else in web2py...

I suggest that a very serious look be done on 0MQ for 
inter-process/inter-thread-communication - it could be the solution for 
web2py to become SSE capable - maybe even Web-Sockets capable...

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.grid search widget omits decimal fields. Any reason for this?

2013-04-08 Thread Massimo Di Pierro
Always trunk. Please.

On Monday, 8 April 2013 10:25:13 UTC-5, Cliff Kachinske wrote:
>
> I can provide a patch.  Should I do the diff against trunk or stable or 
> nightly build?
>
> On Monday, April 8, 2013 10:40:04 AM UTC-4, Cliff Kachinske wrote:
>>
>> Done.  Issue 1436.
>>
>>
>>
>> On Monday, April 8, 2013 10:00:01 AM UTC-4, Massimo Di Pierro wrote:
>>>
>>> Please open a ticket about this. It is an oversight and easy to fix.
>>>
>>> On Monday, 8 April 2013 08:43:40 UTC-5, Cliff Kachinske wrote:

 Is there any reason why the default search widget does not include 
 decimal field types?

 In sqlhtml.py v 2.4.2, decimal field types are omitted from the search 
 options dictionary, lines 1619, 1629.

 Likewise in lines 1637 -1731 there is no value_input defined for 
 decimal field types.

 Is there any reason why decimal field types aren't included here?

 Thanks,
 Cliff Kachinske

>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Upgrading to 2.4.2. breaks virtual field

2013-04-08 Thread Kenneth Lundström

Hello,

have tested 2.4.2., 2.4.5 and today 2.4.6 and still receiving the same 
error.



Kenneth

you're still using 2.4.2 or upgraded to 2.4.6? There were some 
changes, including bug fixes from one to another...



2013/4/8 Kenneth >


Nobody has any pointers how to fix this? I'm using powertable
plugin in my app and if possible don't want to replace it right now.


Kenneth


Den lördagen den 9:e mars 2013 kl. 21:11:20 UTC+2 skrev Kenneth:

Hi,

anybody have any ideas where to start solving this?


  Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.



Traceback(most recent call last):
   File"/gluon/restricted.py",line212,inrestricted

 execccodeinenvironment
   File"/applications/economy/controllers/receipt.py"  
,line705,in

   File"/gluon/globals.py",line193,in

 self._caller=lambdaf:f()

   File"/gluon/tools.py",line2942,inf

 returnaction(*a, **b)
   File"/applications/economy/controllers/receipt.py"  
,line439,inshow_receipts

 returndict(table=powerTable.create())

   File"/applications/economy/models/plugin_powertable.py"  
,line704,inplugin_powertable

 PowerTable(),
   File"/applications/economy/models/plugin_powertable.py"  
,line178,in__init__

 headers[c] =sqlrows.db[t][f].label

   File"/gluon/dal.py",line7758,in__getitem__

 return self.__getattr__(str(key))

   File"/gluon/dal.py",line7765,in__getattr__

 returnogetattr(self,key)

AttributeError:'DAL'object has no attribute'virtual'


  Error snapshot help
  



|('DAL' object has no
attribute 'virtual')|


||

|
|



Den tisdagen den 5:e mars 2013 kl. 20:47:19 UTC+2 skrev Kenneth:

Hi,

I usually find what row causes the problem but not in this
case. I'm using the plugin_PowerGrid. Anyone using
PowerGrid with the new web2py version?


Kenneth



maybe showing what line of your code raised the Exception
will help...


On Tuesday, March 5, 2013 5:51:57 PM UTC+1, Kenneth
wrote:

Hi,

I upgraded my production server to 2.4.2.
yesterday.I thought everything was looking good
until I just got: Error ticket


File"/data/domains/web2py/gluon/dal.py",line7765,in__getattr__

 returnogetattr(self,key)

AttributeError:'DAL'object has no attribute'virtual'

Is this easy to fix?


Kenneth



-- 


---
You received this message because you are subscribed to the Google
Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to web2py+unsubscr...@googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.





--
[]'s
Marco Tulio
--

---
You received this message because you are subscribed to the Google 
Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to web2py+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--

--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Arnon Marcus
Look, I appreciate you're trying to help-out, but it seems you are 
answering the questions you know the answers to, instead of the questions I 
ask.
It's OK to say that you don't know the answer. You are not alone in this 
user-group, perhaps someone else does.

We all got that. it's an external process, but it's implemented already, it 
> "just works", has a simple yet powerful routing algo and its secure. 
> With SSE you have to do it yourself.
>  
>

I know that there is a "somewhat-working" solution for web-sockets, using 
Tornado.
I know it would be better to use it, instead of trying to make SSE work in 
web2py by myself.
In the long-term I'll probably do something like that.

But as you said, not in all scenarios, a web-socket is requited - sometimes 
an SSE does what I need.
And as it is HTTP-based, I thought it should have been easy to implement in 
web2py.

This is exactly the example shown on the videos about 
> websocket_messaging.py . the user receives updates through the ws, and he 
> sends to the default web2py installation with a simple ajax post its 
> message. web2py then queues that message to tornado, that informs all 
> connected users of the new message on the ws channel.
>
>
Again, that is not an answer to my questions. My questions where referring 
to how web2py can implement SSE, not how Tornado can implement web-sockets 
and have web2py push stuff into it.

>
> On the SSE side, you'd have some controller that basically does:
>
> def events():
>   initialization_of_sse
>   while True:
>  yield send_a_message
>
> you have to think to security, routing, etc by yourself.
>
> Basically in that while True loop you'd likely want to inspect your 
> "storage" (redis, ram, dict, database, whatever) if there's a new message 
> for the user.
> You can't "exit" from there and resume itall the logic needs to happen 
> inside that yield(ing) loop.
>

That is answering the question : "How does web2py keep a long-lasting 
connection".
That is NOT answering the question: "How can a different controller-action 
activate this"

I found a way to extract the web2py-SSE example, here are the relevant 
parts (I *bold*'ed the important stuff):

*Controller:*


# -*- coding: utf-8 -*-
import time
from gluon.contenttype import contenttype

### required - do no delete
def user(): return dict(form=auth())
def download(): return response.download(request,db)
def call(): return service()
### end requires

def index():
return dict()

def error():
return dict()

def sse():
return dict()

def buildMsg(eid , msg):
mmsg = "id: %s\n" %eid
mmsg += "data: {\n"
mmsg += "data: \"msg\": \"%s\", \n" %msg
mmsg += "data: \"id\": %s\n" %eid
mmsg += "data: }\n\n"
return mmsg

*def sent_server_event():*
response.headers['Content-Type'] = 'text/event-stream'
response.headers['Cache-Control'] = 'no-cache'
* def sendMsg():*
startedAt = time.time(); #http://www.epochconverter.com/
* while True:*
messaggio = buildMsg(startedAt , time.time())
* yield messaggio*
* time.sleep(5)*
* if ((time.time() - startedAt) > 10):break*
* return sendMsg()*

def event_sender():
response.headers['Content-Type'] = 'text/event-stream'
response.headers['Cache-Control'] = 'no-cache'
mtime = time.time()
return 'data:' + str(mtime)


*View (script-part):*

*
*
if (!window.DOMTokenList) {
  Element.prototype.containsClass = function(name) {
return new RegExp("(?:^|\\s+)" + name + 
"(?:\\s+|$)").test(this.className);
  };

  Element.prototype.addClass = function(name) {
if (!this.containsClass(name)) {
  var c = this.className;
  this.className = c ? [c, name].join(' ') : name;
}
  };

  Element.prototype.removeClass = function(name) {
if (this.containsClass(name)) {
  var c = this.className;
  this.className = c.replace(
  new RegExp("(?:^|\\s+)" + name + "(?:\\s+|$)", "g"), "");
}
  };
}

// sse.php sends messages with text/event-stream mimetype.
*var source = new EventSource('{{=URL("sent_server_event")}}');*

function Logger(id) {
  this.el = document.getElementById(id);
}

Logger.prototype.log = function(msg, opt_class) {
  var fragment = document.createDocumentFragment();
  var p = document.createElement('p');
  p.className = opt_class || 'info';
  p.textContent = msg;
  fragment.appendChild(p);
  this.el.appendChild(fragment);
};

Logger.prototype.clear = function() {
  this.el.textContent = '';
};

var logger = new Logger('log');

*function closeConnection() {*
*  source.close();*
  logger.log('> Connection was closed');
  updateConnectionStatus('Disconnected', false);
}

function updateConnectionStatus(msg, connected) {
  var el = document.querySelector('#connection');
  if (connected) {
if (el.classList) {
  el.classList.add('connected');
  el.classList.remove('disconnected');
} else {
  el.addClass('connected');
  el.removeClass('disconnected');
}
  } else {
if (el.classList) {
  el.classList.remove('connected');
  el.classList.add('disconn

[web2py] Re: representing nested subqueries results in one page (grid)

2013-04-08 Thread Cliff Kachinske
grid and smartgrid are not the best way to achieve what you are trying to 
do.

On Monday, April 8, 2013 10:34:20 AM UTC-4, Jurgis Pralgauskis wrote:
>
> and still would like to be able to load it more interactivelly with 
> smartgird.
>
> now if I try smartgrid 
>
> SQLFORM 
> .smartgrid(db.grandparent,
>  linked_tables=['parent', 'child'], links=[dict(header='children', 
> body=lambda row: get_children_grid(db.grandparent, row))]) if query else None
>
>
> I get browser ERR
> The page isn't redirecting properly:   
>   Firefox has detected that the server is redirecting the request 
> for this address in a way that will never complete.
>
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.grid search widget omits decimal fields. Any reason for this?

2013-04-08 Thread Cliff Kachinske
I can provide a patch.  Should I do the diff against trunk or stable or 
nightly build?

On Monday, April 8, 2013 10:40:04 AM UTC-4, Cliff Kachinske wrote:
>
> Done.  Issue 1436.
>
>
>
> On Monday, April 8, 2013 10:00:01 AM UTC-4, Massimo Di Pierro wrote:
>>
>> Please open a ticket about this. It is an oversight and easy to fix.
>>
>> On Monday, 8 April 2013 08:43:40 UTC-5, Cliff Kachinske wrote:
>>>
>>> Is there any reason why the default search widget does not include 
>>> decimal field types?
>>>
>>> In sqlhtml.py v 2.4.2, decimal field types are omitted from the search 
>>> options dictionary, lines 1619, 1629.
>>>
>>> Likewise in lines 1637 -1731 there is no value_input defined for decimal 
>>> field types.
>>>
>>> Is there any reason why decimal field types aren't included here?
>>>
>>> Thanks,
>>> Cliff Kachinske
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.grid search widget omits decimal fields. Any reason for this?

2013-04-08 Thread Cliff Kachinske
Done.  Issue 1436.



On Monday, April 8, 2013 10:00:01 AM UTC-4, Massimo Di Pierro wrote:
>
> Please open a ticket about this. It is an oversight and easy to fix.
>
> On Monday, 8 April 2013 08:43:40 UTC-5, Cliff Kachinske wrote:
>>
>> Is there any reason why the default search widget does not include 
>> decimal field types?
>>
>> In sqlhtml.py v 2.4.2, decimal field types are omitted from the search 
>> options dictionary, lines 1619, 1629.
>>
>> Likewise in lines 1637 -1731 there is no value_input defined for decimal 
>> field types.
>>
>> Is there any reason why decimal field types aren't included here?
>>
>> Thanks,
>> Cliff Kachinske
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: representing nested subqueries results in one page (grid)

2013-04-08 Thread Jurgis Pralgauskis
and still would like to be able to load it more interactivelly with 
smartgird.

now if I try smartgrid 

SQLFORM 
.smartgrid(db.grandparent,
 linked_tables=['parent', 'child'], links=[dict(header='children', body=lambda 
row: get_children_grid(db.grandparent, row))]) if query else None


I get browser ERR
The page isn't redirecting properly:   
  Firefox has detected that the server is redirecting the request 
for this address in a way that will never complete.

>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: representing nested subqueries results in one page (grid)

2013-04-08 Thread Jurgis Pralgauskis
I figured out a way with grid (recursively loads all the children "stack")
ps.: probably there is a better way to find out which tables are 
referencing you

children_queries= {
 db.grandparent: lambda row: db.parent.parent==row.id,
 db.parent: lambda row: db.child.parent==row.id,
 db.child: lambda row: None,
}

backrefs = {
 db.grandparent: db.parent,
 db.parent: db.child,
 db.child:  None, 
}

def get_children_grid(table, row):
query = children_queries[table](row)
link_body = lambda row: get_children_grid(backrefs[table], row) if 
query else None
return SQLFORM 
.grid(query, 
links=[dict(header='children', body=link_body)]) if query else None
   
SQLFORM 
.grid(db.grandparent,
 links=[dict(header='children', body=lambda row: 
get_children_grid(db.grandparent, row))]) if query else None


but then I'd like to get rid of all the headers/export options...


2013 m. balandis 8 d., pirmadienis 17:21:35 UTC+3, Jurgis Pralgauskis rašė:
>
> Hi, 
>
> can this be accomplished with some grid?
> http://i.stack.imgur.com/Eirfv.png
> [image: http://i.stack.imgur.com/Eirfv.png]
>
> I thougth over a bit: 
> a) with grid - I can construct sequence of joins-- just the parents 
> (Author/Book/Story..) would be repeated for each line (and then might be 
> hidden via js)
>
> b) with smartgrid - maybe possible to hook, that it loads children in the 
> TD (where the link to children is)
>(then would be nice to force loading it without clicking -- but)
>
> probably links parameter could be workaround?
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] representing nested subqueries results in one page (grid)

2013-04-08 Thread Jurgis Pralgauskis
Hi, 

can this be accomplished with some grid?
http://i.stack.imgur.com/Eirfv.png
[image: http://i.stack.imgur.com/Eirfv.png]

I thougth over a bit: 
a) with grid - I can construct sequence of joins-- just the parents 
(Author/Book/Story..) would be repeated for each line (and then might be 
hidden via js)

b) with smartgrid - maybe possible to hook, that it loads children in the 
TD (where the link to children is)
   (then would be nice to force loading it without clicking -- but)

probably links parameter could be workaround?


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py 2.4.6 is OUT

2013-04-08 Thread Marian
Thank you for this great framework!

On Saturday, April 6, 2013 11:36:15 PM UTC+2, Massimo Di Pierro wrote:
>
> ## 2.4.6
>
> - better tests
> - new ANY_OF and IS_IPV6 validators
> - new custom save option
> - many small bug fixes
>
> The bug fixes are worth the upgrade. Nothing should break.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Building Query object based on Rows avoiding 'belongs'

2013-04-08 Thread Marcin Jaworski
Hi All!

Finally I ended up with ugly solution, namely sqlhtml.py customization 
(redefinition of rows), where rows to show in grid are defined based on 
query object.

Thank you for your help and kind egards,
Marcin Jaworski


 

W dniu poniedziałek, 8 kwietnia 2013 10:12:24 UTC+2 użytkownik Marcin 
Jaworski napisał:
>
> Hi,
>
> Thank you for quick reply. 
> I have used the patch to retrieve the rows I needed (for target query 
> object). 
>
> Let's say I have retrieved list of 90 rows identified by id numbers 
> [n,n+1,...n90]. 
>
> My first idea was to combine the results of subsequent 'belongs' queries 
> to build target query object.
>
> target_query_object = db.field.id.belongs(list_of_ids[n1:n30]) 
> Magic_Operator db.field.id.belongs(list_of_ids[n31:n60]) Magic_Operator 
> db.field.id.belongs(list_of_ids[n61:n90])
>
> Unfortunately, I missed the magic operator to join sub queries (the 'and' 
> and 'or' are not giving me what I want of course) . 
> The problem is that query object (and subqueries in my case) does not 
> return the final result I can use with available logical operators (if I 
> understand it correctly), the query 'waits' to operate on database, it is 
> some kind of prepared statements, this is why my trial failed.
>
> The real solution I am seeking is how to select not None rows from grid. I 
> have taken round trip retrieving None rows (using =='' operator) and 
> substracting it (using sets operations) from all rows. This is where i am 
> so far (operators: " !='' " and " is not None " and " > None " are not 
> supported in queries). 
>
> Can you advise?
> Marcin Jaworski
>
>
> W dniu poniedziałek, 8 kwietnia 2013 04:34:57 UTC+2 użytkownik Christian 
> Foster Howes napisał:
>>
>> speaking without reading the docs.so i might be misguided.
>>
>> assuming that you can setup a grid with a rows object, you can use that 
>> patch.  just & the rows together and magic will happen.
>>
>> the key no matter what is to setup multiple queries on GAE and & the 
>> results together, or re-imagine the dataset so there is less than 30 items 
>> in the belongs (which is sometimes impossible).
>>
>> good luck!
>>
>> cfh
>>
>> On Sunday, April 7, 2013 2:13:35 PM UTC-7, Marcin Jaworski wrote:
>>>
>>> Hi web2py users!
>>>
>>> My environment: GAE SDK 1.7.5, web2py version 2.0.9.
>>>
>>> I need a query object as an argument for grid.
>>> I've got a database rows (ids) as the potential base for query 
>>> (list_of_ids) - unfortunately there are more than 30 of them so the 
>>> construct with 'belongs' does not work on GAE:
>>>
>>> query = db.field.id.belongs(list_of_ids)   # does not work on GAE
>>>
>>> There is a great solution to overcome the limit of 'belongs' on GAE:
>>> https://code.google.com/p/web2py/issues/detail?id=160
>>> but it let me identify just rows, when the query object for grid is 
>>> needed in my case.
>>>
>>> Can you advise?
>>> Marcin Jaworski
>>>
>>>
>>>
>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.grid search widget omits decimal fields. Any reason for this?

2013-04-08 Thread Massimo Di Pierro
Please open a ticket about this. It is an oversight and easy to fix.

On Monday, 8 April 2013 08:43:40 UTC-5, Cliff Kachinske wrote:
>
> Is there any reason why the default search widget does not include decimal 
> field types?
>
> In sqlhtml.py v 2.4.2, decimal field types are omitted from the search 
> options dictionary, lines 1619, 1629.
>
> Likewise in lines 1637 -1731 there is no value_input defined for decimal 
> field types.
>
> Is there any reason why decimal field types aren't included here?
>
> Thanks,
> Cliff Kachinske
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] SQLFORM.grid search widget omits decimal fields. Any reason for this?

2013-04-08 Thread Cliff Kachinske
Is there any reason why the default search widget does not include decimal 
field types?

In sqlhtml.py v 2.4.2, decimal field types are omitted from the search 
options dictionary, lines 1619, 1629.

Likewise in lines 1637 -1731 there is no value_input defined for decimal 
field types.

Is there any reason why decimal field types aren't included here?

Thanks,
Cliff Kachinske

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to - using DAL for "Between"

2013-04-08 Thread Niphlod
from datetime import timedelta
now = request.now
six_days_back = now - timedelta(days=6)
db(
(db.issues.date_today >= six_days_back) &
(db.issues.date_today <= request.now)
).select(whateverfieldyouneed)



On Monday, April 8, 2013 3:07:57 PM UTC+2, Rahul wrote:
>
> Hi All,
>  I am working on a query in SQLite  - Where I can search on some data 
> for last 7 days - 
>
> SQLite raw sql query  is as follows: 
> query = db.executesql("SELECT ticket_no, description FROM issues where 
> date_today between datetime ('now', '-6 days') AND datetime ('now', 
> 'localtime')")
>
> I need to know the equivalent DAL version of it. Any help would be much 
> appreciated. 
>
> Rahul
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How to - using DAL for "Between"

2013-04-08 Thread Rahul
Hi All,
 I am working on a query in SQLite  - Where I can search on some data 
for last 7 days - 

SQLite raw sql query  is as follows: 
query = db.executesql("SELECT ticket_no, description FROM issues where 
date_today between datetime ('now', '-6 days') AND datetime ('now', 
'localtime')")

I need to know the equivalent DAL version of it. Any help would be much 
appreciated. 

Rahul

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Niphlod

>
>
> As I said, I've already gone over the websocket_messaging.py file - it 
> has dealings with WebSockets - NOT SSE (!) - and via Tornado, NOT web2py...
>

We all got that. it's an external process, but it's implemented already, it 
"just works", has a simple yet powerful routing algo and its secure. 
With SSE you have to do it yourself.
 

>
>> I didn't get what you mean by "can I explicitely call it": either with 
>> websockets or SSE as soon as the user hits the page, a connection is 
>> established and remains open. There's no request/response cycle, just a 
>> request coming in and a (eventually) infinite response out.
>>
>
> What I mean, is that once the connection is ope, and say, is handled by a 
> "session", then from that moment on, My usage of this connection would be 
> "pushing" through that connection onto the browser. The usage of the "push" 
> would obviously be from another controller.
> I mean, let's take the "chat" use-case :
> User "A" logs into a chat-view, and that sends a GET request to a 
> controller-action, who's job is to opens an SSE connection for that user - 
> a long-lasting session - let's call it "The SSE action". Then user "B" 
> logs into the same view on his side, and the same thing happens for him. Now 
> we have 2 outgoing sessions open - one for each user - 2 "SSE Actions" are 
> waiting to send more responses - each to their respective recipients.
> Now, user "A" writes a comment, and "submits" it. This sends a POST 
> request to a different controller-action that saves the comment to the 
> database -let's call it "The Submission Action". This controller-action is 
> different from the SSE action, and may theoretically even belong to a 
> different controller (say, the system may have chat-views in multiple 
> pages...).
>

This is exactly the example shown on the videos about 
websocket_messaging.py . the user receives updates through the ws, and he 
sends to the default web2py installation with a simple ajax post its 
message. web2py then queues that message to tornado, that informs all 
connected users of the new message on the ws channel.

 

> My question is, then :
> "Can a submission-action 'call' an SSE-action that belongs to a different 
> controller, and has a different session/request/response object(s)? If so 
> How?".
>


On the SSE side, you'd have some controller that basically does:

def events():
  initialization_of_sse
  while True:
 yield send_a_message

you have to think to security, routing, etc by yourself.

Basically in that while True loop you'd likely want to inspect your 
"storage" (redis, ram, dict, database, whatever) if there's a new message 
for the user.
You can't "exit" from there and resume itall the logic needs to happen 
inside that yield(ing) loop.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Difference in headers upload/download vs static file, also in auth.wiki

2013-04-08 Thread Alan Etkin

>
> While debugging why the  tag behaves differently (at least in Mac 
> Chrome) depending on specifying (1) a static link to a soundfile or (2) 
> using the auth.wiki syntax 2/sound.mp3  I notice quite a few 
> differences in the headers. 
>
I have a similar problem with web2py trunk Version 
2.4.6-stable+timestamp.2013.04.07.19.55.04 and Firefox 19.0.2 (on Ubuntu)

I used the wiki interface for adding a link to an uploaded media (mp3 file) 
into a markmin wiki document. The media object is appended to the html 
response with ... etc, but it is not shown in the browser. Using 
the audio source URL as address, the file is served as downloadable file 
(the browser shows a file download dialog).

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Upgrading to 2.4.2. breaks virtual field

2013-04-08 Thread Marco Túlio Cícero de M . Porto
you're still using 2.4.2 or upgraded to 2.4.6? There were some changes,
including bug fixes from one to another...


2013/4/8 Kenneth 

> Nobody has any pointers how to fix this? I'm using powertable plugin in my
> app and if possible don't want to replace it right now.
>
>
> Kenneth
>
>
> Den lördagen den 9:e mars 2013 kl. 21:11:20 UTC+2 skrev Kenneth:
>
>> Hi,
>>
>> anybody have any ideas where to start solving this?
>>
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>>
>> Traceback (most recent call last):
>>   File "/gluon/restricted.py", line 212, in restricted
>> exec ccode in environment
>>   File "/applications/economy/**controllers/receipt.py" 
>> , line 
>> 705, in 
>>   File "/gluon/globals.py", line 193, in 
>> self._caller = lambda f: f()
>>   File "/gluon/tools.py", line 2942, in f
>> return action(*a, **b)
>>   File "/applications/economy/**controllers/receipt.py" 
>> , line 
>> 439, in show_receipts
>> return dict(table=powerTable.create()**)
>>   File "/applications/economy/models/**plugin_powertable.py" 
>> , 
>> line 704, in plugin_powertable
>> PowerTable(),
>>   File "/applications/economy/models/**plugin_powertable.py" 
>> , 
>> line 178, in __init__
>> headers[c] = sqlrows.db[t][f].label
>>   File "/gluon/dal.py", line 7758, in __getitem__
>> return self.__getattr__(str(key))
>>   File "/gluon/dal.py", line 7765, in __getattr__
>> return ogetattr(self, key)
>> AttributeError: 'DAL' object has no attribute 'virtual'
>>
>> Error snapshot [image: help]
>> 
>>
>> ('**DAL' object has no attribute
>> 'virtual')
>>
>>
>>
>>
>>
>> Den tisdagen den 5:e mars 2013 kl. 20:47:19 UTC+2 skrev Kenneth:
>>>
>>> Hi,
>>>
>>> I usually find what row causes the problem but not in this case. I'm
>>> using the plugin_PowerGrid. Anyone using PowerGrid with the new web2py
>>> version?
>>>
>>>
>>> Kenneth
>>>
>>>
>>>
>>> maybe showing what line of your code raised the Exception will help...
>>>

 On Tuesday, March 5, 2013 5:51:57 PM UTC+1, Kenneth wrote:
>
> Hi,
>
> I upgraded my production server to 2.4.2. yesterday.I thought
> everything was looking good until I just got: Error ticket
>
> File "/data/domains/web2py/gluon/**dal.py", line 7765, in __getattr__
> return ogetattr(self, key)
> AttributeError: 'DAL' object has no attribute 'virtual'
>
> Is this easy to fix?
>
>
> Kenneth
>
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
[]'s
Marco Tulio

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Arnon Marcus
Oh, and I forgot the most important aspect:
"How can an active submission-action of user A, *locate *the correct 
session that holds the correct SSE-connection of user B? And how can it use 
that SSE-action *with *that session of user B?"

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Upgrading to 2.4.2. breaks virtual field

2013-04-08 Thread Kenneth
Nobody has any pointers how to fix this? I'm using powertable plugin in my 
app and if possible don't want to replace it right now. 


Kenneth


Den lördagen den 9:e mars 2013 kl. 21:11:20 UTC+2 skrev Kenneth:
>
> Hi,
>
> anybody have any ideas where to start solving this?
>
> Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
>
> Traceback (most recent call last):
>   File "/gluon/restricted.py", line 212, in restricted
> exec ccode in environment
>   File "/applications/economy/controllers/receipt.py" 
> , line 
> 705, in 
>   File "/gluon/globals.py", line 193, in 
> self._caller = lambda f: f()
>   File "/gluon/tools.py", line 2942, in f
> return action(*a, **b)
>   File "/applications/economy/controllers/receipt.py" 
> , line 
> 439, in show_receipts
> return dict(table=powerTable.create())
>   File "/applications/economy/models/plugin_powertable.py" 
> , 
> line 704, in plugin_powertable
> PowerTable(),
>   File "/applications/economy/models/plugin_powertable.py" 
> , 
> line 178, in __init__
> headers[c] = sqlrows.db[t][f].label
>   File "/gluon/dal.py", line 7758, in __getitem__
> return self.__getattr__(str(key))
>   File "/gluon/dal.py", line 7765, in __getattr__
> return ogetattr(self, key)
> AttributeError: 'DAL' object has no attribute 'virtual'
>
> Error snapshot [image: help] 
> 
>  
>
> ('DAL' object has no attribute 'virtual')
>
>
>
>
>
> Den tisdagen den 5:e mars 2013 kl. 20:47:19 UTC+2 skrev Kenneth:
>>
>> Hi, 
>>
>> I usually find what row causes the problem but not in this case. I'm 
>> using the plugin_PowerGrid. Anyone using PowerGrid with the new web2py 
>> version?
>>
>>
>> Kenneth
>>
>>
>>
>> maybe showing what line of your code raised the Exception will help...
>>
>>>
>>> On Tuesday, March 5, 2013 5:51:57 PM UTC+1, Kenneth wrote:

 Hi,

 I upgraded my production server to 2.4.2. yesterday.I thought 
 everything was looking good until I just got: Error ticket

 File "/data/domains/web2py/gluon/dal.py", line 7765, in __getattr__
 return ogetattr(self, key)
 AttributeError: 'DAL' object has no attribute 'virtual'

 Is this easy to fix?


 Kenneth




-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Arnon Marcus


> Nope, or maybe I expressed myself badly: that implementations started 
> named as "comet messaging" but turned to "websocket messaging" at the first 
> iteration. 
> web2py.js has an usable implementation for it and 
> gluon/contrib/websocket_messaging.py is 200 lines of which 70 are comments, 
> it's easy to hack it into.
>  
>

As I said, I've already gone over the websocket_messaging.py file - it has 
dealings with WebSockets - NOT SSE (!) - and via Tornado, NOT web2py...

>
> I didn't get what you mean by "can I explicitely call it": either with 
> websockets or SSE as soon as the user hits the page, a connection is 
> established and remains open. There's no request/response cycle, just a 
> request coming in and a (eventually) infinite response out.
>

What I mean, is that once the connection is ope, and say, is handled by a 
"session", then from that moment on, My usage of this connection would be 
"pushing" through that connection onto the browser. The usage of the "push" 
would obviously be from another controller.
I mean, let's take the "chat" use-case :
User "A" logs into a chat-view, and that sends a GET request to a 
controller-action, who's job is to opens an SSE connection for that user - 
a long-lasting session - let's call it "The SSE action". Then user "B" logs 
into the same view on his side, and the same thing happens for him. Now we 
have 2 outgoing sessions open - one for each user - 2 "SSE Actions" are 
waiting to send more responses - each to their respective recipients.
Now, user "A" writes a comment, and "submits" it. This sends a POST request 
to a different controller-action that saves the comment to the database 
-let's call it "The Submission Action". This controller-action is different 
from the SSE action, and may theoretically even belong to a different 
controller (say, the system may have chat-views in multiple pages...).
My question is, then :
"Can a submission-action 'call' an SSE-action that belongs to a different 
controller, and has a different session/request/response object(s)? If so 
How?".
I hope it's more clear now...

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: web2py 2.4.2 is OUT

2013-04-08 Thread Marco Túlio Cícero de M . Porto
worked for me


2013/4/8 Luc Chase 

> + and - definitely don't work on
>
> (2, 4, 6, 'stable', datetime.datetime(2013, 4, 6, 17, 37, 38))
>
> --
> Luc.
>
> On Sunday, 10 March 2013 14:31:04 UTC, Massimo Di Pierro wrote:
>>
>> This should now be fixed. Can you check?
>>
>> On Tuesday, 5 March 2013 17:21:03 UTC-6, Ralo Tannahill wrote:
>>>
>>> +1 for web2py!!
>>>
>>> In the admin interface I can see:
>>>
>>> Version 2.4.2 stable (2013-03-04 03:26:21)
>>>
>>> Unable to check for upgrades 
>>>
>>> Running on *%s*
>>>
>>> %s should be information about the server type, version..., right? I'm
>>> using Centos 6, nginx+uwsgi. Maybe web2py expects some wsgi variables and
>>> nginx+wsgi locks them? were can I look for more info?
>>>
>>> Regards
>>>
>>> On Monday, 4 March 2013 04:38:19 UTC+1, Massimo Di Pierro wrote:

 The book will be out shortly describing this version.
 I am sure there are some corners to iron but I could not wait any
 longer.

 Changelog:

 - 2D GEO API: geoPoint, getLine, geoPolygon
 - support for 'json' field type in DAL
 - schema export with db.as_json/as_xml, thanks Alan
 - graph representation of models
 - admin based on bootstrap, thanks Paolo
 - support for semantic versioning
 - new bootstrap based admin, thanks Paolo
 - improved scheduler (and change in scheduler field names), thanks
 Niphlod
 - graphiz support added to adm, thanks Jose
 - on_failure in grid
 - db.table.field.abs()
 - better wiki
 - geoPoint, getLine, geoPolygon
 - better reporting of 500 ajax errors
 - better grid
 - improved/fixed mongodb support
 - improved parse_as_rest(patterns=...), thanks Denes
 - improved IMAP DAL support, thanks Alan
 - improved security when cookies in sessions
 - Row.as_xml, as_json, as_dict, as_yaml thanks Alan
 - smarted custom_import
 - setup-ubuntu-12-04-redmine-**unicorn-web2py-uwsgi-nginx.sh
 - added support for motor and pulsar servers, thanks Niphlod
 - added json-rpc2 support
 - added pypyodbc.py driver
 - allow auth.settings.ondelete='**CASCADE'
 - new syntax IS_EXPR(lambda value: ...
 - using google for QR codes (although Graph API will be deprecated in
 2015)
 - upgraded fpdf to 1.7.1
 - bug fixes (including issues with calendar.js and archive tables)

>>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
[]'s
Marco Tulio

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py with ExtJS - advice required on restructing

2013-04-08 Thread Alan Etkin

>
> Thank you Alan .. will give it a try definately. May be I'll be the first 
> to download this plugin?  :)
>

Possibly. Note: I recently added some fixes that might not be included in 
the dowloadable plugin. Anyway, you can copy-paste the hg repository files 
in your application.

To download with Mercurial see the following link:
http://code.google.com/p/plugin-clientapi/source/checkout

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py with ExtJS - advice required on restructing

2013-04-08 Thread at
Thank you Alan .. will give it a try definately. May be I'll be the first 
to download this plugin?  :)

Regards

On Monday, 8 April 2013 00:15:12 UTC+5, Alan Etkin wrote:
>
> > You are right we cant get web2py form helpers but can you 
> authentication, session management, jsonifying etc. We already have
> > placed extjs library and our custom developed .js in static folders, now 
> planning to integrate all extjs into a single app.
>
> Consider using this plugin for connecting the client app with the 
> scaffolding features:
>
> http://code.google.com/p/plugin-clientapi
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: cookies related

2013-04-08 Thread dave Zeng
Hi, Anthony,
   Thanks very much,
   It's helpful for the 1st.
   for my 2nd question, setting cookies on browser client could complete 
the task, but need to load another javascript plugin, so i am trying to 
address it in Web2py. 
   Simply speaking, it's a student site, when student practises, the site 
set the current test in cookies(if the student leave and come back later, 
he could start from this test by default, or the student can specify where 
he starts by 'input' field), and get the next test from server, 
continuously.

Thanks
Dave.

On Sunday, April 7, 2013 10:37:25 PM UTC+10, Anthony wrote:
>
> 1. i am using session to transfer user's input from first page to 
>> second page via 'redirect', but i don't want to maintain session in 
>> filesystem or DB, while seems it's not feasible for web2py, as i tested, 
>> there are session files in session directory. so, is it possible to use 
>> cookies or session without store the session info?
>
>
> If you prefer session data be stored in cookies, from the book:
>

 

>
> To *store sessions in cookies* instead you can do:
>
> session.connect(request,response,cookie_key='yoursecret',compression_level=None)
>
> Here cookie_key is a symmetric encryption key. compression_level is an 
> optional zlib encryption level.
>
> While sessions in cookie are often recommended for scalability reason they 
> are limited in size. Large sessions will result in broken cookies.
>
>  
>
>> 2. The parameters of the first ajax call in 2nd page come from user's 
>> input from the first page, then store and update these parameters to 
>> cookies after the ajax call succeeds. continuously, the later ajax calls 
>> will use the dynamically-updated parameters which stay in cookies from 
>> previous call. So, the problem is: ajax call will use parameters from first 
>> page and then use parameters from cookies later. tried to set cookies in 
>> the 2nd page with info from 1st page, obviously, it doesn't work.
>>
>
> It might be more clear if you show some code. Are you setting and 
> retrieving cookie values on the client side via Javascript, or is all that 
> happening on the server (in which case, sessions in cookies as noted above 
> should work)?
>
> Anthony
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Multi-tenany and url routing

2013-04-08 Thread Domagoj Kovač
For now i will try a bit different approach.

I will have myapp/company_name_value/login when user logs in i will set a 
cookie with company_name_value and session.company_id. When user is logged 
out, i will use cookie value for redirection to proper login page. 

My initial idea was to handle everything based on subdomain for example 
company_name_value.my_domain.com but this creates a different problem, so 
for now only possible solution is the one explained above. Is there any 
better way?  

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: auth.settings.extra_fields

2013-04-08 Thread Domagoj Kovač
I added companies definition in db.py. It will be ok for now. Thanks.

On Monday, April 8, 2013 11:05:22 AM UTC+2, Domagoj Kovač wrote:
>
> Is there any way to load models manually? 
>
> On Monday, April 8, 2013 10:23:55 AM UTC+2, Niphlod wrote:
>>
>> uhm. if you want that field to be a reference to the values on the table, 
>> the table must be defined, so I don't see how a SQLFORM.factory could help 
>> you with that.
>> You simply have a conditional model that for your app logic doesn't need 
>> to be conditional .
>>
>> On Monday, April 8, 2013 10:20:56 AM UTC+2, Domagoj Kovač wrote:
>>>
>>> I see it now. Thanks man! I have a different problem now, now i don't 
>>> get any errors immediately but when i go on users/create i get an error 
>>> saying:
>>>  'DAL' object has no attribute 
>>> 'companies'
>>> obviously companies model is not loaded, i am thinking on switching to 
>>> SQLform.factory, would this be a better solution? In models i define my 
>>> tables and then in my controller i make a form, then insert and updated 
>>> goes manually, but this is not so problematic.
>>>
>>>
>>> On Monday, April 8, 2013 9:52:24 AM UTC+2, Niphlod wrote:

 too many db. 

 requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s'))

 needs to be

 requires=IS_IN_DB(db, 'companies.id', '%(name)s')



 On Monday, April 8, 2013 9:39:15 AM UTC+2, Domagoj Kovač wrote:
>
> Hi,
>
> i tried moving companies outside of db.py. 
>
> In db.py i have:
>
> auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
> default=False),
>Field('company_id', 'reference 
> companies', requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s')))]
>
> Error i am receiving now is:
>  too many values to unpack
> What is wrong now?
>
> On Friday, April 5, 2013 7:09:28 PM UTC+2, Anthony wrote:
>>
>> Note, simply doing (db, 'companies.id', ...) may not completely 
>> resolve the problem. Even doing that, the db.companies table is only 
>> getting defined conditionally when the "companies" controller is called, 
>> but the db.auth_user table is defined on every request, and it could be 
>> used by other controllers. If the auth_user table links to another 
>> table, 
>> it may be a good idea to make sure that other table is defined whenever 
>> the 
>> auth_user table is defined (i.e., maybe move the db.companies table 
>> definition into db.py or some other model that isn't conditionally 
>> executed).
>>
>> Anthony
>>
>> On Friday, April 5, 2013 11:30:38 AM UTC-4, Niphlod wrote:
>>>
>>> Nope.
>>> when "auth" definition is encountered, if you want to use 
>>> db.companies.id written as it is, db.define_table('companies') 
>>> should have been executead already.
>>> You need to change your IS_IN_DB call to (db, 'companies.id', 
>>> '%(name)s') ... notice the ticks around companies.id, it's a 
>>> string
>>> When you do it that way, the db.companies table will be called not 
>>> at "models definition" time, but at the time the page is rendered (so, 
>>> allowing all the models to be executed before --> having at your 
>>> disposition the companies table)
>>>
>>> On Friday, April 5, 2013 5:11:32 PM UTC+2, Domagoj Kovač wrote:

 Thanks guys,

 right now my db.py looks like this:

 from gluon.tools import Auth, Crud, Service, PluginManager, 
 prettydate
 auth = Auth(db)
 crud, service, plugins = Crud(db), Service(), PluginManager()

 db.define_table('companies',
 Field('name', 'string',
   required=True,
   requires=IS_NOT_EMPTY(),
   label=LABEL(T("Naziv"), 
 _for="companies_name")),
 Field('url_sufix', 'string',
   required=True,
   requires=IS_NOT_EMPTY(),
   unique=True,
   label=LABEL(T("Url-sufix"), 
 _for="companies_url_sufix")),
 Field('logo', 'upload',
   label=LABEL(T("Logo"), 
 _for="companies_logo")),
 Field('deleted', 'boolean'))


 auth.settings.extra_fields['auth_user'] = [Field('deleted', 
 'boolean', default=False),
Field('company_id', 
 'reference companies', requires=IS_IN_DB(db, db.companies.id, 
 '%(name)s'))]

 ## create all tables needed by auth if not custom tables
 auth.define_tables(username=False, signature=False)

 Is there any way i could have my companies definition in

[web2py] SQLFORM.factory does not update record with upload field

2013-04-08 Thread António Ramos
Hello

my db.py

db.define_table('tab1',
Field('f1'),
Field('f2','upload',uploadfolder=os.path.join(request.folder,'uploads'))
)
db.tab1.f2.requires=IS_NOT_EMPTY()

my controller
def tab1():
if request.args(0):
print "editing record"
row=db(db.tab1.id==request.args(0)).select()[0]
db.tab1['f1'].default = row.f1
db.tab1['f2'].default = row.f2
form=SQLFORM.factory(db.tab1,upload=URL('download'))
if form.process().accepted: #update or create
print "updating or creating record"
return dict(form=form)
first i create a record with some text in f1 and a file in f2.
then i edit this record with myapp/default/tab1/*1*
If i submit without changing f1 or f2 field, i get the error about field f2
not having a file to upload.


Can someone help me to understand how to edit a record with sqlform.factory
and upload fields?

*This is just a demo of my problem. *
*In my project i´m using sqlform.factory to edit records from more than one
table.*

Thank you
António

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: scheduler sincronization

2013-04-08 Thread Niphlod
ok, so to recap, the problem lies only with sqlite. 
I'm not saying it's not an issue I'll continue looking into, I'm just glad 
that at least with a db that has no concurrency issues (like postgres) the 
code runs fine.
I'll be back on testing it with sqlite this evening: I'm not that confident 
that I'll reproduce the behaviour you're seeing but at least I'll try to 
inspect what can go wrong.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: nssm & scheduler seems to be a nobrainer...

2013-04-08 Thread Marian
Hardlinking the whole applications folder into web2py seems to work...

On Monday, April 8, 2013 10:36:40 AM UTC+2, Marian wrote:
>
> I don't use signals, but I found the problem...
>
> I linked my application via hardlink into the web2py applications folder 
> so I can work with aptana studio and don't have to mess around with 
> deploying everytime I change something.
> I guess I need another way to separate web2py and the applications. Maybe 
> you have a best practise for this?
>
> Sorry for the troubles ;)
>
> On Monday, April 8, 2013 10:25:34 AM UTC+2, Niphlod wrote:
>>
>> are you "playing" with signals by any chance ?
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: .sum() and .count() in grid?

2013-04-08 Thread Johann Spies
Thanks for the explanation of using views Niphod.  I have used Postgresql's
select into... in the past for similar situations, but using views seems to
be a better option.

Regards
Johann


On 6 April 2013 00:04, Niphlod  wrote:

> often referred as "materialized views" for the ones who can spare me a
> lecture about what are exactly those :P, let's say you have an
> iper-complicated query that "reconstructs" to a "table" that you want to
> show in a grid just for searching purposes (other purposes not listed,
> sorry, they make absolute no sense)
>
> the dba that is in you says "I'll write a view for my iper-complicated
> query" ...
> so, you code something like
> create view iperquery as
> select something_that_resemble_a_sequence, bla1, bla2, bla3,
>  .
> from bla1
>  .
> left outer join (
>select blablabla
>group by blablabla
> )
>  .
> where max(whatever) > 0
>
> Perfect. now you can do a "select * from iperquery" and your db engine
> does all the work.
> To use "iperquery" as a table (read-only mode, for write only go to see
> docs about your engine support for keyed views, another story I'm NOT going
> to cover here) 
>
> db.define_table('iperquery',
>  Field('something_that_resemble_a_sequence', 'id')
>  Field('bla1'),
>  Field('bla2'),
>  .,
>  migrate=False
> )
>
> the migrate=False bit is the key: web2py won't try creating it and assumes
> there's a table ready to be used.
> You just need to:
>  - include a pkey, better if resembles a sequence, and have a Field of
> type 'id' matching it
>  - tune the Field types accordingly to the type of column of your view
>
>
> On Friday, April 5, 2013 11:24:23 PM UTC+2, Jurgis Pralgauskis wrote:
>>
>> You'll better code a view and access it as a "fake table".
>>>
>>
>> are there examplses of this?
>>
>> Is it possible to show virtual fields in grid (in appadmin they don't
>> show up)?
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



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

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: auth.settings.extra_fields

2013-04-08 Thread Domagoj Kovač
Is there any way to load models manually? 

On Monday, April 8, 2013 10:23:55 AM UTC+2, Niphlod wrote:
>
> uhm. if you want that field to be a reference to the values on the table, 
> the table must be defined, so I don't see how a SQLFORM.factory could help 
> you with that.
> You simply have a conditional model that for your app logic doesn't need 
> to be conditional .
>
> On Monday, April 8, 2013 10:20:56 AM UTC+2, Domagoj Kovač wrote:
>>
>> I see it now. Thanks man! I have a different problem now, now i don't get 
>> any errors immediately but when i go on users/create i get an error saying:
>>  'DAL' object has no attribute 
>> 'companies'
>> obviously companies model is not loaded, i am thinking on switching to 
>> SQLform.factory, would this be a better solution? In models i define my 
>> tables and then in my controller i make a form, then insert and updated 
>> goes manually, but this is not so problematic.
>>
>>
>> On Monday, April 8, 2013 9:52:24 AM UTC+2, Niphlod wrote:
>>>
>>> too many db. 
>>>
>>> requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s'))
>>>
>>> needs to be
>>>
>>> requires=IS_IN_DB(db, 'companies.id', '%(name)s')
>>>
>>>
>>>
>>> On Monday, April 8, 2013 9:39:15 AM UTC+2, Domagoj Kovač wrote:

 Hi,

 i tried moving companies outside of db.py. 

 In db.py i have:

 auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
 default=False),
Field('company_id', 'reference 
 companies', requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s')))]

 Error i am receiving now is:
  too many values to unpack
 What is wrong now?

 On Friday, April 5, 2013 7:09:28 PM UTC+2, Anthony wrote:
>
> Note, simply doing (db, 'companies.id', ...) may not completely 
> resolve the problem. Even doing that, the db.companies table is only 
> getting defined conditionally when the "companies" controller is called, 
> but the db.auth_user table is defined on every request, and it could be 
> used by other controllers. If the auth_user table links to another table, 
> it may be a good idea to make sure that other table is defined whenever 
> the 
> auth_user table is defined (i.e., maybe move the db.companies table 
> definition into db.py or some other model that isn't conditionally 
> executed).
>
> Anthony
>
> On Friday, April 5, 2013 11:30:38 AM UTC-4, Niphlod wrote:
>>
>> Nope.
>> when "auth" definition is encountered, if you want to use 
>> db.companies.id written as it is, db.define_table('companies') 
>> should have been executead already.
>> You need to change your IS_IN_DB call to (db, 'companies.id', 
>> '%(name)s') ... notice the ticks around companies.id, it's a 
>> string
>> When you do it that way, the db.companies table will be called not at 
>> "models definition" time, but at the time the page is rendered (so, 
>> allowing all the models to be executed before --> having at your 
>> disposition the companies table)
>>
>> On Friday, April 5, 2013 5:11:32 PM UTC+2, Domagoj Kovač wrote:
>>>
>>> Thanks guys,
>>>
>>> right now my db.py looks like this:
>>>
>>> from gluon.tools import Auth, Crud, Service, PluginManager, 
>>> prettydate
>>> auth = Auth(db)
>>> crud, service, plugins = Crud(db), Service(), PluginManager()
>>>
>>> db.define_table('companies',
>>> Field('name', 'string',
>>>   required=True,
>>>   requires=IS_NOT_EMPTY(),
>>>   label=LABEL(T("Naziv"), 
>>> _for="companies_name")),
>>> Field('url_sufix', 'string',
>>>   required=True,
>>>   requires=IS_NOT_EMPTY(),
>>>   unique=True,
>>>   label=LABEL(T("Url-sufix"), 
>>> _for="companies_url_sufix")),
>>> Field('logo', 'upload',
>>>   label=LABEL(T("Logo"), _for="companies_logo")),
>>> Field('deleted', 'boolean'))
>>>
>>>
>>> auth.settings.extra_fields['auth_user'] = [Field('deleted', 
>>> 'boolean', default=False),
>>>Field('company_id', 
>>> 'reference companies', requires=IS_IN_DB(db, db.companies.id, 
>>> '%(name)s'))]
>>>
>>> ## create all tables needed by auth if not custom tables
>>> auth.define_tables(username=False, signature=False)
>>>
>>> Is there any way i could have my companies definition in 
>>> /companies/companies.py but still do this.
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@go

[web2py] Re: nssm & scheduler seems to be a nobrainer...

2013-04-08 Thread Marian
I don't use signals, but I found the problem...

I linked my application via hardlink into the web2py applications folder so 
I can work with aptana studio and don't have to mess around with deploying 
everytime I change something.
I guess I need another way to separate web2py and the applications. Maybe 
you have a best practise for this?

Sorry for the troubles ;)

On Monday, April 8, 2013 10:25:34 AM UTC+2, Niphlod wrote:
>
> are you "playing" with signals by any chance ?
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: track_changes bug or feature?

2013-04-08 Thread Daniel Gonzalez Zaballos
Thanks! I said it because restarting the server with every little change in
a development environment, is a little weird. I'll change some imports to
make them inside methods.


2013/4/6 Massimo Di Pierro 

> This is intended. classone is importend once and it imports classtwo. This
> happens only once before http requests arrive. Python caches modules.
>
> track changes only affect import done explicitly at runtime (when http
> requests are processed).
>
> Changing this would require that web2py keep track of all dependencies
> (who import who). This would slow down everything.
>
> Massimo
>
>
> On Monday, 25 March 2013 09:55:19 UTC-5, demetrio wrote:
>>
>> Hi everyone,
>>
>> I have notice an strange behaviour of the track_changes feature (working
>> on web2py 2.3.2 and python 2.7.3).
>>
>> Imagine the following structure:
>>
>> modules/
>> ├── classone.py
>> ├── __init__.py
>> └── mymodule
>> ├── classtwo.py
>> └── __init__.py
>>
>> (assuming that there is a models/0.py file with the track_changes(True)
>> statement)
>>
>> In the file classone.py I have the following:
>> #=**=
>> #!/usr/bin/env python
>> # coding: utf8
>> from gluon import *
>> *from mymodule.classtwo import ClassTwo*
>>
>> class ClassOne(object):
>> def say_something(self):
>> classtwo = ClassTwo()
>> return classtwo.say_something()
>> #=**=
>>
>> And in classtwo.py this:
>> #=**=
>> #!/usr/bin/env python
>> # coding: utf8
>> from gluon import *
>>
>> class ClassTwo(object):
>> def say_something(self):
>> return "Hi!"
>> #=**=
>>
>> In this case, the changes inside ClassTwo are not tracked, but if I
>> change class one to:
>>
>> #=**=
>> #!/usr/bin/env python
>> # coding: utf8
>> from gluon import *
>>
>> class ClassOne(object):
>> def say_something(self):
>> *from mymodule.classtwo import ClassTwo*
>> classtwo = ClassTwo()
>> return classtwo.say_something()
>> #=**=
>>
>> Now it works correctly and all the changes are tracked, notice that now
>> the import statement is inside of a method.
>>
>> In the first case, the custom_importer() function is only called at the
>> first execution to import ClassTwo, but in the second case,
>> custom_importer its called in all executions.
>>
>> I have made an example application with this issue attached to this mail.
>>
>> Is this intended or it is a bug?
>>
>> greetings, Daniel.
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: scheduler sincronization

2013-04-08 Thread paolo.vall...@gmail.com
Hi Niphlod, sorry for the delay I had time only on the weekend to run few
tests. On my pc, I run it for hours using postgres. The maximum delay found
in starting a new task was 17s.

 Paolo


2013/4/4 paolo.vall...@gmail.com 

> Unfortunately I can't install any dbms on that machine, I will make a test
> on an other 'similar' machine where I have postgres installed.
>
>  Paolo
>
>
> 2013/4/3 Niphlod 
>
>> ok, at least it seems consistent:
>> there's:
>> - no send_heartbeat(), do_assign_tasks=True line
>> - no Inside If, do_assign_tasks=True line
>> in all the log.
>>
>> PS: I still can't reproduce the "erratic" behaviour, but a baseline
>> question rises: do you get this also using another db engine ?
>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/u_PgzKLuQmw/unsubscribe?hl=en.
>>  To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: nssm & scheduler seems to be a nobrainer...

2013-04-08 Thread Niphlod
are you "playing" with signals by any chance ?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: auth.settings.extra_fields

2013-04-08 Thread Niphlod
uhm. if you want that field to be a reference to the values on the table, 
the table must be defined, so I don't see how a SQLFORM.factory could help 
you with that.
You simply have a conditional model that for your app logic doesn't need to 
be conditional .

On Monday, April 8, 2013 10:20:56 AM UTC+2, Domagoj Kovač wrote:
>
> I see it now. Thanks man! I have a different problem now, now i don't get 
> any errors immediately but when i go on users/create i get an error saying:
>  'DAL' object has no attribute 
> 'companies'
> obviously companies model is not loaded, i am thinking on switching to 
> SQLform.factory, would this be a better solution? In models i define my 
> tables and then in my controller i make a form, then insert and updated 
> goes manually, but this is not so problematic.
>
>
> On Monday, April 8, 2013 9:52:24 AM UTC+2, Niphlod wrote:
>>
>> too many db. 
>>
>> requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s'))
>>
>> needs to be
>>
>> requires=IS_IN_DB(db, 'companies.id', '%(name)s')
>>
>>
>>
>> On Monday, April 8, 2013 9:39:15 AM UTC+2, Domagoj Kovač wrote:
>>>
>>> Hi,
>>>
>>> i tried moving companies outside of db.py. 
>>>
>>> In db.py i have:
>>>
>>> auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
>>> default=False),
>>>Field('company_id', 'reference 
>>> companies', requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s')))]
>>>
>>> Error i am receiving now is:
>>>  too many values to unpack
>>> What is wrong now?
>>>
>>> On Friday, April 5, 2013 7:09:28 PM UTC+2, Anthony wrote:

 Note, simply doing (db, 'companies.id', ...) may not completely 
 resolve the problem. Even doing that, the db.companies table is only 
 getting defined conditionally when the "companies" controller is called, 
 but the db.auth_user table is defined on every request, and it could be 
 used by other controllers. If the auth_user table links to another table, 
 it may be a good idea to make sure that other table is defined whenever 
 the 
 auth_user table is defined (i.e., maybe move the db.companies table 
 definition into db.py or some other model that isn't conditionally 
 executed).

 Anthony

 On Friday, April 5, 2013 11:30:38 AM UTC-4, Niphlod wrote:
>
> Nope.
> when "auth" definition is encountered, if you want to use 
> db.companies.id written as it is, db.define_table('companies') should 
> have been executead already.
> You need to change your IS_IN_DB call to (db, 'companies.id', 
> '%(name)s') ... notice the ticks around companies.id, it's a 
> string
> When you do it that way, the db.companies table will be called not at 
> "models definition" time, but at the time the page is rendered (so, 
> allowing all the models to be executed before --> having at your 
> disposition the companies table)
>
> On Friday, April 5, 2013 5:11:32 PM UTC+2, Domagoj Kovač wrote:
>>
>> Thanks guys,
>>
>> right now my db.py looks like this:
>>
>> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
>> auth = Auth(db)
>> crud, service, plugins = Crud(db), Service(), PluginManager()
>>
>> db.define_table('companies',
>> Field('name', 'string',
>>   required=True,
>>   requires=IS_NOT_EMPTY(),
>>   label=LABEL(T("Naziv"), _for="companies_name")),
>> Field('url_sufix', 'string',
>>   required=True,
>>   requires=IS_NOT_EMPTY(),
>>   unique=True,
>>   label=LABEL(T("Url-sufix"), 
>> _for="companies_url_sufix")),
>> Field('logo', 'upload',
>>   label=LABEL(T("Logo"), _for="companies_logo")),
>> Field('deleted', 'boolean'))
>>
>>
>> auth.settings.extra_fields['auth_user'] = [Field('deleted', 
>> 'boolean', default=False),
>>Field('company_id', 
>> 'reference companies', requires=IS_IN_DB(db, db.companies.id, 
>> '%(name)s'))]
>>
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(username=False, signature=False)
>>
>> Is there any way i could have my companies definition in 
>> /companies/companies.py but still do this.
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server-Sent Events

2013-04-08 Thread Niphlod


You said that the commet-thing is no longer existing, as "websockets" where 
> already included in web2py.js, which as I remember correctly is referenced 
> in the main application layout. But what about SSE? I mean, sure, it's just 
> an HTTP request, at start, but there is a different model for 
> "responding"... 
>

Nope, or maybe I expressed myself badly: that implementations started named 
as "comet messaging" but turned to "websocket messaging" at the first 
iteration. 
web2py.js has an usable implementation for it and 
gluon/contrib/websocket_messaging.py is 200 lines of which 70 are comments, 
it's easy to hack it into.
 

> How is web2py built for doing that? Is it keeping the session afloat for 
> that connection, if it get's the correct MIME-type? Will I just be able to 
> reuse the same controller-action for consecutive replies? 
>

given that there's no "web2py+sse" package around, but only that app, you 
should wait/ask for who did that app ^_^ 
Of course the sse the implementation can be easily done within web2py, but 
given that the issue is that the connection stays open, you should run 
web2py in an evented environment.
>From what I can see without having tested anything, you just return the 
text/event-stream content-type and in a loop you yield the message 
"segment". 

Can I explicitly call it from another controller, from a different session? 
> Where should a "yield" be placed? There is ZERO documentation about this in 
> the web2py book, and there was only one thread about this in this group, 
> which had an attached "example application" packed in a w2p file that I 
> couldn't use for some reason...  
>

Of course you need to disable session locking when accessing to that 
controller with session.forget(response): basically that controller is 
"held captive" as soon as the user's connects to it. 
I didn't get what you mean by "can I explicitely call it": either with 
websockets or SSE as soon as the user hits the page, a connection is 
established and remains open. There's no request/response cycle, just a 
request coming in and a (eventually) infinite response out.
Where you yield is at your discretion, but at least you should yield at the 
end of a single message.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: auth.settings.extra_fields

2013-04-08 Thread Domagoj Kovač
I see it now. Thanks man! I have a different problem now, now i don't get 
any errors immediately but when i go on users/create i get an error saying:
 'DAL' object has no attribute 'companies'
obviously companies model is not loaded, i am thinking on switching to 
SQLform.factory, would this be a better solution? In models i define my 
tables and then in my controller i make a form, then insert and updated 
goes manually, but this is not so problematic.


On Monday, April 8, 2013 9:52:24 AM UTC+2, Niphlod wrote:
>
> too many db. 
>
> requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s'))
>
> needs to be
>
> requires=IS_IN_DB(db, 'companies.id', '%(name)s')
>
>
>
> On Monday, April 8, 2013 9:39:15 AM UTC+2, Domagoj Kovač wrote:
>>
>> Hi,
>>
>> i tried moving companies outside of db.py. 
>>
>> In db.py i have:
>>
>> auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
>> default=False),
>>Field('company_id', 'reference 
>> companies', requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s')))]
>>
>> Error i am receiving now is:
>>  too many values to unpack
>> What is wrong now?
>>
>> On Friday, April 5, 2013 7:09:28 PM UTC+2, Anthony wrote:
>>>
>>> Note, simply doing (db, 'companies.id', ...) may not completely resolve 
>>> the problem. Even doing that, the db.companies table is only getting 
>>> defined conditionally when the "companies" controller is called, but the 
>>> db.auth_user table is defined on every request, and it could be used by 
>>> other controllers. If the auth_user table links to another table, it may be 
>>> a good idea to make sure that other table is defined whenever the auth_user 
>>> table is defined (i.e., maybe move the db.companies table definition into 
>>> db.py or some other model that isn't conditionally executed).
>>>
>>> Anthony
>>>
>>> On Friday, April 5, 2013 11:30:38 AM UTC-4, Niphlod wrote:

 Nope.
 when "auth" definition is encountered, if you want to use 
 db.companies.id written as it is, db.define_table('companies') should 
 have been executead already.
 You need to change your IS_IN_DB call to (db, 'companies.id', 
 '%(name)s') ... notice the ticks around companies.id, it's a string
 When you do it that way, the db.companies table will be called not at 
 "models definition" time, but at the time the page is rendered (so, 
 allowing all the models to be executed before --> having at your 
 disposition the companies table)

 On Friday, April 5, 2013 5:11:32 PM UTC+2, Domagoj Kovač wrote:
>
> Thanks guys,
>
> right now my db.py looks like this:
>
> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
> auth = Auth(db)
> crud, service, plugins = Crud(db), Service(), PluginManager()
>
> db.define_table('companies',
> Field('name', 'string',
>   required=True,
>   requires=IS_NOT_EMPTY(),
>   label=LABEL(T("Naziv"), _for="companies_name")),
> Field('url_sufix', 'string',
>   required=True,
>   requires=IS_NOT_EMPTY(),
>   unique=True,
>   label=LABEL(T("Url-sufix"), 
> _for="companies_url_sufix")),
> Field('logo', 'upload',
>   label=LABEL(T("Logo"), _for="companies_logo")),
> Field('deleted', 'boolean'))
>
>
> auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
> default=False),
>Field('company_id', 
> 'reference companies', requires=IS_IN_DB(db, db.companies.id, 
> '%(name)s'))]
>
> ## create all tables needed by auth if not custom tables
> auth.define_tables(username=False, signature=False)
>
> Is there any way i could have my companies definition in 
> /companies/companies.py but still do this.
>


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: nssm & scheduler seems to be a nobrainer...

2013-04-08 Thread Marian
I think you are right, it has something to do with the application itself. 
It dies directly on startup with exit code 1. The scheduler works when it 
is started in command line, so I think there is a problem with the 
environment or something like that.


On Monday, April 8, 2013 9:41:38 AM UTC+2, Niphlod wrote:
>
> If a scheduler in the welcome app works, I'm quite sure (90%, give or 
> take) that the problem lies in your app code
>
> the point is: your scheduler doesn't work as a service cause as soon as 
> it's started it dies or because while running all task fail ?
>
>
> On Monday, April 8, 2013 9:28:30 AM UTC+2, Marian wrote:
>>
>> Thank you Niphlod for the slice. :)
>>
>> But sadly it's not working for me. The problem is somehow my application 
>> and not nssm. If I define a scheduler in the welcome app it works.
>> In my app even a blank scheduler function fails.
>> In scheduler.py I found a check on WEB2PY_PATH, so I set it but without 
>> effect
>> I tried to remove all dependencies from custom modules without effect.
>>
>> I think it fails in gluon.shell. What could cause this issue? I am not 
>> trying to do anny fancy stuff. ;)
>>
>> if import_models:
>> try:
>> run_models_in(environment)
>> except RestrictedError, e:
>> sys.stderr.write(e.traceback + '\n')
>> sys.exit(1)
>>
>>
>>
>> On Saturday, April 6, 2013 9:37:56 PM UTC+2, Brian M wrote:
>>>
>>> Did you get it working? If not I can check how I did it on my server 
>>> later today 
>>>
>>> On Friday, April 5, 2013 7:35:15 AM UTC-5, Marian wrote:

 Hm maybe I have a hint, I found a failed entry in db.scheduler_run:

 gluon.shell line 137: sys.exit(1).

 When I try to restart the service, I don't get new failed tasks, so I 
 cannot say where this specific one came from.




 On Friday, April 5, 2013 1:36:37 PM UTC+2, Marian wrote:
>
> That would be awesome. Thanks for the great work! :)
>
> On Friday, April 5, 2013 12:46:36 PM UTC+2, Niphlod wrote:
>>
>> As soon as I get home I'll make screenshot of the configs  I 
>> hadn't any problems a few months back, but I'll recheck for sure and 
>> post 
>> here or on web2pyslices.com the steps involved.
>>
>> On Friday, April 5, 2013 11:34:30 AM UTC+2, Marian wrote:
>>>
>>> I dug around in the event log and found:
>>>
>>> Started C:\Python27\pythonw.exe D:\web2py\web2py.py -K imagecontest 
>>> for service web2py_scheduler_imagecontest4 in C:\Python27\.
>>>
>>> Program C:\Python27\pythonw.exe for service 
>>> web2py_scheduler_imagecontest4 exited with return code 1.
>>>
>>> Killing process tree of process 7296 for service 
>>> web2py_scheduler_imagecontest4 with exit code 1
>>>
>>> The scheduler works when used directly with python.
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Building Query object based on Rows avoiding 'belongs'

2013-04-08 Thread Marcin Jaworski
Hi,

Thank you for quick reply. 
I have used the patch to retrieve the rows I needed (for target query 
object). 

Let's say I have retrieved list of 90 rows identified by id numbers 
[n,n+1,...n90]. 

My first idea was to combine the results of subsequent 'belongs' queries to 
build target query object.

target_query_object = db.field.id.belongs(list_of_ids[n1:n30]) 
Magic_Operator db.field.id.belongs(list_of_ids[n31:n60]) Magic_Operator 
db.field.id.belongs(list_of_ids[n61:n90])

Unfortunately, I missed the magic operator to join sub queries (the 'and' 
and 'or' are not giving me what I want of course) . 
The problem is that query object (and subqueries in my case) does not 
return the final result I can use with available logical operators (if I 
understand it correctly), the query 'waits' to operate on database, it is 
some kind of prepared statements, this is why my trial failed.

The real solution I am seeking is how to select not None rows from grid. I 
have taken round trip retrieving None rows (using =='' operator) and 
substracting it (using sets operations) from all rows. This is where i am 
so far (operators: " !='' " and " is not None " and " > None " are not 
supported in queries). 

Can you advise?
Marcin Jaworski


W dniu poniedziałek, 8 kwietnia 2013 04:34:57 UTC+2 użytkownik Christian 
Foster Howes napisał:
>
> speaking without reading the docs.so i might be misguided.
>
> assuming that you can setup a grid with a rows object, you can use that 
> patch.  just & the rows together and magic will happen.
>
> the key no matter what is to setup multiple queries on GAE and & the 
> results together, or re-imagine the dataset so there is less than 30 items 
> in the belongs (which is sometimes impossible).
>
> good luck!
>
> cfh
>
> On Sunday, April 7, 2013 2:13:35 PM UTC-7, Marcin Jaworski wrote:
>>
>> Hi web2py users!
>>
>> My environment: GAE SDK 1.7.5, web2py version 2.0.9.
>>
>> I need a query object as an argument for grid.
>> I've got a database rows (ids) as the potential base for query 
>> (list_of_ids) - unfortunately there are more than 30 of them so the 
>> construct with 'belongs' does not work on GAE:
>>
>> query = db.field.id.belongs(list_of_ids)   # does not work on GAE
>>
>> There is a great solution to overcome the limit of 'belongs' on GAE:
>> https://code.google.com/p/web2py/issues/detail?id=160
>> but it let me identify just rows, when the query object for grid is 
>> needed in my case.
>>
>> Can you advise?
>> Marcin Jaworski
>>
>>
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: auth.settings.extra_fields

2013-04-08 Thread Niphlod
too many db. 

requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s'))

needs to be

requires=IS_IN_DB(db, 'companies.id', '%(name)s')



On Monday, April 8, 2013 9:39:15 AM UTC+2, Domagoj Kovač wrote:
>
> Hi,
>
> i tried moving companies outside of db.py. 
>
> In db.py i have:
>
> auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
> default=False),
>Field('company_id', 'reference 
> companies', requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s')))]
>
> Error i am receiving now is:
>  too many values to unpack
> What is wrong now?
>
> On Friday, April 5, 2013 7:09:28 PM UTC+2, Anthony wrote:
>>
>> Note, simply doing (db, 'companies.id', ...) may not completely resolve 
>> the problem. Even doing that, the db.companies table is only getting 
>> defined conditionally when the "companies" controller is called, but the 
>> db.auth_user table is defined on every request, and it could be used by 
>> other controllers. If the auth_user table links to another table, it may be 
>> a good idea to make sure that other table is defined whenever the auth_user 
>> table is defined (i.e., maybe move the db.companies table definition into 
>> db.py or some other model that isn't conditionally executed).
>>
>> Anthony
>>
>> On Friday, April 5, 2013 11:30:38 AM UTC-4, Niphlod wrote:
>>>
>>> Nope.
>>> when "auth" definition is encountered, if you want to use 
>>> db.companies.id written as it is, db.define_table('companies') should 
>>> have been executead already.
>>> You need to change your IS_IN_DB call to (db, 'companies.id', 
>>> '%(name)s') ... notice the ticks around companies.id, it's a string
>>> When you do it that way, the db.companies table will be called not at 
>>> "models definition" time, but at the time the page is rendered (so, 
>>> allowing all the models to be executed before --> having at your 
>>> disposition the companies table)
>>>
>>> On Friday, April 5, 2013 5:11:32 PM UTC+2, Domagoj Kovač wrote:

 Thanks guys,

 right now my db.py looks like this:

 from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
 auth = Auth(db)
 crud, service, plugins = Crud(db), Service(), PluginManager()

 db.define_table('companies',
 Field('name', 'string',
   required=True,
   requires=IS_NOT_EMPTY(),
   label=LABEL(T("Naziv"), _for="companies_name")),
 Field('url_sufix', 'string',
   required=True,
   requires=IS_NOT_EMPTY(),
   unique=True,
   label=LABEL(T("Url-sufix"), 
 _for="companies_url_sufix")),
 Field('logo', 'upload',
   label=LABEL(T("Logo"), _for="companies_logo")),
 Field('deleted', 'boolean'))


 auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
 default=False),
Field('company_id', 
 'reference companies', requires=IS_IN_DB(db, db.companies.id, 
 '%(name)s'))]

 ## create all tables needed by auth if not custom tables
 auth.define_tables(username=False, signature=False)

 Is there any way i could have my companies definition in 
 /companies/companies.py but still do this.

>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Problem with form.process().accepted ?

2013-04-08 Thread Nguyen Minh Tuan
Thank you!
That's the problem.


On Monday, April 8, 2013 1:06:29 PM UTC+7, Anthony wrote:
>
> Is it possible that your browser isn't accepting cookies, or that you are 
> somehow clearing the session? Without cookies, the session won't work, and 
> by default, SQLFORM uses the session to store the _formkey token to protect 
> against CSRF attacks. To see if that's the problem, you can try:
>
> if form.process(session=None).accepted:
>
> With session=None, it won't use the session (and therefore won't protect 
> against CSRF). If it works in that case, then there's a problem with the 
> session cookie and/or session.
>
> Anthony
>
> On Sunday, April 7, 2013 11:41:02 PM UTC-4, Nguyen Minh Tuan wrote:
>>
>> Thanks Anthony,
>> When I submit with blank data, no error msg displayed.
>> I expected error msg displayed because I set this field mandatory as below
>>
>> db.define_table('person', Field('personname', 'string', requires = 
>> IS_NOT_EMPTY()))
>>
>> I found that :   if form.process().accepted:   always return false, so 
>> redirect command never reached.
>> The 
>>
>> elseif :
>>  response.flash = "input info"
>>
>> always run, so page and flash "input info" are displayed again 
>>
>> Regards,
>> Tuan.
>>
>> On Friday, April 5, 2013 8:22:50 PM UTC+7, Anthony wrote:
>>>
>>> redirect('default', 'list')
>>>
>>>
>>> Should be:
>>>
>>> redirect(URL('default', 'list'))
>>>
>>> When I submit form with empty value (person name), validation does not 
 work.

>>>
>>> What do you mean it doesn't work? Do you not see the error message on 
>>> the form? What do you expect, and what happens instead? It works when I try 
>>> the code? 
>>>
>>> Anthony
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: nssm & scheduler seems to be a nobrainer...

2013-04-08 Thread Niphlod
If a scheduler in the welcome app works, I'm quite sure (90%, give or take) 
that the problem lies in your app code

the point is: your scheduler doesn't work as a service cause as soon as 
it's started it dies or because while running all task fail ?


On Monday, April 8, 2013 9:28:30 AM UTC+2, Marian wrote:
>
> Thank you Niphlod for the slice. :)
>
> But sadly it's not working for me. The problem is somehow my application 
> and not nssm. If I define a scheduler in the welcome app it works.
> In my app even a blank scheduler function fails.
> In scheduler.py I found a check on WEB2PY_PATH, so I set it but without 
> effect
> I tried to remove all dependencies from custom modules without effect.
>
> I think it fails in gluon.shell. What could cause this issue? I am not 
> trying to do anny fancy stuff. ;)
>
> if import_models:
> try:
> run_models_in(environment)
> except RestrictedError, e:
> sys.stderr.write(e.traceback + '\n')
> sys.exit(1)
>
>
>
> On Saturday, April 6, 2013 9:37:56 PM UTC+2, Brian M wrote:
>>
>> Did you get it working? If not I can check how I did it on my server 
>> later today 
>>
>> On Friday, April 5, 2013 7:35:15 AM UTC-5, Marian wrote:
>>>
>>> Hm maybe I have a hint, I found a failed entry in db.scheduler_run:
>>>
>>> gluon.shell line 137: sys.exit(1).
>>>
>>> When I try to restart the service, I don't get new failed tasks, so I 
>>> cannot say where this specific one came from.
>>>
>>>
>>>
>>>
>>> On Friday, April 5, 2013 1:36:37 PM UTC+2, Marian wrote:

 That would be awesome. Thanks for the great work! :)

 On Friday, April 5, 2013 12:46:36 PM UTC+2, Niphlod wrote:
>
> As soon as I get home I'll make screenshot of the configs  I 
> hadn't any problems a few months back, but I'll recheck for sure and post 
> here or on web2pyslices.com the steps involved.
>
> On Friday, April 5, 2013 11:34:30 AM UTC+2, Marian wrote:
>>
>> I dug around in the event log and found:
>>
>> Started C:\Python27\pythonw.exe D:\web2py\web2py.py -K imagecontest 
>> for service web2py_scheduler_imagecontest4 in C:\Python27\.
>>
>> Program C:\Python27\pythonw.exe for service 
>> web2py_scheduler_imagecontest4 exited with return code 1.
>>
>> Killing process tree of process 7296 for service 
>> web2py_scheduler_imagecontest4 with exit code 1
>>
>> The scheduler works when used directly with python.
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: auth.settings.extra_fields

2013-04-08 Thread Domagoj Kovač
Hi,

i tried moving companies outside of db.py. 

In db.py i have:

auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
default=False),
   Field('company_id', 'reference 
companies', requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s')))]

Error i am receiving now is:
 too many values to unpack
What is wrong now?

On Friday, April 5, 2013 7:09:28 PM UTC+2, Anthony wrote:
>
> Note, simply doing (db, 'companies.id', ...) may not completely resolve 
> the problem. Even doing that, the db.companies table is only getting 
> defined conditionally when the "companies" controller is called, but the 
> db.auth_user table is defined on every request, and it could be used by 
> other controllers. If the auth_user table links to another table, it may be 
> a good idea to make sure that other table is defined whenever the auth_user 
> table is defined (i.e., maybe move the db.companies table definition into 
> db.py or some other model that isn't conditionally executed).
>
> Anthony
>
> On Friday, April 5, 2013 11:30:38 AM UTC-4, Niphlod wrote:
>>
>> Nope.
>> when "auth" definition is encountered, if you want to use 
>> db.companies.idwritten as it is, db.define_table('companies') should have 
>> been executead 
>> already.
>> You need to change your IS_IN_DB call to (db, 'companies.id', 
>> '%(name)s') ... notice the ticks around companies.id, it's a string
>> When you do it that way, the db.companies table will be called not at 
>> "models definition" time, but at the time the page is rendered (so, 
>> allowing all the models to be executed before --> having at your 
>> disposition the companies table)
>>
>> On Friday, April 5, 2013 5:11:32 PM UTC+2, Domagoj Kovač wrote:
>>>
>>> Thanks guys,
>>>
>>> right now my db.py looks like this:
>>>
>>> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
>>> auth = Auth(db)
>>> crud, service, plugins = Crud(db), Service(), PluginManager()
>>>
>>> db.define_table('companies',
>>> Field('name', 'string',
>>>   required=True,
>>>   requires=IS_NOT_EMPTY(),
>>>   label=LABEL(T("Naziv"), _for="companies_name")),
>>> Field('url_sufix', 'string',
>>>   required=True,
>>>   requires=IS_NOT_EMPTY(),
>>>   unique=True,
>>>   label=LABEL(T("Url-sufix"), 
>>> _for="companies_url_sufix")),
>>> Field('logo', 'upload',
>>>   label=LABEL(T("Logo"), _for="companies_logo")),
>>> Field('deleted', 'boolean'))
>>>
>>>
>>> auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean', 
>>> default=False),
>>>Field('company_id', 
>>> 'reference companies', requires=IS_IN_DB(db, db.companies.id, 
>>> '%(name)s'))]
>>>
>>> ## create all tables needed by auth if not custom tables
>>> auth.define_tables(username=False, signature=False)
>>>
>>> Is there any way i could have my companies definition in 
>>> /companies/companies.py but still do this.
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: nssm & scheduler seems to be a nobrainer...

2013-04-08 Thread Marian
Thank you Niphlod for the slice. :)

But sadly it's not working for me. The problem is somehow my application 
and not nssm. If I define a scheduler in the welcome app it works.
In my app even a blank scheduler function fails.
In scheduler.py I found a check on WEB2PY_PATH, so I set it but without 
effect
I tried to remove all dependencies from custom modules without effect.

I think it fails in gluon.shell. What could cause this issue? I am not 
trying to do anny fancy stuff. ;)

if import_models:
try:
run_models_in(environment)
except RestrictedError, e:
sys.stderr.write(e.traceback + '\n')
sys.exit(1)



On Saturday, April 6, 2013 9:37:56 PM UTC+2, Brian M wrote:
>
> Did you get it working? If not I can check how I did it on my server later 
> today 
>
> On Friday, April 5, 2013 7:35:15 AM UTC-5, Marian wrote:
>>
>> Hm maybe I have a hint, I found a failed entry in db.scheduler_run:
>>
>> gluon.shell line 137: sys.exit(1).
>>
>> When I try to restart the service, I don't get new failed tasks, so I 
>> cannot say where this specific one came from.
>>
>>
>>
>>
>> On Friday, April 5, 2013 1:36:37 PM UTC+2, Marian wrote:
>>>
>>> That would be awesome. Thanks for the great work! :)
>>>
>>> On Friday, April 5, 2013 12:46:36 PM UTC+2, Niphlod wrote:

 As soon as I get home I'll make screenshot of the configs  I hadn't 
 any problems a few months back, but I'll recheck for sure and post here or 
 on web2pyslices.com the steps involved.

 On Friday, April 5, 2013 11:34:30 AM UTC+2, Marian wrote:
>
> I dug around in the event log and found:
>
> Started C:\Python27\pythonw.exe D:\web2py\web2py.py -K imagecontest 
> for service web2py_scheduler_imagecontest4 in C:\Python27\.
>
> Program C:\Python27\pythonw.exe for service 
> web2py_scheduler_imagecontest4 exited with return code 1.
>
> Killing process tree of process 7296 for service 
> web2py_scheduler_imagecontest4 with exit code 1
>
> The scheduler works when used directly with python.
>


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: .sum() and .count() in grid?

2013-04-08 Thread Johann Spies
I can use SQLTABLE for this and then have to write some code for pagination
and search options - all which are already in the SQLFORM.grid available.
In this case addition, deletion and editing will be avoided.

Regards
Johann


On 4 April 2013 15:17, Niphlod  wrote:

> I'm guessing it will be hard. You'll better code a view and access it as a
> "fake table".
>
> PS: you show it in a grid then what record do you want to
> add/edit/delete ?
> I'm guessing that this time you want to use the grid just to search,
> orderby and paginate, but there's a LOT of logic inside it for more things
> that needs to be considered.
>
> On Thursday, April 4, 2013 12:23:58 PM UTC+2, Johann Spies wrote:
>>
>> How would I be able to use a query like this (or the DAL equivalent) to
>> show the result in a grid?
>>
>> select so as Journal, SUM(aantal) as Articles
>> from isi.nr_arts_per_journal
>> group by Journal
>> order by Journal
>>
>> Regars
>> Johann
>>
>> --
>> Because experiencing your loyal love is better than life itself,
>> my lips will praise you.  (Psalm 63:3)
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



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

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.