[web2py] Strikethrough with MARKMIN

2011-12-27 Thread lyn2py
How do I strikethrough some text using MARKMIN?

It's not available in the book, but I noticed that MARKMIN has a
strikethrough attribute.

Thanks!


[web2py] Re: need help with xmlrpclib

2011-12-27 Thread pbreit
In the first, you are POSTing directly to ereceipts-server.com. In the 
second, the request is going through a different server, however it is 
specified in your Transport() function.

We might need to see your Transport() function. Are you able to determine 
if web2py is returning the 400 error or the web server? Is it generating an 
error in the web2py error logs? Is the POST even making it to the 
ereceipts-server.com server? Or it could be failing at the proxy server.

Proxy situations are difficult to debug. While it's good to know what your 
server is sending, it's much better to know what the proxy server is 
sending and what the destination server is receiving.


[web2py] Using powertable plugin emits deprecation warning for me -- is it just me?

2011-12-27 Thread nick name
I suspect not, I've filed bug 581 ( 
http://code.google.com/p/web2py/issues/detail?id=581 )

But I haven't seen any other reports of this. Am I doing something wrong?


[web2py] Re: How to add link for downloading CSV file with specifying filename

2011-12-27 Thread Brian M
Yep, Alan's suggestion is what I use too.  See 
https://groups.google.com/d/topic/web2py/qjTF3_wHlWQ/discussion for some 
more details on how I do it


[web2py] Re: Error after upgrading - column auth_user.registration_id does not exist -

2011-12-27 Thread lyn2py
auth.user_id
or
auth_user.id
might be what you're looking for


On Dec 28, 7:42 am, "david.waldrop"  wrote:
> I just upgraded to web2py 1.99 for an app that have been operational for
> over a year and now get the following error.  I have looked at all the code
> and cannot find a reference to registration_id and am not ysing any custom
> auth.   Any help or ideas where to look next would be greatly appreciated???
>
> TICKET ID
>
> 108.45.61.175.2011-12-27.17-29-47.014c5022-dacd-41c5-b997-d4a63c907e7e
>  column auth_user.registration_id does
> not exist LINE 1: ...r.registration_key, auth_user.reset_password_key,
> auth_user ^VERSIONweb2py™(1, 99, 4, datetime.datetime(2011, 12, 14, 14,
> 46, 14), 'stable')PythonPython 2.7.1: /usr/local/bin/pythonTRACEBACK
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
>
> Traceback (most recent call last):
>   File "/home/dlwatey/webapps/web2py/web2py/gluon/restricted.py", line 204, 
> in restricted
>     exec ccode in environment
>   File 
> "/home/dlwatey/webapps/web2py/web2py/applications/init/controllers/default. 
> py" 
> , 
> line 75, in 
>   File "/home/dlwatey/webapps/web2py/web2py/gluon/globals.py", line 172, in 
> 
>     self._caller = lambda f: f()
>   File 
> "/home/dlwatey/webapps/web2py/web2py/applications/init/controllers/default. 
> py" 
> , 
> line 52, in user
>     return dict(form=auth())
>   File "/home/dlwatey/webapps/web2py/web2py/gluon/tools.py", line 1141, in 
> __call__
>     return getattr(self,args[0])()
>   File "/home/dlwatey/webapps/web2py/web2py/gluon/tools.py", line 1703, in 
> login
>     user = self.db(table_user[username] == 
> form.vars[username]).select().first()
>   File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 6333, in 
> select
>     return self.db._adapter.select(self.query,fields,attributes)
>   File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 1282, in 
> select
>     rows = response(sql)
>   File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 1272, in 
> response
>     self.execute(sql)
>   File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 1359, in 
> execute
>     return self.log_execute(*a, **b)
>   File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 1353, in 
> log_execute
>     ret = self.cursor.execute(*a, **b)
> ProgrammingError: column auth_user.registration_id does not exist
> LINE 1: ...r.registration_key, auth_user.reset_password_key, auth_user


[web2py] Re: Is this possible?

2011-12-27 Thread lyn2py
Thank you Joseph and Jonathan - I'll look into the methods you both
suggested! :)

On Dec 27, 11:39 pm, Jonathan Lundell  wrote:
> On Dec 27, 2011, at 2:49 AM, lyn2py wrote:
>
>
>
>
>
>
>
>
>
> > I already have in routes.py:
> > routers = dict(
> >    BASE = dict(
> >        default_controller='default',
> >        default_function='index'
> >    )
> > )
>
> > How should my code be organized so that I can achieve:
> > website.com/items --> shows all the items
> > website.com/items/127 --> displays details of item #127
>
> > Right now, it's being done this way:
> > website.com/items --> shows all the items
> > website.com/items/display/127 --> displays details of item #127
>
> > Must the changes be made to routes.py or can the code base be slightly
> > modified to achieve it?
>
> An easy way is to put the item number in a query string: website.com/items?127
>
> Another way would be to use the function default/items instead of items/index.
>
> If you really, really want items to be a controller and have the URL syntax 
> you're looking for, use something like this:
>
> routers = dict(
>    yourapp = dict(
>        functions = { 'items' : ['index', ... ] }
>    )
> )
>
> The idea is that you need to inform the router of the function names in the 
> items controller.
>
> Suggestion: website.com/item/127 looks a little more natural than items/127, 
> at least to me. Easiest to do by putting your code in default/item and 
> default/items.


[web2py] Re: Advanced Live Search

2011-12-27 Thread Anthony
On Tuesday, December 27, 2011 6:19:23 PM UTC-5, smirghor wrote:
>
> Hi Anthony. 
> Thanks for your answer. I seem to be unable to replicate what you 
> said. How do you test if the checkboxes are checked? 
>

Should just be:

if request.vars.title:

etc. 


[web2py] Error after upgrading - column auth_user.registration_id does not exist -

2011-12-27 Thread david.waldrop
I just upgraded to web2py 1.99 for an app that have been operational for 
over a year and now get the following error.  I have looked at all the code 
and cannot find a reference to registration_id and am not ysing any custom 
auth.   Any help or ideas where to look next would be greatly appreciated???

TICKET ID

108.45.61.175.2011-12-27.17-29-47.014c5022-dacd-41c5-b997-d4a63c907e7e
 column auth_user.registration_id does 
not exist LINE 1: ...r.registration_key, auth_user.reset_password_key, 
auth_user ^VERSIONweb2py™(1, 99, 4, datetime.datetime(2011, 12, 14, 14, 
46, 14), 'stable')PythonPython 2.7.1: /usr/local/bin/pythonTRACEBACK

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.

Traceback (most recent call last):
  File "/home/dlwatey/webapps/web2py/web2py/gluon/restricted.py", line 204, in 
restricted
exec ccode in environment
  File 
"/home/dlwatey/webapps/web2py/web2py/applications/init/controllers/default.py" 
, 
line 75, in 
  File "/home/dlwatey/webapps/web2py/web2py/gluon/globals.py", line 172, in 

self._caller = lambda f: f()
  File 
"/home/dlwatey/webapps/web2py/web2py/applications/init/controllers/default.py" 
, 
line 52, in user
return dict(form=auth())
  File "/home/dlwatey/webapps/web2py/web2py/gluon/tools.py", line 1141, in 
__call__
return getattr(self,args[0])()
  File "/home/dlwatey/webapps/web2py/web2py/gluon/tools.py", line 1703, in login
