Re: [web2py] Re: REF: Generated SQLFORM form behavior sought

2013-04-25 Thread Johann Spies
What about using the keepvalues option:

From the book:

form.accepts(vars, session=None, formname='default',
 keepvalues=False, onvalidation=None,
 dbio=True, hideerror=False):

Change keepvalues to True

Regards
Johann


On 24 April 2013 18:23, Niphlod niph...@gmail.com wrote:

 I think you need to be more clear...either you want to:
 - add a new record -- if you want to preload default values you just
 have to set them beforehand
 - edit an existing record -- it's obvious that what you edit (and submit)
 has the same value of the next attempt to edit the same record


 On Wednesday, April 24, 2013 6:00:11 PM UTC+2, software.ted wrote:

 yah that exactly, but when you add a new record, the saved record does
 not show in the form. I want the fields to remain with saved content. Even
 when i use the example u have givenbut when i click on a button with an
 id with an existing record in the db it shows without any problem...when i
 make changes the record remains in the fields.


 On Wed, Apr 24, 2013 at 5:51 PM, Niphlod nip...@gmail.com wrote:

 you mean an edit form ?
 record = db.table(1)
 form = SQLFORM(db.table, record)



 On Wednesday, April 24, 2013 5:35:18 PM UTC+2, software.ted wrote:

 Is there a way to make the form generated by SQLFORM return the current
 fields saved in the DB instead of making the fields blank? What i want is
 to return the record.

 --
 ....
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he
 is all - Thomas Carlyle 1795-1881

 /~

  --

 ---
 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_outhttps://groups.google.com/groups/opt_out
 .






 --
 ..**..**
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is
 all - Thomas Carlyle 1795-1881

 /~

  --

 ---
 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.




Re: [web2py] SQL Server Connection String Please HELP

2013-04-25 Thread Marian
I had big problems with the connection to a mssql server.


My working connection string is this:

mssql://DRIVER={SQL Server};SERVER=HOST\DATABASE,PORT;UID=USER;PWD=PASSWORD


On Wednesday, April 24, 2013 11:16:58 PM UTC+2, Tim Richardson wrote:



  
 b = SQLDB('mssql://username:password@localhost:portnumber/databaseNAME')
  
 Can someone give me a some examples or link to any information where I 
 can see how a simple program connects to a SQL SERVER DB and selects a few 
 records from a table and displays them...
  
 I have been researching to find examples, but I have not found anything 
 specific to my problem,
  

  


 this is how I access a local server. The machine is server-win2003.

 db = DAL('mssql://*user*:*pass*@server-win2003\hcnsql07/vcidat') 

 In this case, the SQL Server has an instance name of hcnsql07
 and the database is vcidat
 Probably that part of the connection string is the trickiest (the server 
 name and instance). I use Microsoft SQL Server Management Studio to connect 
 to the database to prove to myself that  I know exactly the name of the 
 server. In case you didn't know, there are free Express editions of 
 Management Studio for download.


-- 

--- 
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 custom fails to hide errors

2013-04-25 Thread yashar
i set form.errors = dict() at the end of controller but i still get errors, 
is this a bug or i'm doing a wrong 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] Count and distinct

2013-04-25 Thread Domagoj Kovač
Hi,

i have a count problem.

I have two queries.

assets = db((db.asset.asset_class_id == asset_class_id) 
(db.asset_value.asset_id == db.asset.id) 
(db.asset_value.location_value == 
location_id)).select(db.asset.ALL,

   orderby=~db.asset.id,

   limitby=limit_by,

   groupby=db.asset.id)

number_of_records = db((db.asset.asset_class_id == 
asset_class_id) 
   (db.asset_value.asset_id == db.asset.id) 

   (db.asset_value.location_value == 
location_id)).count(distinct=True)

If i turn off distinct i get number_od_records = 3, if i turn on distinct 
then i get number_od_records = 1, but asset returns 2 records with the same 
conditions.
What am i doing worng?
 

-- 

--- 
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: Count and distinct

2013-04-25 Thread Domagoj Kovač
In documentation i see:

 count = db.person.id.count()
 for row in db(db.person.id==db.thing.owner_id).select(
db.person.name, count, groupby=db.person.name):
print row.person.name, row[count]
Alex 2
Bob 1


but i need to limit the number of rows

-- 

--- 
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: REF: Generated SQLFORM form behavior sought

2013-04-25 Thread Teddy Nyambe
Hey cheers!!! exactly what am looking for


On Thu, Apr 25, 2013 at 8:40 AM, Johann Spies johann.sp...@gmail.comwrote:

 What about using the keepvalues option:

 From the book:

 form.accepts(vars, session=None, formname='default',
  keepvalues=False, onvalidation=None,
  dbio=True, hideerror=False):

 Change keepvalues to True

 Regards
 Johann


 On 24 April 2013 18:23, Niphlod niph...@gmail.com wrote:

 I think you need to be more clear...either you want to:
 - add a new record -- if you want to preload default values you just
 have to set them beforehand
 - edit an existing record -- it's obvious that what you edit (and
 submit) has the same value of the next attempt to edit the same record


 On Wednesday, April 24, 2013 6:00:11 PM UTC+2, software.ted wrote:

 yah that exactly, but when you add a new record, the saved record does
 not show in the form. I want the fields to remain with saved content. Even
 when i use the example u have givenbut when i click on a button with an
 id with an existing record in the db it shows without any problem...when i
 make changes the record remains in the fields.


 On Wed, Apr 24, 2013 at 5:51 PM, Niphlod nip...@gmail.com wrote:

  you mean an edit form ?
 record = db.table(1)
 form = SQLFORM(db.table, record)



 On Wednesday, April 24, 2013 5:35:18 PM UTC+2, software.ted wrote:

 Is there a way to make the form generated by SQLFORM return the
 current fields saved in the DB instead of making the fields blank? What i
 want is to return the record.

 --
 ....
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he
 is all - Thomas Carlyle 1795-1881

 /~

  --

 ---
 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_outhttps://groups.google.com/groups/opt_out
 .






 --
 ..**..**
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he
 is all - Thomas Carlyle 1795-1881

 /~

  --

 ---
 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.






-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 

--- 
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] REF: file upload not working when form is rendered using LOAD() or component=()

2013-04-25 Thread Teddy Nyambe
I am having a nightmare getting file upload to work when the form is loaded
using LOAD or component=(URL, tarrget=div). The file fails to be uploaded
but the record is added to the DB without the file record. It does also not
appear in the upload folder


-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 

--- 
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] Connecting to remote database - ERROR', '42P07', 'relation mytable already exists

2013-04-25 Thread at
Hi,

I am trying to connect to a remote postgres database running on a ubuntu 
server. The application is hosted on windows 7 server. Getting following 
error on application startup:
class 'gluon.contrib.pg8000.errors.ProgrammingError' ('ERROR', '42P07', 
'relation mytable already exists') 
The strange thing is in databases folder, I already have mytable file. Any 
idea what could be the issue?

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: REF: file upload not working when form is rendered using LOAD() or component=()

2013-04-25 Thread Leonel Câmara
You need to use some ajax file upload mechanism.

Here's an example:
http://www.web2pyslices.com/slice/show/1438/ajax-file-upload-in-loadweb2py-components

