[web2py] Re: Possibly a problem with CAS redirection in v2.8.2

2014-01-03 Thread Tim Richardson
My issue 1840 is the same thing

On Friday, 3 January 2014 04:02:03 UTC+11, Vinicius Assef wrote:

 I've just opened a ticket about it: 
 http://code.google.com/p/web2py/issues/detail?id=1841 

 On Tue, Dec 24, 2013 at 9:12 AM, Vinicius Assef 
 vinic...@gmail.comjavascript: 
 wrote: 
  Anyone? 
  
  On Fri, Dec 20, 2013 at 6:05 PM, Vinicius Assef 
  vinic...@gmail.comjavascript: 
 wrote: 
  Hi guys, 
  I'm playing around with CAS and faced this error: 
   begin here  
  The webpage at 
 http://localhost:8000/cas/default/user/cas/login?service=http://localhost:8000/consumer/default/user/login#
  
  has resulted in too many redirects. Clearing your cookies for this 
  site or allowing third-party cookies may fix the problem. If not, it 
  is possibly a server configuration issue and not a problem with your 
  computer. 
  
  Error code: ERR_TOO_MANY_REDIRECTS 
   end here  
  
  It occurs in v2.8.2, but not in v2.7.4. 
  
  My scenario is simple: 
  1- One CAS provider application, called cas. Actually, a raw copy of 
  welcome application. Nothing more, nothing less. 
  2- One CAS consumer, called consumer. Another copy of welcome 
  application with just one single modification in db.py: 
  auth = Auth(db, cas_provider=
 http://localhost:8000/cas/default/user/cas;) 
  3- In consumer application, I have a default.py/protected() function 
  with @auth.requires_login() decorator. 
  
  The workflow to reproduce the error is: 
  1) Try to go to http://localhost:8000/consumer/protected. 
  2) The login form will show up (from cas application). 
  3) When I fill the form and click submit, the error happens. 
  
  Is there anything I must configure in v2.8.2 to allow CAS to work out? 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Virtual field for latitude and longitude from geometry field?

2014-01-03 Thread Paolo Valleri
st_*() are db engine functions, you should query the db to get the output 
you are looking for. Given that, in your virtual field you should make a 
new query, something like that:

Field.Virtual('latitude', lambda row: db(db.location.id == row.location.id).
select(db.location.point.st_x()).first()[db.location.point.st_x()]

Paolo

On Thursday, January 2, 2014 9:59:14 PM UTC+1, Christian Foster Howes wrote:

 i bet that by the time your lambda is running the point has been converted 
 to a string already.  can you see if that is true?  i'm not sure how to 
 invoke db functions in a lambda of a virtual field. :(

 On Wednesday, January 1, 2014 5:50:54 PM UTC-8, User wrote:

 Suppose I have a table like:

 db.define_table('location',
 Field(name, 'string'),
 Field('point', 'geometry()')
 )

 I want to have the latitude and longitude as attributes also (whose value 
 can be derived from the point field).  So I try this:

 db.define_table('location',
 Field(name, 'string'),
 Field('point', 'geometry()'),
 Field.Virtual('latitude', lambda row: row.location.point.st_x()),
 Field.Virtual('longitude', lambda row: row.location.point.st_y()),
 )

 But it doesn't work and fails silently.  The model just doesn't have 
 latitude or longitude fields. I also tried with Field.Method but this 
 complains that 'point' is of typer str.

 I guess the complication is that st_x() translates into a database 
 function.  I'm thinking about parsing the point string which is of the form 
 POINT(x y) as a workaround but I'd rather use st_x if someone can show me 
 how.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: OT: movuca internal error on comment

2014-01-03 Thread Alan Etkin
 

 that's what I get trying to add a comment to a post of mine.


Manuele, can you please try to add the comment now?
 


 Sorry but I didn't find a contact form on web2pyslices site.


We should add at least a link to this list for posting issues.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] question about SQLFORM.grid

2014-01-03 Thread Robert Bjornson
Hi all,

I am a newcomer to web2py, and have what I hope is a simple beginner 
question.

I am following the mywiki example in the getting started tutorial. In it, 
one can display all the documents for a page
using this url:

*http://127.0.0.1:8000/mywiki/default/documents/1*

*The controller for this page creates a SQLFORM.grid, using this code:*







*def documents(): browser, edit all documents attached to a certain 
page page = db.page(request.args(0,cast=int)) or 
redirect(URL('index')) db.document.page_id.default = page.id
 db.document.page_id.writable = False grid = 
SQLFORM.grid(db.document.page_id==page.id,args=[page.id]) return 
dict(page=page, grid=grid)When the page is rendered by the view, each row 
in the grid, representing a document, has three buttons: view, edit, 
delete.If I look at the action for these buttons I see that they are 
refinements of my current url.  For example edit 
is:http://127.0.0.1:8000/mywiki/default/documents/1/edit/document/1?_signature=75f1c501a80734585179ab4cafd9a8ac90ee7a51I
 
don't understand how this url is getting dispatched.  I would think it 
would go to default.py/documents(), with an args list of [1, edit,document, 
1], and vars of {_signature:75f1c501a80734585179ab4cafd9a8ac90ee7a51}But, 
I don't see any code in documents() that would handle this is the 
appropriate way.  From the page I end up on when I click edit, it seems 
like it's dispatching to mywiki/controllers/appadmin.py.  I can't figure 
out why it gets there.Thanks for your help.Rob *


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: GAE: defaults on _tableobj

2014-01-03 Thread Quint
I created an issue for this:

https://code.google.com/p/web2py/issues/detail?id=1842

On Thursday, January 2, 2014 6:45:59 PM UTC+1, Quint wrote:

 Hello everybody,

 Happy New Year!

 I'm using GAE and sometimes a need to call some GAE datastore functions 
 directly.

 (For instance when I want to supply a key_name when I put() an entity so 
 I can have better performance to get() that entity from db.
 Or when I want to use put_multi())

 Anyway, I can use the *_tableobj* property of the web2py table to 
 access the GAE model class.

 But, this class does not have the defaults applied to it's properties 
 while the Fields on the web2py table do.
 This means that when I put() my _tableobj instance (using GAE API) , the 
 defaults are not set in the database record.

 At the moment a call this function in my db model after each table 
 definition:


 @classmethod
 def set_defaults(cls, table):
 
 Takes a web2py table and sets the defaults of all Fields and sets
 those defaults on the associated properties of the tableobj
 (tableobj = the GAE model class associated with the web2py table)
 
 for propname, prop in table._tableobj._properties.iteritems():
 field = getattr(table, propname, None)
 if None != field and isinstance(field, Field):
 prop._default = field.default

 Can this (or something like this) be integrated in the create_table() 
 method of GoogleDatastoreAdapter() so it's done when the table gets created?

 Thanks,

 Regards

 Quint



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] SEO for multilingual web sites

2014-01-03 Thread Gael Princivalle
Hello all.

I've put on line my first web2py website, thanks to all for help.
It's native in English, with Italian translation. So I've got things like 
that:

Controller:
def products():
...
response.title = 'My web site' + ' -' + T('Products')
...

And in my views I load text from db like that:
...
{{if T.accepted_language=='it':}}
{{=(category.description_it)}}
{{else:}}
{{=(category.description_en)}}
{{pass}}
...

The problem seems to be that search engines take care only about English 
pages, and not Italian ones.
Perhaps it's normal, URL don't change if page is displayed in English or 
Italian.
Certainly I have to set language in routers.py for having different URL's 
depending of languages.

I've tried like that but I obtain always en in my URL, also if I display 
pages in Italian:
mydomain.com/en/products

I don't have /it/ also with the it language.

routers = dict(
BASE = dict(
domains = {
mydomain.com : myapp,
}
),
myapp = dict(
languages=['en', 'it'],
default_language=None
),
)

Here is how I manage language selection in menu:
In layout.html I append the language menu:
...
{{if response.menu:}}
{{if session.language is None:}}
{{session.language == T.accepted_language}}
{{pass}}
{{if session.language == 'it' or T.accepted_language == 'it':}}
{{response.menu.append(('IT', False, URL('default', 'it'), [('EN', 
False, URL('default', 'en'), [])]))}}
{{else:}}
{{response.menu.append(('EN', False, URL('default', 'en'), [('IT', 
False, URL('default', 'it'), [])]))}}
{{pass}}
{{=MENU(response.menu, _class='nav',li_class='dropdown',ul_class=
'dropdown-menu')}}
{{pass}}
...