user = self.db(table_user[username] == form.vars[username]).select().first()
  File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 6333, in select
return self.db._adapter.select(self.query,fields,attributes)
  File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 1282, in select
rows = response(sql)
  File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 1272, in 
response
self.execute(sql)
  File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 1359, in execute
return self.log_execute(*a, **b)
  File "/home/dlwatey/webapps/web2py/web2py/gluon/dal.py", line 1353, in 
log_execute
ret = self.cursor.execute(*a, **b)
ProgrammingError: column auth_user.registration_id does not exist
LINE 1: ...r.registration_key, auth_user.reset_password_key, auth_user






[web2py] Re: Advanced Live Search

2011-12-27 Thread smirghor
I figured this work if I have the name attributes for the checkboxes
(and in my case the name attributes are the same as the id
attributes). Thanks again!


On Dec 27, 5:19 pm, smirghor  wrote:
> Hi Anthony.
> Thanks for your answer. I seem to be unable to replicate what you
> said. How do you test if the checkboxes are checked?
>
> On Dec 27, 2:16 pm, Anthony  wrote:
>
>
>
>
>
>
>
> > You can submit multiple inputs (via id) with the ajax() function, so if you
> > give your checkbox inputs id's (e.g., id='title' and id='body'), you should
> > be able to do:
>
> > ajax('callback', ['keyword', 'title', 'body'], 'target')
>
> > and in the controller, access request.vars.keyword, request.vars.title, and
> > request.vars.body (I think title and body will be None if they are not
> > checked).
>
> > Anthony
>
> > On Tuesday, December 27, 2011 2:29:56 PM UTC-5, smirghor wrote:
>
> > > In the example in chapter 3 of the book, mywiki application we have:
>
> > > def search():
> > >      "an ajax wiki search page"
> > >      return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
> > >               _onkeyup="ajax('callback', ['keyword'], 'target');")),
> > >               target_div=DIV(_id='target'))
>
> > > def callback():
> > >      "an ajax callback that returns a  of links to wiki pages"
> > >      query = db.page.title.contains(request.vars.keyword)
> > >      pages = db(query).select(orderby=db.page.title)
> > >      links = [A(p.title, _href=URL('show',args=p.id)) for p in pages]
> > >      return UL(*links)
>
> > > Assume that we would like to search a keyword both in the title and
> > > the body of the wiki in the following manner:
> > > 1. The default search searches in the title and body both.
> > > 2. We have two check boxes with the attribute name set to "title" and
> > > "body" respectively. Initially both are checked. But the user can
> > > uncheck one of them to request the application to search only in the
> > > other field. What is the best way to achieve this?
>
> > > Specifically, if I add two checkboxes to the search function return
> > > expression, i.e.:
> > > INPUT(_type="checkbox", _name="title" ), "Title",
> > > INPUT(_type="checkbox", _name="body"), "Body",
> > > how I can check whether they are checked or not from within the
> > > callback function? I'd like to use these two checkboxes to express
> > > which fields of the database should be searched.


[web2py] Re: Advanced Live Search

2011-12-27 Thread smirghor
Hi Anthony.
Thanks for your answer. I seem to be unable to replicate what you
said. How do you test if the checkboxes are checked?


On Dec 27, 2:16 pm, Anthony  wrote:
> You can submit multiple inputs (via id) with the ajax() function, so if you
> give your checkbox inputs id's (e.g., id='title' and id='body'), you should
> be able to do:
>
> ajax('callback', ['keyword', 'title', 'body'], 'target')
>
> and in the controller, access request.vars.keyword, request.vars.title, and
> request.vars.body (I think title and body will be None if they are not
> checked).
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, December 27, 2011 2:29:56 PM UTC-5, smirghor wrote:
>
> > In the example in chapter 3 of the book, mywiki application we have:
>
> > def search():
> >      "an ajax wiki search page"
> >      return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
> >               _onkeyup="ajax('callback', ['keyword'], 'target');")),
> >               target_div=DIV(_id='target'))
>
> > def callback():
> >      "an ajax callback that returns a  of links to wiki pages"
> >      query = db.page.title.contains(request.vars.keyword)
> >      pages = db(query).select(orderby=db.page.title)
> >      links = [A(p.title, _href=URL('show',args=p.id)) for p in pages]
> >      return UL(*links)
>
> > Assume that we would like to search a keyword both in the title and
> > the body of the wiki in the following manner:
> > 1. The default search searches in the title and body both.
> > 2. We have two check boxes with the attribute name set to "title" and
> > "body" respectively. Initially both are checked. But the user can
> > uncheck one of them to request the application to search only in the
> > other field. What is the best way to achieve this?
>
> > Specifically, if I add two checkboxes to the search function return
> > expression, i.e.:
> > INPUT(_type="checkbox", _name="title" ), "Title",
> > INPUT(_type="checkbox", _name="body"), "Body",
> > how I can check whether they are checked or not from within the
> > callback function? I'd like to use these two checkboxes to express
> > which fields of the database should be searched.


[web2py] Re: How to add link for downloading CSV file with specifying filename

2011-12-27 Thread Alan Etkin
One way would be to modify the response.headers object in the
controller with the customized filename.

response.headers["Content-Disposition"] = "attachment;Filename=%s.doc"
% 

And then return the csv data

The user's click would call the web2py action to return de csv (you
can define it in the view)

The web2py book uses this statement (10.1.6) to specify the content:
response.headers['Content-Type']='application/vnd.ms-excel'


On 27 dic, 16:50, thstart  wrote:
> I generate CSV content ready to use as a .csv file; don't use a database
> and have a function to do that.
>
> I want this .csv file to be available for download after click and
> the filename to be set from the application.
>
> How to do that in web2py?


[web2py] Re: web2py sitting behind load balancer showing lb IP not client IP

2011-12-27 Thread Dave
I already said I can't change settings on the load balancer.  There is
no default route on this network so the traffic must be sourced from
the inside interface of the load balancer as it hits the web server.

Here's the problem:

diff -r 9619eb054669 gluon/globals.py
--- a/gluon/globals.py  Tue Dec 27 10:16:19 2011 -0600
+++ b/gluon/globals.py  Tue Dec 27 17:07:00 2011 -0500
@@ -548,7 +548,7 @@

 (record_id_name, table, record_id, unique_key) = \
 response._dbtable_and_field
-dd = dict(locked=False, client_ip=request.env.remote_addr,
+dd = dict(locked=False, client_ip=request.client.replace(':',
'.'),
   modified_datetime=request.now,
   session_data=cPickle.dumps(dict(self)),
   unique_key=unique_key)

The code for storing sessions on disk was using request.client which
checks http_x_forwarded_for before using remote_addr.  The code for
writing the session to database was just using remote_addr which was
always showing my private IP of the load balancer.  The above patch
should take care of it.

Thanks,
Dave

On Dec 23, 7:40 pm, pbreit  wrote:
> What web server are you running? On Nginx there's a module to take the
> x-forwarded-for and make it the client ip.
>
> http://wiki.nginx.org/HttpRealIpModule


[web2py] Re: new appliances - Happy Holidays

2011-12-27 Thread Omi Chiba
Oh, my app for final project is there !
:)