If you follow that example, I recommend you put the javascript directly on 
the webpages that will use it so you don't have to deal with versions of 
web2py_ajax_page, etc. that are different from the regular web2py ones 
elsewhere.

Quinta-feira, 25 de Abril de 2013 11:23:59 UTC+1, software.ted escreveu:

 I am having a nightmare getting file upload to work when the form is 
 loaded using LOAD or component=(URL, tarrget=div). The file fails to be 
 uploaded but the record is added to the DB without the file record. It does 
 also not appear in the upload folder


 -- 

 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is 
 all - Thomas Carlyle 1795-1881

 /~ 


-- 

--- 
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: twitter error using recipe from admin page

2013-04-25 Thread Leonel Câmara
Well the local variable 'r' referenced before assignment seems obvious, if 
you have no data, like it is happening now (the response has results:[]), 
then r never gets defined. You could fix this setting r = [] before the 
for. 

Quarta-feira, 24 de Abril de 2013 10:01:05 UTC+1, 黄祥 escreveu:

 hi folks,

 i'm trying to add twitter recent tweets that i learned from admin page. 
 but when i'm implemented it returns an error :

 Unable to download because:
 local variable 'r' referenced before assignment

 did anyone ever face the same situation? any hints, or solutions to solve 
 this problems?

 thanks a lot before


-- 

--- 
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: Connecting to remote database - ERROR', '42P07', 'relation mytable already exists

2013-04-25 Thread Niphlod
you may have the mytable file but the connection string when it was 
generated was different (there's a hash in front of all .table files just 
for this). Anyway, if you're sure that you don't need to trigger any 
migration, just set fake_migrate_all=True for one request and all .table 
files will be regenerated without trying to do anything to your database 
tables.

On Thursday, April 25, 2013 12:24:59 PM UTC+2, at wrote:

 Hi,

 I am trying to connect to a remote postgres database running on a ubuntu 
 server. The application is hosted on windows 7 server. Getting following 
 error on application startup:
 class 'gluon.contrib.pg8000.errors.ProgrammingError' ('ERROR', '42P07', 
 'relation mytable already exists') 
 The strange thing is in databases folder, I already have mytable file. Any 
 idea what could be the issue?

 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: Count and distinct

2013-04-25 Thread Niphlod
what's the purpose of limiting the number of rows you have to count  ?

On Thursday, April 25, 2013 11:39:50 AM UTC+2, Domagoj Kovač wrote:

 In documentation i see:

  count = db.person.id.count()
  for row in db(db.person.id==db.thing.owner_id).select(
 db.person.name, count, groupby=db.person.name):
 print row.person.name, row[count]
 Alex 2
 Bob 1


 but i need to limit the number of rows


-- 

--- 
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: REF: File Upload does not work on a component loaded using ajax....

2013-04-25 Thread Niphlod
http://web2py.com/books/default/chapter/29/12?search=uploads

*Because Ajax post does not support multipart forms, i.e. file uploads, 
upload fields will not work with the LOAD component. You could be fooled 
into thinking it would work because upload fields will function normally if 
POST is done from the individual component's .load view. Instead, uploadsare 
done with ajax-compatible 3rd-party widgets and web2py manual upload 
store commands.
*
On Thursday, April 25, 2013 5:58:07 AM UTC+2, software.ted wrote:

 I have experimented with this and i think there is something wrong...

 *Controllers*:

 def index():
  return locals()
 def post():
 form = SQLFORM(db.pics, upload=URL('download'))
 if form.process().accepted:
 response.flash = 'Data saved'
 elif form.process().accepted:
 response.flash = 'Error with form'
 return dict(form=form)
 def download():
 return response.download(request, db)

 Views:

 View-
-albums
  + index.html

 {{extend 'layout.html'}}

 {{=A('Upload Picture', component=URL('album','post.load'), 
 target='photo-space', _class='btn')}}
 div id=photo-space/div

 + post.load

 {{=form}}

 The funny thing is when if i access the post normally and not as a 
 component the file is being uploaded and but as a component as shown in the 
 code above, the image is not being uploaded and the database field for 
 image is empty but the name of the picture is added.

 Any thought on this or its by design that its not working!?

  
 -- 

 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is 
 all - Thomas Carlyle 1795-1881

 /~ 


-- 

--- 
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: Count and distinct

2013-04-25 Thread Domagoj Kovač
You misunderstood me. In the post above there is a regular select without 
limitby clause, i want to limit number of records in that select, so i 
assume count will be also limit? 

-- 

--- 
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: REF: File Upload does not work on a component loaded using ajax....

2013-04-25 Thread Teddy Nyambe
Thanx!!! will check it out.


On Thu, Apr 25, 2013 at 2:09 PM, Niphlod niph...@gmail.com wrote:

 http://web2py.com/books/default/chapter/29/12?search=uploads

 *Because Ajax post does not support multipart forms, i.e. file uploads,
 upload fields will not work with the LOAD component. You could be fooled
 into thinking it would work because upload fields will function normally if
 POST is done from the individual component's .load view. Instead, uploadsare 
 done with ajax-compatible 3rd-party widgets and web2py manual upload
 store commands.
 *

 On Thursday, April 25, 2013 5:58:07 AM UTC+2, software.ted wrote:

 I have experimented with this and i think there is something wrong...

 *Controllers*:

 def index():
  return locals()
 def post():
 form = SQLFORM(db.pics, upload=URL('download'))
 if form.process().accepted:
 response.flash = 'Data saved'
 elif form.process().accepted:
 response.flash = 'Error with form'
 return dict(form=form)
 def download():
 return response.download(request, db)

 Views:

 View-
-albums
  + index.html

 {{extend 'layout.html'}}

 {{=A('Upload Picture', component=URL('album','post.**load'),
 target='photo-space', _class='btn')}}
 div id=photo-space/div

 + post.load

 {{=form}}

 The funny thing is when if i access the post normally and not as a
 component the file is being uploaded and but as a component as shown in the
 code above, the image is not being uploaded and the database field for
 image is empty but the name of the picture is added.

 Any thought on this or its by design that its not working!?


 --
 ..**..**
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is
 all - Thomas Carlyle 1795-1881

 /~

  --

 ---
 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.






-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 

--- 
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] Combining inner and left outer joins in a query

2013-04-25 Thread Philip Kilner

Hi,

I have three tables, say parent, child and grandchild, and want to 
do an inner join on parent and child, and left outer join on child  
grandchild. So, all parents with children, and all grandchildren if they 
exist.


However, I can't accomplish this in a single query, and have been 
staring at it long enough to need some input!


I want to do something like: -

selected=db(db.parent.ALL, db.child.ALL, db.grandchild.ALL,
join=db.child.on(db.child.parent_id==db.parent.id),
left=db.grandchild.on(db.child.id==db.grandchild.child_id)
)

...which isn't right but hopefully gets across what I'm after.

How should I be combining the two types of join?


--

Regards,

PhilK


e: p...@xfr.co.uk - m: 07775 796 747

'work as if you lived in the early days of a better nation'
- alasdair gray

--

--- 
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 custom fails to hide errors