In controller:
def it():
session.language = 'it'
if request.env.http_referer:
redirect(request.env.http_referer)
else:
redirect(URL('index'))
return dict()

def en():
session.language = 'en-us'
if request.env.http_referer:
redirect(request.env.http_referer)
else:
redirect(URL('index'))
return dict()

And in controller for every view at the beginning of functions I set my 
session.language variable:
def products():
if session.language:
T.force(session.language)
...

1/ How can I have /it/ instead of /en/ with Italian pages ?
2/ If I use a tool like that 
http://www.seoutility.com/it/tools/google/sitemap_generator.aspx does for 
sitemap.xml generation it will find also Italian pages ?

Thanks, regards.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: OT: movuca internal error on comment

2014-01-03 Thread Manuele Pesenti
Il 03/01/14 10:25, Alan Etkin ha scritto:
  

 that's what I get trying to add a comment to a post of mine.


 Manuele, can you please try to add the comment now?
here it is: http://www.web2pyslices.com/slice/showcomment/1500
anyway I found that in spite of the error I got yesterday the comment
has been already posted. That's way I added a new test comment.

Thanks

M.
  


 Sorry but I didn't find a contact form on web2pyslices site.


 We should add at least a link to this list for posting issues.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Grid back button for custom single view

2014-01-03 Thread Gael Princivalle
Yes, that's the fastest solution. I will tried first to call a different 
html page for the custom single record view page, instead of calling the 
same where I have the grid. Thanks a lot.

Il giorno domenica 29 dicembre 2013 18:28:06 UTC+1, Niphlod ha scritto:

 your problem is architectural: you just proved that you can't rely on the 
 referrer header to make the app behave like you'd wish. 
 Save the back url in a session variable and use that one instead ^_^

 On Sunday, December 29, 2013 4:02:48 PM UTC+1, Gael Princivalle wrote:

 Goog question.

 In fact initialy referer is my previous page (http:
 //.../default/products_listing?keywords=od), and after when the browser 
 load js and css files referer is my single view page (http:
 //.../default/products_listing/view/products/376?keywords=od).

 I think a way to resolve it is making a different html page for the 
 single row view. Have you got any suggestion ?

 Thanks.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] web2py running en AppFog

2014-01-03 Thread José Antonio López Lorenzo
DEMO: http://web2py.eu01.aws.af.cm/
EXPLANATION: http://jallander.wordpress.com/2014/01/03/web2py-en-appfog/
SERVER: https://www.appfog.com/

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: OT: movuca internal error on comment

2014-01-03 Thread Alan Etkin
 anyway I found that in spite of the error I got yesterday the comment has 
been already posted.

Ok, this is because the comment is commited before the buggy notification 
feature starts :P.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Error in Custom Register Page in web2py

2014-01-03 Thread Akash Agrawall
Have to define all the attributes in custom form otherwise it won't 
run... wasn't doing the same. define it as hidden if you don't want 
user to see them. !!

On Tuesday, December 31, 2013 5:54:34 PM UTC+5:30, Akash Agrawall wrote:

 Hie folks. When I click on submit button of the CUSTOM REGISTRATION 
 form. it redirects to the same page.. ?? No idea what this is 
 about.. 
 Controller: default.py
 def register():
 form=auth.register()
 form.add_button('Cancel', URL('register'))
 if form.accepts(request.vars,session):
 print did it
 response.flash=Your Registration request has been 
 successfully submitted
 redirect(URL('home'))
 elif form.errors:
 response.flash=Errors in form
 else:
 response.flash=nothing mah badd
 return dict(late=late, form=form)

 View: register.html
 {{extend 'layout.html'}}
 a href={{=URL('home')}}Home/a » Book Connect
 p style=font-family:Times New Roman;font-size:17px;
 We facilitate sharing of books with partner Schools, NGOs, community 
 centers, and shelter homes. 
 br/br/
 In case  you represent any of the above, please register with us as 
 partner to avail our book sharing program BookConnect. Once registered with 
 us, you can search through our book repository and request for the books. 
 /p
 br/
 {{=form.custom.begin}}
 table
 tr
 td style=width:51%;Namenbsp;span 
 style=color:red;*/span/tdtd {{=form.custom.widget.Name}}/td
 /tr
 tr
 td style=width:51%;Emailnbsp;span 
 style=color:red;*/span/tdtd {{=form.custom.widget.email}}/td
 /tr
 tr 
 td style=width:51%Passwordnbsp;span 
 style=color:red;*/span/tdtd {{=form.custom.widget.password}}/td
 /tr
 tr
 td style=width:45%Addressnbsp;span 
 style=color:red;/span/tdtd {{=form.custom.widget.Address}}/td
 /tr
 tr
 td style=width:45%Contact Personnbsp;span 
 style=color:red;/span/tdtd{{=form.custom.widget.Contact_person}}/td
 /tr
 tr
 td style=width:45%Contact No 1nbsp;span 
 style=color:red;*/span/tdtd{{=form.custom.widget.Contact_No_1}}/td
 /tr
 tr
 td style=width:45%Contact No 2nbsp;span 
 style=color:red;/span/tdtd{{=form.custom.widget.Contact_No_2}}/td
 /tr
 tr
 td style=width:45%Descriptionnbsp;span 
 style=color:red;/span/tdtd{{=form.custom.widget.Description}}/td
 /tr
 tr
 td 
 style=width:45%Websitenbsp;/tdtd{{=form.custom.widget.Website}}/td
 /tr
 tr
 td style=width:40%Date of 
 Request/tdtd{{=form.custom.widget.Date_of_request}}/td
 /tr
 tr style=visibility:hiddentd 
 style=width:40%Status/tdtd{{=form.custom.widget.Date_of_request}}/td/tr
 trtd{{=form.custom.submit}} 
!--a class=btn btn-default 
 href={{=URL('donate_book')}}Cancel/a--/td/tr
 /table
 {{=form.custom.end}}


 print form.errors - Storage {}
 pritn form.accepts(request.vars,session) - false


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: favicon problem

2014-01-03 Thread Gael Princivalle
Same cache problem also for me. Just replace .ico and .png files and test 
it in an anonymous browser window.

Il giorno domenica 17 giugno 2012 12:20:54 UTC+2, Paolo Caruccio ha scritto:

 In my case was a cache problem. Below the solution worked for me:

  1. below replacing files clear the cache of browsers (IE9, OP12, FF13, 
 CH19). Repeat the operation if needed.
  2. rename the default files (i.e.: __favicon.ico and __favicon.png
  3. put new files in static folder
  4. open the browser and go to app url

 Anyway in layout.html there is this instruction (line 34 in last trunk):
   !-- Place favicon.ico and apple-touch-icon.png in the root of your 
 domain and delete these references --
link rel=shortcut icon href={{=URL('static','favicon.ico')}} 
 type=image/x-icon
link rel=apple-touch-icon href={{=URL('static','favicon.png')}}

 At last, if you modified the routes.py, check the routes_in section for:
   
   (r'.*:/favicon.ico', r'/init/static/favicon.ico')

 where init is your app.


 Il giorno lunedì 28 maggio 2012 11:56:07 UTC+2, Marian Siwiak ha scritto:

 Hello,

 I replaced favicon.ico and favicon.png file in static folder of my app, 
 but on my webpage I still get an old icon. Any suggestions? I thought it 
 might be some cache problems, but I used different browser, and still - 
 web2py app icon is there...

 best regards,
 Marian



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: web2py and SEO

2014-01-03 Thread Gael Princivalle
Hi Bruno.

In a same page where you make translations, how can you manage meta 
informations for all languages ?
With a if T.accepted_language you can set different values, but when you 
give your site to a tool like that :
http://www.seoutility.com/it/tools/google/sitemap_generator.aspx
it see only meta informations in default language.

page title (response.meta.title)
page keywords ( response.meta.keywords)
page description ( response.meta.description)

How do you manage this argument ?

Thanks.


Il giorno venerdì 6 agosto 2010 15:13:58 UTC+2, rochacbruno ha scritto:

 SEO is basically done through:

 page title (response.meta.title)
 page keywords ( response.meta.keywords)
 page description ( response.meta.description)

 plus: 
 the robots.txt file under website root directory, 
 good practices for creating links and inserting images, 
 Semantic html markup ( I mean always including name , alt, title for 
 relevant tags), 
 and also using correctly the most relevant tags (h1,h2,h..., em, 
 strong etc )

 And one of the most important thing: Build a sitemap [1]

 web2py is ready to do all that, but we need to do it all from the scratch, 
 what we need now is a helper or a mechanism to make it more user friendly.As 
 is done by the plugin ALL-IN-ONE-PACK-SEO on wordpress for example.


 [1] http://en.wikipedia.org/wiki/Site_map





 2010/8/6 mdipierro mdip...@cs.depaul.edu javascript:

 web2py does not care. I do not think there is any difference between
 frameworks about this. The issue how you use them.

 web2py provides response.meta that combined with the default layout
 allows you to set

 response.meta.keywords
 response.meta.description
 response.meta.author

 If you have recommendations about specific features that need to be
 implemented at the framework level, let us know.






 On Aug 6, 6:13 am, puercoespin jzaragoza.puercoes...@gmail.com
 wrote:
  Is web2py designed for a good practices about SEO? Are some frameworks
  SEO-friends and others no SEO-friends and, if this is true, are web2py
  SEO-friend?
 
  Thanks




 -- 

 http://rochacbruno.com.br
  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Happy New Year everybody!

2014-01-03 Thread Gael Princivalle
An happy new year also to you Massimo and to all web2pyer's in all other 
the world.

Il giorno mercoledì 1 gennaio 2014 23:06:30 UTC+1, Massimo Di Pierro ha 
scritto:

 Happy new year everybody,

 some good news:
 1) python is growing popularity

 https://sites.google.com/site/pydatalog/pypl/python-blog/pythonisthelanguageoftheyear
 2) there will be a web2py tutorial at PyCon. I will tell you more asap!
 3) the web2py community is still growing and in 2013 I saw more and more 
 high quality programs built with web2py.

 Massimo


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Happy New Year everybody!

