[web2py] form with variable number of fields

2012-06-11 Thread rahulserver
Is there a way to create a form from controller(or view) in web2py to have 
variable number of fields depending on query?
To be more specific,I have following table in my model:

db.define_table('Commitments',Field('Account',requires=IS_IN_DB(db,db.Account_Master.id,
 
'%(Account)s 
%(State)s')),Field('TID',db.Transaction_Master),Field('Entry_Date','date',default=request.now),Field('pending','boolean',default=True),Field('Due_Date','date'),Field('Mode',requires=IS_IN_SET(('DD','Direct_Banking','Cash','Other')),default='Other'),Field('Amount','integer',default=0),Field('Remark'))

The client wants to select a particular account and find all its entries in 
a form wherein he may check or uncheck the value of field 'pending' and 
accordingly the value of this field gets updated. So this needs a form with 
variable number of rows. I do not want to use sqlform.grid for this and I 
would prefer to have the code in the controller.


Re: [web2py] SQLFORM.grid - questions/suggestions

2012-06-11 Thread Johann Spies
On 8 June 2012 16:31, Massimo Di Pierro massimo.dipie...@gmail.com wrote:

 Please open a ticket about this. This change is a line but put presents
 logical problems. The user can interact with a gird in ways it cannot
 interact with sqltable. groupby is the only missing option because it is
 delicate. the user interaction may break it.



 Issue 848 http://code.google.com/p/web2py/issues/detail?id=848


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


Re: [web2py] Re: access db and settings from modules

2012-06-11 Thread Cornelius Kölbel
Thanks for the current hint.
Kind regards
Cornelius

Am 11.06.2012 01:59, schrieb howesc:
 from gluon.globals import current


 current has request, response, auth set automatically.  you can store
 things in current (it is a Storage object).  It has been recommended
 that if you add things to current you put them in their own
 dict/storage perhaps with your appname as key (so as to not get things
 confused).  so i do:

   current.myapp = Storage()
   current.myapp.db = db

 and then later access it in modules.

 cfh

 On Sunday, June 10, 2012 6:04:45 AM UTC-7, cornelinux wrote:

 Hello,

 I want to push several functionalities to some modules.
 I am wondering if there is a more elegant way to make the db and
 settings objects usable in the modules.
 I could pass them as parameters. But is there another way to access
 those objects in the modules code?
 (I know that e.g. pylons allows to import the config object, thus
 having
 all the data of the request and application at hand.)

 Thank a lot and kind regards
 Cornelius






signature.asc
Description: OpenPGP digital signature


[web2py] naming convention of download files

2012-06-11 Thread Cornelius Kölbel
Hello,

my application is generating pdfs which should be available via the
normal web2py download controller.
I realize, that the file in the uploads/-directory is named like:

tablename.fieldname.something.binascii.hexlify(filename).pdf

But what is the something? OK, it does not seem to matter, if I set it
to anything, but I'd like to stick to the normal web2py download workflow.

Thanks a lot and kind regards
Cornelius



signature.asc
Description: OpenPGP digital signature


Re: [web2py] How to limit upload speed in web2py?

2012-06-11 Thread Charles Tang
What do you mean about the webserver config? Where is it in web2py?

On Wednesday, June 6, 2012 11:15:42 PM UTC+8, sebastian wrote:

 via your webserver config...

 On Wed, Jun 6, 2012 at 8:14 AM, Charles Tang atao...@gmail.com wrote:

 I am using SQLForm to submit a large file and want to limit the upload 
 speed. How to do it ? Thanks.




 -- 
 Sebastian E. Ovide






[web2py] sending email with gmail has stopped working

2012-06-11 Thread david.waldrop
I have several applications that use gmail to send invitations and for 
authorization.  Recently they have both stopped working in the production 
environments yet continue to work when running on my development machines. 
 I have looked at the message boards and tried everything I saw 
(ensuring the sender is form the same domain, changing the login 
credentials, etc) but am still stuck.  Here is the basic config:

## configure email
mail=auth.settings.mailer
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = 'x...@gmail.com'
mail.settings.login = 'id:pw'

My hunch is gmail is blocking the calls but I do not know how to diagnose 
or fix.  Any ideas or suggestions would be greatly appreciated.  






Re: [web2py] Re: session in cookies

2012-06-11 Thread Michele Comitini
Does it make sense if we impose  that the in cookie session can be
enabled only on SSL session?
Could we also leverage the browser local store as an option?

mic

2012/6/10 Massimo Di Pierro massimo.dipie...@gmail.com:
 If you have a high traffic site where the traffic is generated by multiple
 users, you end up with lots of sessions. If you store them in db or disk you
 have a possible bottle neck. In particular if you have many servers. If your
 sessions are small they can be stored on the client. That is what Flask
 does. We are working to make this an option (not a default) in web2py.

 massimo


 On Sunday, 10 June 2012 08:49:16 UTC-5, szimszon wrote:

 Hi All!

 What is the use case behind a session in cookies scenario?

 Tnx.


[web2py] Using The Google Translator

2012-06-11 Thread Rahul
Hey All,
 I am really confused - I want to know if I need to pay for using 
the below code into my webpage ? This invokes the google translator online.

div id=google_translate_element/divscript
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en'
}, 'google_translate_element');
}
/scriptscript 
src=//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit/script

Cheers Rahul D


[web2py] Re: Using The Google Translator

2012-06-11 Thread Rahul
Or is there a better way to translate webpages for free may be something 
like using - jquery.translate-1.4.7-debug-all.js 

Rahul D

On Monday, June 11, 2012 4:17:47 PM UTC+5:30, Rahul wrote:

 Hey All,
  I am really confused - I want to know if I need to pay for using 
 the below code into my webpage ? This invokes the google translator online.

 div id=google_translate_element/divscript
 function googleTranslateElementInit() {
 new google.translate.TranslateElement({
 pageLanguage: 'en'
 }, 'google_translate_element');
 }
 /scriptscript src=//
 translate.google.com/translate_a/element.js?cb=googleTranslateElementInit
 /script
 
 Cheers Rahul D



[web2py] newcron.py, line 227 AttributeError: 'list' object has no attribute 'split'

2012-06-11 Thread szimszon
http://code.google.com/p/web2py/issues/detail?id=849

Exception in thread Thread-21:
Traceback (most recent call last):
  File /usr/lib/python2.7/threading.py, line 551, in __bootstrap_inner
self.run()
  File /home/szimszon/fejlesztes/sajat/web2py/gluon/newcron.py, line 227, in 