On Dec 21, 10:12 pm, Massimo Di Pierro 
wrote:
> I finally did it. I cleaned upappliances; deleted the very old ones;
> upgraded some old ones; fixed some; added some good ones. They all
> work now with the latest web2py. I moved them all on githup.
>
> http://web2py.com/applianceshttps://github.com/mdipierro/web2py-appliances
>
> Eachappliancescomes prepackaged (w2p) with screenshots. Each app as
> an ABOUT file that needs to be edited. This is on my TODO list but I
> could use your help.
>
> I will take patches. ;-)
>
> I am planning a better interface to this github repo that will list
> screenshots. Perhaps tomorrow
>
> Happy Holidays everybody.
>
> Massimo


[web2py] Re: How to make a function to download a file?

2011-12-27 Thread Anthony
Maybe try writing the content to a StringIO object and using 
response.stream (see http://web2py.com/books/default/chapter/29/4#response).

Anthony

On Thursday, December 22, 2011 10:09:04 PM UTC-5, thstart wrote:
>
> I want the visitors to be able to download a CSV file.
>
> here is my code:
> def download():
> response.headers['Content-Type'] = 'text/csv'
> attachment = 'attachment;filename=' + file+ '.csv'
> response.headers['Content-Disposition'] = attachment
> 
> content = ',,'
> raise HTTP(200,str(content),
>**{'Content-Type':'text/csv',
>   'Content-Disposition':attachment + ';'})
>
> When I click on the link download, I get 'Undefined' in the browser
> and nothing is downloaded.
>
> What is wrong?
>
>

[web2py] Re: Record Versioning

2011-12-27 Thread JF
Hi,
 
I was working on 1.99.4, Cleaned the Application, Packed it to give it a 
try with 1.99.3.
 
It actually worked correctly with 1.99.3.  But it turns out that it is 
the Clean up that fixed the problem.
 
Probably that the few modifications I made to the tables corrupted the 
database.
 
Knowing that, I will always do a Clean up after modifying anything in the 
tables.
 
Thanks,
 
JF


[web2py] Re: How to debug web service

2011-12-27 Thread Alan Etkin
Have you read the request data processed by the web2py service? You
could send it to a log, store it in db or just print it on the
standard output (in development) with the print command for comparing
the strings.

On 27 dic, 13:09, Mirek Zvolský  wrote:
> I have problem with web2py web 
> servicehttps://groups.google.com/forum/#!searchin/web2py/xmlrpclib/web2py/gZ...
>
> and I received no answer here in google group.
> OK, it is my problem.
>
> But, can somebody teach me or give some starting ideas, how to do debugging
> of such problems ?
> Thanks


[web2py] Re: How to debug web service

2011-12-27 Thread Alan Etkin
I also think the problem is the rpc client code, since the request
output looks the same in both cases. Why do you create a new Transport
instance instead of leaving the default value?

On Dec 27, 1:09 pm, Mirek Zvolský  wrote:
> I have problem with web2py web 
> servicehttps://groups.google.com/forum/#!searchin/web2py/xmlrpclib/web2py/gZ...
>
> and I received no answer here in google group.
> OK, it is my problem.
>
> But, can somebody teach me or give some starting ideas, how to do debugging
> of such problems ?
> Thanks


[web2py] Re: Advanced Live Search

2011-12-27 Thread Anthony
You can submit multiple inputs (via id) with the ajax() function, so if you 
give your checkbox inputs id's (e.g., id='title' and id='body'), you should 
be able to do:

ajax('callback', ['keyword', 'title', 'body'], 'target')

and in the controller, access request.vars.keyword, request.vars.title, and 
request.vars.body (I think title and body will be None if they are not 
checked).

Anthony

On Tuesday, December 27, 2011 2:29:56 PM UTC-5, smirghor wrote:
>
> In the example in chapter 3 of the book, mywiki application we have: 
>
> def search(): 
>  "an ajax wiki search page" 
>  return dict(form=FORM(INPUT(_id='keyword',_name='keyword', 
>   _onkeyup="ajax('callback', ['keyword'], 'target');")), 
>   target_div=DIV(_id='target')) 
>
> def callback(): 
>  "an ajax callback that returns a  of links to wiki pages" 
>  query = db.page.title.contains(request.vars.keyword) 
>  pages = db(query).select(orderby=db.page.title) 
>  links = [A(p.title, _href=URL('show',args=p.id)) for p in pages] 
>  return UL(*links) 
>
>
> Assume that we would like to search a keyword both in the title and 
> the body of the wiki in the following manner: 
> 1. The default search searches in the title and body both. 
> 2. We have two check boxes with the attribute name set to "title" and 
> "body" respectively. Initially both are checked. But the user can 
> uncheck one of them to request the application to search only in the 
> other field. What is the best way to achieve this? 
>
> Specifically, if I add two checkboxes to the search function return 
> expression, i.e.: 
> INPUT(_type="checkbox", _name="title" ), "Title", 
> INPUT(_type="checkbox", _name="body"), "Body", 
> how I can check whether they are checked or not from within the 
> callback function? I'd like to use these two checkboxes to express 
> which fields of the database should be searched. 
>
>
>
>
>

[web2py] Advanced Live Search

2011-12-27 Thread smirghor
In the example in chapter 3 of the book, mywiki application we have:

def search():
 "an ajax wiki search page"
 return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
  _onkeyup="ajax('callback', ['keyword'], 'target');")),
  target_div=DIV(_id='target'))

def callback():
 "an ajax callback that returns a  of links to wiki pages"
 query = db.page.title.contains(request.vars.keyword)
 pages = db(query).select(orderby=db.page.title)
 links = [A(p.title, _href=URL('show',args=p.id)) for p in pages]
 return UL(*links)


Assume that we would like to search a keyword both in the title and
the body of the wiki in the following manner:
1. The default search searches in the title and body both.
2. We have two check boxes with the attribute name set to "title" and
"body" respectively. Initially both are checked. But the user can
uncheck one of them to request the application to search only in the
other field. What is the best way to achieve this?

Specifically, if I add two checkboxes to the search function return
expression, i.e.:
INPUT(_type="checkbox", _name="title" ), "Title",
INPUT(_type="checkbox", _name="body"), "Body",
how I can check whether they are checked or not from within the
callback function? I'd like to use these two checkboxes to express
which fields of the database should be searched.






[web2py] How to add link for downloading CSV file with specifying filename

2011-12-27 Thread thstart
I generate CSV content ready to use as a .csv file; don't use a database 
and have a function to do that.

I want this .csv file to be available for download after click and 
the filename to be set from the application.

How to do that in web2py?


[web2py] Re: How to make a function to download a file?

2011-12-27 Thread thstart
I don't use a database to create the CSV content but generate is as a comma 
delimited text. Also I want to set the file name to be downloaded.

I don't see how to do it from the book.

This line has to be changed in order to work:

raise HTTP(200,str(content),
   **{'Content-Type':'text/csv',
  'Content-Disposition':attachment + ';'})




[web2py] Re: how to remove duplicate tables in smartgrid?

2011-12-27 Thread Cliff
I don't know what you're trying to do, but maybe you should read this
http://web2py.com/books/default/chapter/29/6#Self-Reference-and-aliases

If you have products A, B and C; and, B and C relate to A; then that's
what you need to read.

> Any way to prevent this?
Yes.  Don't refer to the product table twice in your related product
table.