2014-01-03 Thread Richard Vézina
Happy new year to all!!

:)

Richard


On Fri, Jan 3, 2014 at 9:41 AM, Gael Princivalle
gaelprinciva...@gmail.comwrote:

 An happy new year also to you Massimo and to all web2pyer's in all other
 the world.


 Il giorno mercoledì 1 gennaio 2014 23:06:30 UTC+1, Massimo Di Pierro ha
 scritto:

 Happy new year everybody,

 some good news:
 1) python is growing popularity
 https://sites.google.com/site/pydatalog/pypl/python-blog/
 pythonisthelanguageoftheyear
 2) there will be a web2py tutorial at PyCon. I will tell you more asap!
 3) the web2py community is still growing and in 2013 I saw more and more
 high quality programs built with web2py.

 Massimo

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] Waiting for Scheduler Task to Complete is Blocking Work?

2014-01-03 Thread EW
I'm having trouble figuring out how to determine when a scheduler task is 
done.  My code/scheduler task work is working.  But when I added this loop, 
it does not--when I go into the admin interface and look at the 
scheduler_task table, the task is not in the table at all.  The printouts 
show the task as always being in the QUEUED status.  Is this code somehow 
blocking the worker from picking up the task?  What is the best way to 
determine when a task has been completed?
 
 
 q = scheduler.queue_task(read_blox, pvars=dict(json_dir_id=r.id), immediate
=True) #This line alone works without the following code   
 
task_id = int(q.id) 
res = scheduler.task_status(task_id)   
  
print res 
while not res.status == 'COMPLETED':   
  
res = scheduler.task_status(task_id)   
  
print res 
print 'completed'

 
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Brando
I have the following code to insert a dictionary into my sqlite db from a 
module. 

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from gluon import current
from gluon.dal import DAL, Field
from gluon.sqlhtml import SQLFORM
from gluon.validators import IS_NOT_EMPTY, IS_EMAIL, IS_LENGTH

class Parse(object):

def __init__(self):
self.db = current.db
# self.db = 
DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
# self.db = DAL(sqlite://mydb.sqlite)
self.session = current.session
self.request = current.request
self.response = current.response
self.cache = current.cache
self.maketable()
self.settings()
# self.set_validators()
self.addtodb()
def settings():

self.settings = {
'filepath': 'tom', #File path.
'filename': 'dick', #Name of the file being processed.
'hostname': 'harry', #What is the hostname?
}


def maketable(self):
self.testrecord = self.db.define_table(testrecord,
Field(filepath),
Field(filename),
Field(hostname)
 )

def addtodb(self):
self.db.testrecord.insert(**self.settings)
self.testrecord = self.db().select(self.db.testrecord.ALL)
return self.testrecord


If I change either tom, dick or harry; save the file, and reload my 
browser; I still get tom, dick and harry being returned to the screen. 
 HOWEVER, if I stop the web2py server, quit web2py (osx), and restart 
web2py I will get my new values when I reload the url.  

Any ideas what is going on here?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Anthony
It's the same with any Python module -- they only get loaded once on first 
import. web2py does include a feature to automatically re-load upon change, 
though not recommended for production. In a model file (before any imports):

from gluon.custom_import import track_changes; track_changes(True)


See 
http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules
.

Anthony

On Friday, January 3, 2014 11:14:36 AM UTC-5, Brando wrote:

 I have the following code to insert a dictionary into my sqlite db from a 
 module. 

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-

 from gluon import current
 from gluon.dal import DAL, Field
 from gluon.sqlhtml import SQLFORM
 from gluon.validators import IS_NOT_EMPTY, IS_EMAIL, IS_LENGTH

 class Parse(object):

 def __init__(self):
 self.db = current.db
 # self.db = 
 DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
 # self.db = DAL(sqlite://mydb.sqlite)
 self.session = current.session
 self.request = current.request
 self.response = current.response
 self.cache = current.cache
 self.maketable()
 self.settings()
 # self.set_validators()
 self.addtodb()

 def settings(self):

 self.settings = {
 'filepath': 'tom', #File path.
 'filename': 'dick', #Name of the file being processed.
 'hostname': 'harry', #What is the hostname?
 }


 def maketable(self):
 self.testrecord = self.db.define_table(testrecord,
 Field(filepath),
 Field(filename),
 Field(hostname)
  )

 def addtodb(self):
 self.db.testrecord.insert(**self.settings)
 self.testrecord = self.db().select(self.db.testrecord.ALL)
 return self.testrecord


 If I change either tom, dick or harry; save the file, and reload my 
 browser; I still get tom, dick and harry being returned to the screen. 
  HOWEVER, if I stop the web2py server, quit web2py (osx), and restart 
 web2py I will get my new values when I reload the url.  

 Any ideas what is going on here?




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Error in Custom Register Page in web2py

2014-01-03 Thread Anthony
No, it's better to set the readable and writable attributes to False if you 
want particular fields to be excluded from the form.

for fields in ['field1', 'field2', 'field3']:
db.auth_user[field].readable = db.auth_user[field].writable = False
form = auth.register()

Anthony