run
proc = subprocess.Popen(self.cmd.split(),
AttributeError: 'list' object has no attribute 'split'

Version 2.00.0 (2012-06-10 01:18:28) dev




[web2py] Re: Watching a table for changes

2012-06-11 Thread Omri Har-Shemesh
Hi Anthony,

thanks for the reply! 
I have been looking at the code and there is something I don't really 
understand (sorry for a noob question):
when the functions get called, they are called using a pattern:

ret = ...
ret and [f(fields,ret) for f in self._after_insert]
return ret

The question is - should the function I define return something?
Is the result of the function call used somehow, somewhere?

I suspect that using ret and [] is simply in order to invoke the functions,
but then I don't understand why not use something like
[f(fields,ret) for f in self._after_insert]
without using the and operator.

Best wishes,
Omri

On Wednesday, June 6, 2012 3:44:46 PM UTC+2, Anthony wrote:

 In trunk, there are now triggers for DAL tables:

 self._before_insert = []
 self._before_update = [lambda self,fs:self.delete_uploaded_files(
 fs)]
 self._before_delete = [lambda self:self.delete_uploaded_files()]
 self._after_insert = []
 self._after_update = []
 self._after_delete = []

 You could define a function that stores a timestamp in the cache and add 
 it to the three _after_ triggers for the relevant tables. Then just check 
 the timestamp to see if it is more recent than the last request. To 
 determine the time of the last request, you could store a timestamp in the 
 session upon each request (so it will be specific to each user).

 Anthony

 On Wednesday, June 6, 2012 5:30:56 AM UTC-4, Omri Har-Shemesh wrote:

 Is it possible to watch a table for changes and define a callback 
 whenever the table is changed?
 I am trying to implement a mechanism where the client is asking for data 
 every 5 seconds from the server
 and the server should only return not a null value whenever the data has 
 changed. The problem is that
 the data is quite complex and is inferred from several tables. Therefore, 
 in order to save processing time,
 I want to calculate this data and return it only when I know it has 
 changed.

 Thanks,
 Omri



[web2py] Re: newcron.py, line 227 AttributeError: 'list' object has no attribute 'split'

2012-06-11 Thread szimszon
It's on the console where you start the web2py.py...

2012. június 11., hétfő 14:19:45 UTC+2 időpontban szimszon a következőt 
írta:

 http://code.google.com/p/web2py/issues/detail?id=849

 Exception in thread Thread-21:
 Traceback (most recent call last):
   File /usr/lib/python2.7/threading.py, line 551, in __bootstrap_inner
 self.run()
   File /home/szimszon/fejlesztes/sajat/web2py/gluon/newcron.py, line 227, 
 in run
 proc = subprocess.Popen(self.cmd.split(),
 AttributeError: 'list' object has no attribute 'split'

 Version 2.00.0 (2012-06-10 01:18:28) dev




[web2py] Dashboard for web2py.

2012-06-11 Thread Ashraf Mansour
Hi,

Pls, let me know about the successfully integrate-able dashboards with 
web2py.

Thanks,

Ashraf


[web2py] Multiple level database diagram

2012-06-11 Thread Hassan Alnatour
Dear ALL ,

I am creating an application with is a reference about some city's , so the 
website has some city's , every city has  some areas  and every area has 
some other stuff  ,it all up to 6 levels ,  so what is the best was to do 
that in the database ? 

i am thinking about making every level as a separate table..


Best Regards,



Re: [web2py] Multiple level database diagram

2012-06-11 Thread Alec Taylor
What kind of queries are you planning to run on this data?

Your answer will help us decide whether this is better to have in few
or many tables.

Also of relevance are the normal forms
(http://en.wikipedia.org/wiki/Database_normalization)

On Tue, Jun 12, 2012 at 12:39 AM, Hassan Alnatour
halna...@gardeniatelco.com wrote:
 Dear ALL ,

 I am creating an application with is a reference about some city's , so the
 website has some city's , every city has  some areas  and every area has
 some other stuff  ,it all up to 6 levels ,  so what is the best was to do
 that in the database ?

 i am thinking about making every level as a separate table..


 Best Regards,



Re: [web2py] Multiple level database diagram

2012-06-11 Thread hasan alnator
I think some  simple queries nothing complex , i will just sort every level
by its parent .


Re: [web2py] Re: How can I have static files outside of static directory?

2012-06-11 Thread Carl
this is the proof-of-hack I've done to work with both GWT and Web2py. Works 
across Development and Production modes.

To get the Web2py server URL to make requests to the server I use this code 
in my GWT client app:

String server_url;
if (GWT.isProdMode()) {
server_url = GWT.getHostPageBaseURL().replace(GWTAPPNAME, 
WEB2PY_APPNAME) + query;
} else {
server_url = GWT.getHostPageBaseURL() + init/ + query;
server_url = server_url.replace(:, :8000);
}

WEB2PY_APPNAME is welcome, init or whatever you've named your server 
application in Web2py's application directory.
GWT_APPNAME is the name of your GWT project.

Simply add default/YOU_FUNC to server_url and use in RequestBuilder 
builder = new RequestBuilder(RequestBuilder.GET, URL.encode(server_url)); 
calls.

In development mode GWT and Web2py (obviously) use different ports but can 
be set-up to use the same IP address (e.g., they both default to 127.0.0.1).
So, in dev mode, we replace port  with 8000.

Finally, one needs to run a web browser with security turned off to our 
JScript code to call another server. This is crazy but I've not found an 
alternative approach. Launch Chrome with -disable-web-security on the 
cmdline will achieve this.

That's it. The remainder of the code can be mode agnostic. Publishing this 
to solicit better set-ups that use GWT and Web2py.



On Saturday, 9 June 2012 23:39:24 UTC+1, howesc wrote:

 ok, then can you use your webserver to handle the static file handling 
 rather than web2py?  that sounds like your best bet given your 
 restrictions. 

 cfh 

 On 6/9/12 15:20 , Carl wrote: 
  It'd be nice that it wouldn't matter but tech often like that. Web2py 
 treats files differently based upon location (see e manual's section on 
 Web2py's static directory). 
  
  GWT sees its root and all files below and nothing above. 
  
  And if I stick a GWT HTML file outside of static then Web2py doesn't 
 allow static access to it. 
  
  



[web2py] Re: Watching a table for changes

2012-06-11 Thread Omri Har-Shemesh
Hi Again,

I tried adding a method using:
def SomeMethod(fields,res):
print inside SomeMethod

db.my_table._after_insert.append(SomeMethod)

but nothing seems to happen. Is it possible that the implementation of the 
adapters
does not call the methods inside _after_insert, _after_update and 
_after_delete?

Best wishes,
Omri



On Monday, June 11, 2012 3:06:35 PM UTC+2, Omri Har-Shemesh wrote:

 Hi Anthony,

 thanks for the reply! 
 I have been looking at the code and there is something I don't really 
 understand (sorry for a noob question):
 when the functions get called, they are called using a pattern:

 ret = ...
 ret and [f(fields,ret) for f in self._after_insert]
 return ret

 The question is - should the function I define return something?
 Is the result of the function call used somehow, somewhere?

 I suspect that using ret and [] is simply in order to invoke the functions,
 but then I don't understand why not use something like
 [f(fields,ret) for f in self._after_insert]
 without using the and operator.

 Best wishes,
 Omri

 On Wednesday, June 6, 2012 3:44:46 PM UTC+2, Anthony wrote:

 In trunk, there are now triggers for DAL tables:

 self._before_insert = []
 self._before_update = [lambda self,fs:self.delete_uploaded_files(
 fs)]
 self._before_delete = [lambda self:self.delete_uploaded_files()]
 self._after_insert = []
 self._after_update = []
 self._after_delete = []

 You could define a function that stores a timestamp in the cache and add 
 it to the three _after_ triggers for the relevant tables. Then just check 
 the timestamp to see if it is more recent than the last request. To 
 determine the time of the last request, you could store a timestamp in the 
 session upon each request (so it will be specific to each user).

 Anthony

 On Wednesday, June 6, 2012 5:30:56 AM UTC-4, Omri Har-Shemesh wrote:

 Is it possible to watch a table for changes and define a callback 
 whenever the table is changed?
 I am trying to implement a mechanism where the client is asking for data 
 every 5 seconds from the server
 and the server should only return not a null value whenever the data has 
 changed. The problem is that
 the data is quite complex and is inferred from several tables. 
 Therefore, in order to save processing time,
 I want to calculate this data and return it only when I know it has 
 changed.

 Thanks,
 Omri



[web2py] Re: Watching a table for changes

2012-06-11 Thread Anthony
Here's the full code for insert:

def insert(self, **fields):
self._attempt_upload(fields)
if any(f(fields) for f in self._before_insert): return 0
ret = self._db._adapter.insert(self,self._listify(fields))
ret and [f(fields,ret) for f in self._after_insert]
return ret

ret is the id of the inserted record (or 0 if the insert fails). ret is 
passed to the _after_insert functions in case those functions need to 
reference the inserted record for any reason. It does not appear the 
functions need to return anything. The reason for ret and [f(fields, ret)...is 
so the _after_insert functions only get executed if the insert was 
successful. If the insert failed, ret will be 0, which will evaluate to 
False, which will prevent the part after the and from being evaluated 
(i.e., the functions won't be called).

Note, if any of the _before_insert functions return anything that evaluates 
to True (i.e., any values other than False, None, 0, or an empty string, 
list, dict, etc.), then the insert will be abandoned (i.e., 0 is returned 
immediately). So, the _before_insert functions can be used to prevent an 
insert if desired.

Anthony

On Monday, June 11, 2012 9:06:35 AM UTC-4, Omri Har-Shemesh wrote:

 Hi Anthony,

 thanks for the reply! 
 I have been looking at the code and there is something I don't really 
 understand (sorry for a noob question):
 when the functions get called, they are called using a pattern:

 ret = ...
 ret and [f(fields,ret) for f in self._after_insert]
 return ret

 The question is - should the function I define return something?
 Is the result of the function call used somehow, somewhere?

 I suspect that using ret and [] is simply in order to invoke the functions,
 but then I don't understand why not use something like
 [f(fields,ret) for f in self._after_insert]
 without using the and operator.

 Best wishes,
 Omri

 On Wednesday, June 6, 2012 3:44:46 PM UTC+2, Anthony wrote:

 In trunk, there are now triggers for DAL tables:

 self._before_insert = []
 self._before_update = [lambda self,fs:self.delete_uploaded_files(
 fs)]
 self._before_delete = [lambda self:self.delete_uploaded_files()]
 self._after_insert = []
 self._after_update = []
 self._after_delete = []

 You could define a function that stores a timestamp in the cache and add 
 it to the three _after_ triggers for the relevant tables. Then just check 
 the timestamp to see if it is more recent than the last request. To 
 determine the time of the last request, you could store a timestamp in the 
 session upon each request (so it will be specific to each user).

 Anthony

 On Wednesday, June 6, 2012 5:30:56 AM UTC-4, Omri Har-Shemesh wrote:

 Is it possible to watch a table for changes and define a callback 
 whenever the table is changed?
 I am trying to implement a mechanism where the client is asking for data 
 every 5 seconds from the server
 and the server should only return not a null value whenever the data has 
 changed. The problem is that
 the data is quite complex and is inferred from several tables. 
 Therefore, in order to save processing time,
 I want to calculate this data and return it only when I know it has 
 changed.

 Thanks,
 Omri



[web2py] Re: Watching a table for changes

2012-06-11 Thread Anthony


 I tried adding a method using:
 def SomeMethod(fields,res):
 print inside SomeMethod

 db.my_table._after_insert.append(SomeMethod)

 but nothing seems to happen. Is it possible that the implementation of the 
 adapters
 does not call the methods inside _after_insert, _after_update and 
 _after_delete?


I would think it should work. Have you also defined any _before_insert 
functions -- if they return anything, the insert will be aborted? Also, are 
you sure the insert is happening -- if not, the _after_insert functions 
won't run. You may need to show more code.

Anthony 


[web2py] Re: Watching a table for changes

2012-06-11 Thread Omri Har-Shemesh
In order to attach the function, I have a function which is being called 
through JSON-RPC, and looks like this:

@service.jsonrpc
def append_listeners():
   print db.comments._after_insert  # prints []
   db.comments._after_insert.append(MyFunction)
   print db.comments._after_insert  # prints [function MyFunction at 
0xabfb8df4]

No matter how many times I call this function, the print statements stay 
the same (except for the address of the function MyFunction).
I modified the insert function in dal.py for debugging:
def insert(self, **fields):
print _after_insert array: , self._after_insert  # prints 
_after_insert array:  []
print table name: , self._tablename # prints table name: comments
self._attempt_upload(fields)
if any(f(fields) for f in self._before_insert): return 0
ret =  self._db._adapter.insert(self,self._listify(fields))
ret and [f(fields,ret) for f in self._after_insert]
return ret

and indeed, when I insert something to the comments table, I get two lines 
printed out as shown in the comments text.
It seems that the additional function is not saved in the table object.

Am I doing something fundamentally wrong? Should I add the function from 
the model file? Or at any other place?

Thanks,
Omri



On Monday, June 11, 2012 5:33:53 PM UTC+2, Anthony wrote:

 I tried adding a method using:
 def SomeMethod(fields,res):
 print inside SomeMethod

 db.my_table._after_insert.append(SomeMethod)

 but nothing seems to happen. Is it possible that the implementation of 
 the adapters
 does not call the methods inside _after_insert, _after_update and 
 _after_delete?


 I would think it should work. Have you also defined any _before_insert 
 functions -- if they return anything, the insert will be aborted? Also, are 
 you sure the insert is happening -- if not, the _after_insert functions 
 won't run. You may need to show more code.

 Anthony 



[web2py] How to Top Bar fixed

2012-06-11 Thread Kevin Miller
Is there an easy way how to make the top bar in web2py fixed?


Thanks


[web2py] Re: Using The Google Translator

2012-06-11 Thread Anthony
It looks like that tool is offered for free: 
http://translate.google.com/translate_tools -- but it puts a Google branded 
widget on the page. There's also a Google Translate API (
https://developers.google.com/translate/v2/pricing), which you can access 
on the server side (via a Python library), but that is a paid service (it 
used to be free, but no more).

Anthony

On Monday, June 11, 2012 6:47:47 AM UTC-4, Rahul wrote:

 Hey All,
  I am really confused - I want to know if I need to pay for using 
 the below code into my webpage ? This invokes the google translator online.

 div id=google_translate_element/divscript
 function googleTranslateElementInit() {
 new google.translate.TranslateElement({
 pageLanguage: 'en'
 }, 'google_translate_element');
 }
 /scriptscript src=//
 translate.google.com/translate_a/element.js?cb=googleTranslateElementInit
 /script
 
 Cheers Rahul D



[web2py] Re: Watching a table for changes

2012-06-11 Thread Anthony
Model (i.e., DAL Table) definitions do not survive across requests -- 
during a request, you define the table, and then you use the table object 
to access the db, etc. In your workflow, you are adding the _after_insert 
function in one request (i.e., the RPC request) but doing the insert in a 
separate request. This is not how web2py works -- you have to add the 
_after_insert function in the same request as the insert.

More generally, keep in mind that your application code is executed on each 
request -- whatever you define in a given request is specific to that 
request and does not persist to subsequent requests (unless, of course, you 
explicitly store it in the cache, session, db, filesystem, etc.).

Anthony

On Monday, June 11, 2012 11:56:36 AM UTC-4, Omri Har-Shemesh wrote:

 In order to attach the function, I have a function which is being called 
 through JSON-RPC, and looks like this:

 @service.jsonrpc
 def append_listeners():
print db.comments._after_insert  # prints []
db.comments._after_insert.append(MyFunction)
print db.comments._after_insert  # prints [function MyFunction at 
 0xabfb8df4]

 No matter how many times I call this function, the print statements stay 
 the same (except for the address of the function MyFunction).
 I modified the insert function in dal.py for debugging:
 def insert(self, **fields):
 print _after_insert array: , self._after_insert  # prints 
 _after_insert array:  []
 print table name: , self._tablename # prints table name: 
 comments
 self._attempt_upload(fields)
 if any(f(fields) for f in self._before_insert): return 0
 ret =  self._db._adapter.insert(self,self._listify(fields))
 ret and [f(fields,ret) for f in self._after_insert]
 return ret

 and indeed, when I insert something to the comments table, I get two lines 
 printed out as shown in the comments text.
 It seems that the additional function is not saved in the table object.

 Am I doing something fundamentally wrong? Should I add the function from 
 the model file? Or at any other place?

 Thanks,
 Omri



 On Monday, June 11, 2012 5:33:53 PM UTC+2, Anthony wrote:

 I tried adding a method using:
 def SomeMethod(fields,res):
 print inside SomeMethod

 db.my_table._after_insert.append(SomeMethod)

 but nothing seems to happen. Is it possible that the implementation of 
 the adapters
 does not call the methods inside _after_insert, _after_update and 
 _after_delete?


 I would think it should work. Have you also defined any _before_insert 
 functions -- if they return anything, the insert will be aborted? Also, are 
 you sure the insert is happening -- if not, the _after_insert functions 
 won't run. You may need to show more code.

 Anthony 



Re: [web2py] Re: session in cookies

2012-06-11 Thread Anthony


 Does it make sense if we impose  that the in cookie session can be 
 enabled only on SSL session?


I assume the cookie is cryptographically signed so it can't be modified, so 
SSL shouldn't be necessary (though could optionally be turned on for 
additional protection to keep the contents private).
 

 Could we also leverage the browser local store as an option?


How would the server access the session then?

Anthony


[web2py] Virual Field is not working

2012-06-11 Thread Suresh
Please look into the following code:

db = DAL(sqlite://storage.sqlite)

from gluon.tools import *
auth = Auth(db)
auth.define_tables()
crud = Crud(db)

db.define_table('country',
   Field('name', unique=True),
   format = '%(name)s')

db.define_table('state',
   Field('country_id', db.country),
   Field('name', unique=True),
   format = '%(name)s')


class StateVirtualFields(object):
def namecountryid(self):
return str(self.state.country_id)+self.state.name
db.state.virtualfields.append(StateVirtualFields())




db.define_table('city',
   Field('state_id', db.state), 
   Field('name', unique=True),
   format = '%(name)s')   


db.country.name.requires = IS_NOT_IN_DB(db, db.country.name)
db.country.name.requires = IS_NOT_EMPTY()

db.state.name.requires = IS_NOT_IN_DB(db, db.state.name)
db.state.name.requires = IS_NOT_EMPTY()
#db.state.country_id.writable = db.state.country_id.readable = False
db.state.country_id.requires = IS_IN_DB(db, db.country.id, '%(name)s')
db.state.namecountryid.requires = IS_NOT_IN_DB(db, db.state.namecountryid)

Last statement does not work.

Please help.

Suresh


[web2py] Re: Table already exists, yes I know so SKIP it.

2012-06-11 Thread vilas patil
Hi Massimo,
I tried it but it didnt work out.
I tried both fake_migrate=True and migrate=False. But it is not working. 
It is now giving eroor as: 
 invalid table name: auth_user
 
Detailed stack trace is:
Traceback (most recent call last):
  File C:\src\web2py\gluon\restricted.py, line 205, in restricted
exec ccode in environment
  File C:\src\web2py\gluon\tools.py, line 1309, in define_tables
format='%(first_name)s %(last_name)s (%(id)s)'))
  File C:\src\web2py\gluon\dal.py, line 6292, in define_table
raise SyntaxError, 'invalid table name: %s' % tablename
SyntaxError: invalid table name: auth_user
 
Please help.
 
Regards,
Vilas Patil

On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote:

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?



[web2py] Re: Table already exists, yes I know so SKIP it.

2012-06-11 Thread vilas patil
Hi Massimo,
I have done it but now I get error as :
web2py_session_myappname
 
where myappname is the name of my application.
 
I have tried both options migrate=False and fake_migrate=True but it didnt 
work out.
 
I have 2 applications which are accessing same database. When I seee 
database table from first application, it shows tables. But when I try to 
view tables of other application I get above error.
 
Detailed stack trace is:
 
 Traceback (most recent call last):  File C:\src\web2py\gluon\main.py, 
line 510, in wsgibasesession._try_store_in_db(request, response)  File 
C:\src\web2py\gluon\globals.py, line 561, in _try_store_in_db
record_id = table.insert(**dd)  File C:\src\web2py\gluon\dal.py, line 
6829, in insertreturn 
self._db._adapter.insert(self,self._listify(fields))  File 
C:\src\web2py\gluon\dal.py, line 928, in insertraise 
eOperationalError: no such table: web2py_session_myappname
 
Please help.
 
Regards,
Vilas Patil
 

On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote:

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?


On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote: 

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?


On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote: 

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?


On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote: 

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?



[web2py] Re: newcron.py, line 227 AttributeError: 'list' object has no attribute 'split'

2012-06-11 Thread simon
I also get this. It appears after the cron fix update to trunk.

On Monday, 11 June 2012 14:23:20 UTC+1, szimszon wrote:

 It's on the console where you start the web2py.py...

 2012. június 11., hétfő 14:19:45 UTC+2 időpontban szimszon a következőt 
 írta:

 http://code.google.com/p/web2py/issues/detail?id=849

 Exception in thread Thread-21:
 Traceback (most recent call last):
   File /usr/lib/python2.7/threading.py, line 551, in __bootstrap_inner
 self.run()
   File /home/szimszon/fejlesztes/sajat/web2py/gluon/newcron.py, line 227, 
 in run
 proc = subprocess.Popen(self.cmd.split(),
 AttributeError: 'list' object has no attribute 'split'

 Version 2.00.0 (2012-06-10 01:18:28) dev




Re: [web2py] How to limit upload speed in web2py?

2012-06-11 Thread Anthony
On Monday, June 11, 2012 5:36:19 AM UTC-4, Charles Tang wrote:

 What do you mean about the webserver config? Where is it in web2py?


In production you would typically use an external web server, like Apache, 
so the configuration would in the external server, not web2py.

Anthony


[web2py] Re: Virual Field is not working

2012-06-11 Thread Anthony


 db.state.namecountryid.requires = IS_NOT_IN_DB(db, db.state.namecountryid)


Virtual fields are not for doing inserts/updates and therefore do not take 
validators.

Anthony 


[web2py] Re: naming convention of download files

2012-06-11 Thread Anthony


 my application is generating pdfs which should be available via the 
 normal web2py download controller. 
 I realize, that the file in the uploads/-directory is named like: 

 tablename.fieldname.something.binascii.hexlify(filename).pdf 

 But what is the something?


Looks like it's the last 16 (non-hyphen) characters of a uuid: 
http://code.google.com/p/web2py/source/browse/gluon/dal.py#7897.

Note, for manual uploads, you can call the field's store() method directly: 
http://web2py.com/books/default/chapter/29/6#Manual-uploads.

Anthony


Re: [web2py] Re: Not open source yet... but

2012-06-11 Thread Nomad


 i was intrested in checking this out but there appears to be no source 
 available at the posted url. Is there somewhere i can get a look at this ? 



I'm currently working on a websockets project using web2py as a front end 
 and this would be a good teaching tool



Re: [web2py] windows users... help!

2012-06-11 Thread Mariano Reingart
No, it still doesn't work:

C:\Users\Mariano\Downloads\web2py_win_3\web2pyweb2py.exe
Traceback (most recent call last):
  File web2py.py, line 16, in module
zipimport.ZipImportError: can't find module 'gluon'

Microsoft.VC90.CRT is also not solved.

If you want, I can look more deeply this when I get some time.

Regards

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Sat, Jun 9, 2012 at 1:48 PM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
 Can you please try again?


 On Saturday, 9 June 2012 10:45:36 UTC-5, Mariano Reingart wrote:

 I'm missing something?

 C:\Users\Mariano\Downloads\web2py_win27\web2pyweb2py.exe
 Traceback (most recent call last):
   File c:\Python27\lib\site-packages\py2exe\boot_common.py, line 92, in
 modul
 e
     import linecache
 zipimport.ZipImportError: can't find module 'linecache'
 Traceback (most recent call last):
   File web2py.py, line 4, in module
 zipimport.ZipImportError: can't find module 'os'


 ALSO, you're not BUNDLING Microsoft.VC90.CRT (MSVCR90.DLL required by
 Python2.7) so IT WILL NOT RUN on clean windows installations (see
 attached screenshots).
 Warning: that runtime is not shipped by default, and it is a
 SideBySide (SxS) assembly, so it is not enought just to copy the dll
 as in python2.5

 I'll submit the required patch for setup.py ASAP

 Best regards

 Mariano Reingart
 http://www.sistemasagiles.com.ar
 http://reingart.blogspot.com


 On Fri, Jun 8, 2012 at 1:43 PM, Massimo Di Pierro
 massimo.dipie...@gmail.com wrote:
  We have a new nightly build using python 2.7 (thanks Niphlod). We need
  help
  testing that it is backward compatible.
 
  Massimo


Re: [web2py] Re: Virual Field is not working

2012-06-11 Thread Bruno Rocha
You can achieve the expected result using computed fields.

db.define_table(state, Field(namecountryid))

db.state.namecountryid.compute = lambda row: str(row.country_id)+row.name

db.state.requires = IS_NOT_IN_DB()

Also, You can use validators for that, but you will need to do some selects
inside the custom validators.

*Bruno Cezar Rocha*

http://www.CursoDePython.com.br
[image: Facebook] http://facebook.com/rochacbruno [image:
Twitter]http://twitter.com/rochacbruno [image:
LinkedIn] http://linkedin.com/in/rochacbruno [image:
about.me]http://about.me/rochacbruno [image:
Amazon] http://amazon.com/author/rochacbruno [image:
AngelList]http://angel.co/rochacbruno [image:
Blog RSS] http://www.web2pyslices.com/slice/list.rss?author=1 [image:
Facebook Page] http://facebook.com/CursoDePython [image:
foursquare]http://foursquare.com/rochacbruno [image:
Google Plus] https://plus.google.com/u/0/116110204708544946953/posts [image:
pinterest] http://pinterest.com/rochacbruno [image:
SlideShare]http://slideshare.com/rochacbruno [image:
YouTube] http://youtube.com/user/brunovegan
 [image: Google Talk] rochacbruno [image: Skype] blouweb