2013-04-25 Thread Anthony
During validation, each input gets its own reference to form.errors, so if 
you simply replace form.errors, each input will still refer to the original 
form.errors. So, instead of replacing form.errors, you have to alter it:

form.errors.clear()

Anyway, this shouldn't be necessary, because you can just do:

form.process(..., hideerror=True)

Anthony

On Thursday, April 25, 2013 3:02:46 AM UTC-4, yashar wrote:

 i set form.errors = dict() at the end of controller but i still get 
 errors, is this a bug or i'm doing a wrong 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: sqlform custom fails to hide errors

2013-04-25 Thread yashar
thanks, what is the difference between hideerror in sqlform and 
form.process? i noticed errors hide only if i use hideerror in sqlform not 
in form.process

On Thursday, April 25, 2013 5:16:27 PM UTC+4:30, Anthony wrote:

 During validation, each input gets its own reference to form.errors, so if 
 you simply replace form.errors, each input will still refer to the original 
 form.errors. So, instead of replacing form.errors, you have to alter it:

 form.errors.clear()

 Anyway, this shouldn't be necessary, because you can just do:

 form.process(..., hideerror=True)

 Anthony

 On Thursday, April 25, 2013 3:02:46 AM UTC-4, yashar wrote:

 i set form.errors = dict() at the end of controller but i still get 
 errors, is this a bug or i'm doing a wrong 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.




Re: [web2py] Re: REF: file upload not working when form is rendered using LOAD() or component=()

2013-04-25 Thread Teddy Nyambe
This is not cool, its giving me a weird behaviour and its not even working.


On Thu, Apr 25, 2013 at 1:19 PM, Leonel Câmara leonelcam...@gmail.comwrote:

 You need to use some ajax file upload mechanism.

 Here's an example:

 http://www.web2pyslices.com/slice/show/1438/ajax-file-upload-in-loadweb2py-components

 If you follow that example, I recommend you put the javascript directly on
 the webpages that will use it so you don't have to deal with versions of
 web2py_ajax_page, etc. that are different from the regular web2py ones
 elsewhere.

 Quinta-feira, 25 de Abril de 2013 11:23:59 UTC+1, software.ted escreveu:

 I am having a nightmare getting file upload to work when the form is
 loaded using LOAD or component=(URL, tarrget=div). The file fails to be
 uploaded but the record is added to the DB without the file record. It does
 also not appear in the upload folder


 --
 ..**..**
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is
 all - Thomas Carlyle 1795-1881

 /~

  --

 ---
 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.






-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 

--- 
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: REF: File Upload does not work on a component loaded using ajax....

2013-04-25 Thread Teddy Nyambe
Can I have an example looked at a slice it does not work either!


On Thu, Apr 25, 2013 at 2:18 PM, Teddy Nyambe software@gmail.comwrote:

 Thanx!!! will check it out.


 On Thu, Apr 25, 2013 at 2:09 PM, Niphlod niph...@gmail.com wrote:

 http://web2py.com/books/default/chapter/29/12?search=uploads

 *Because Ajax post does not support multipart forms, i.e. file uploads,
 upload fields will not work with the LOAD component. You could be fooled
 into thinking it would work because upload fields will function normally if
 POST is done from the individual component's .load view. Instead, uploadsare 
 done with ajax-compatible 3rd-party widgets and web2py manual upload
 store commands.
 *

 On Thursday, April 25, 2013 5:58:07 AM UTC+2, software.ted wrote:

 I have experimented with this and i think there is something wrong...

 *Controllers*:

 def index():
  return locals()
 def post():
 form = SQLFORM(db.pics, upload=URL('download'))
 if form.process().accepted:
 response.flash = 'Data saved'
 elif form.process().accepted:
 response.flash = 'Error with form'
 return dict(form=form)
 def download():
 return response.download(request, db)

 Views:

 View-
-albums
  + index.html

 {{extend 'layout.html'}}

 {{=A('Upload Picture', component=URL('album','post.**load'),
 target='photo-space', _class='btn')}}
 div id=photo-space/div

 + post.load

 {{=form}}

 The funny thing is when if i access the post normally and not as a
 component the file is being uploaded and but as a component as shown in the
 code above, the image is not being uploaded and the database field for
 image is empty but the name of the picture is added.

 Any thought on this or its by design that its not working!?


 --
 ..**..**
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he
 is all - Thomas Carlyle 1795-1881

 /~

  --

 ---
 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.






 --

 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is
 all - Thomas Carlyle 1795-1881

 /~




-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 

--- 
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 custom fails to hide errors

2013-04-25 Thread Anthony
Technically, hideerror is an argument of the .accepts() method of FORM (and 
therefore SQLFORM) -- it is also an argument of .validate() and .process(), 
which ultimately call .accepts(). Because of the way it is implemented, you 
can also pass hideerror directly to FORM() and SQLFORM(). It should work 
either way. If it's not working with form.process(), please show your code.

Anthony

On Thursday, April 25, 2013 9:04:01 AM UTC-4, yashar wrote:

 thanks, what is the difference between hideerror in sqlform and 
 form.process? i noticed errors hide only if i use hideerror in sqlform not 
 in form.process

 On Thursday, April 25, 2013 5:16:27 PM UTC+4:30, Anthony wrote:

 During validation, each input gets its own reference to form.errors, so 
 if you simply replace form.errors, each input will still refer to the 
 original form.errors. So, instead of replacing form.errors, you have to 
 alter it:

 form.errors.clear()

 Anyway, this shouldn't be necessary, because you can just do:

 form.process(..., hideerror=True)

 Anthony

 On Thursday, April 25, 2013 3:02:46 AM UTC-4, yashar wrote:

 i set form.errors = dict() at the end of controller but i still get 
 errors, is this a bug or i'm doing a wrong 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] custom widget dont work

2013-04-25 Thread Alexandre Andrade
I am trying to customize a json field to use a widget to be used at
SQLFORM.smartgrid that:

1. create a custom number of inputs to receive quantity of items for each
month of project
2. put this values on json field
3. update them at database.

the 2 first i could put to work, using the code below, but for some reason,
the value of json input dont save to database. What i am missing?


http://pastebin.com/MAkZAG7b

-- 
Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos

-- 

--- 
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] Datetime calculations and some genearal functionality advice

2013-04-25 Thread Trevor Overman
So for the website that I'm developing I want my users to be able to set 
availabilities, and after they have expired, I want them to be set as 
inactive . Also another feature would be validating the form to make sure 
the start and end time contained a vaild availibility (ex. the start time  
the end time). Then after this, I would like to create a list of all of the 
current available users at this current moment.

Here's my model

#user availability
db.define_table('user_availability',
   Field('user_id', 'reference auth_user', default=auth.user_id, readable=
False, writable=False),
   Field('start_availability', 'datetime', requires=IS_DATETIME()),
   Field('end_availability', 'datetime', requires=IS_DATETIME()))
   


Controller

 form_create_user_availability = SQLFORM(db.user_availability)

if form_create_user_availability.process(formname=
'form_create_user_availability').accepted:
session.flash = 'Availability Added'
redirect(URL('user/profile')) 
elif form_create_user_availability.errors:
response.flash = 'Error'


Anyway, any help or advice on how to achieve this would be awesome !