On Friday, January 3, 2014 9:01:39 AM UTC-5, Akash Agrawall wrote:

 Have to define all the attributes in custom form otherwise it won't 
 run... wasn't doing the same. define it as hidden if you don't want 
 user to see them. !!

 On Tuesday, December 31, 2013 5:54:34 PM UTC+5:30, Akash Agrawall wrote:

 Hie folks. When I click on submit button of the CUSTOM REGISTRATION 
 form. it redirects to the same page.. ?? No idea what this is 
 about.. 
 Controller: default.py
 def register():
 form=auth.register()
 form.add_button('Cancel', URL('register'))
 if form.accepts(request.vars,session):
 print did it
 response.flash=Your Registration request has been 
 successfully submitted
 redirect(URL('home'))
 elif form.errors:
 response.flash=Errors in form
 else:
 response.flash=nothing mah badd
 return dict(late=late, form=form)

 View: register.html
 {{extend 'layout.html'}}
 a href={{=URL('home')}}Home/a » Book Connect
 p style=font-family:Times New Roman;font-size:17px;
 We facilitate sharing of books with partner Schools, NGOs, community 
 centers, and shelter homes. 
 br/br/
 In case  you represent any of the above, please register with us as 
 partner to avail our book sharing program BookConnect. Once registered with 
 us, you can search through our book repository and request for the books. 
 /p
 br/
 {{=form.custom.begin}}
 table
 tr
 td style=width:51%;Namenbsp;span 
 style=color:red;*/span/tdtd {{=form.custom.widget.Name}}/td
 /tr
 tr
 td style=width:51%;Emailnbsp;span 
 style=color:red;*/span/tdtd {{=form.custom.widget.email}}/td
 /tr
 tr 
 td style=width:51%Passwordnbsp;span 
 style=color:red;*/span/tdtd {{=form.custom.widget.password}}/td
 /tr
 tr
 td style=width:45%Addressnbsp;span 
 style=color:red;/span/tdtd {{=form.custom.widget.Address}}/td
 /tr
 tr
 td style=width:45%Contact Personnbsp;span 
 style=color:red;/span/tdtd{{=form.custom.widget.Contact_person}}/td
 /tr
 tr
 td style=width:45%Contact No 1nbsp;span 
 style=color:red;*/span/tdtd{{=form.custom.widget.Contact_No_1}}/td
 /tr
 tr
 td style=width:45%Contact No 2nbsp;span 
 style=color:red;/span/tdtd{{=form.custom.widget.Contact_No_2}}/td
 /tr
 tr
 td style=width:45%Descriptionnbsp;span 
 style=color:red;/span/tdtd{{=form.custom.widget.Description}}/td
 /tr
 tr
 td 
 style=width:45%Websitenbsp;/tdtd{{=form.custom.widget.Website}}/td
 /tr
 tr
 td style=width:40%Date of 
 Request/tdtd{{=form.custom.widget.Date_of_request}}/td
 /tr
 tr style=visibility:hiddentd 
 style=width:40%Status/tdtd{{=form.custom.widget.Date_of_request}}/td/tr
 trtd{{=form.custom.submit}} 
!--a class=btn btn-default 
 href={{=URL('donate_book')}}Cancel/a--/td/tr
 /table
 {{=form.custom.end}}


 print form.errors - Storage {}
 pritn form.accepts(request.vars,session) - false



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Brando
Actually, any changes made to my module file will not be reflected until i 
restart the web2py.app.










On Friday, January 3, 2014 8:14:36 AM UTC-8, Brando wrote:

 I have the following code to insert a dictionary into my sqlite db from a 
 module. 

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-

 from gluon import current
 from gluon.dal import DAL, Field
 from gluon.sqlhtml import SQLFORM
 from gluon.validators import IS_NOT_EMPTY, IS_EMAIL, IS_LENGTH

 class Parse(object):

 def __init__(self):
 self.db = current.db
 # self.db = 
 DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
 # self.db = DAL(sqlite://mydb.sqlite)
 self.session = current.session
 self.request = current.request
 self.response = current.response
 self.cache = current.cache
 self.maketable()
 self.settings()
 # self.set_validators()
 self.addtodb()

 def settings(self):

 self.settings = {
 'filepath': 'tom', #File path.
 'filename': 'dick', #Name of the file being processed.
 'hostname': 'harry', #What is the hostname?
 }


 def maketable(self):
 self.testrecord = self.db.define_table(testrecord,
 Field(filepath),
 Field(filename),
 Field(hostname)
  )

 def addtodb(self):
 self.db.testrecord.insert(**self.settings)
 self.testrecord = self.db().select(self.db.testrecord.ALL)
 return self.testrecord


 If I change either tom, dick or harry; save the file, and reload my 
 browser; I still get tom, dick and harry being returned to the screen. 
  HOWEVER, if I stop the web2py server, quit web2py (osx), and restart 
 web2py I will get my new values when I reload the url.  

 Any ideas what is going on here?




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Waiting for Scheduler Task to Complete is Blocking Work?

2014-01-03 Thread Anthony
scheduler.queue_task() simply inserts a record into the scheduler_task 
table. However, assuming this code is part of an HTTP request, the insert 
won't get committed until the request is complete. Yet your code then 
includes a while loop that will not exit until after the insert (and after 
the task has completed), which will never happen. I suppose you could call 
db.commit() right after queuing the task, but then what is the point of 
using the scheduler? The purpose of scheduling a task in the background is 
so it can happen outside of a single request-response cycle. Yet, if your 
request waits until the task is complete before returning, you might as 
well just do the task directly in the request rather than bothering to have 
the scheduler do it.

Anthony

On Friday, January 3, 2014 10:59:29 AM UTC-5, EW wrote:

 I'm having trouble figuring out how to determine when a scheduler task is 
 done.  My code/scheduler task work is working.  But when I added this loop, 
 it does not--when I go into the admin interface and look at the 
 scheduler_task table, the task is not in the table at all.  The printouts 
 show the task as always being in the QUEUED status.  Is this code somehow 
 blocking the worker from picking up the task?  What is the best way to 
 determine when a task has been completed?
  
  
  q = scheduler.queue_task(read_blox, pvars=dict(json_dir_id=r.id),immediate
 =True) #This line alone works without the following code 

 task_id = int(q.id) 
 res = scheduler.task_status(task_id) 
 
 print res 
 while not res.status == 'COMPLETED': 
 
 res = scheduler.task_status(task_id) 
 
 print res 
 print 'completed'

  
  


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Error in Custom Register Page in web2py

2014-01-03 Thread Akash Agrawall
true that... this one is better..


On Fri, Jan 3, 2014 at 9:59 PM, Anthony abasta...@gmail.com wrote:

 No, it's better to set the readable and writable attributes to False if
 you want particular fields to be excluded from the form.

 for fields in ['field1', 'field2', 'field3']:
 db.auth_user[field].readable = db.auth_user[field].writable =
 False
 form = auth.register()

 Anthony


 On Friday, January 3, 2014 9:01:39 AM UTC-5, Akash Agrawall wrote:

 Have to define all the attributes in custom form otherwise it won't
 run... wasn't doing the same. define it as hidden if you don't want
 user to see them. !!

 On Tuesday, December 31, 2013 5:54:34 PM UTC+5:30, Akash Agrawall wrote:

 Hie folks. When I click on submit button of the CUSTOM REGISTRATION
 form. it redirects to the same page.. ?? No idea what this is
 about..
 Controller: default.py
 def register():
 form=auth.register()
 form.add_button('Cancel', URL('register'))
 if form.accepts(request.vars,session):
 print did it
 response.flash=Your Registration request has been
 successfully submitted
 redirect(URL('home'))
 elif form.errors:
 response.flash=Errors in form
 else:
 response.flash=nothing mah badd
 return dict(late=late, form=form)

 View: register.html
 {{extend 'layout.html'}}
 a href={{=URL('home')}}Home/a » Book Connect
 p style=font-family:Times New Roman;font-size:17px;
 We facilitate sharing of books with partner Schools, NGOs, community
 centers, and shelter homes.
 br/br/
 In case  you represent any of the above, please register with us as
 partner to avail our book sharing program BookConnect. Once registered with
 us, you can search through our book repository and request for the books.
 /p
 br/
 {{=form.custom.begin}}
 table
 tr
 td style=width:51%;Namenbsp;span 
 style=color:red;*/span/tdtd
 {{=form.custom.widget.Name}}/td
 /tr
 tr
 td style=width:51%;Emailnbsp;span
 style=color:red;*/span/tdtd {{=form.custom.widget.email}}/td
 /tr
 tr 
 td style=width:51%Passwordnbsp;span 
 style=color:red;*/span/tdtd
 {{=form.custom.widget.password}}/td
 /tr
 tr
 td style=width:45%Addressnbsp;span style=color:red;/span/tdtd
 {{=form.custom.widget.Address}}/td
 /tr
 tr
 td style=width:45%Contact Personnbsp;span
 style=color:red;/span/tdtd{{=form.custom.widget.
 Contact_person}}/td
 /tr
 tr
 td style=width:45%Contact No 1nbsp;span
 style=color:red;*/span/tdtd{{=form.custom.widget.
 Contact_No_1}}/td
 /tr
 tr
 td style=width:45%Contact No 2nbsp;span
 style=color:red;/span/tdtd{{=form.custom.widget.
 Contact_No_2}}/td
 /tr
 tr
 td style=width:45%Descriptionnbsp;span
 style=color:red;/span/tdtd{{=form.custom.widget.
 Description}}/td
 /tr
 tr
 td style=width:45%Websitenbsp;/tdtd{{=form.custom.
 widget.Website}}/td
 /tr
 tr
 td style=width:40%Date of Request/tdtd{{=form.
 custom.widget.Date_of_request}}/td
 /tr
 tr style=visibility:hiddentd style=width:40%Status/td
 td{{=form.custom.widget.Date_of_request}}/td/tr
 trtd{{=form.custom.submit}}