On Dec 26, 7:18 am, Jim Gregory  wrote:
> I am creating an application that has a one-to-many table that
> references the same table twice:
>
> db.define_table('product',
>     Field('title', required=True, unique=True),
>     Field('sku', required = True, unique=True),
>     Field('description', 'text'),
>     format = '%(title)s'
>     )
>
> db.define_table('related_product',
>     Field('product_id', db.product, writable=False),
>     Field('product', 'reference product'),
>         )
>
> If I create a smartgrid on the 'product' table using:
> def product():
>     return dict(grid=SQLFORM.smartgrid(
>         db.product,
>         linked_tables=['related_product'],
>         ))
>
> the "related_product" table appears twice because it references the
> "product" table twice.  Any way to prevent this?
>
> -Jim


Re: [web2py] Web Service - Connect from Andriod App

2011-12-27 Thread Jonathan Lundell
On Dec 27, 2011, at 9:05 AM, Bruce Wade wrote:

> Every device will have it's own login, just like every member has their own 
> login. The accounts would be created on the website/server.
> 
> On Tue, Dec 27, 2011 at 9:00 AM, Jonathan Lundell  wrote:
> On Dec 27, 2011, at 8:47 AM, Bruce Wade wrote:
> 
>> I am planing a web2py web services that will allow my custom android app to 
>> communicate together. My primary concern is how would I secure it? IE: Have 
>> it so applications need to login in order to interact? Any documentation you 
>> can point me to would be helpful.
>> 
> 
> Will each device have its own login account? How will the account be created 
> (from the app? on the website?)?
> 

I'd consider using JSON-RPC or XML-RPC and basic auth.

Here's a thread dealing with a bug in that process that has some useful 
examples: https://groups.google.com/forum/#!topic/web2py/lLCCUrwB5x0

Depending on how secure you need to be, https might be a good idea as well.

[web2py] Re: Wifi Tags.

2011-12-27 Thread Mchurch
Many thanks!! I'll keep You updated guys!

On 27 Dic, 14:33, Khalil KHAMLICHI  wrote:
> Yep, you can use pycurl (which has support for cookies) to query the AP and
> load the data into some db with eventually : Ap_name, timestamp, . . . And
> other fields.


[web2py] Re: Instant press 2.1.0 holiday edition (?)

2011-12-27 Thread Alan Etkin
Yes, I should update. I'll ask the system admin (Mariano Reingart) to
do so.

On 26 dic, 23:50, Martín Mulone  wrote:
> Requirement:   you need at least version 1.99.4
>
> Actualizá alan ese web2py es muy viejo.
>
> 2011/12/26 Alan Etkin 
>
>
>
> > Here is the last error created (after the service was recovered and
> > tried to access instant press app, i am not the server admin and have
> > no access to the system except by the web2py admin interface)
>
> > web2py™         Version 1.94.6 (2011-03-27 18:20:38)
> > Python  Python 2.5.2: /usr/bin/python
> > Traceback
>
> > Traceback (most recent call last):
> >  File "/home/web2py/gluon/restricted.py", line 188, in restricted
> >    exec ccode in environment
> >  File "/home/web2py/applications/ipress/models/00main.py", line 18,
> > in 
> >    from appsettings import app_settings
> > ImportError: No module named appsettings
>
> > Regards
>
> > On 26 dic, 22:43, Martín Mulone  wrote:
> > > Any hint or traceback?.
>
> > > 2011/12/26 Alan Etkin 
>
> > > > Good work Martin. Thanks
>
> > > > I tried to load the installer with appadmin on a production server and
> > > > the server stopped working :/
> > > > Anyway, i don't think it is related to instant press issues.
>
> > > > By the way, i think the admin access is hard to find in the default
> > > > view for logged-in users. Maybe it could be emphazised (of course,
> > > > that is a really small detail)
>
> > > > On 26 dic, 16:49, Ovidio Marinho  wrote:
> > > > > Revolviendo la discursion del post new Post:
>
> > > > > no momiento en que se fixa la noticia en Body la primieira viez e en
> > > > > Extarct en primera viez, se tienes en la view principal home la
> > noticia
> > > > em
> > > > > body e um boton (leia mas) que se lhama a url extract. En segunda
> > viez
> > > > que
> > > > > actualizo el browse el boton leia mas nao mas se apresenta. Isto es
> > a si
> > > > > miesmo ou ha algo errado.?
>
> > > > > By the time we type the news we have two choices and body extract, I
> > > > > realized thatwhen we put the first time the news on the main page
> > shows
> > > > a read
> > > > > more button.But if this update the Browse button does not appear
> > again,
> > > > this
> > > > >  is normal or is something wrong?
>
> > > > >        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
>
> > > > >                         Apóio
>
> > > > > 2011/12/26 Martín Mulone 
>
> > > > > > ckeditor, tinyMCE, etc all WYSIWYG web editor are xhtml output.
> > None of
> > > > > > the them support markup languages.
>
> > > > > > 2011/12/26 Ovidio Marinho 
>
> > > > > >>       Would not it be better to use the CKEditor as to insert
> > photos
> > > > into
> > > > > >>  a new pageneeds to address in localhost?
>
> > > > > >>        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
>
> > > > > >>                         Apóio
>
> > > > > >> 2011/12/26 Martín Mulone 
>
> > > > > >>> The "Admin" password is only showed the first time, when the
> > user is
> > > > > >>> created (because is random generated). Delete all the content
> > inside
> > > > > >>> "databases" folder. And point again to localhost:8000/app/.
>
> > > > > >>> You have to see something like this (attached)
>
> > > > > >>> 2011/12/26 Ovidio Marinho 
>
> > > > >  Once we enter the administrator password is not shown in the
> > Main
> > > > Menu
>
> > > > >         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
>
> > > > >                          Apóio
>
> > > > >  2011/12/26 Martín Mulone 
>
> > > > > > fixed. Sorry, try again.
>
> > > > > > 2011/12/26 Marin Pranjić 
>
> > > > > >> On Mon, Dec 26, 2011 at 3:21 PM, Martín Mulone <
> > > > > >> mulone.mar...@gmail.com> wrote:
>
> > > > > >>> Instant press is not dead, I update it to vesion 2.1.0
> > holiday
> > > > > >>> edition (?).
>
> > > > > >>> *What's new?.*
> > > > > >>> Hierarchy pages to menu, now working.
> > > > > >>> Now layout is based in getskeleton. New design. New panel.
> > > > > >>> Fix bugs.
> > > > > >>> Added edit link to page, and articles