-Trevor

-- 

--- 
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] Combining inner and left outer joins in a query

2013-04-25 Thread Richard Vézina
I think your mistake is the following :

db(where clauses).select(tables and join)

So your query should read like this :

rows=db(WHERE CLAUSE IF YOU HAVE SOME OTHER THAN THE
JOIN).select(db.parent.ALL,
db.child.ALL, db.grandchild.ALL, join=db.child.on(db.child.**parent_id==
db.parent.id), left=db.grandchild.on(db.**child.id http://db.child.id/
==db.grandchild.child_**id))

Richard


On Thu, Apr 25, 2013 at 8:38 AM, Philip Kilner p...@xfr.co.uk wrote:

 Hi,

 I have three tables, say parent, child and grandchild, and want to
 do an inner join on parent and child, and left outer join on child 
 grandchild. So, all parents with children, and all grandchildren if they
 exist.

 However, I can't accomplish this in a single query, and have been staring
 at it long enough to need some input!

 I want to do something like: -

 selected=db(db.parent.ALL, db.child.ALL, db.grandchild.ALL,
 join=db.child.on(db.child.**parent_id==db.parent.id),
 left=db.grandchild.on(db.**child.id http://db.child.id
 ==db.grandchild.child_**id)
 )

 ...which isn't right but hopefully gets across what I'm after.

 How should I be combining the two types of join?


 --

 Regards,

 PhilK


 e: p...@xfr.co.uk - m: 07775 796 747

 'work as if you lived in the early days of a better nation'
 - alasdair gray

 --

 --- 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+unsubscribe@**googlegroups.comweb2py%2bunsubscr...@googlegroups.com
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://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: Datetime calculations and some genearal functionality advice

2013-04-25 Thread 黄祥
for form validation and list user i think you can do something like :

e.g. using sqlform.grid (you can modified it if you want to use sqlform)

def __onvalidation_booking(form):
if form.vars.start_availability  form.vars.end_availability:
form.errors.end_availability = 'End Availability must Greater than 
Start Availability'

def availability():
query = db.user_availability.is_active==True
grid=SQLFORM.grid(query, user_signature=False, 
  onvalidation=__onvalidation_booking)
return locals()

and for conditional after they have expired, set as inactive 
(is_active=False), i think you can do something like background process 
(cron jobs) to check every day/hour after the conditional is fulfilled it 
will updated the value is_active=False.

hope this can help

-- 

--- 
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: saving UPS shipping labels

2013-04-25 Thread Christian Foster Howes
how are you setting self.accept_result.dict_response?  if it is request 
args or vars web2py does some checking to prevent various code injection 
attacks.  maybe that is mucking with your binary data?

On Friday, April 19, 2013 1:51:29 PM UTC-7, Jim Gregory wrote:

 I'm working on a script to generate UPS shipping labels and save them on 
 our server.  The shipping labels are passed as binary data in an XML file 
 from UPS. I am using the ClassicUPS library to parse the XML file and save 
 the data. 

 I wrote a simple script to test the library, and it works OK when I run it 
 on the command line.  However, when I include the function to save the file 
 in a controller, the saved files are corrupted.   If I use Imagemagick to 
 read the file, it returns the error 'improper image header'.  The function 
 in the library that saves the data is:

 def save_label(self, fd):
 raw_epl = 
 self.accept_result.dict_response['ShipmentAcceptResponse']['ShipmentResults']['PackageResults']['LabelImage']['GraphicImage']
 binary = a2b_base64(raw_epl)
 fd.write(binary)

 I call the function using:
 shipment.save_label(open('label.gif','wb'))

 where shipment is a shipping label object produced by the library.

 Does web2py do something that would corrupt the header?


-- 

--- 
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: Use DAL connection pool for MongoDB?

2013-04-25 Thread Alan Etkin


 DAL now supports MongoDB which is nice for auth and forms. But I'd like to 
 use the MongoDB query facilities (and maybe GridFS). 
 Is it possible to obtain a connection to the database through DAL or 
 should just use pymongo's MongoClient, as if it was another application?


A possible solution here: 
http://www.web2pyslices.com/slice/show/1580/save-the-earth-from-a-total-data-mess-with-mongodbadapter#comment_1420

-- 

--- 
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: REF: file upload not working when form is rendered using LOAD() or component=()

2013-04-25 Thread Leonel Câmara
It's not working because you're doing something wrong. Probably because
you're just copy pasting things without thinking.

Here is an example of a working view using it, you can replace {{=form}}
with your LOAD.

{{extend 'layout.html'}}
{{block head}}
script src=http://malsup.github.com/jquery.form.js;/script
script
function web2py_trap_form(action,target) {
jQuery('#'+target+' form').each(function(i){
var form=jQuery(this);
if(!form.hasClass('no_trap'))
if(form.find('.upload').length0) {
form.ajaxForm({
url: action,
success: function(data, statusText, xhr) {
jQuery('#'+target).html(xhr.responseText);
web2py_trap_form(action,target);
web2py_ajax_init();
}
});
} else {
form.submit(function(e){
jQuery('.flash').hide().html('');
web2py_ajax_page('post',action,form.serialize(),target);
e.preventDefault();
});
}
});
}
/script
{{end}}

{{=form}}

{{block extrascript}}
script
/* hack because jquery.form.js does not properly passes headers */
jQuery('.flash').hide().html({{=response.flash}}).slideDown();
eval({{=XML(response.js or '')}});
/script
{{end}}



On Thu, Apr 25, 2013 at 2:16 PM, Teddy Nyambe software@gmail.comwrote:

 This is not cool, its giving me a weird behaviour and its not even
 working.


 On Thu, Apr 25, 2013 at 1:19 PM, Leonel Câmara leonelcam...@gmail.comwrote:

 You need to use some ajax file upload mechanism.

 Here's an example:

 http://www.web2pyslices.com/slice/show/1438/ajax-file-upload-in-loadweb2py-components

 If you follow that example, I recommend you put the javascript directly
 on the webpages that will use it so you don't have to deal with versions of
 web2py_ajax_page, etc. that are different from the regular web2py ones
 elsewhere.

 Quinta-feira, 25 de Abril de 2013 11:23:59 UTC+1, software.ted escreveu:

 I am having a nightmare getting file upload to work when the form is
 loaded using LOAD or component=(URL, tarrget=div). The file fails to be
 uploaded but the record is added to the DB without the file record. It does
 also not appear in the upload folder


 --
 ..**..**
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he
 is all - Thomas Carlyle 1795-1881

 /~

  --

 ---
 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.






 --

 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is
 all - Thomas Carlyle 1795-1881

 /~

 --

 ---
 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/ggwmUyp8BEI/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] compute field insert/update

2013-04-25 Thread Ivan Šandrk
I'm using a compute field to set uid's for model instances. The problem is 
that the compute function gets called on INSERT and on each subsequent 
UPDATE operation.

I don't want the UPDATE's to change this field - can I somehow detect where 
there's an INSERT or an UPDATE in progress? I thought about checking the 
field's previous value, but unfortunately compute fields are excluded.

-- 

--- 
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: CAS provider: additional fields only picked up at creation of local user