!--a class=btn btn-default href={{=URL('donate_book')}}
 Cancel/a--/td/tr
 /table
 {{=form.custom.end}}


 print form.errors - Storage {}
 pritn form.accepts(request.vars,session) - false

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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/UtyexKmQpZY/unsubscribe.
 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.




-- 
akash.wanteds

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Waiting for Scheduler Task to Complete is Blocking Work?

2014-01-03 Thread EW
Ah, that makes sense!  
 
But I still need help...the reason I want to use the scheduler is to have a 
worker do database inserts and simultaneously update an sql grid of the 
table being inserted into (as described in this question you've already 
seen https://groups.google.com/forum/#!topic/web2py/Hp3o-b7XGQ4).  But I 
want to know how I can tell that the scheduler task has completed.  This 
way I could stop constantly reloading the grid and also give a visual cue 
that the database inserts have completed, i.e. hide my loading image.  
How/Where can I detect that the scheduler task has completed? 
 

On Friday, January 3, 2014 9:09:36 AM UTC-8, Anthony wrote:

 scheduler.queue_task() simply inserts a record into the scheduler_task 
 table. However, assuming this code is part of an HTTP request, the insert 
 won't get committed until the request is complete. Yet your code then 
 includes a while loop that will not exit until after the insert (and after 
 the task has completed), which will never happen. I suppose you could call 
 db.commit() right after queuing the task, but then what is the point of 
 using the scheduler? The purpose of scheduling a task in the background is 
 so it can happen outside of a single request-response cycle. Yet, if your 
 request waits until the task is complete before returning, you might as 
 well just do the task directly in the request rather than bothering to have 
 the scheduler do it. 

 Anthony

 On Friday, January 3, 2014 10:59:29 AM UTC-5, EW wrote: 

  I'm having trouble figuring out how to determine when a scheduler task 
 is done.  My code/scheduler task work is working.  But when I added this 
 loop, it does not--when I go into the admin interface and look at the 
 scheduler_task table, the task is not in the table at all.  The printouts 
 show the task as always being in the QUEUED status.  Is this code somehow 
 blocking the worker from picking up the task?  What is the best way to 
 determine when a task has been completed?
  
  
  q = scheduler.queue_task(read_blox, pvars=dict(json_dir_id=r.id),immediate
 =True) #This line alone works without the following code 

 task_id = int(q.id) 
 res = scheduler.task_status(task_id) 
 
 print res 
 while not res.status == 'COMPLETED': 
 
 res = scheduler.task_status(task_id) 
 
 print res 
 print 'completed'

  
  



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: request desktop site is not work when open web2py admin in mobile

2014-01-03 Thread Dave S
Stifan, your posts are normally easy to read, but this one has me confused. 
 Those That Know What They Are Doing may have better understanding, but in 
the meantime you might try rewording your question.  My best guess is that 
you want to run your server's admin app from a mobile device (e.g., 
phone/phablet/tablet).  But it could also be you want a web2py server 
running on the mobile to do something to another machine.

/dps


On Thursday, January 2, 2014 2:16:47 PM UTC-8, 黄祥 wrote:

 hi,

 i figure it out that request desktop site is not work when open web2py 
 admin in mobile, is it normal? i think i can use upload and install packed 
 installation from mobile when request desktop site is enable. i test it 
 with chrome and firefox on android but got the same result.

 thanks and best regards,
 stifan


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Brando
Anthony, I added the line to a modeland it still doesn't work. Any other 
thoughts?

Also, why is it not recommended for production?




On Friday, January 3, 2014 8:26:13 AM UTC-8, Anthony wrote:

 It's the same with any Python module -- they only get loaded once on first 
 import. web2py does include a feature to automatically re-load upon change, 
 though not recommended for production. In a model file (before any imports):

 from gluon.custom_import import track_changes; track_changes(True)


 See 
 http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules
 .

 Anthony

 On Friday, January 3, 2014 11:14:36 AM UTC-5, Brando wrote:

 I have the following code to insert a dictionary into my sqlite db from a 
 module. 

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-

 from gluon import current
 from gluon.dal import DAL, Field
 from gluon.sqlhtml import SQLFORM
 from gluon.validators import IS_NOT_EMPTY, IS_EMAIL, IS_LENGTH

 class Parse(object):

 def __init__(self):
 self.db = current.db
 # self.db = 
 DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
 # self.db = DAL(sqlite://mydb.sqlite)
 self.session = current.session
 self.request = current.request
 self.response = current.response
 self.cache = current.cache
 self.maketable()
 self.settings()
 # self.set_validators()
 self.addtodb()

 def settings(self):

 self.settings = {
 'filepath': 'tom', #File path.
 'filename': 'dick', #Name of the file being processed.
 'hostname': 'harry', #What is the hostname?
 }


 def maketable(self):
 self.testrecord = self.db.define_table(testrecord,
 Field(filepath),
 Field(filename),
 Field(hostname)
  )

 def addtodb(self):
 self.db.testrecord.insert(**self.settings)
 self.testrecord = self.db().select(self.db.testrecord.ALL)
 return self.testrecord


 If I change either tom, dick or harry; save the file, and reload my 
 browser; I still get tom, dick and harry being returned to the screen. 
  HOWEVER, if I stop the web2py server, quit web2py (osx), and restart 
 web2py I will get my new values when I reload the url.  

 Any ideas what is going on here?




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Anthony
On Friday, January 3, 2014 2:22:42 PM UTC-5, Brando wrote:

 Anthony, I added the line to a model and it still doesn't work. Any other 
 thoughts?


Not sure. Did you restart? Maybe pack and attach a minimal app that 
demonstrates the problem.
 

 Also, why is it not recommended for production?


It adds extra overhead to every import (have to check the last modified 
time of the module file on the filesystem).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Waiting for Scheduler Task to Complete is Blocking Work?

2014-01-03 Thread Anthony
Maybe when the task is scheduled, either store the task ID in the session 
or return it to the browser. Then from the browser, make Ajax requests 
every x seconds to an action that checks the task status. When the task is 
complete, the browser can then reload the grid.

Anthony