[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Cliff
My bad.

The problem was self inflicted, caused by a diagnostic change I made
to html.py.

On Dec 27, 12:07 pm, Cliff  wrote:
> Done.
>
> Thanks.
>
> On Dec 27, 11:36 am, Anthony  wrote:
>
>
>
>
>
>
>
> > Can you open a ticket:http://code.google.com/p/web2py/issues/list


Re: [web2py] Web Service - Connect from Andriod App

2011-12-27 Thread Bruce Wade
Every device will have it's own login, just like every member has their own
login. The accounts would be created on the website/server.

On Tue, Dec 27, 2011 at 9:00 AM, Jonathan Lundell wrote:

> On Dec 27, 2011, at 8:47 AM, Bruce Wade wrote:
>
> I am planing a web2py web services that will allow my custom android app
> to communicate together. My primary concern is how would I secure it? IE:
> Have it so applications need to login in order to interact? Any
> documentation you can point me to would be helpful.
>
>
> Will each device have its own login account? How will the account be
> created (from the app? on the website?)?
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Cliff
Done.

Thanks.

On Dec 27, 11:36 am, Anthony  wrote:
> Can you open a ticket:http://code.google.com/p/web2py/issues/list


[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Anthony
I think you want format='%(dog_name)s' -- there is no 'name' field in the 
'dog' table.

Anthony

On Tuesday, December 27, 2011 11:11:18 AM UTC-5, Cliff wrote:
>
> This is kind of a show stopper.  Smartgrid appears to stumble over 
> table format definitions. 
>
> Note the commented out format line in this model. 
> db.define_table('dog', 
> Field('dog_name', length=32), 
> ##format='%(name)s', 
>) 
> db.define_table('owner', 
> Field('name', length=32), 
> Field('phone', length=32), 
>) 
> db.define_table('dog_owner', 
> Field('dog_id', db.dog), 
> Field('owner_id', db.owner) 
>) 
>
> Uncomment the line and smartgrid 1.99.4 raises this exception when 
> trying to 
> add a record to the dog_owner table: 
>  string indices must be integers, not str 
>
> Here is the traceback: 
> Traceback (most recent call last): 
>   File "/home/cjk/w-99-4/web2py/gluon/restricted.py", line 204, in 
> restricted 
> exec ccode in environment 
>   File "/home/cjk/w-99-4/web2py/applications/doggies/controllers/ 
> dog.py", line 5, in  
>   File "/home/cjk/w-99-4/web2py/gluon/globals.py", line 172, in 
>  
> self._caller = lambda f: f() 
>   File "/home/cjk/w-99-4/web2py/applications/doggies/controllers/ 
> dog.py", line 2, in index 
> form = SQLFORM.smartgrid(db.dog) 
>   File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 1991, in 
> smartgrid 
> user_signature=user_signature,**kwargs) 
>   File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 1581, in grid 
> _class='web2py_form').process( 
>   File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 862, in 
> __init__ 
> inp = self.widgets.options.widget(field, default) 
>   File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 220, in widget 
> return SELECT(*opts, **attr) 
>   File "/home/cjk/w-99-4/web2py/gluon/html.py", line 587, in __init__ 
> self._postprocessing() 
>   File "/home/cjk/w-99-4/web2py/gluon/html.py", line 1704, in 
> _postprocessing 
> if value and str(c['_value'])==str(value): 
> TypeError: string indices must be integers, not str 
>
> Here is the controller: 
> def index(): 
> form = SQLFORM.smartgrid( 
> db.owner, 
> ui = 'jquery-ui', 
> onvalidation = crud.archive, 
> ) 
> return dict(form=form) 
>
> To duplicate the problem: 
> Add one owner and one dog. 
> In your browser, open localhost:8000/dogapp/owner/index 
> Edit the owner. 
> Click the Dog Owner link 
> Note the empty grid with add button. 
> Click Add 
> Observe web2py error message 
>
> Similar exceptions occur if you use IS_IN_DB to define a format 
> string. 
>
>

Re: [web2py] Web Service - Connect from Andriod App

2011-12-27 Thread Jonathan Lundell
On Dec 27, 2011, at 8:47 AM, Bruce Wade wrote:

> I am planing a web2py web services that will allow my custom android app to 
> communicate together. My primary concern is how would I secure it? IE: Have 
> it so applications need to login in order to interact? Any documentation you 
> can point me to would be helpful.
> 

Will each device have its own login account? How will the account be created 
(from the app? on the website?)?

[web2py] smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Cliff
This is kind of a show stopper.  Smartgrid appears to stumble over
table format definitions.

Note the commented out format line in this model.
db.define_table('dog',
Field('dog_name', length=32),
##format='%(name)s',
   )
db.define_table('owner',
Field('name', length=32),
Field('phone', length=32),
   )
db.define_table('dog_owner',
Field('dog_id', db.dog),
Field('owner_id', db.owner)
   )

Uncomment the line and smartgrid 1.99.4 raises this exception when
trying to
add a record to the dog_owner table:
 string indices must be integers, not str

Here is the traceback:
Traceback (most recent call last):
  File "/home/cjk/w-99-4/web2py/gluon/restricted.py", line 204, in
restricted
exec ccode in environment
  File "/home/cjk/w-99-4/web2py/applications/doggies/controllers/
dog.py", line 5, in 
  File "/home/cjk/w-99-4/web2py/gluon/globals.py", line 172, in

self._caller = lambda f: f()
  File "/home/cjk/w-99-4/web2py/applications/doggies/controllers/
dog.py", line 2, in index
form = SQLFORM.smartgrid(db.dog)
  File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 1991, in
smartgrid
user_signature=user_signature,**kwargs)
  File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 1581, in grid