2013-04-25 Thread Massimo Di Pierro
auth_user stores the information about users
auth_cas stores the tickets used by CAS to determine whether a user is 
logged in or not. 
It is used for the CAS server, not client.

On Wednesday, 24 April 2013 14:00:17 UTC-5, mjm wrote:

 The docs at 
 http://web2py.com/books/default/chapter/29/09#Central-Authentication-Servicesay:
  Thanks 
 to CAS 2.0 all fields that are readable on the provider and have a 
 corresponding field in the auth_user table of the consumer will be copied 
 automatically.

 This is correct but does not mention that the contents of the additional 
 field are only copied to the corresponding local field when the user logs 
 in the first time, ie when the local user is created. When the original 
 field (in the CAS provider) changes and the user later logs in locally the 
 contents of the changed field are not copied again. 
 This may be by design but may be confusing (it was to me). I suggest 
 appending the docs. 

 Also does anyone know what the local auth_cas table is for?

 TIA

 Marcel


-- 

--- 
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] Query doesn't select the proper range

2013-04-25 Thread David S
I've got a query which looks like this:

(db.tracking.number = 0)  (db.tracking.number = 22000)

where number is an integer. And this should select everything with  
numberbetween 0 and 22000 but it doesn't. For example, if I set the query to 
just

(db.tracking.number = 0)

as expected it grabs anything with a number greater than or equal to 0 and 
I can see all the data. However, if I set it to

(db.tracking.number = 250)

it grabs everything greater than 250, less than 1000, and will also pick up 
numbers where if a trailing zero was added, it would be within the range 
(ex: 26-260, 27-270, 28-280, 29-290, 30-300, ... ).

I have some strings formatted like this: X# which I use re.sub to 
remove characters and then use int() to convert the remaining number to a 
int before ever being put into the table. I've checked to make sure 
everything really is an integer before going into the table and it all 
seems to be OK. I'm not sure if this is a python quirk, SQL quirk, or a 
web2py quirk. Any suggestions?

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.




[web2py] seems to be a bug in dal v 2.4.2

2013-04-25 Thread Cliff Kachinske
Code very similar to this has worked in prior versions of Web2py.

pertinent code from controller:

PRODS = db.purchased_products
POPRODS = db.purchase_order_products

#base query just does a join
q = LOTS.product_id==PRODS.id

# find out if we need to add to the base query
field = request.get_vars.search_field.lower()
key = request.get_vars.search_key

# lengthy code validates keyset is a list of two dates where the earlier 
date is first

elif 'between' in field:
   # commented code fails as discussed below
#q = ((LOTS.received_date=keyset[0]) 
 # (LOTS.received_date=keyset[1]))
# this fails also
q = LOTS.received_date=keyset[0]
q = LOTS.received_date=keyset[1]

adding these lines to dal.py at line 1752

print '*' * 80
for item in a:
print item
for key in b.keys():
print 'key %s: item: %s' %(key, b[key])

produces this output from a[0], which is the query generated by dal
SELECT  product_lots.id, product_lots.received_date, 
product_lots.qty_received, purchased_products.purchased_product_name FROM 
product_lots, purchased_products WHERE product_lots.product_id = 
purchased_products.id) AND (product_lots.received_date = '4/1/13 and 
4/5/13')) AND (product_lots.is_active = 'T')) AND 
(purchased_products.is_active = 'T')) ORDER BY product_lots.received_date;

which has this defect in the where clause:  AND (product_lots.received_date 
= '4/1/13 and 4/5/13'))
it should be: AND(product_lots.received_date = '4/1/13') 
AND(product_lots.received_date ='4/5/13')

which raises this exception:


DataError: invalid input syntax for type date: 4/1/13 and 4/5/13
LINE 1: ...d_products.id) AND (product_lots.received_date = '4/1/13 an...
 ^

-- 

--- 
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: Connecting to remote database - ERROR', '42P07', 'relation mytable already exists

2013-04-25 Thread at

Thanks for the help. It worked.

After regeneration of .table files, fake_migrate_all flag should be set to 
False again, right?

Regards

On Thursday, 25 April 2013 17:04:15 UTC+5, Niphlod wrote:

 you may have the mytable file but the connection string when it was 
 generated was different (there's a hash in front of all .table files just 
 for this). Anyway, if you're sure that you don't need to trigger any 
 migration, just set fake_migrate_all=True for one request and all .table 
 files will be regenerated without trying to do anything to your database 
 tables.

 On Thursday, April 25, 2013 12:24:59 PM UTC+2, at wrote:

 Hi,

 I am trying to connect to a remote postgres database running on a ubuntu 
 server. The application is hosted on windows 7 server. Getting following 
 error on application startup:
 class 'gluon.contrib.pg8000.errors.ProgrammingError' ('ERROR', '42P07', 
 'relation mytable already exists') 
 The strange thing is in databases folder, I already have mytable file. 
 Any idea what could be the issue?

 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: Bootstrap typeahead

2013-04-25 Thread Annet
Thank you both for your replies.

The reason I asked was I want to narrow the number of third party 
JavaScript plugins down as much as I can.
Furthermore, the autocomplete/typeahead source is a table containing 5000+ 
records, that's why my
source is a json one.

For now I'll stick with a customized version of jQuery UI.

Regards,

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: Connecting to remote database - ERROR', '42P07', 'relation mytable already exists

2013-04-25 Thread Niphlod
yes ideally you run in production with migrate=False. 
When you need to change table models, than migrate=True.

When you run into sync problems, and only then, fake_migrate_all is there 
to help.

On Thursday, April 25, 2013 6:47:35 PM UTC+2, at wrote:


 Thanks for the help. It worked.

 After regeneration of .table files, fake_migrate_all flag should be set to 
 False again, right?

 Regards

 On Thursday, 25 April 2013 17:04:15 UTC+5, Niphlod wrote:

 you may have the mytable file but the connection string when it was 
 generated was different (there's a hash in front of all .table files just 
 for this). Anyway, if you're sure that you don't need to trigger any 
 migration, just set fake_migrate_all=True for one request and all .table 
 files will be regenerated without trying to do anything to your database 
 tables.

 On Thursday, April 25, 2013 12:24:59 PM UTC+2, at wrote:

 Hi,

 I am trying to connect to a remote postgres database running on a ubuntu 
 server. The application is hosted on windows 7 server. Getting following 
 error on application startup:
 class 'gluon.contrib.pg8000.errors.ProgrammingError' ('ERROR', 
 '42P07', 'relation mytable already exists') 
 The strange thing is in databases folder, I already have mytable file. 
 Any idea what could be the issue?

 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: seems to be a bug in dal v 2.4.2

2013-04-25 Thread Niphlod
prepare a table model and a select() to reproduce the issue please...

PS: I'm not sure that = is recommended/supported.

-- 

--- 
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: Query doesn't select the proper range

2013-04-25 Thread Niphlod

As long as web2py goes, it issues a select to your database engine and 
that one is responsible for picking up the records you want.
Is the select generated by web2py correct ?
If yes, then it's a problem either with your backend or your data.
If not, then pack an app to reproduce the issue.

PS: are you sure that you are NOT using SQLite and changed that column from 
an original string to the integer type ? If you did, then the issue is 
right there: SQLite doesn't handle column type migrations.

On Thursday, April 25, 2013 6:17:53 PM UTC+2, David S wrote:

 I've got a query which looks like this:

 (db.tracking.number = 0)  (db.tracking.number = 22000)

 where number is an integer. And this should select everything with  
 numberbetween 0 and 22000 but it doesn't. For example, if I set the query to 
 just

 (db.tracking.number = 0)

 as expected it grabs anything with a number greater than or equal to 0 
 and I can see all the data. However, if I set it to

 (db.tracking.number = 250)

 it grabs everything greater than 250, less than 1000, and will also pick 
 up numbers where if a trailing zero was added, it would be within the range 
 (ex: 26-260, 27-270, 28-280, 29-290, 30-300, ... ).

 I have some strings formatted like this: X# which I use re.sub to 
 remove characters and then use int() to convert the remaining number to a 
 int before ever being put into the table. I've checked to make sure 
 everything really is an integer before going into the table and it all 
 seems to be OK. I'm not sure if this is a python quirk, SQL quirk, or a 
 web2py quirk. Any suggestions?

 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.




[web2py] Re: compute field insert/update

2013-04-25 Thread Niphlod
a computed field gets calculated on update by design. it's something 
dependant on all other rows values, so if they change, the computed value 
needs to change also.
If you want to calculate it only on insert, why don't you just set a 
default value ?
If the case is more complicated, I urge you to make good use of triggers: 
they're definitely a time saver.

web2py.com/books/default/chapter/29/06#before-and-after-callbacks

On Thursday, April 25, 2013 5:47:30 PM UTC+2, Ivan Šandrk wrote:

 I'm using a compute field to set uid's for model instances. The problem is 
 that the compute function gets called on INSERT and on each subsequent 
 UPDATE operation.

 I don't want the UPDATE's to change this field - can I somehow detect 
 where there's an INSERT or an UPDATE in progress? I thought about checking 
 the field's previous value, but unfortunately compute fields are excluded.


-- 

--- 
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: Count and distinct

2013-04-25 Thread Niphlod
that's more or less exactly what I don't understand. you usually 
count() something without any limits because you don't know the cardinality 
of your wanted resultset.

If you limit your resultset to n rows, what's the purpose of counting ?

That's why there's no db(query).count(limitby=(0,n)) syntax 



On Thursday, April 25, 2013 2:12:16 PM UTC+2, Domagoj Kovač wrote:

 You misunderstood me. In the post above there is a regular select without 
 limitby clause, i want to limit number of records in that select, so i 
 assume count will be also limit? 

-- 

--- 
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: compute field insert/update

2013-04-25 Thread Ivan Šandrk
Ah silly me, I totally overlooked the default functionality. And those 
triggers seem useful. Thanks :-)