Blog: Updated: uwsgi + nginx script for Ubuntu
11.10http://www.web2pyslices.com/slice/show/1495/updated-uwsgi-nginx-script-for-ubuntu-1110
  Want a signature like mine?
http://r1.wisestamp.com/r/landing?promo=16dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_16
Click
here.http://r1.wisestamp.com/r/landing?promo=16dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_16



On Mon, Jun 11, 2012 at 2:08 PM, Anthony abasta...@gmail.com wrote:

 db.state.namecountryid.**requires = IS_NOT_IN_DB(db,
 db.state.namecountryid)


 Virtual fields are not for doing inserts/updates and therefore do not take
 validators.

 Anthony



Re: [web2py] Re: naming convention of download files

2012-06-11 Thread Cornelius Kölbel

Am 11.06.2012 19:19, schrieb Anthony:

 my application is generating pdfs which should be available via the
 normal web2py download controller.
 I realize, that the file in the uploads/-directory is named like:


 tablename.fieldname.something.binascii.hexlify(filename).pdf

 But what is the something?


 Looks like it's the last 16 (non-hyphen) characters of a
 uuid: http://code.google.com/p/web2py/source/browse/gluon/dal.py#7897.

 Note, for manual uploads, you can call the field's store() method
 directly: http://web2py.com/books/default/chapter/29/6#Manual-uploads.

 Anthony