_class='web2py_form').process(
  File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 862, in
__init__
inp = self.widgets.options.widget(field, default)
  File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 220, in widget
return SELECT(*opts, **attr)
  File "/home/cjk/w-99-4/web2py/gluon/html.py", line 587, in __init__
self._postprocessing()
  File "/home/cjk/w-99-4/web2py/gluon/html.py", line 1704, in
_postprocessing
if value and str(c['_value'])==str(value):
TypeError: string indices must be integers, not str

Here is the controller:
def index():
form = SQLFORM.smartgrid(
db.owner,
ui = 'jquery-ui',
onvalidation = crud.archive,
)
return dict(form=form)

To duplicate the problem:
Add one owner and one dog.
In your browser, open localhost:8000/dogapp/owner/index
Edit the owner.
Click the Dog Owner link
Note the empty grid with add button.
Click Add
Observe web2py error message

Similar exceptions occur if you use IS_IN_DB to define a format
string.



[web2py] How to debug web service

2011-12-27 Thread Mirek Zvolský
I have problem with web2py web service
https://groups.google.com/forum/#!searchin/web2py/xmlrpclib/web2py/gZA0J6LXa4w/Cpbnz5hjKmkJ

and I received no answer here in google group.
OK, it is my problem.

But, can somebody teach me or give some starting ideas, how to do debugging 
of such problems ?
Thanks


[web2py] Re: Record Versioning

2011-12-27 Thread Massimo Di Pierro
This should work. Which version? If you have the bug with the latest
version please open a ticket in google code.

On Dec 27, 2:55 am, JF  wrote:
> Have another issue.  It seems the datetime in my archive will always be the
> datetime of creation of the initial record, not the updates.
>
> Here is a glimpse of the Model:
> --- 
> ---
> db.define_table('part',
>     Field('iditm', db.item),
>     Field('idbsn', db.business),
>     Field('mpn', 'string'),
>     Field('created_on', 'datetime', default=request.now,
> update=request.now, readable=False, writable=False),
>     Field('created_by', db.auth_user, default=auth.user_id, readable=False,
> writable=False))
>
> db.define_table('part_archive',
>     Field('current_record', db.part), db.part)
> --- 
> ---
>
> And here is a glimpse of the Controller:
>
> --- 
> ---
> @auth.requires_login()
> def edit():
>     "edit an existing mpn page"
>     thispage = db.part[request.args(0)]
>     if not thispage:
>         redirect(URL(r=request, f='index'))
>
>     form = crud.update(db.part, thispage, onaccept=auth.archive,
>         next = URL(r=request, f='edit', args=request.args),
>         deletable = False)
>    archive = db(db.part_archive.current_record==thispage.id).select()
>    return dict(form=form, thispage=thispage, archive=archive)
>
> --- 
> ---
>
> I thought the "update=request.now" in the Model would update the Field
> 'created_on'.
>
> What would be a good way to update this field whenever the Record is
> updated?  I want to archive the datetime a table is updated.
>
> Thanks,
>
> JF


[web2py] Re: smartgrid and auth.archive() ugly code; how to improve?

2011-12-27 Thread Anthony
What if you do:

SQLFORM.smartgrid(..., oncreate=crud.archive, onupdate=crud.archive)

or

SQLFORM.smartgrid(..., onupdate=lambda form: crud.archive(form, 
archive_current=False))

Note, archive_current=False tells it to archive the previous record (the 
one being updated) rather than the current record (the updated version).

Anthony

On Tuesday, December 27, 2011 10:54:35 AM UTC-5, Cliff wrote:
>
> This also works SQLFORM.smartgrid(..., onvalidation=crud.archive... 
>
> But, I now discover archive never saves the original record.  You can 
> edit the record and it saves the edits, but it never gets the first 
> version of it. 
>
> This statement from the Official Book"on updating, it stores a copy of 
> the record (as it was before the update)" is incorrect, at least as 
> far as smartgrid is concerned.  I haven't tried it with SQLFORM by 
> itself or with CRUD. 
>
> On Dec 27, 9:38 am, Anthony  wrote: 
> > Have you tried: 
> > 
> > form = SQLFORM.smartgrid(..., onupdate=auth.archive) 
> > 
> > Also, note there is also crud.archive, which is the same as 
> auth.archive. 
> > 
> > Anthony 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Tuesday, December 27, 2011 7:22:34 AM UTC-5, Cliff wrote: 
> > 
> > > This is some ugly code that makes auth.archive() work with smartgrid: 
> > 
> > > if len(request.args) > 3 and request.args[-4] == 'owner' and\ 
> > >request.args[-3] == 'edit' and request.args[-2]=='owner'\ 
> > >and form[2].process(onsuccess=auth.archive).accepted: 
> > > pass 
> > 
> > > Surely there must be a better way.  Any and all hints gratefully 
> > > accepted.



[web2py] Web Service - Connect from Andriod App

2011-12-27 Thread Bruce Wade
Hi,

I am planing a web2py web services that will allow my custom android app to
communicate together. My primary concern is how would I secure it? IE: Have
it so applications need to login in order to interact? Any documentation
you can point me to would be helpful.

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: smartgrid and auth.archive() ugly code; how to improve?

2011-12-27 Thread Cliff
Setting archive_current=False works.

Thank you.

On Dec 27, 11:09 am, Anthony  wrote:
> What if you do:
>
> SQLFORM.smartgrid(..., oncreate=crud.archive, onupdate=crud.archive)
>
> or
>
> SQLFORM.smartgrid(..., onupdate=lambda form: crud.archive(form,
> archive_current=False))
>
> Note, archive_current=False tells it to archive the previous record (the
> one being updated) rather than the current record (the updated version).
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, December 27, 2011 10:54:35 AM UTC-5, Cliff wrote:
>
> > This also works SQLFORM.smartgrid(..., onvalidation=crud.archive...
>
> > But, I now discover archive never saves the original record.  You can
> > edit the record and it saves the edits, but it never gets the first
> > version of it.
>
> > This statement from the Official Book"on updating, it stores a copy of
> > the record (as it was before the update)" is incorrect, at least as
> > far as smartgrid is concerned.  I haven't tried it with SQLFORM by
> > itself or with CRUD.
>
> > On Dec 27, 9:38 am, Anthony  wrote:
> > > Have you tried:
>
> > > form = SQLFORM.smartgrid(..., onupdate=auth.archive)
>
> > > Also, note there is also crud.archive, which is the same as
> > auth.archive.
>
> > > Anthony
>
> > > On Tuesday, December 27, 2011 7:22:34 AM UTC-5, Cliff wrote:
>
> > > > This is some ugly code that makes auth.archive() work with smartgrid:
>
> > > > if len(request.args) > 3 and request.args[-4] == 'owner' and\
> > > >        request.args[-3] == 'edit' and request.args[-2]=='owner'\
> > > >        and form[2].process(onsuccess=auth.archive).accepted:
> > > >         pass
>
> > > > Surely there must be a better way.  Any and all hints gratefully
> > > > accepted.


[web2py] Re: Parsing of username field during register

2011-12-27 Thread Anthony
Note, this should be fixed in trunk now. By default, IS_MATCH will simply 
check for a match but will not extract the matching substring (it will 
return the entire original value). If you do IS_MATCH(extract=True), then 
it will extract only the matching substring (which was the old, incorrect, 
behavior).

Anthony

On Friday, December 23, 2011 10:46:12 AM UTC-5, Anthony wrote:
>
> By default, the 'username' field gets the following validators:
>
> (IS_MATCH('[\w\.\-]+'), IS_NOT_IN_DB(db, table.username))
>
> The IS_MATCH is doing the truncating. Actually, I think that's a bug -- 
> IS_MATCH isn't supposed to transform the input, only check the regex 
> pattern. For now, though, I suppose you could overwrite that tuple with 
> your own validators:
>
> auth.settings.table_user.username.requires = [IS_MATCH('[\w\.\- ]+'),
> IS_NOT_IN_DB(db, auth.settings.table_user.username)]
>
> Note, I added a space to the IS_MATCH regex.
>
> Anthony
>
> On Friday, December 23, 2011 10:11:44 AM UTC-5, greenguerilla wrote:
>>
>> Hi, 
>>
>> I noticed something strange when testing the registration of users. 
>>
>> If I attempt to register as user: 'My Name' (note the space), the form 
>> validation passes and I get an 'email sent' message. 
>> What actually happens though, is the the username gets inserted into 
>> the db as 'my'. 
>> I'm fine with the lowercasing but I would rather strip the spaces and 
>> insert the user as 'myname' 
>> I have been searching for a hook to do this and I have tried the two 
>> methods: 
>>
>> auth.settings.register_onvalidation = clean_username 
>> auth.settings.register_onaccept = clean_username 
>>
>> Where 'clean_username' is a function to strip all the spaces from the 
>> entered text. 
>> My problem is that the username has already been stripped by the time 
>> it gets this far. Strangely enough this doesn't happen for the 
>> username field in the login form. 
>>
>> Does anywhere know where this might be happening and how I can 
>> override it? 
>>
>> Thanks, 
>>
>> John 
>>
>

[web2py] Re: Bug in widget.py: lack type='int' in new added --socket-timeout param

2011-12-27 Thread Massimo Di Pierro
Thanks I changed to 60secs by default and type casted to int as you
suggested.

On Dec 27, 2:39 am, evantan  wrote:
> In version 1.99.4,  socket-timeout was added to start params, which is very
> needed to  tuning socket.settimeout in rocket.py. The default value 1
> second often lead to " (timed out) " error in a
> slow network,such as WAN than LAN.
>
> But  in widget.py line 557:
>
>     parser.add_option('--socket-timeout',
>                       default=1,
>                       dest='socket_timeout',
>                       help='timeout for socket (1 second)')
>
> lack a type to cast this param.Should be:
>
>     parser.add_option('--socket-timeout',
>                       default=1,
>                       type='int',
>                       dest='socket_timeout',
>                       help='timeout for socket (1 second)')
>
> This bug lead to deadly exceptions(see below) when set "python web2py.py
> ... --socket-timeout=60 ..." in start time:
>
> -->Traceback
> Exception in thread Thread-8:
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.7/threading.py", line 552, in
> __bootstrap_inner
>     self.run()
>   File "/home/git/web2py/gluon/rocket.py", line 1282, in run
>     conn = Connection(*conn)
>   File "/home/git/web2py/gluon/rocket.py", line 130, in __init__
>     self.socket.settimeout(SOCKET_TIMEOUT)
>   File "/usr/local/lib/python2.7/socket.py", line 224, in meth
>     return getattr(self._sock,name)(*args)
> TypeError: a float is required
> <-Traceback


[web2py] Re: Book translation

2011-12-27 Thread Massimo Di Pierro
You will soon be able to do this online.

On Dec 27, 10:03 am, Mirek Zvolský  wrote:
> I want start translation of the book 4th edition (czech language).
> Can I read somewhere hints, how to do it?
> Idea: Can we have menu item in web2py.com/book (Translations?) with such
> hints?


[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Anthony
Can you open a ticket: http://code.google.com/p/web2py/issues/list



[web2py] Re: How to use response.optimize_css?

2011-12-27 Thread szimszon
My bad. The css files aren't in response.files :-o


[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Cliff
I get the same error with the correct field name.

On Dec 27, 11:15 am, Anthony  wrote:
> I think you want format='%(dog_name)s' -- there is no 'name' field in the
> 'dog' table.
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, December 27, 2011 11:11:18 AM UTC-5, Cliff wrote:
>
> > This is kind of a show stopper.  Smartgrid appears to stumble over
> > table format definitions.
>
> > Note the commented out format line in this model.
> > db.define_table('dog',
> >                 Field('dog_name', length=32),
> > ##                format='%(name)s',
> >                )
> > db.define_table('owner',
> >                 Field('name', length=32),
> >                 Field('phone', length=32),
> >                )
> > db.define_table('dog_owner',
> >                 Field('dog_id', db.dog),
> >                 Field('owner_id', db.owner)
> >                )
>
> > Uncomment the line and smartgrid 1.99.4 raises this exception when
> > trying to
> > add a record to the dog_owner table:
> >  string indices must be integers, not str
>
> > Here is the traceback:
> > Traceback (most recent call last):
> >   File "/home/cjk/w-99-4/web2py/gluon/restricted.py", line 204, in
> > restricted
> >     exec ccode in environment
> >   File "/home/cjk/w-99-4/web2py/applications/doggies/controllers/
> > dog.py", line 5, in 
> >   File "/home/cjk/w-99-4/web2py/gluon/globals.py", line 172, in
> > 
> >     self._caller = lambda f: f()
> >   File "/home/cjk/w-99-4/web2py/applications/doggies/controllers/
> > dog.py", line 2, in index
> >     form = SQLFORM.smartgrid(db.dog)
> >   File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 1991, in
> > smartgrid
> >     user_signature=user_signature,**kwargs)
> >   File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 1581, in grid
> >     _class='web2py_form').process(
> >   File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 862, in
> > __init__
> >     inp = self.widgets.options.widget(field, default)
> >   File "/home/cjk/w-99-4/web2py/gluon/sqlhtml.py", line 220, in widget
> >     return SELECT(*opts, **attr)
> >   File "/home/cjk/w-99-4/web2py/gluon/html.py", line 587, in __init__
> >     self._postprocessing()
> >   File "/home/cjk/w-99-4/web2py/gluon/html.py", line 1704, in
> > _postprocessing
> >     if value and str(c['_value'])==str(value):
> > TypeError: string indices must be integers, not str
>
> > Here is the controller:
> > def index():
> >     form = SQLFORM.smartgrid(
> >         db.owner,
> >         ui = 'jquery-ui',
> >         onvalidation = crud.archive,
> >     )
> >     return dict(form=form)
>
> > To duplicate the problem:
> > Add one owner and one dog.
> > In your browser, open localhost:8000/dogapp/owner/index
> > Edit the owner.
> > Click the Dog Owner link
> > Note the empty grid with add button.
> > Click Add
> > Observe web2py error message
>
> > Similar exceptions occur if you use IS_IN_DB to define a format
> > string.


[web2py] Book translation

2011-12-27 Thread Mirek Zvolský
I want start translation of the book 4th edition (czech language).
Can I read somewhere hints, how to do it?
Idea: Can we have menu item in web2py.com/book (Translations?) with such 
hints?


[web2py] Re: Unittest vs other tests in web2py

2011-12-27 Thread Anthony
A few resources:

http://packages.python.org/web2py_utils/test_runner.html
http://www.web2pyslices.com/slices/take_slice/142
http://web2py.com/AlterEgo/default/show/260

Anthony

On Tuesday, December 27, 2011 3:26:25 AM UTC-5, lyn2py wrote:
>
> Hello guys, 
>
> My application is growing bigger and I may not be able to "hand test" 
> each component of the application as it grows. 
>
> I was wondering if you are using any testing libraries or devices on 
> web2py, what you recommend and how is your experience with it? 
>
> I am looking for something easy to use ...just like web2py :) 
>
> I have not done any testing before, and I am completely new to this. 
> Any advice is appreciated. 
>
> Thanks!



[web2py] Re: smartgrid and auth.archive() ugly code; how to improve?

2011-12-27 Thread Cliff
This also works SQLFORM.smartgrid(..., onvalidation=crud.archive...

But, I now discover archive never saves the original record.  You can
edit the record and it saves the edits, but it never gets the first
version of it.

This statement from the Official Book"on updating, it stores a copy of
the record (as it was before the update)" is incorrect, at least as
far as smartgrid is concerned.  I haven't tried it with SQLFORM by
itself or with CRUD.

On Dec 27, 9:38 am, Anthony  wrote:
> Have you tried:
>
> form = SQLFORM.smartgrid(..., onupdate=auth.archive)
>
> Also, note there is also crud.archive, which is the same as auth.archive.
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, December 27, 2011 7:22:34 AM UTC-5, Cliff wrote:
>
> > This is some ugly code that makes auth.archive() work with smartgrid:
>
> > if len(request.args) > 3 and request.args[-4] == 'owner' and\
> >        request.args[-3] == 'edit' and request.args[-2]=='owner'\
> >        and form[2].process(onsuccess=auth.archive).accepted:
> >         pass
>
> > Surely there must be a better way.  Any and all hints gratefully
> > accepted.


Re: [web2py] Is this possible?

2011-12-27 Thread Jonathan Lundell
On Dec 27, 2011, at 2:49 AM, lyn2py wrote:

> I already have in routes.py:
> routers = dict(
>BASE = dict(
>default_controller='default',
>default_function='index'
>)
> )
> 
> How should my code be organized so that I can achieve:
> website.com/items --> shows all the items
> website.com/items/127 --> displays details of item #127
> 
> Right now, it's being done this way:
> website.com/items --> shows all the items
> website.com/items/display/127 --> displays details of item #127
> 
> Must the changes be made to routes.py or can the code base be slightly
> modified to achieve it?

An easy way is to put the item number in a query string: website.com/items?127

Another way would be to use the function default/items instead of items/index. 

If you really, really want items to be a controller and have the URL syntax 
you're looking for, use something like this:

routers = dict(
   yourapp = dict(
   functions = { 'items' : ['index', ... ] }
   )
)

The idea is that you need to inform the router of the function names in the 
items controller.

Suggestion: website.com/item/127 looks a little more natural than items/127, at 
least to me. Easiest to do by putting your code in default/item and 
default/items.

[web2py] Re: smartgrid and auth.archive() ugly code; how to improve?

2011-12-27 Thread Anthony
Have you tried:

form = SQLFORM.smartgrid(..., onupdate=auth.archive)

Also, note there is also crud.archive, which is the same as auth.archive.

Anthony

On Tuesday, December 27, 2011 7:22:34 AM UTC-5, Cliff wrote:
>
> This is some ugly code that makes auth.archive() work with smartgrid: 
>
> if len(request.args) > 3 and request.args[-4] == 'owner' and\ 
>request.args[-3] == 'edit' and request.args[-2]=='owner'\ 
>and form[2].process(onsuccess=auth.archive).accepted: 
> pass 
>
>
> Surely there must be a better way.  Any and all hints gratefully 
> accepted.



Re: [web2py] Re: Wifi Tags.

2011-12-27 Thread Khalil KHAMLICHI
Yep, you can use pycurl (which has support for cookies) to query the AP and
load the data into some db with eventually : Ap_name, timestamp, . . . And
other fields.


[web2py] smartgrid and auth.archive() ugly code; how to improve?

2011-12-27 Thread Cliff
This is some ugly code that makes auth.archive() work with smartgrid:

if len(request.args) > 3 and request.args[-4] == 'owner' and\
   request.args[-3] == 'edit' and request.args[-2]=='owner'\
   and form[2].process(onsuccess=auth.archive).accepted:
pass


Surely there must be a better way.  Any and all hints gratefully
accepted.


[web2py] Re: Is this possible?

2011-12-27 Thread Joseph Jude
Your code base should be adjusted. Both Anthony & Jonathan helped me with 
similar problem for me.

Here is my 
routes.py: 
https://bitbucket.org/id804097/minnaedu/src/570149716878/webapp/routes.py
here is my 
controller/index: 
https://bitbucket.org/id804097/minnaedu/src/570149716878/webapp/applications/init/controllers/default.py

here is the final application: minnaedu.appspot.com

Hope these help

Joseph


[web2py] Is this possible?

2011-12-27 Thread lyn2py
I already have in routes.py:
routers = dict(
BASE = dict(
default_controller='default',
default_function='index'
)
)

How should my code be organized so that I can achieve:
website.com/items --> shows all the items
website.com/items/127 --> displays details of item #127

Right now, it's being done this way:
website.com/items --> shows all the items
website.com/items/display/127 --> displays details of item #127

Must the changes be made to routes.py or can the code base be slightly
modified to achieve it?

Thanks!


[web2py] Re: Wifi Tags.

2011-12-27 Thread Alan Etkin
Great, i missed that feature. That way you would need to fire Access
Point requests periodically to update the device list from the web2py
server

On Dec 27, 3:54 am, Khalil KHAMLICHI 
wrote:
> I guess you could connect to the WIFI AP and query them for connected
> hosts. (but still have to use request.client to know whos who)
>
> You will need to parse the pages from Wifi ap to get your information.


[web2py] Bug in widget.py: lack type='int' in new added --socket-timeout param

2011-12-27 Thread evantan
In version 1.99.4,  socket-timeout was added to start params, which is very 
needed to  tuning socket.settimeout in rocket.py. The default value 1 
second often lead to " (timed out) " error in a 
slow network,such as WAN than LAN.

But  in widget.py line 557:

parser.add_option('--socket-timeout',
  default=1,
  dest='socket_timeout',
  help='timeout for socket (1 second)')

lack a type to cast this param.Should be:

parser.add_option('--socket-timeout',
  default=1,
  type='int',
  dest='socket_timeout',
  help='timeout for socket (1 second)')


This bug lead to deadly exceptions(see below) when set "python web2py.py 
... --socket-timeout=60 ..." in start time:  

-->Traceback 
Exception in thread Thread-8:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/threading.py", line 552, in 
__bootstrap_inner
self.run()
  File "/home/git/web2py/gluon/rocket.py", line 1282, in run
conn = Connection(*conn)
  File "/home/git/web2py/gluon/rocket.py", line 130, in __init__
self.socket.settimeout(SOCKET_TIMEOUT)
  File "/usr/local/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
TypeError: a float is required
<-Traceback


[web2py] Re: Record Versioning

2011-12-27 Thread lyn2py
JF, did you try to remove "default=request.now" from "created_on"?

On Dec 27, 4:55 pm, JF  wrote:
> Have another issue.  It seems the datetime in my archive will always be the
> datetime of creation of the initial record, not the updates.
>
> Here is a glimpse of the Model:
> --- 
> ---
> db.define_table('part',
>     Field('iditm', db.item),
>     Field('idbsn', db.business),
>     Field('mpn', 'string'),
>     Field('created_on', 'datetime', default=request.now,
> update=request.now, readable=False, writable=False),
>     Field('created_by', db.auth_user, default=auth.user_id, readable=False,
> writable=False))
>
> db.define_table('part_archive',
>     Field('current_record', db.part), db.part)
> --- 
> ---
>
> And here is a glimpse of the Controller:
>
> --- 
> ---
> @auth.requires_login()
> def edit():
>     "edit an existing mpn page"
>     thispage = db.part[request.args(0)]
>     if not thispage:
>         redirect(URL(r=request, f='index'))
>
>     form = crud.update(db.part, thispage, onaccept=auth.archive,
>         next = URL(r=request, f='edit', args=request.args),
>         deletable = False)
>    archive = db(db.part_archive.current_record==thispage.id).select()
>    return dict(form=form, thispage=thispage, archive=archive)
>
> --- 
> ---
>
> I thought the "update=request.now" in the Model would update the Field
> 'created_on'.
>
> What would be a good way to update this field whenever the Record is
> updated?  I want to archive the datetime a table is updated.
>
> Thanks,
>
> JF


[web2py] Re: Record Versioning

2011-12-27 Thread JF
Have another issue.  It seems the datetime in my archive will always be the 
datetime of creation of the initial record, not the updates.
 
Here is a glimpse of the Model:
--
db.define_table('part',
Field('iditm', db.item),
Field('idbsn', db.business),
Field('mpn', 'string'),
Field('created_on', 'datetime', default=request.now, 
update=request.now, readable=False, writable=False),
Field('created_by', db.auth_user, default=auth.user_id, readable=False, 
writable=False))
 
db.define_table('part_archive',
Field('current_record', db.part), db.part)
--
 
And here is a glimpse of the Controller:
 
 
--
@auth.requires_login()
def edit():
"edit an existing mpn page"
thispage = db.part[request.args(0)]
if not thispage:
redirect(URL(r=request, f='index'))
 
form = crud.update(db.part, thispage, onaccept=auth.archive, 
next = URL(r=request, f='edit', args=request.args),
deletable = False)
   archive = db(db.part_archive.current_record==thispage.id).select()
   return dict(form=form, thispage=thispage, archive=archive)
 
--
 
I thought the "update=request.now" in the Model would update the Field 
'created_on'.
 
What would be a good way to update this field whenever the Record is 
updated?  I want to archive the datetime a table is updated.
 
Thanks,
 
JF
 


[web2py] Unittest vs other tests in web2py

2011-12-27 Thread lyn2py
Hello guys,

My application is growing bigger and I may not be able to "hand test"
each component of the application as it grows.

I was wondering if you are using any testing libraries or devices on
web2py, what you recommend and how is your experience with it?

I am looking for something easy to use ...just like web2py :)

I have not done any testing before, and I am completely new to this.
Any advice is appreciated.

Thanks!