On Thursday, April 25, 2013 8:23:24 PM UTC+2, Niphlod wrote:

 a computed field gets calculated on update by design. it's something 
 dependant on all other rows values, so if they change, the computed value 
 needs to change also.
 If you want to calculate it only on insert, why don't you just set a 
 default value ?
 If the case is more complicated, I urge you to make good use of 
 triggers: they're definitely a time saver.

 web2py.com/books/default/chapter/29/06#before-and-after-callbacks

 On Thursday, April 25, 2013 5:47:30 PM UTC+2, Ivan Šandrk wrote:

 I'm using a compute field to set uid's for model instances. The problem 
 is that the compute function gets called on INSERT and on each subsequent 
 UPDATE operation.

 I don't want the UPDATE's to change this field - can I somehow detect 
 where there's an INSERT or an UPDATE in progress? I thought about checking 
 the field's previous value, but unfortunately compute fields are excluded.



-- 

--- 
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: Query doesn't select the proper range

2013-04-25 Thread David S
I am using SQLite and had changed from string-int so I deleted all of the 
database files in /myapp/databases and then reloaded all of the data. The 
issue persisted :( 

The select generated is correct. I think you're right in saying it's 
something wrong with the backend.

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.




[web2py] wymeditor

2013-04-25 Thread Annet
Does any one use wymeditor in web2py?

I downloaded version 0.5 and put it in the static folder, and included the 
following tag in layout.html 

script 
src={{=URL('static','wymeditor/jquery.wymeditor.min.js')}}/script

and used the following function:

script type=text/javascript
$(document).ready(function(){
  $('#promo_text').wymeditor();
});
/script

For some reason this doesn't turn the promo_text textarea into a wymeditor 
instance.
What do I overlook?

Regards,

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: Count and distinct

2013-04-25 Thread Domagoj Kovač


count = db.person.id.count()

I understand this line of code, it is obvious that limitby clause here 
would be stupid.

 for row in db(db.person.id==db.thing.owner_id).select(
db.person.name, count, groupby=db.person.name):
print row.person.name, row[count]
Alex 2
Bob 1

I don't understand what is the purpose of the count here, and is this count 
related to the count above.


-- 

--- 
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: Alternative to SQLFORM for Angular

2013-04-25 Thread RHC
Thanks to all of you for your suggestions. I'm not sure which way I'll 
tackle this, but I have a good understanding now of what my options are to 
tweak the SQLFORM feature. Your help is much appreciated.

-- 

--- 
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: Count and distinct

2013-04-25 Thread Derek
Yeah, I agree. I read the documentation and I have no clue what is 
happening there. Are there two people named Alex? Does 'Alex' own two 
items? Why is it grouping by person name instead of person id? Why is 
'count' assigned as a count of person IDs, used as an argument in the 
select (presumably it's just an int?) and then used as an iterator 
(assuming the count of person IDs is 2, then it's just getting row 2?)?

On Thursday, April 25, 2013 12:55:46 PM UTC-7, Domagoj Kovač wrote:

 count = db.person.id.count()

 I understand this line of code, it is obvious that limitby clause here 
 would be stupid.

  for row in db(db.person.id==db.thing.owner_id).select(
 db.person.name, count, groupby=db.person.name):
 print row.person.name, row[count]
 Alex 2
 Bob 1

 I don't understand what is the purpose of the count here, and is this 
 count related to the count above.




-- 

--- 
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: Use DAL connection pool for MongoDB?

2013-04-25 Thread mjm
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 hide comments column (w2p_fc) from SQLFORM.grid() when edit some record

2013-04-25 Thread Christian Espinoza

Thanks Mark!

-- 

--- 
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: Count and distinct

2013-04-25 Thread Anthony
db.person.id.count() returns an Expression object. It generates SQL like 
COUNT(person.id). When it is passed to the .select(), the count is 
returned as one of the columns in the result. The key used to identify the 
count column in each Row object of the result is the count SQL itself 
(i.e., COUNT(person.id)), so you can access the count in each row via:

row['COUNT(person.id)']

However, the __str__ method of the Expression object will also return the 
SQL, so you can instead do:

row[str(count)]

To make things even easier, if you pass an Expression object as the key to 
a Row, it will automatically apply the __str__ method, so you can just do:

row[count]

which is the method used in the book example.

Anthony

On Thursday, April 25, 2013 3:55:46 PM UTC-4, Domagoj Kovač wrote:

 count = db.person.id.count()

 I understand this line of code, it is obvious that limitby clause here 
 would be stupid.

  for row in db(db.person.id==db.thing.owner_id).select(
 db.person.name, count, groupby=db.person.name):
 print row.person.name, row[count]
 Alex 2
 Bob 1

 I don't understand what is the purpose of the count here, and is this 
 count related to the count above.




-- 

--- 
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: getting data from query with SQLFORM.grid

2013-04-25 Thread Christian Espinoza
Hi Massimo, I'm wondering how apply this change, I tried with the last
version, but isn't work yet,
I thought that was implemented in gluon\sqlhtml.py line 2242...

I'm trying to call it on this way:

grid = SQLFORM.grid()

return dict(form=form, grid=grid, license_plate=license_plate,
summary=show_summary(summary), help=help, rows=grid.rows)

but I got this error:

Versión

web2py™Version 2.4.6-stable+timestamp.2013.04.21.19.50.11
PythonPython 2.7.3: /usr/bin/python (prefix: /usr)

Traceback

Traceback (most recent call last):
  File /home/www-data/web2py/gluon/restricted.py, line 212, in restricted
exec ccode in environment
  File /home/www-data/web2py/applications/avl/controllers/reports.py,
line 426, in module
  File /home/www-data/web2py/gluon/globals.py, line 194, in lambda
self._caller = lambda f: f()
  File /home/www-data/web2py/applications/avl/controllers/reports.py,
line 336, in events
return dict(form=form, grid=grid, license_plate=license_plate,
summary=show_summary(summary), help=help, rows=grid.rows)
AttributeError: 'DIV' object has no attribute 'rows'

Error snapshot

type 'exceptions.AttributeError'('DIV' object has no attribute 'rows')

Thanks for your time.
Christian.

2013/4/9 Massimo Di Pierro massimo.dipie...@gmail.com:
 h... looks like the rows are not stored. I can easily change and allow
 you to do:


 grid = SQLFORM.grid(...)
 grid.rows = 

 it would contain the records you see on the page only. Would this be ok?
 Pros/Cons?


 On Tuesday, 9 April 2013 10:12:57 UTC-5, Christian Espinoza wrote:

 Hi Massimo, I'm rendering a grid in a view and I'm need add a graph to it,
 maybe using flot js lib
 the graph will need the same grid data, and I'm wondering how get the row
 data without running a query only for the graphs
 and taking advantage from the raw data used by SQLFORM.grid()...

 Christian.




 El martes, 9 de abril de 2013 11:14:50 UTC-3, Massimo Di Pierro escribió:

 I do not understand the question. :-(

 On Tuesday, 9 April 2013 08:38:48 UTC-5, Christian Espinoza wrote:

 Hi guys, I'm answering how can I take advantage from SQLFORM.grid in
 order to get aditionally the data from the query
 something like:

 SQLFORM.grid():
 .
 .
 return (htmlcode, rawrows)


  grid, rows = SQLFORM.grid(query,fields=campos,
  editable=False,
  searchable=False,
  deletable=False,
  create=False,
  details=False,
  user_signature=False,
  orderby=db_events.events.event_datetime
  )

 There are something working like that?

 Thanks in advance.
 Christian.

 --

 ---
 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/Q6bEe_rscFw/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: onvalidation in SQLFORM.grid (V2.0.9)

2013-04-25 Thread Martín Miranda
Hiding  errors in SQLFORM.grid?

for example:
form = SQLFORM(db.table):
if form.accepts(request.vars, hideerror=True):
   

In SQLFORM.grid?

El viernes, 14 de septiembre de 2012 08:25:45 UTC-3, Gerd escribió:

 Hi!

 I receive the following error

 Traceback (most recent call last):
   File /home/gniemetz/webapps/web2py/web2py/gluon/restricted.py, line 209, 
 in restricted
 exec ccode in environment
   File 
 /home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py
  https://tauchbuch.niemetz.it/admin/edit/tauchbuch/controllers/default.py, 
 line 92, in module
   File /home/gniemetz/webapps/web2py/web2py/gluon/globals.py, line 186, in 
 lambda
 self._caller = lambda f: f()
   File /home/gniemetz/webapps/web2py/web2py/gluon/tools.py, line 2809, in f
 return action(*a, **b)
   File 
 /home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py
  https://tauchbuch.niemetz.it/admin/edit/tauchbuch/controllers/default.py, 
 line 16, in index
 if grid.errors:
 AttributeError: 'DIV' object has no attribute 'errors'



 This is the controller

 @auth.requires_login()
 def index():
 grid = SQLFORM 
 https://web2py.niemetz.it/examples/global/vars/SQLFORM.grid(db.Logbuch,fields=[db.Logbuch.Datum,db.Logbuch.Kurs,db.Logbuch.Thema,db.Logbuch.Kommentar],maxtextlength=50,orderby=[~db.Logbuch.Datum],onvalidation=check_km)
 if grid.errors:
 response 
 https://web2py.niemetz.it/examples/global/vars/response.flash = 'Bitte 
 Eingaben überprüfen'
 return locals()

 def check_km(form):
 if form.vars.KM_Beginn = form.vars.KM_Ende:
 form.errors.KM_Ende = 'KM-Stand Ende kleiner/gleich KM-Stand Beginn'


 What i'm trying to do is to set response.flash

 What am i doing wrong here?

 Thanks,
 regards
 Gerd




-- 

--- 
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: seems to be a bug in dal v 2.4.2

2013-04-25 Thread Massimo Di Pierro
= is now in trunk but one cannot do

query  = date_field  4/1/13 and 4/5/13

On Thursday, 25 April 2013 13:16:52 UTC-5, Niphlod wrote:

 prepare a table model and a select() to reproduce the issue please...

 PS: I'm not sure that = is recommended/supported.


-- 

--- 
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: Load testing Web2py application under GAE using gatling: session cookie is not recogonized

2013-04-25 Thread Aravindan Rs
I raised the issue https://code.google.com/p/web2py/issues/detail?id=1462

Thanks and warm regards,
Aravindan.

On Wednesday, 24 April 2013 09:54:01 UTC+5:30, Massimo Di Pierro wrote:

 This is reasonable request and we may be able to accommodate it. Please 
 open a ticket on google code.

 http://code.google.com/p/web2py/issues/

 so it gets tracked.

 On Tuesday, 23 April 2013 21:06:08 UTC-5, Aravindan Rs wrote:

 Hello,

 I have deployed my web2py application on Google app engine. I'm trying to 
 use Gatling (http://gatling-tool.org/) for load testing my web 
 application. Just accessing my home page (which is a static page with a few 
 images and links) exhausts my free quota of DB write operations per day. 

 On further debugging I realized that each request was creating a new 
 session record in the table web2py_session_appname table. 

 Investigating the HTTP request and response traces from my Gatling 
 client, I see that the client is setting the Cookie parameter 
 (session_id_appname) correctly in the request - same as the one sent by 
 my web2py app in the Set-Cookie parameter of the last response. The 
 SetCookie value sent back by server is enclosed in double quote (). The 
 Cookie sent from client also contains double quote. 

 The code in gluons/globals.py tries to parse the cookie value using 
 below line of code:

 (record_id, unique_key) = response.session_id.split(':')

 The record_id now contains a double quote - so the record is not found in 
 db and a new session record is created each time.

 *I privately modified the globals.py code to use underscore ('_') 
 instead of colon (':') as delimiter in the session cookie - the cookie no 
 more contains double quote and the problem is solved.*

 Please note that this problem is faced only when I use gatling; using 
 normal browsers (chrome, FF, IE) does not result is new session record 
 created each time. I think the problem is due to the way gatling is 
 handling double quote in as part of cookie value. Also when I test with my 
 local web2py instance with gatling, the problem is not faced as session 
 cookies which are stored as files in file system does not contain ':' and 
 hence no double quoting.

 I don't see yet a way to modify gatling. 

 *My question to web2py community:*
 Do you see it as a fair request to change the delimiter used in DB 
 session cookies from ':' to something else (e.g. _) so that cookies are not 
 double quoted - this will accommodate also clients which know only to 
 handle 'cookie version 0'.

 If this is an acceptable change, where should raise my request / 
 contribute my changes?

 Thanks and warm regards,
 Aravindan.



-- 

--- 
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: seems to be a bug in dal v 2.4.2

2013-04-25 Thread Anthony
On Thursday, April 25, 2013 7:11:17 PM UTC-4, Massimo Di Pierro wrote:

 = is now in trunk but one cannot do


I think it's always been possible to do = with Query objects because the 
__and__ method is defined. What was recently added was __rand__ and 
__ror__, which according to 
http://docs.python.org/2/reference/datamodel.html#emulating-numeric-types 
allows 
binary operations with swapped operands. So, if you have A  B, and A 
doesn't implement the __and__ method but B implements the __rand__ method, 
then it will execute B.__rand__(A). Not sure what the use case is for 
queries, though.

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: seems to be a bug in dal v 2.4.2

2013-04-25 Thread Cliff Kachinske
The = is working on other query clauses, just not the ones I said were 
giving problems.

I'll get dal.py from trunk tomorrow AM and try it.

@Massimo, perhaps I wasn't clear.  This query  = date_field  4/1/13 and 
4/5/13 stuff isn't what I wrote, it's what dal.py emitted.

On Thursday, April 25, 2013 9:29:19 PM UTC-4, Anthony wrote:

 On Thursday, April 25, 2013 7:11:17 PM UTC-4, Massimo Di Pierro wrote:

 = is now in trunk but one cannot do


 I think it's always been possible to do = with Query objects because the 
 __and__ method is defined. What was recently added was __rand__ and 
 __ror__, which according to 
 http://docs.python.org/2/reference/datamodel.html#emulating-numeric-types 
 allows 
 binary operations with swapped operands. So, if you have A  B, and A 
 doesn't implement the __and__ method but B implements the __rand__ method, 
 then it will execute B.__rand__(A). Not sure what the use case is for 
 queries, though.

 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] recaptcha in custom forms

2013-04-25 Thread 黄祥
hi

is it possible to use recaptcha in custom forms?
i've already tested it but it return an error :
Traceback

1.
2.
3.
4.
5.
6.
7.
8.

Traceback (most recent call last):
  File /home/stifank/Desktop/web2py/gluon/restricted.py, line 212, in 
restricted
exec ccode in environment
  File 
/home/stifank/Desktop/web2py/applications/stifix/views/default/contact_us.html,
 line 164, in module
  File /home/stifank/Desktop/web2py/gluon/tools.py, line 732, in __init__
self.remote_addr = request.env.remote_addr
AttributeError: 'NoneType' object has no attribute 'env'


the things that i've done :
*models/db.py*
db.define_table('contact_us',
Field('name', notnull=True),
Field('email', notnull=True),
Field('phone', notnull=True),
Field('address', 'text', notnull=True),
Field('city', notnull=True),
Field('messages', 'text', notnull=True),
format='%(email)s %(name)s')

from gluon.tools import Recaptcha
db.contact_us.captcha = Recaptcha(request,
'PUBLIC_KEY', 'PRIVATE_KEY')

*controllers/default.py*
def contact_us():
form=SQLFORM(db.contact_us)
if form.process().accepted:
response.flash = T('messages sent')
elif form.errors:
response.flash = T('there is an error in the form')
else:
response.flash = T('please fill out the form')
return dict(form=form)

*views/default/contact_us.html*
{{=form.custom.begin}}
table
tbody
tr
td{{=DIV(B(T(form.custom.label.name), SPAN(' *', 
_style='color:red')))}}
{{=DIV(form.custom.widget.name)}}
/td
td{{=DIV(B(T(form.custom.label.email), SPAN(' *', 
_style='color:red')))}}
{{=DIV(form.custom.widget.email)}}
/td
/tr
tr
td{{=DIV(B(T(form.custom.label.phone), SPAN(' *', 
_style='color:red')))}}
{{=DIV(form.custom.widget.phone)}}
/td
td{{=DIV(B(T(form.custom.label.city), SPAN(' *', 
_style='color:red')))}}
{{=DIV(form.custom.widget.city)}}
/td
/tr
tr
td colspan=2{{=DIV(B(T(form.custom.label.address), SPAN(' *', 
_style='color:red')))}}
{{=DIV(form.custom.widget.address)}}
/td
/tr
tr
td colspan=2{{=DIV(B(T(form.custom.label.messages), SPAN(' 
*', _style='color:red')))}}
{{=DIV(form.custom.widget.messages)}}
/td
/tr
tr
*td colspan=2{{=DIV(Recaptcha(error_message='invalid', 
label='Verify:', options='theme:white, lang:fr'))}}*
*/td*
/tr
tr
td colspan=2{{=DIV(form.custom.submit)}}
/td
/tr
/tbody
/table
{{=form.custom.end}}

did anyone knows how to achieve it?
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: twitter error using recipe from admin page

2013-04-25 Thread 黄祥
it's work now, thank you so much for your hint leonel. for the recipe in 
admin page it seems have limitation, because when i use it, no tweets 
showed up, when i use the twitter widget it can 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.




[web2py] Re: seems to be a bug in dal v 2.4.2

2013-04-25 Thread Massimo Di Pierro
I do not think the problem is == but the data you are comparing (a date 
with a string).

On Thursday, 25 April 2013 21:13:09 UTC-5, Cliff Kachinske wrote:

 The = is working on other query clauses, just not the ones I said were 
 giving problems.

 I'll get dal.py from trunk tomorrow AM and try it.

 @Massimo, perhaps I wasn't clear.  This query  = date_field  4/1/13 and 
 4/5/13 stuff isn't what I wrote, it's what dal.py emitted.

 On Thursday, April 25, 2013 9:29:19 PM UTC-4, Anthony wrote:

 On Thursday, April 25, 2013 7:11:17 PM UTC-4, Massimo Di Pierro wrote:

 = is now in trunk but one cannot do


 I think it's always been possible to do = with Query objects because the 
 __and__ method is defined. What was recently added was __rand__ and 
 __ror__, which according to 
 http://docs.python.org/2/reference/datamodel.html#emulating-numeric-types 
 allows 
 binary operations with swapped operands. So, if you have A  B, and A 
 doesn't implement the __and__ method but B implements the __rand__ method, 
 then it will execute B.__rand__(A). Not sure what the use case is for 
 queries, though.

 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.