On Friday, January 3, 2014 1:30:36 PM UTC-5, EW wrote:

 Ah, that makes sense!  
  
 But I still need help...the reason I want to use the scheduler is to have 
 a worker do database inserts and simultaneously update an sql grid of the 
 table being inserted into (as described in this question you've already 
 seen https://groups.google.com/forum/#!topic/web2py/Hp3o-b7XGQ4).  But I 
 want to know how I can tell that the scheduler task has completed.  This 
 way I could stop constantly reloading the grid and also give a visual cue 
 that the database inserts have completed, i.e. hide my loading image.  
 How/Where can I detect that the scheduler task has completed? 
  

 On Friday, January 3, 2014 9:09:36 AM UTC-8, Anthony wrote:

 scheduler.queue_task() simply inserts a record into the scheduler_task 
 table. However, assuming this code is part of an HTTP request, the insert 
 won't get committed until the request is complete. Yet your code then 
 includes a while loop that will not exit until after the insert (and after 
 the task has completed), which will never happen. I suppose you could call 
 db.commit() right after queuing the task, but then what is the point of 
 using the scheduler? The purpose of scheduling a task in the background is 
 so it can happen outside of a single request-response cycle. Yet, if your 
 request waits until the task is complete before returning, you might as 
 well just do the task directly in the request rather than bothering to have 
 the scheduler do it. 

 Anthony

 On Friday, January 3, 2014 10:59:29 AM UTC-5, EW wrote: 

  I'm having trouble figuring out how to determine when a scheduler task 
 is done.  My code/scheduler task work is working.  But when I added this 
 loop, it does not--when I go into the admin interface and look at the 
 scheduler_task table, the task is not in the table at all.  The printouts 
 show the task as always being in the QUEUED status.  Is this code somehow 
 blocking the worker from picking up the task?  What is the best way to 
 determine when a task has been completed?
  
  
  q = scheduler.queue_task(read_blox, pvars=dict(json_dir_id=r.id),immediate
 =True) #This line alone works without the following code   
  
 task_id = int(q.id) 
 res = scheduler.task_status(task_id)   
   
 print res 
 while not res.status == 'COMPLETED':   
   
 res = scheduler.task_status(task_id)   
   
 print res 
 print 'completed'

  
  



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Richard Vézina
Which version of web2py do you use?

from gluon.custom_import import track_changes; track_changes(True)


Have been broken during sometime...

Richard




On Fri, Jan 3, 2014 at 2:50 PM, Brando bhe...@trustcc.com wrote:

 Here is the test app.






 On Friday, January 3, 2014 11:35:22 AM UTC-8, Anthony wrote:

 On Friday, January 3, 2014 2:22:42 PM UTC-5, Brando wrote:

 Anthony, I added the line to a model and it still doesn't work. Any
 other thoughts?


 Not sure. Did you restart? Maybe pack and attach a minimal app that
 demonstrates the problem.


 Also, why is it not recommended for production?


 It adds extra overhead to every import (have to check the last modified
 time of the module file on the filesystem).

 Anthony

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 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.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Brando


 Version

 2.8.2-stable+timestamp.2013.11.28.13.54.07
 (Running on Rocket 1.2.6, Python 2.7.3)






Also, I doubt it's relevant, but I'm using Sublime Text as my IDE. 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Happy New Year everybody!

2014-01-03 Thread Dave S
On Wednesday, January 1, 2014 2:06:30 PM UTC-8, Massimo Di Pierro wrote:

 Happy new year everybody,

 some good news:
 1) python is growing popularity

 https://sites.google.com/site/pydatalog/pypl/python-blog/pythonisthelanguageoftheyear
 2) there will be a web2py tutorial at PyCon. I will tell you more asap!
 3) the web2py community is still growing and in 2013 I saw more and more 
 high quality programs built with web2py.




Web2py has helped me reach the New year ina happy state of mind!

Thanks to Massimo and the gang, and to the community here.

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Virtual field for latitude and longitude from geometry field?

2014-01-03 Thread User
Didn't realize you could make a second query in a Virtual field but makes 
sense now that I see it.  Although I'd rather not make the extra query (2 
actually since longitude would need to do the same thing) so I guess I will 
just add latitude and longitude directly to my original select instead of 
trying to make them Virtual fields. e.g.

db(db.location.id0).select(db.location.ALL, db.location.point.st_x(), db.
location.point.st_y())



On Friday, January 3, 2014 4:16:57 AM UTC-5, Paolo Valleri wrote:

 st_*() are db engine functions, you should query the db to get the output 
 you are looking for. Given that, in your virtual field you should make a 
 new query, something like that:

 Field.Virtual('latitude', lambda row: db(db.location.id == row.location.id
 ).select(db.location.point.st_x()).first()[db.location.point.st_x()]

 Paolo

 On Thursday, January 2, 2014 9:59:14 PM UTC+1, Christian Foster Howes 
 wrote:

 i bet that by the time your lambda is running the point has been 
 converted to a string already.  can you see if that is true?  i'm not sure 
 how to invoke db functions in a lambda of a virtual field. :(

 On Wednesday, January 1, 2014 5:50:54 PM UTC-8, User wrote:

 Suppose I have a table like:

 db.define_table('location',
 Field(name, 'string'),
 Field('point', 'geometry()')
 )

 I want to have the latitude and longitude as attributes also (whose 
 value can be derived from the point field).  So I try this:

 db.define_table('location',
 Field(name, 'string'),
 Field('point', 'geometry()'),
 Field.Virtual('latitude', lambda row: row.location.point.st_x()),
 Field.Virtual('longitude', lambda row: row.location.point.st_y()),
 )

 But it doesn't work and fails silently.  The model just doesn't have 
 latitude or longitude fields. I also tried with Field.Method but this 
 complains that 'point' is of typer str.

 I guess the complication is that st_x() translates into a database 
 function.  I'm thinking about parsing the point string which is of the form 
 POINT(x y) as a workaround but I'd rather use st_x if someone can show me 
 how.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Authorization for Webhooks

2014-01-03 Thread Francisco Costa
I had a similar problem with a webook.

In my case I read the HTTP POST with request.body.read()

Chek it here: 
http://web2py.com/books/default/chapter/29/04/the-core?search=request.body.read%28%29

And this example: http://www.web2py.com/AlterEgo/default/show/197

On Sunday, February 13, 2011 11:29:36 PM UTC, AsmanCom wrote:

 I can see the stored data, but I just do not know how  to extract the 
 required values, 

 Do I have to unpickle these files somehow, or is there perhaps a more 
 framework-conform-approach to query these two values? 

 I would not like to import external libraries for this. 

 I thought querying user_name/is_logged_in by session_id would be a 
 basic built in functionality... 

 THX 

 Dieter Asman 


 On 13 Feb., 15:54, Massimo Di Pierro massimo.dipie...@gmail.com 
 wrote: 
  The session it is the name of the sessions file under app/sessions. It 
  is a pickle. Try open it and see what is inside. 
  
  On Feb 13, 6:43 am, AsmanCom d.as...@web.de wrote: 
  
  
  
  
  
  
  
   Does nobody know, how to query these two values by the given 
   session_id (session_id_myapp=127.0.0.1-2b77d424-4e72-4d3f-a0de- 
   badbcdbe6a30)? 
  
   1. is_logged_in (boolean) 
   2. username or user email (string) 
  
   I looked in the book, i´ve searched this group, i´ve searched the web, 
   but still can´t find any Solution... 
  
   So could anyone, who knows about the auth-process, please take a look 
   at it. 
  
   Thanks in advance. 
   Dieter Asman

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: request desktop site is not work when open web2py admin in mobile

2014-01-03 Thread 黄祥
hi dave, 

i'm sorry, i mean when i access to web2py server from mobile devices, e.g. 
access pythonanywhere.com from mobile devices. when i got the web2py app 
*.w2p on my email in my mobile i think i can get upload and install it to 
pythonanywhere.com from my mobile.

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] sessions and logout

2014-01-03 Thread Wonton
Hello everyone,

Recently I suffered the problem with the number of session files growing 
very fast in my server. This worried me a lot because the server is a 
development environment with only 4 or 5 testers, so when the number of 
users is higher I guess I will have a big problem with this issue.
I've tried to investigate about this but I'm not expert working with web2py 
or with servers, so I have some questions:

- A session file is created associated to a user each time that user logs 
in. Is this ok?
- My users make a login through auth.login_bare(user, password), does this 
create a session file then?
- What should be the code to remove the session file of a user when he/she 
makes a logout?
- I've set my auth.settings.expiration to 9, does this affect to 
sessions too? As far as I know it only affects to when an inactive user is 
automatically logged out, is this correct?
- Testing this I've seen that with no logged users in my server, if I 
manually remove the sessions files, some of them are created again!! Why 
and how? As I said I have no users logged in the server.

Regarding to the logout problem I've seen that my logout method is as 
simple as this:

 def logout():
if auth.user:
auth.log_event(auth.messages.logout_log, auth.user)
session.auth = None

I don't really make a logout of the user so I change my method to this:

 def logout():
if auth.user:
print 'check 1'
auth.logout()
print 'check 2'
session.auth = None

But when this method is called, the output is this:
check1

check 2 is never printed so, has the user actually make a logout?

I know they are a lot of questions, but any kind of help will be very 
appreciated.

Kind regards!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: executesql as_dict=True replacing ids during join

2014-01-03 Thread Massimo Di Pierro
I think if there is a duplicated entry, and as_dict=True we should raise an 
exception and explain the reasons. Unless there is a way to make this this 
not ambiguous.


On Thursday, 2 January 2014 19:13:26 UTC-6, Anthony wrote:

 This may be tricky. In case of as_dict=True, executesql() uses the 
 adapter.cursor.description to get the column names, but there is no 
 indication which column name comes from which table, so if both tables have 
 the same column name, the dict will only get one of the columns. 
 executesql() does take a colnames argument, so you can instead supply the 
 column names directly, which is probably the best we can do in case of a 
 join.

 Anthony

 On Thursday, January 2, 2014 7:49:20 PM UTC-5, Massimo Di Pierro wrote:

 I think it is a bug. Please open a ticket linking this thread.

 On Thursday, 2 January 2014 13:20:04 UTC-6, ssuresh wrote:

 I found a peculiar problem when executing a join query on two tables. I 
 have two tables table1 and table2. Both have ids as their pks. table1 has a 
 FK on table2 using table2_id field.

 Now when i do an executesql of the following query, 

 rows=executesql('select * from table1,table2 where table1.table2_id=
 table2.id',as_dict=True)

 I always get only one id field in the return dict and I dont know 
 whether the id is of table1 or table2.

 Am I doing something wrong, or is it a possible bug?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Can't get web2py working with GAE locally

2014-01-03 Thread Massimo Di Pierro
It is in handlers/gaehandler.py 
There reason we moved is that we do now want to pollute the main folder and 
we do now want to overwrote any changes you may have to make to it upon 
upgrade. You have to 

cp handlers/gaehandler.py ./


On Thursday, 2 January 2014 20:33:35 UTC-6, Jaime Sempere wrote:

 Hi everyone, this is driving me mad.

 I used web2py and GAE one year ago and I liked a lot, fast and easy to 
 work with gae. Now that I wanted to start another app, I have download GAE 
 and Web2Py again (for having last releases and starting in a cleannew 
 folder).

 So, first change that I see is that when I run dev_appserver from GAE 
 forces to use python 2.7. My first guess then, is that I need to change 
 gaehandler in app.yaml and leave the code like this:

 application: myapp
 version: 1
 api_version: 1


   #script: gaehandler.py # CGI
   script: gaehandler.wsgiapp# WSGI (Python 2.7 only)
   secure: optional

 But when I do a http://localhost:8080/

 I obtain this error in console:

 ERROR2014-01-03 02:25:39,821 wsgi.py:262] 
 Traceback (most recent call last):
   File 
 /home/mrkite/DesarrolloATUBETV/google_appengine/google/appengine/runtime/wsgi.py,
  
 line 239, in Handle
 handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
   File 
 /home/mrkite/DesarrolloATUBETV/google_appengine/google/appengine/runtime/wsgi.py,
  
 line 298, in _LoadHandler
 handler, path, err = LoadObject(self._handler)
   File 
 /home/mrkite/DesarrolloATUBETV/google_appengine/google/appengine/runtime/wsgi.py,
  
 line 84, in LoadObject
 obj = __import__(path[0])
 ImportError: No module named gaehandler
 INFO 2014-01-03 02:25:39,834 module.py:617] default: GET / HTTP/1.1 
 500 -
 INFO 2014-01-03 02:25:40,208 module.py:617] default: GET /favicon.ico 
 HTTP/1.1 304 -




 And of course I can't see any html returned. Why gaehandler is missing?

 I can reach localhost:8001/myapp   (web2py server)
 But not   localhost:8080  (gae)

 And second question: for running my appGAE locally do I need to have 
 running web2py server? I used to have both running, but now I have seen 
 that I need to change default port 8000 to other (i.e. 8001), because gae 
 is using 8000 and 8080.


 Any help would be very appreciated. Thank you 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: question about SQLFORM.grid