Hi Anthony,
hm, so the uuid seems to be there to take into account, that multiple
files with the same filename might be uploaded. That makes sense,
exspecially if not all files README.txt have the same content.

Interesting enough I was able to totally skip the file database table
completely.
I got a unique name for my data sets and _generate_ files with unique
filenames from those datasets.
I know there is a dataset P03-1232012312.
So if I want to download the file P03-1232012312_EN.pdf I need to call
.../download/t_files.f_file.xxx.5030332d31323332303132333132.pdf

which works without any database table.
Hm, I hope I do not miss anything.

Kind regards
Cornelius


signature.asc
Description: OpenPGP digital signature


[web2py] Re: newcron.py, line 227 AttributeError: 'list' object has no attribute 'split'

2012-06-11 Thread Niphlod
I'm running from source and I don't see the error, but I think I know 
what's going on.

Have you something in your applications crontab ?

also, are you on linux, mac or windows ?

Il giorno lunedì 11 giugno 2012 18:49:58 UTC+2, simon ha scritto:

 I also get this. It appears after the cron fix update to trunk.

 On Monday, 11 June 2012 14:23:20 UTC+1, szimszon wrote:

 It's on the console where you start the web2py.py...

 2012. június 11., hétfő 14:19:45 UTC+2 időpontban szimszon a következőt 
 írta:

 http://code.google.com/p/web2py/issues/detail?id=849

 Exception in thread Thread-21:
 Traceback (most recent call last):
   File /usr/lib/python2.7/threading.py, line 551, in __bootstrap_inner
 self.run()
   File /home/szimszon/fejlesztes/sajat/web2py/gluon/newcron.py, line 227, 
 in run
 proc = subprocess.Popen(self.cmd.split(),
 AttributeError: 'list' object has no attribute 'split'

 Version 2.00.0 (2012-06-10 01:18:28) dev




[web2py] Re: newcron.py, line 227 AttributeError: 'list' object has no attribute 'split'

2012-06-11 Thread szimszon
I'm running it on Linux and I have nothing in cron. I use scheduler and 
linux crontab.

2012. június 11., hétfő 20:58:55 UTC+2 időpontban Niphlod a következőt írta:

 I'm running from source and I don't see the error, but I think I know 
 what's going on.

 Have you something in your applications crontab ?

 also, are you on linux, mac or windows ?

 Il giorno lunedì 11 giugno 2012 18:49:58 UTC+2, simon ha scritto:

 I also get this. It appears after the cron fix update to trunk.

 On Monday, 11 June 2012 14:23:20 UTC+1, szimszon wrote:

 It's on the console where you start the web2py.py...

 2012. június 11., hétfő 14:19:45 UTC+2 időpontban szimszon a következőt 
 írta:

 http://code.google.com/p/web2py/issues/detail?id=849

 Exception in thread Thread-21:
 Traceback (most recent call last):
   File /usr/lib/python2.7/threading.py, line 551, in __bootstrap_inner
 self.run()
   File /home/szimszon/fejlesztes/sajat/web2py/gluon/newcron.py, line 
 227, in run
 proc = subprocess.Popen(self.cmd.split(),
 AttributeError: 'list' object has no attribute 'split'

 Version 2.00.0 (2012-06-10 01:18:28) dev




Re: [web2py] Re: naming convention of download files

2012-06-11 Thread Anthony


 hm, so the uuid seems to be there to take into account, that multiple 
 files with the same filename might be uploaded. That makes sense, 
 exspecially if not all files README.txt have the same content.


If the filename is very long, part of it might get cut off depending on the 
length attribute of the upload field (particularly since the b16encode 
increases the name length), so even files with different original names 
could end up with the same truncated b16encode value. The uuid will also 
prevent someone from guessing the URL for a file even if they know (or 
correctly guess) the original filename.
 

 Interesting enough I was able to totally skip the file database table 
 completely.
 I got a unique name for my data sets and _generate_ files with unique 
 filenames from those datasets.
 I know there is a dataset P03-1232012312.
 So if I want to download the file P03-1232012312_EN.pdf I need to call
 .../download/t_files.f_file.xxx.5030332d31323332303132333132.pdf


Are you using the standard download function, which calls 
response.download()? If so, that only works by checking the db. Or having 
you created a custom download function that just opens the file and streams 
it?

Anthony
 


[web2py] Re: newcron.py, line 227 AttributeError: 'list' object has no attribute 'split'

2012-06-11 Thread Niphlod
uhm, maybe it's the default cron on admin that is giving error.

BTW, I'm getting an annoying pyfpdf window every time I start web2py from 
current trunk.

Fix is easy: when cron lines are defined as *applications/etc or 
**/applications/etc self.cmd becomes a list already for the intellingent 
parsing. Michael asked for allowing also custom processes to be run, but 
they required splitting, so we need to check if self.cmd is yet a list 
(usual cron lines) or not (custom processes)

@@ -223,8 +223,12 @@
 self.shell = shell
 
 def run(self):
+if isinstance(self.cmd, (list,tuple)):
+cmd = self.cmd
+else:
+cmd = self.cmd.split()
 import subprocess
-proc = subprocess.Popen(self.cmd.split(),
+proc = subprocess.Popen(cmd,
 stdin=subprocess.PIPE,
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE,




Il giorno lunedì 11 giugno 2012 21:13:59 UTC+2, szimszon ha scritto:

 I'm running it on Linux and I have nothing in cron. I use scheduler and 
 linux crontab.

 2012. június 11., hétfő 20:58:55 UTC+2 időpontban Niphlod a következőt 
 írta:

 I'm running from source and I don't see the error, but I think I know 
 what's going on.

 Have you something in your applications crontab ?

 also, are you on linux, mac or windows ?

 Il giorno lunedì 11 giugno 2012 18:49:58 UTC+2, simon ha scritto:

 I also get this. It appears after the cron fix update to trunk.

 On Monday, 11 June 2012 14:23:20 UTC+1, szimszon wrote:

 It's on the console where you start the web2py.py...

 2012. június 11., hétfő 14:19:45 UTC+2 időpontban szimszon a következőt 
 írta:

 http://code.google.com/p/web2py/issues/detail?id=849

 Exception in thread Thread-21:
 Traceback (most recent call last):
   File /usr/lib/python2.7/threading.py, line 551, in __bootstrap_inner
 self.run()
   File /home/szimszon/fejlesztes/sajat/web2py/gluon/newcron.py, line 
 227, in run
 proc = subprocess.Popen(self.cmd.split(),
 AttributeError: 'list' object has no attribute 'split'

 Version 2.00.0 (2012-06-10 01:18:28) dev




[web2py] Re: newcron.py, line 227 AttributeError: 'list' object has no attribute 'split'

2012-06-11 Thread Niphlod
PS: forget about pyfpdf, I was importing the module directly.



[web2py] Re: Table already exists, yes I know so SKIP it.

2012-06-11 Thread Cliff Kachinske
If applications share a table, you must decide which app owns the table. 
 Only that application should ever migrate the table.

Assuming an application called 'foo', this could be accomplished by 
something like this in your model file.

should_migrate = False
if request.application=='foo':
  should_migrate = True

db.define_table('foo_objects',
  Field('foo_object_name' 
  ),
  migrate=should_migrate
)

Be aware, though, that upgrading your applications in production becomes 
somewhat twitchy.  If you have another application, 'bar' that requires a 
change to the foo_objects table, you need to follow a sequence of events 
like this:

   1. upload the foo_objects model file.
   2. do a request in foo to make the migration kick in.  Just open the 
   database administrator page or do a refresh if you already have it open.
   3. upload the bar model table that references foo_objects
   4. upload the bar controller that references the table

You really need to do upgrades like this via script or other automated tool.

On Wednesday, April 8, 2009 12:18:01 AM UTC-4, TheDude wrote:

 OperationalError: (1050, Table 'users' already exists) 

 I know it already exists, but I want you to just know about it rather 
 than try to create it all the time. I tried clearing out my /databases 
 folder as well. Any other ideas?



Re: [web2py] Re: naming convention of download files

2012-06-11 Thread Cornelius Kölbel


Am 11.06.2012 21:26, schrieb Anthony:

 hm, so the uuid seems to be there to take into account, that
 multiple files with the same filename might be uploaded. That
 makes sense, exspecially if not all files README.txt have the same
 content.


 If the filename is very long, part of it might get cut off depending
 on the length attribute of the upload field (particularly since the
 b16encode increases the name length), so even files with different
 original names could end up with the same truncated b16encode value.
 The uuid will also prevent someone from guessing the URL for a file
 even if they know (or correctly guess) the original filename.
  

 Interesting enough I was able to totally skip the file database
 table completely.
 I got a unique name for my data sets and _generate_ files with
 unique filenames from those datasets.
 I know there is a dataset P03-1232012312.
 So if I want to download the file P03-1232012312_EN.pdf I need to call
 .../download/t_files.f_file.xxx.5030332d31323332303132333132.pdf


 Are you using the standard download function, which calls
 response.download()? If so, that only works by checking the db. Or
 having you created a custom download function that just opens the file
 and streams it?

 Anthony
  
Beat me, but I am using the simplest download function

def download():
return response.download(request,db)

and it works without database entries.
Well - I got a table defined like this:

db.define_table(t_files,
#Field('file', 'upload', uploadfield='picture_file'),
Field('f_file', 'upload'),
migrate=settings.migrate)

But there is nothing in it.

Kind regards
Cornelius


signature.asc
Description: OpenPGP digital signature


Re: [web2py] Re: naming convention of download files

2012-06-11 Thread Anthony


Beat me, but I am using the simplest download function

 def download(): 
 return response.download(request,db)

 and it works without database entries.
 Well - I got a table defined like this:

 db.define_table(t_files,
 #Field('file', 'upload', uploadfield='picture_file'),
 Field('f_file', 'upload'),
 migrate=settings.migrate)

 But there is nothing in it.


Yeah, it's sufficient that you have defined the table. 
response.download()simply needs to access the t_files.f_file Field object in 
order to get the 
upload folder (which is an attribute of that Field) -- it doesn't actually 
query the database itself.

Anthony


Re: [web2py] Re: naming convention of download files

2012-06-11 Thread Cornelius Koelbel
Am 11.06.2012 22:20, schrieb Anthony:


 Beat me, but I am using the simplest download function

 def download():
 return response.download(request,db)

 and it works without database entries.
 Well - I got a table defined like this:

 db.define_table(t_files,
 #Field('file', 'upload', uploadfield='picture_file'),
 Field('f_file', 'upload'),
 migrate=settings.migrate)

 But there is nothing in it.


 Yeah, it's sufficient that you have defined the table.
 response.download() simply needs to access the t_files.f_file Field
 object in order to get the upload folder (which is an attribute of
 that Field) -- it doesn't actually query the database itself.

 Anthony
...and now I know how to change the upload-folder! ;-)

Thanks
Cornelius


Re: [web2py] Re: session in cookies

2012-06-11 Thread Michele Comitini
2012/6/11 Anthony abasta...@gmail.com:
 Does it make sense if we impose  that the in cookie session can be
 enabled only on SSL session?


 I assume the cookie is cryptographically signed so it can't be modified, so
 SSL shouldn't be necessary (though could optionally be turned on for
 additional protection to keep the contents private).
Knowing the application and its state can someone find the key since
there is a single encryption/decription key?



 Could we also leverage the browser local store as an option?


 How would the server access the session then?
encrypting its content with a once from server and sending back
encrypted data in a header?


 Anthony


[web2py] recaptcha and web2py

2012-06-11 Thread Kevin Miller
Hey all,

I have enabled the recaptcha system by using:

from gluon.tools import Recaptcha
auth.settings.captcha = Recaptcha(request,
'PUBLIC_KEY', 'PRIVATE_KEY')



as recommended by the web2py book. However, even my reset password
needs a recaptcha. I don't even want it for the login.
I only want it for registration. How can I remove the recaptcha from
the request password and login and keep it on registration form?



Thanks.
**


[web2py] Re: recaptcha and web2py

2012-06-11 Thread Niphlod
check auth.settings

login_captcha = None
register_captcha = None
retrieve_username_captcha = None
retrieve_password_captcha = None

Il giorno lunedì 11 giugno 2012 22:55:31 UTC+2, dundee ha scritto:

 Hey all,

 I have enabled the recaptcha system by using: 

 from gluon.tools import Recaptcha
 auth.settings.captcha = Recaptcha(request,

 'PUBLIC_KEY', 'PRIVATE_KEY')



 as recommended by the web2py book. However, even my reset password needs a 
 recaptcha. I don't even want it for the login.

 I only want it for registration. How can I remove the recaptcha from the 
 request password and login and keep it on registration form?



 Thanks.
 **




Re: [web2py] Re: session in cookies

2012-06-11 Thread Anthony


  I assume the cookie is cryptographically signed so it can't be modified, 
 so 
  SSL shouldn't be necessary (though could optionally be turned on for 
  additional protection to keep the contents private). 
 Knowing the application and its state can someone find the key since 
 there is a single encryption/decription key? 


I don't know all the details of the implementation, but I think an HMAC 
hash is being used, so I would think it should be secure. Also, it looks 
like the content itself is being encrypted as well.
 

  Could we also leverage the browser local store as an option? 
  
  
  How would the server access the session then? 
 encrypting its content with a once from server and sending back 
 encrypted data in a header?


But the session has to go back to the server on every request anyway, so 
why bother storing in local storage at all?

Anthony
 


Re: [web2py] Re: recaptcha and web2py

2012-06-11 Thread Kevin Miller
Thanks for the reply.

I tried:

auth.settings.login_captcha = None

This did not work for me. Then I tried
auth.settings.login_captcha = False and that did the trick.

Thank you very much.

Regards.


On Mon, Jun 11, 2012 at 4:06 PM, Niphlod niph...@gmail.com wrote:

 check auth.settings

 login_captcha = None
 register_captcha = None
 retrieve_username_captcha = None
 retrieve_password_captcha = None

 Il giorno lunedì 11 giugno 2012 22:55:31 UTC+2, dundee ha scritto:

 Hey all,

 I have enabled the recaptcha system by using:

 from gluon.tools import Recaptcha
 auth.settings.captcha = Recaptcha(request,

 'PUBLIC_KEY', 'PRIVATE_KEY')



 as recommended by the web2py book. However, even my reset password needs a 
 recaptcha. I don't even want it for the login.

 I only want it for registration. How can I remove the recaptcha from the 
 request password and login and keep it on registration form?



 Thanks.
 **





-- 
Kevin Miller
Acting Data Controller
Department of Computing
UWI, Mona
Kingston 7


Re: [web2py] Re: session in cookies

2012-06-11 Thread Derek


On Monday, June 11, 2012 1:31:47 PM UTC-7, mcm wrote:

 2012/6/11 Anthony abasta...@gmail.com: 
  Does it make sense if we impose  that the in cookie session can be 
  enabled only on SSL session? 
  
  
  I assume the cookie is cryptographically signed so it can't be modified, 
 so 
  SSL shouldn't be necessary (though could optionally be turned on for 
  additional protection to keep the contents private). 
 Knowing the application and its state can someone find the key since 
 there is a single encryption/decription key? 

 I don't see why someone couldn't brute force it on their system once they 
get a session. I suppose it would help to have the key change on a regular 
enough basis for this to not be a problem. 
Seeing as how RC-5 72 bit key still hasn't been brute forced yet (
http://stats.distributed.net/projects.php?project_id=8) and that's using 
2000 computers for the past few years, they anticipate it will take them 90 
years to complete the project. So, 128-bit encryption with a key generated 
on server start should be secure enough. By the time you break the 
encryption, your key will be useless.

  
  
  Could we also leverage the browser local store as an option? 
  
  
  How would the server access the session then? 
 encrypting its content with a once from server and sending back 
 encrypted data in a header? 

  
  Anthony 


On Monday, June 11, 2012 1:31:47 PM UTC-7, mcm wrote:

 2012/6/11 Anthony abasta...@gmail.com: 
  Does it make sense if we impose  that the in cookie session can be 
  enabled only on SSL session? 
  
  
  I assume the cookie is cryptographically signed so it can't be modified, 
 so 
  SSL shouldn't be necessary (though could optionally be turned on for 
  additional protection to keep the contents private). 
 Knowing the application and its state can someone find the key since 
 there is a single encryption/decription key? 

  
  
  Could we also leverage the browser local store as an option? 
  
  
  How would the server access the session then? 
 encrypting its content with a once from server and sending back 
 encrypted data in a header? 

  
  Anthony 