2014-01-03 Thread Massimo Di Pierro


On Thursday, 2 January 2014 11:41:52 UTC-6, Robert Bjornson wrote:

 Hi all,

 I am a newcomer to web2py, and have what I hope is a simple beginner 
 question.

 I am following the mywiki example in the getting started tutorial. In 
 it, one can display all the documents for a page
 using this url:

 *http://127.0.0.1:8000/mywiki/default/documents/1 
 http://127.0.0.1:8000/mywiki/default/documents/1*

 *The controller for this page creates a SQLFORM.grid, using this code:*





 *def documents(): browser, edit all documents attached to a certain 
 page page = db.page(request.args(0,cast=int)) or 
 redirect(URL('index')) db.document.page_id.default = page.id 
 http://page.id db.document.page_id.writable = False grid = 
 SQLFORM.grid(db.document.page_id==page.id http://page.id,args=[page.id 
 http://page.id]) return dict(page=page, grid=grid)When the page is 
 rendered by the view, each row in the grid, representing a document, has 
 three buttons: view, edit, delete.If I look at the action for these buttons 
 I see that they are refinements of my current url.  For example edit 
 is:http://127.0.0.1:8000/mywiki/default/documents/1/edit/document/1?_signature=75f1c501a80734585179ab4cafd9a8ac90ee7a51
  
 http://127.0.0.1:8000/mywiki/default/documents/1/edit/document/1?_signature=75f1c501a80734585179ab4cafd9a8ac90ee7a51I
  
 don't understand how this url is getting dispatched.  I would think it 
 would go to default.py/documents() http://default.py/documents(), with an 
 args list of [1, edit,document, 1], and vars of 
 {_signature:75f1c501a80734585179ab4cafd9a8ac90ee7a51}But, I don't see any 
 code in documents() that would handle this is the appropriate way. *


You assumption is correct. * SQLFORM.grid handles the code.*
 



 * From the page I end up on when I click edit, it seems like it's 
 dispatching to mywiki/controllers/appadmin.py.  I can't figure out why it 
 gets there.Thanks for your help.Rob *




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: web2py running en AppFog

2014-01-03 Thread Massimo Di Pierro
I am sorry. I need a little more explanations. :-(

On Friday, 3 January 2014 06:46:43 UTC-6, José Antonio López Lorenzo wrote:

 DEMO: http://web2py.eu01.aws.af.cm/
 EXPLANATION: http://jallander.wordpress.com/2014/01/03/web2py-en-appfog/
 SERVER: https://www.appfog.com/


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: sessions and logout

2014-01-03 Thread Massimo Di Pierro
No because auth.logout(next=...) redirects to he value of next. Next 
defaults to auth.settings.logout_next which is set to URL('index')

What you want is:

def logout():
auth.logout(logout_onlogout=lambda user: session.auth=None)

On Friday, 3 January 2014 19:44:43 UTC-6, Wonton wrote:

 Hello everyone,

 Recently I suffered the problem with the number of session files growing 
 very fast in my server. This worried me a lot because the server is a 
 development environment with only 4 or 5 testers, so when the number of 
 users is higher I guess I will have a big problem with this issue.
 I've tried to investigate about this but I'm not expert working with 
 web2py or with servers, so I have some questions:

 - A session file is created associated to a user each time that user logs 
 in. Is this ok?
 - My users make a login through auth.login_bare(user, password), does this 
 create a session file then?
 - What should be the code to remove the session file of a user when he/she 
 makes a logout?
 - I've set my auth.settings.expiration to 9, does this affect to 
 sessions too? As far as I know it only affects to when an inactive user is 
 automatically logged out, is this correct?
 - Testing this I've seen that with no logged users in my server, if I 
 manually remove the sessions files, some of them are created again!! Why 
 and how? As I said I have no users logged in the server.

 Regarding to the logout problem I've seen that my logout method is as 
 simple as this:

  def logout():
 if auth.user:
 auth.log_event(auth.messages.logout_log, auth.user)
 session.auth = None

 I don't really make a logout of the user so I change my method to this:

  def logout():
 if auth.user:
 print 'check 1'
 auth.logout()
 print 'check 2'
 session.auth = None

 But when this method is called, the output is this:
 check1

 check 2 is never printed so, has the user actually make a logout?

 I know they are a lot of questions, but any kind of help will be very 
 appreciated.

 Kind regards!


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] How to declare a pre-defined sqlite database

2014-01-03 Thread pythonic . jonathan
Hi,
I'm new to web2py. I have a SQLite database that must be pre-created and 
pre-populated (done by a separate python script) and would like to use it 
in my web2py application. There are currently 22 tables with anything from 
2 to 12 columns and I anticipate considerable changes will be made to the 
structure as I develop this.

My understanding is that I need to use the define_table DAL thing in my 
model.
However, my questions:

a) Is there a way to not have to do this but have web2py pick it up 
automatically?

b) If not, is there a way to automatically create the DAL code? I can 
create a Python script to do it for me, but it seems like something someone 
would have done already.