[web2py] Re: sending email with gmail has stopped working

2012-06-11 Thread david.waldrop
Still have this issue.  However I am not sure it has anything to do with 
the server being blocked by Google.  Now when I try in my development 
environment the emaisl are failing as well.  I have tried using the same 
original gmail credentials, as well as a different smtp server 
and corresponding account, but the send still fails with the following 
message

WARNING:web2py.Mail.send failure:(10060, 'Operation timed out')

Has anyone else encountered this in the past?  Is anyone else having this 
issue with gmail now?


Re: [web2py] Re: Nginx-uwsgi problem.

2012-06-11 Thread Ovidio Marinho
We have an application running under apache2 with 51 tables in
postgres and runs very well on apache, when put to run with the
postgres nginx a request timeout error appears and locks the
web-server. What might be happening? which the configuration to run
web2py + postgresql + nginx?




       Ovidio Marinho Falcao Neto
                Web Developer
             ovidio...@gmail.com
          ovidiomari...@itjp.net.br
                 ITJP - itjp.net.br
               83   8826 9088 - Oi
               83   9334 0266 - Claro
                        Brasil



2012/5/22 Bruce Wade bruce.w...@gmail.com:
 OK so here is a little bit before and after I still have a lot of work to
 do:

 Before:
 
 /
 
 Sat May 12 15:39:07 2012    profiler.log.tmp

          85845 function calls (84497 primitive calls) in 0.128 seconds

    Ordered by: internal time
    List reduced from 743 to 80 due to restriction 80

 After:
 
 /
 
 Tue May 22 16:14:27 2012    profile.log.tmp

          52095 function calls (50779 primitive calls) in 0.085 seconds

    Ordered by: internal time
    List reduced from 727 to 80 due to restriction 80

 On Mon, May 14, 2012 at 12:06 PM, Bruce Wade bruce.w...@gmail.com wrote:

 Yes, I have started moving everything from models to custom api modules
 this weekend.

 I am going to try to use most of the tips provided by everyone.

 For the adviewer I will look to see what is calling 10 query's. However I
 can not cache this query as the returned ads most be random for every user.
 Also I load 5 ads at first so besides rating the ad there should only be one
 major query ever 5 * 20 (seconds).

 I will have a lot of these changes done by Weds and will provide a new
 profile report.

 --
 Thanks

 On Mon, May 14, 2012 at 11:07 AM, Massimo Di Pierro
 massimo.dipie...@gmail.com wrote:

 If one has more than 10 tables, one should use conditional models and one
 should move all state dependent settings into the controllers that need
 them,

 Massimo


 On Monday, 14 May 2012 11:36:00 UTC-5, pbreit wrote:

 Aren't 135 table definitions going to be a problem in a high volume app?
 Aren't many/most of those 85k-100k function calls going to 
 examining/parsing
 all those tabledefs?




 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/brucelwade
 http://www.wadecybertech.com
 http://www.fittraineronline.com - Fitness Personal Trainers Online
 http://www.warplydesigned.com




 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/brucelwade
 http://www.wadecybertech.com
 http://www.fittraineronline.com - Fitness Personal Trainers Online
 http://www.warplydesigned.com



[web2py] Web2py and Projection Queries

2012-06-11 Thread Alex Benfica
Hello people!

First of all... thank you Massimo and howesc!

About this question that I did and Massimo and howesc answerd on Stack 
Overflow.
I tried to put some code there... but I could't...

http://stackoverflow.com/questions/10940995/does-google-app-engine-projection-queries-are-supported-by-web2py

I did the web2py update to trunk and some parts of my code stopped working.
Most of problems I got where like this below, that I still don't know how 
to solve and keep it efficient, as I need to find the values by name, not 
by id.

I order to make it work, I just removed the fields I specified.

Was this way (causing errors)
self.db(self.tabela.nome == nome).select(self.tabela.valor, 
self.tabela.valor_blob, self.tabela.nome)

I did that... now it selects all fields again... but works!
self.db(self.tabela.nome == nome).select()

I'm problably missing something! How can I use projection queries with 
web2py? The ID field that web2py creates are the same ID used by datastore 
on GAE?
I have a product that I need find by name... can I query it using 
projection queries? Is that?




rows = self.db(self.tabela.nome == nome).select(self.tabela.valor, 
self.tabela.valor_blob, self.tabela.nome)
  File D:\Dropbox\Devel\www\web2py\gluon\dal.py, line 8161, in select
return adapter.select(self.query,fields,attributes)
  File D:\Dropbox\Devel\www\web2py\gluon\dal.py, line 4149, in select
for t in fields] for item in items]
  File C:\Program Files 
(x86)\Google\google_appengine\google\appengine\ext\db\__init__.py, line 
2313, in next
return self.__model_class.from_entity(self.__iterator.next())
  File C:\Program Files 