Thanks.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] parse_as_rest possible problem

2014-01-03 Thread Felipe Augusto Meirelles
Hi,

Can some one on the devs team explain this on DAL.py (line 8098):
if count  limits[1]-limits[0]:
return Row({'status':400,'error':'too many 
records','response':None})

I'm trying to use the parse_as_rest function, sending a request as 
/auth-user?offset=16limit=10. This should give me 10 records starting 
at the record 17, am I right?
If I remove this this condition, it seems to work just fine.

Any thoughts?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: executesql as_dict=True replacing ids during join

2014-01-03 Thread Anthony
I agree. Because executesql() can execute any arbitrary SQL, it can't know 
how to properly name the columns, so the best approach when there are 
duplicate column names is probably just to require explicit specification 
via the colnames argument.

Anthony

On Friday, January 3, 2014 9:18:53 PM UTC-5, Massimo Di Pierro wrote:

 I think if there is a duplicated entry, and as_dict=True we should raise 
 an exception and explain the reasons. Unless there is a way to make this 
 this not ambiguous.


 On Thursday, 2 January 2014 19:13:26 UTC-6, Anthony wrote:

 This may be tricky. In case of as_dict=True, executesql() uses the 
 adapter.cursor.description to get the column names, but there is no 
 indication which column name comes from which table, so if both tables have 
 the same column name, the dict will only get one of the columns. 
 executesql() does take a colnames argument, so you can instead supply the 
 column names directly, which is probably the best we can do in case of a 
 join.

 Anthony

 On Thursday, January 2, 2014 7:49:20 PM UTC-5, Massimo Di Pierro wrote:

 I think it is a bug. Please open a ticket linking this thread.

 On Thursday, 2 January 2014 13:20:04 UTC-6, ssuresh wrote:

 I found a peculiar problem when executing a join query on two tables. I 
 have two tables table1 and table2. Both have ids as their pks. table1 has 
 a 
 FK on table2 using table2_id field.

 Now when i do an executesql of the following query, 

 rows=executesql('select * from table1,table2 where table1.table2_id=
 table2.id',as_dict=True)

 I always get only one id field in the return dict and I dont know 
 whether the id is of table1 or table2.

 Am I doing something wrong, or is it a possible bug?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: parse_as_rest possible problem

2014-01-03 Thread Massimo Di Pierro
I am removing those lines because I cannot find a good reason for them. 


On Friday, 3 January 2014 09:26:07 UTC-6, Felipe Augusto Meirelles wrote:

 Hi,

 Can some one on the devs team explain this on DAL.py (line 8098):
 if count  limits[1]-limits[0]:
 return Row({'status':400,'error':'too many 
 records','response':None})

 I'm trying to use the parse_as_rest function, sending a request as 
 /auth-user?offset=16limit=10. This should give me 10 records starting 
 at the record 17, am I right?
 If I remove this this condition, it seems to work just fine.

 Any thoughts?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: executesql as_dict=True replacing ids during join

2014-01-03 Thread Massimo Di Pierro
OK. Done. Please check it.

On Friday, 3 January 2014 20:54:02 UTC-6, Anthony wrote:

 I agree. Because executesql() can execute any arbitrary SQL, it can't know 
 how to properly name the columns, so the best approach when there are 
 duplicate column names is probably just to require explicit specification 
 via the colnames argument.

 Anthony

 On Friday, January 3, 2014 9:18:53 PM UTC-5, Massimo Di Pierro wrote:

 I think if there is a duplicated entry, and as_dict=True we should raise 
 an exception and explain the reasons. Unless there is a way to make this 
 this not ambiguous.


 On Thursday, 2 January 2014 19:13:26 UTC-6, Anthony wrote:

 This may be tricky. In case of as_dict=True, executesql() uses the 
 adapter.cursor.description to get the column names, but there is no 
 indication which column name comes from which table, so if both tables have 
 the same column name, the dict will only get one of the columns. 
 executesql() does take a colnames argument, so you can instead supply the 
 column names directly, which is probably the best we can do in case of a 
 join.

 Anthony

 On Thursday, January 2, 2014 7:49:20 PM UTC-5, Massimo Di Pierro wrote:

 I think it is a bug. Please open a ticket linking this thread.

 On Thursday, 2 January 2014 13:20:04 UTC-6, ssuresh wrote:

 I found a peculiar problem when executing a join query on two tables. 
 I have two tables table1 and table2. Both have ids as their pks. table1 
 has 
 a FK on table2 using table2_id field.

 Now when i do an executesql of the following query, 

 rows=executesql('select * from table1,table2 where table1.table2_id=
 table2.id',as_dict=True)

 I always get only one id field in the return dict and I dont know 
 whether the id is of table1 or table2.

 Am I doing something wrong, or is it a possible bug?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] Important New Year News: PyCon 2014 Tutorial

2014-01-03 Thread Massimo Di Pierro
There will be a web2py tutorial at PyCon 2014.

https://us.pycon.org/2014/schedule/presentation/133/

Congratulations to Clifford Williams for proposing the tutorial and passing 
the selection process.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] Important New Year News: Edison Award

2014-01-03 Thread Massimo Di Pierro
Web2py/me have been nominated for the Edison Award. Please wish web2py (and 
me) good luck. :-)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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] auth signature and enable record versioning

2014-01-03 Thread 黄祥
hi,

i wonder what is the correlation between auth signature and enable record 
versioning.
e.g.
# on_define_bank
def on_define_bank(table): 
# notnull
table.bank.notnull = True

# create table : bank
db.define_table('bank', 
Field('bank'), 
auth.signature,
on_define = on_define_bank, 
format = '%(bank)s')

# enable_record_versioning
db.bank._enable_record_versioning()

# 1st question
this one work fine but if i make it lazy for enable_record_versioning, the 
archieve table is created but can't be accessed (it return an error), so i 
must comment or disable auth.signature to make it work. i wonder it why?
e.g.
# on_define_bank
def on_define_bank(table): 
# enable_record_versioning
table._enable_record_versioning()
# notnull
table.bank.notnull = True

# create table : bank
db.define_table('bank', 
Field('bank'), 
on_define = on_define_bank, 
format = '%(bank)s')

# 2nd question
let say i didn't use enable_record_versioning for each table and use 
auth.enable_record_versioning(db) at the end of define table. if i define 
auth.signature for each table, it will create the table archieve 
(enable_record_versioning is work), but when i comment or disable 
auth.signature on each tables, only auth tables is get the table archieve 
(enable_record_versioning work only in auth tables). i wonder it why?

any explaination about this?

thanks and best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: How to declare a pre-defined sqlite database

2014-01-03 Thread 黄祥
i think you can do it with the extract_sqlite_models.py that ships with 
web2py. the path is web2py/scripts/extract_sqlite_models.py.
you must have python installed when execute in windows environment.

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Important New Year News: Edison Award

2014-01-03 Thread 黄祥
have the wonthefull luck for you and web2py 
\(^o^)/

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: What is the purpose of data-w2p_disable_with?

2014-01-03 Thread User
Good to know.  How can I remove it for all my links?

On Monday, December 30, 2013 8:18:11 PM UTC-5, Anthony wrote:

 That's so the link can be temporarily disabled (the text will be replaced 
 with Working...) when it is used to trigger an Ajax request. However, I 
 don't know why it's included in the anchor tag in all cases -- seems like 
 it would only be needed when the cid, component, or callback 
 arguments are used.

 Anthony

 On Monday, December 30, 2013 5:39:53 PM UTC-5, User wrote:

 Links I build with the anchor A html helper look like:

 a href=/myapp/mycontroller/view/5 data-w2p_disable_with=defaultAnchor 
 Text/a

 What is the purpose of the data-w2p_disable_with = default attribute 
 and how can I remove it?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Important New Year News: Edison Award

2014-01-03 Thread Avi A
Good luck :).

On Saturday, January 4, 2014 6:08:38 AM UTC+2, Massimo Di Pierro wrote:

 Web2py/me have been nominated for the Edison Award. Please wish web2py 
 (and me) good luck. :-)



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: web2py running en AppFog

2014-01-03 Thread webpypy

Hi,

Please, translate this

EXPLANATION: http://jallander.wordpress.com/2014/01/03/web2py-en-appfog/


to English.

Regards,

Ashraf 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.