(x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py, 
line 2809, in next
next_batch = self.__batcher.next()
  File C:\Program Files 
(x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py, 
line 2671, in next
return self.next_batch(self.AT_LEAST_ONE)
  File C:\Program Files 
(x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py, 
line 2708, in next_batch
batch = self.__next_batch.get_result()
  File C:\Program Files 
(x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py, 
line 604, in get_result
return self.__get_result_hook(self)
  File C:\Program Files 
(x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py, 
line 2450, in __query_result_hook
self._batch_shared.conn.check_rpc_success(rpc)
  File C:\Program Files 
(x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py, 
line 1214, in check_rpc_success
raise _ToDatastoreError(err)
BadRequestError: cannot use projection on a property with an equality filter


[web2py] Re: Web2py and Projection Queries

2012-06-11 Thread Alex Benfica

Doing some research I found the docs...

You cannot project a property that also is referenced in an equality 
filter. For example SELECT A FROM kind WHERE A = 1 is not supported, but SELECT 
A FROM kind WHERE B = 1 or SELECT A FROM kind WHERE A  1 is supported.

So I did ...

self.db(self.tabela.nome == nome).select(self.tabela.valor, 
self.tabela.valor_blob)

I cannot (and it is obvioulsy not necessary too) use the field nome in 
query and select.

Now its working fine...

Anyone can give any idea about how to test projection x nomal queries?
I would like to benchmark each situation and post here.

Thanks.



[web2py] Re: Web2py and Projection Queries

2012-06-11 Thread Alex Benfica
Hi Massimo and howesc!

Testing again... I found a problem:

Do not return errors ( but returns no rows... ).
rows = self.db(self.tabela.nome == nome).select(self.tabela.valor, 
self.tabela.valor_blob)

Returns the desired rows...
rows = self.db(self.tabela.nome == nome).select()






On Monday, June 11, 2012 10:10:18 PM UTC-3, Alex Benfica wrote:

 Hello people!

 First of all... thank you Massimo and howesc!

 About this question that I did and Massimo and howesc answerd on Stack 
 Overflow.
 I tried to put some code there... but I could't...


 http://stackoverflow.com/questions/10940995/does-google-app-engine-projection-queries-are-supported-by-web2py

 I did the web2py update to trunk and some parts of my code stopped working.
 Most of problems I got where like this below, that I still don't know how 
 to solve and keep it efficient, as I need to find the values by name, not 
 by id.

 I order to make it work, I just removed the fields I specified.

 Was this way (causing errors)
 self.db(self.tabela.nome == nome).select(self.tabela.valor, 
 self.tabela.valor_blob, self.tabela.nome)

 I did that... now it selects all fields again... but works!
 self.db(self.tabela.nome == nome).select()

 I'm problably missing something! How can I use projection queries with 
 web2py? The ID field that web2py creates are the same ID used by datastore 
 on GAE?
 I have a product that I need find by name... can I query it using 
 projection queries? Is that?




 rows = self.db(self.tabela.nome == nome).select(self.tabela.valor, 
 self.tabela.valor_blob, self.tabela.nome)
   File D:\Dropbox\Devel\www\web2py\gluon\dal.py, line 8161, in select
 return adapter.select(self.query,fields,attributes)
   File D:\Dropbox\Devel\www\web2py\gluon\dal.py, line 4149, in select
 for t in fields] for item in items]
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py, line 
 2313, in next
 return self.__model_class.from_entity(self.__iterator.next())
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py, 
 line 2809, in next
 next_batch = self.__batcher.next()
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py, 
 line 2671, in next
 return self.next_batch(self.AT_LEAST_ONE)
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py, 
 line 2708, in next_batch
 batch = self.__next_batch.get_result()
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py, 
 line 604, in get_result
 return self.__get_result_hook(self)
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py, 
 line 2450, in __query_result_hook
 self._batch_shared.conn.check_rpc_success(rpc)
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py, 
 line 1214, in check_rpc_success
 raise _ToDatastoreError(err)
 BadRequestError: cannot use projection on a property with an equality 
 filter



[web2py] How to use the languages/pt-br.py contents as the default validation messages

2012-06-11 Thread BCSALTDA
Hi everybody,

I´m developing my first web2py application with form.custom.widgets and I 
want to change at once all validations message of my form to the pt-br.py 
definitions (translations).

What I know:
1)  I can define my validation messages in db,py, (I don´t want do it)
2)  I have languages/pt-br.py with the translations of all validation 
messages that I want to use
3) I have the file application/admin/layout.html with an example of 
language switch wich I copied and tried to reproduce without success

After several tries I always have back the default english messages, ex. value 
already in database or empty

So, how I make the pt-br.py portuguese messages as default?

Bellow follows the code:

controller: default.py

from gluon.admin import *
from gluon.fileutils import abspath, read_file, write_file
from glob import glob
from gluon.tools import Crud

import shutil
import platform


crud = Crud(db)

def cadastro_pf():
table=db.pf
form = crud.update(table,request.args(0))
table.id.represent = lambda id, row: \
   A('edit:',id,_href=URL(args=(table,id)))
search, rows = crud.search(table)
return dict(form=form,search=search,rows=rows)

view: cadastro_pf.html

{{extend 'layout.html'}}
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
meta http-equiv=content-type content=text/html; charset=utf-8 
/
meta http-equiv=P3P content=CP=\IDC DSP COR CURa ADMa OUR IND 
PHY ONL COM STA\ /
title{{=response.title or URL()}}/title
{{response.files.append(URL('static','css/styles.css'))}}
{{include 'web2py_ajax.html'}}
scriptjQuery.noConflict();/script
/head
   body class={{=T('direction: ltr') == 'direction: rtl' and 'RTLbody' or 
''}} {{block sectionclass}}home{{end}}
h5CADASTRO/h5
!
 
--
div id=dados_pessoais
div  style=background-color:#CCh6font color=blueSEUS 
DADOS/font/h6{{=form.custom.begin}}/div
div
nome*: br{{=form.custom.widget.nome}}/br
sobrenome*: br{{=form.custom.widget.sobrenome}}/br
email*: br{{=form.custom.widget.email}}/br
senha*: br{{=form.custom.widget.senha}}/br
sexo*: br{{=form.custom.widget.sexo}}
/div
div
p/p{{=INPUT(_type=submit, _name=submit, _value=Continua)}}
/div
div id=footer class=fixed
{{=T('Powered by')}} {{=A('web2py', 
_href='http://www.web2py.com')}}trade; {{=T('created by')}} Massimo Di 
Pierro copy;2007-2011 -
{{if hasattr(T,'get_possible_languages'):}}
span
  {{=T('Admin language')}}
  select name=adminlanguage onchange=var date = new 
Date();cookieDate=date.setTime(date.getTime()+(100*24*60*60*1000));document.cookie='adminLanguage='+this.options[this.selectedIndex].value+';
 
expires='+cookieDate+'; path=/';window.location.reload()
{{for language in T.get_possible_languages():}}
option {{=T.accepted_language==language and 'selected' or ''}} 
{{=language}}/option
{{pass}}
  /select
/span
{{pass}}
/div

!
 
--
div
div   style=background-color:#CC;nbsp;/div
div
p/p{{=INPUT(_type=submit, _name=submit, _value=Continua)}}
/div
div id=footer class=fixed
{{=T('Powered by')}} {{=A('web2py', 
_href='http://www.web2py.com')}}trade; {{=T('created by')}} Massimo Di 
Pierro copy;2007-2011 -
{{if hasattr(T,'get_possible_languages'):}}
span
  {{=T('Admin language')}}
  select name=adminlanguage onchange=var date = new 
Date();cookieDate=date.setTime(date.getTime()+(100*24*60*60*1000));document.cookie='adminLanguage='+this.options[this.selectedIndex].value+';
 
expires='+cookieDate+'; path=/';window.location.reload()
{{for language in T.get_possible_languages():}}
option {{=T.accepted_language==language and 'selected' or ''}} 
{{=language}}/option
{{pass}}
  /select
/span
{{pass}}
/div

!
 
--
font color=blue_/font
{{BEAUTIFY(request.vars)}}
font color=green_/font
{{BEAUTIFY(form.vars)}}
font color=red_/font
{{BEAUTIFY(form.errors)}}
{{=form.custom.end}}
/div

 /body
/html


[web2py] Mongodb - ImportError: cannot import name son

2012-06-11 Thread Michael Freitas
I tried to setup a new application using the latest source code form trunk 
and mongodb.  I get the error pasted at the end when I try to register a 
new user in my app.  I tried changing the from pymongo import son to 
from bson import son in the dal.py with no luck.  I can import son from 
bson within the python shell.
 
I am running on mac osx lion (using macports python 2.6), pymonogo 2.2 
(macports), mongodb 2.0.6 (macports) and web2py (2, 0, 0, 
datetime.datetime(2012, 6, 9, 17, 47, 2), 'dev')

Traceback (most recent call last):
  File /Users/mfreitas/Downloads/web2py/gluon/restricted.py, line 205, in 
restricted
exec ccode in environment
  File 
/Users/mfreitas/Downloads/web2py/applications/mongotest/controllers/default.py
 http://127.0.0.1:8000/admin/default/edit/mongotest/controllers/default.py, 
line 14, in module
  File /Users/mfreitas/Downloads/web2py/gluon/globals.py, line 175, in 
lambda
self._caller = lambda f: f()
  File 
/Users/mfreitas/Downloads/web2py/applications/mongotest/controllers/default.py
 http://127.0.0.1:8000/admin/default/edit/mongotest/controllers/default.py, 
line 3, in user
def user(): return dict(form=auth())
  File /Users/mfreitas/Downloads/web2py/gluon/tools.py, line 1196, in __call__
return getattr(self,args[0])()
  File /Users/mfreitas/Downloads/web2py/gluon/tools.py, line 2027, in register
onvalidation=onvalidation,hideerror=self.settings.hideerror):
  File /Users/mfreitas/Downloads/web2py/gluon/sqlhtml.py, line 1130, in 
accepts
hideerror=hideerror,
  File /Users/mfreitas/Downloads/web2py/gluon/html.py, line 1862, in accepts
status = self._traverse(status,hideerror)
  File /Users/mfreitas/Downloads/web2py/gluon/html.py, line 790, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File /Users/mfreitas/Downloads/web2py/gluon/html.py, line 790, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File /Users/mfreitas/Downloads/web2py/gluon/html.py, line 790, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File /Users/mfreitas/Downloads/web2py/gluon/html.py, line 790, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File /Users/mfreitas/Downloads/web2py/gluon/html.py, line 797, in _traverse
newstatus = self._validate()
  File /Users/mfreitas/Downloads/web2py/gluon/html.py, line 1620, in _validate
(value, errors) = validator(value)
  File /Users/mfreitas/Downloads/web2py/gluon/validators.py, line 552, in 
__call__
rows = self.dbset(field == value, ignore_common_filters = 
self.ignore_common_filters).select(limitby=(0, 1))
  File /Users/mfreitas/Downloads/web2py/gluon/dal.py, line 8147, in select
fields = adapter.expand_all(fields, adapter.tables(self.query))
  File /Users/mfreitas/Downloads/web2py/gluon/dal.py, line 4629, in select
mongosort_list, limitby_limit, limitby_skip = \
  File /Users/mfreitas/Downloads/web2py/gluon/dal.py, line 4574, in _select
ImportError: cannot import name son





[web2py] Web2py abstraction layer and union

2012-06-11 Thread Amber Doctor
I'm trying to translate the below sql statement into web2py but I'm not
sure how to handle the union. Maybe I'm just not seeing the web2py union
command that would make translating this simple.

Anyone have any suggestions?

select * from drink where drink.drink_key not in (select drink_key from
ingredients_alcohol where alcohol_key not in (select alcohol_key from
alcohol where alcohol_type_key in (select alcohol_type_key from alcohol
where alcohol_key in (3, 2, 5))) union select drink_key from
ingredients_mixer where mixer_key not in (select mixer_key from mixer where
mixer_type_key in (select mixer_type_key from mixer where mixer_key in (2,
4, 6))) union select drink_key from ingredients_garnish where garnish_key
not in (1, 2, 5))


Thanks,
Amber


[web2py] Re: Web2py and Projection Queries

2012-06-11 Thread Anthony
Is tabela.valor_blob a Blob field? The GAE documentation says projections 
can only include indexed properties, so no Text or Blob properties -- see 
https://developers.google.com/appengine/docs/python/datastore/queries#Query_Projection.
 
I would think that would result in an error, though.

Anthony

On Monday, June 11, 2012 9:35:28 PM UTC-4, Alex Benfica wrote:

 Hi Massimo and howesc!

 Testing again... I found a problem:

 Do not return errors ( but returns no rows... ).
 rows = self.db(self.tabela.nome == nome).select(self.tabela.valor, 
 self.tabela.valor_blob)
 
 Returns the desired rows...
 rows = self.db(self.tabela.nome == nome).select()






 On Monday, June 11, 2012 10:10:18 PM UTC-3, Alex Benfica wrote:

 Hello people!

 First of all... thank you Massimo and howesc!

 About this question that I did and Massimo and howesc answerd on Stack 
 Overflow.
 I tried to put some code there... but I could't...


 http://stackoverflow.com/questions/10940995/does-google-app-engine-projection-queries-are-supported-by-web2py

 I did the web2py update to trunk and some parts of my code stopped 
 working.
 Most of problems I got where like this below, that I still don't know how 
 to solve and keep it efficient, as I need to find the values by name, not 
 by id.

 I order to make it work, I just removed the fields I specified.

 Was this way (causing errors)
 self.db(self.tabela.nome == nome).select(self.tabela.valor, 
 self.tabela.valor_blob, self.tabela.nome)

 I did that... now it selects all fields again... but works!
 self.db(self.tabela.nome == nome).select()

 I'm problably missing something! How can I use projection queries with 
 web2py? The ID field that web2py creates are the same ID used by datastore 
 on GAE?
 I have a product that I need find by name... can I query it using 
 projection queries? Is that?




 rows = self.db(self.tabela.nome == nome).select(self.tabela.valor, 
 self.tabela.valor_blob, self.tabela.nome)
   File D:\Dropbox\Devel\www\web2py\gluon\dal.py, line 8161, in select
 return adapter.select(self.query,fields,attributes)
   File D:\Dropbox\Devel\www\web2py\gluon\dal.py, line 4149, in select
 for t in fields] for item in items]
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py, line 
 2313, in next
 return self.__model_class.from_entity(self.__iterator.next())
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py,
  
 line 2809, in next
 next_batch = self.__batcher.next()
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py,
  
 line 2671, in next
 return self.next_batch(self.AT_LEAST_ONE)
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py,
  
 line 2708, in next_batch
 batch = self.__next_batch.get_result()
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py, 
 line 604, in get_result
 return self.__get_result_hook(self)
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py,
  
 line 2450, in __query_result_hook
 self._batch_shared.conn.check_rpc_success(rpc)
   File C:\Program Files 
 (x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py, 
 line 1214, in check_rpc_success
 raise _ToDatastoreError(err)
 BadRequestError: cannot use projection on a property with an equality 
 filter



Re: [web2py] Re: Nginx-uwsgi problem.

2012-06-11 Thread pbreit
Probably going to need a lot more information. Have you used Nginx before? 
What does nginx.conf look like? Are you getting any error messages? Nginx 
error log? Do you have to kill nginx, uwsgi or web2py to run again?

[web2py] Re: sending email with gmail has stopped working

2012-06-11 Thread pbreit
Works OK for me. Maybe you're blocked?

https://accounts.google.com/b/0/DisplayUnlockCaptcha

Or for Google Apps:
https://www.google.com/a/[your domain].com/UnlockCaptcha


[web2py] Re: form with variable number of fields

2012-06-11 Thread Massimo Di Pierro
This is best done in JS clientside. something like:

jQuery(function(){
   jQuery('#table_field__row').hide();
  
 
jQuery('#table_otherfield').change(function(){if(jQuery('#table_otherfield').checked())
 jQuery('#table_field__row').show();});
});

On Monday, 11 June 2012 01:08:44 UTC-5, rahulserver wrote:

 Is there a way to create a form from controller(or view) in web2py to have 
 variable number of fields depending on query?
 To be more specific,I have following table in my model:

 db.define_table('Commitments',Field('Account',requires=IS_IN_DB(db,
 db.Account_Master.id, '%(Account)s 
 %(State)s')),Field('TID',db.Transaction_Master),Field('Entry_Date','date',default=request.now),Field('pending','boolean',default=True),Field('Due_Date','date'),Field('Mode',requires=IS_IN_SET(('DD','Direct_Banking','Cash','Other')),default='Other'),Field('Amount','integer',default=0),Field('Remark'))

 The client wants to select a particular account and find all its entries 
 in a form wherein he may check or uncheck the value of field 'pending' and 
 accordingly the value of this field gets updated. So this needs a form with 
 variable number of rows. I do not want to use sqlform.grid for this and I 
 would prefer to have the code in the controller.



[web2py] Re: Dashboard for web2py.

2012-06-11 Thread Massimo Di Pierro
What kind of dashboard?

On Monday, 11 June 2012 09:31:56 UTC-5, Ashraf Mansour wrote:

 Hi,

 Pls, let me know about the successfully integrate-able dashboards with 
 web2py.

 Thanks,

 Ashraf



[web2py] Re: Table already exists, yes I know so SKIP it.

2012-06-11 Thread pbreit
Contrary to the book, I seem to recall that both migrate and 
fake_migrate/fake_migrate_all need to be True for the .table files to get 
re-generated. I'm not sure if that's intended or a bug.


On Monday, June 11, 2012 8:04:55 AM UTC-7, vilas patil wrote:

 Hi Massimo,
 I have done it but now I get error as :
 web2py_session_myappname
  
 where myappname is the name of my application.
  
 I have tried both options migrate=False and fake_migrate=True but it didnt 
 work out.
  
 I have 2 applications which are accessing same database. When I seee 
 database table from first application, it shows tables. But when I try to 
 view tables of other application I get above error.
  
 Detailed stack trace is:
  
  Traceback (most recent call last):  File C:\src\web2py\gluon\main.py, 
 line 510, in wsgibasesession._try_store_in_db(request, response)  File 
 C:\src\web2py\gluon\globals.py, line 561, in _try_store_in_db
 record_id = table.insert(**dd)  File C:\src\web2py\gluon\dal.py, line 
 6829, in insertreturn 
 self._db._adapter.insert(self,self._listify(fields))  File 
 C:\src\web2py\gluon\dal.py, line 928, in insertraise 
 eOperationalError: no such table: web2py_session_myappname
  
 Please help.
  
 Regards,
 Vilas Patil
  
 
 On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote:

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?


 On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote: 

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?


 On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote: 

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?


 On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote: 

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?


On Monday, June 11, 2012 8:04:55 AM UTC-7, vilas patil wrote:

 Hi Massimo,
 I have done it but now I get error as :
 web2py_session_myappname
  
 where myappname is the name of my application.
  
 I have tried both options migrate=False and fake_migrate=True but it didnt 
 work out.
  
 I have 2 applications which are accessing same database. When I seee 
 database table from first application, it shows tables. But when I try to 
 view tables of other application I get above error.
  
 Detailed stack trace is:
  
  Traceback (most recent call last):  File C:\src\web2py\gluon\main.py, 
 line 510, in wsgibasesession._try_store_in_db(request, response)  File 
 C:\src\web2py\gluon\globals.py, line 561, in _try_store_in_db
 record_id = table.insert(**dd)  File C:\src\web2py\gluon\dal.py, line 
 6829, in insertreturn 
 self._db._adapter.insert(self,self._listify(fields))  File 
 C:\src\web2py\gluon\dal.py, line 928, in insertraise 
 eOperationalError: no such table: web2py_session_myappname
  
 Please help.
  
 Regards,
 Vilas Patil
  
 
 On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote:

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 
  folder as well. Any other ideas?


 On Wednesday, 8 April 2009 09:54:52 UTC+5:30, mdipierro wrote: 

 If the table already exists 

 db.define_table(, migrate=False) 

 Massimo 

 On Apr 7, 11:18 pm, TheDude officed...@gmail.com wrote: 
  OperationalError: (1050, Table 'users' already exists) 
  
  I know it already exists, but I want you to just know about it rather 
  than try to create it all the time. I tried clearing out my /databases 

[web2py] Re: Web2py abstraction layer and union

2012-06-11 Thread pbreit
I don't think UNION Is yet supported. Someone suggested:

r1=db((db.document.person==db.person.id)  (db.person.company == 
company_id)).select(db.document.ALL,orderby=db.document.name)

r2=db(db.document.company == company_id).select(orderby=db.document.name)

docs=r1|r2


[web2py] Re: Web2py abstraction layer and union

2012-06-11 Thread Massimo Di Pierro
your  

select is:


select * from drink where drink.drink_key not in (

 select drink_key from ingredients_alcohol where alcohol_key not in (

select alcohol_key from alcohol where alcohol_type_key in (

select alcohol_type_key from alcohol where alcohol_key in (3, 2, 5)

)

 ) union select drink_key from ingredients_mixer where mixer_key not in (

   select mixer_key from mixer where mixer_type_key in (

  select mixer_type_key from mixer where mixer_key in (2, 4, 6)

   )

) union select drink_key from ingredients_garnish where garnish_key not in 
(1, 2, 5))


There is no union in web2py but you can do:


db(~db.drink.drink_key.belongs(

 select drink_key from ingredients_alcohol where alcohol_key not in (

select alcohol_key from alcohol where alcohol_type_key in (

select alcohol_type_key from alcohol where alcohol_key in (3, 2, 5)

)

 ) union select drink_key from ingredients_mixer where mixer_key not in (

   select mixer_key from mixer where mixer_type_key in (

  select mixer_type_key from mixer where mixer_key in (2, 4, 6)

   )

) union select drink_key from ingredients_garnish where garnish_key not in 
(1, 2, 5))).select()


The union could be done at the web2py level but you would have to break tho 
into 4 selects.


Anyway, union selects are slow. You may want to consider using a single 
table ingredients and have a type.


On Monday, 11 June 2012 12:49:50 UTC-5, Amber Doctor wrote:

 I'm trying to translate the below sql statement into web2py but I'm not 
 sure how to handle the union. Maybe I'm just not seeing the web2py union 
 command that would make translating this simple.

 Anyone have any suggestions?

 select * from drink where drink.drink_key not in (select drink_key from 
 ingredients_alcohol where alcohol_key not in (select alcohol_key from 
 alcohol where alcohol_type_key in (select alcohol_type_key from alcohol 
 where alcohol_key in (3, 2, 5))) union select drink_key from 
 ingredients_mixer where mixer_key not in (select mixer_key from mixer where 
 mixer_type_key in (select mixer_type_key from mixer where mixer_key in (2, 
 4, 6))) union select drink_key from ingredients_garnish where garnish_key 
 not in (1, 2, 5))


 Thanks,
 Amber