[web2py] Re: $100 reward to get a simple web2py app runnnig on GAE with Google Cloud SQL

2015-12-18 Thread Massimo Di Pierro
Instead of the reward please try these instructions (which work for me) and 
then write a blog post or a new section in the online book. :-)

1) install mysql (on mac "brew install mysql")
2) start mysql (on mac "mysql.server start")
3) sudo mysql
mysql> CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'foo';
mysql> CREATE DATABASE mydatabase;
mysql> GRANT INSERTON *.* TO 'testuser'@'localhost' IDENTIFIED BY 'foo';
4) download the trunk web2py and trunk dal

5) copy web2py/examples/app.yaml web2py/app.yaml and call your app 
"myappname"

6) copy web2py/handlers/gaehandler.py web2py/gaehandler.py

7) make a new app called test which is a clone of welcome and create a new 
model file which contains:

db1 = DAL('google:sql://testuser:yourappname/mydatabase')
8) start web2py with:

dev_appserver.py ./ --mysql_user=testuser --mysql_password=foo

I just did all the steps and it works for me. I had to comment two lines in 
the google sql adapter because they removed the charset argument from the 
connector.

Massimo

On Saturday, 12 December 2015 21:05:04 UTC-6, Tom Campbell wrote:
>
> I want to get a minimal web2py app running on Google Application Engine, 
> using Google Cloud SQL as the backing store. Have not succeeded. Obviously 
> because I have a much bigger app running locally and want to get that up 
> and running.
>
> If anyone can show me how to do this via Skype, a well-written text file, 
> tin can on a string, whatever, I'd happily pay $100 via PayPal, check, or 
> credit card. It will be a tiny web2py app that I write and the catch is 
> you'll have to sit with me online until I repeat the process once. I'm in 
> Seattle time, so GMT-8.
>
>
>
>

-- 
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/d/optout.


[web2py] Re: wfastcgi on IIS ... no more wfastcgi.py script?

2015-12-18 Thread Massimo Di Pierro
Could you put this in the book? Thanks Tim.

On Sunday, 13 December 2015 23:21:47 UTC-6, Tim Richardson wrote:
>
> Ok. Some tips to a future me if I have to do this again.
>
> wfastcgi is now a module. So currently the deployment instructions in the 
> web2py book give a download link. It's not necessary any longer. But some 
> paths have changed, and the configuration process is more automated.
>  
> https://pypi.python.org/pypi/wfastcgi
>
> 1) install it with pip
>
> 2) as administrator command prompt, run the executable 
> PYTHON_ROOT/Scripts/wfastcgi-enable.exe 
> This will update your IIS config. It seems to change the FastCGI setting 
> at the server level of the config
>
> It also sends some output to standard output, as described in the readme 
> at the pypi page above.
>
> If you follow the deployment instructions in the web2py book, you will 
> have a web.config file at the root of your web2py folder. 
>
> To finish updating the IIS configuration, you could copy the settings from 
> https://pypi.python.org/pypi/wfastcgi into the web.config page. 
> This meant, for me, adding a section like this:
>
> 
>  
>path="*"
>verb="*"
>modules="FastCgiModule"
>scriptProcessor=
> "e:\python27_32\python2.7.exe|e:\python27_32\lib\site-packages\wfastcgi.pyc"
>resourceType="Unspecified"
>requireAccess="Script" />
> 
>
> I didn't have the handlers section in the existing file. The 
> scriptProcessor value involves a pipe. You can copy that value from the 
> output of step (2). 
> When IIS starts, it will read from the file and update its configuration. 
> But it can only do that if you change Feature Delegation -> Handler 
> Mappings to Read/Write. It defaults to Read, which means the server gives 
> errors at start up which look like this: "The requested page cannot be 
> accessed because the related configuration data for the page is invalid"
>
> Get that sorted, and IIS will copy into its configuration the correct 
> setting. You can observe by going to the site setting for your web2py app 
> in IIS configuration, and views Handler Mappings. There you will see a 
> handler Python FastCGI configured according to the path above. You could 
> bypass the text file and set this up in IIS settings directly, per screen 
> shot. If you have existing IIS setup, you could probably just change the 
> path. I didn't know what I was doing so I didn't take this shortcut. 
>
>
> 
>
>
>
>
>
>
>  
>

-- 
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/d/optout.


[web2py] Re: Web2py and the Semantic Web question or problem

2015-12-18 Thread Massimo Di Pierro
Plugins belong in app so they are only listed there. Mind a plugin is an 
arbitrary set of files within an that follows the convention 
plugin_[name]*. So there is no place where all plugins are listed.

You make a distinction between an app and an appliance. I am not sure what 
you mean by "appliance". You can merge apps into larger apps or you have 
multiple apps share the same data. But if distinct apps use the same 
database each must have its own declaration of models because, by 
definition, an app must be autonomous.

Nobody has tried connect web2py to a triple store and I would love to see 
this.

Massimo



On Monday, 14 December 2015 06:23:18 UTC-6, Bruce Whealton wrote:
>
> Hello,
>  I recently started a course on Web2py on Pluralsight.  I was 
> excited to see support for marking up web pages with RDFa.  It is a great 
> idea to get more people
> using the Semantic Web technologies. 
> So, I downloaded the semantic appliance.  At first I thought maybe 
> I only need to drop the plugin into any site.  I have since realized that 
> more is included in the
> appliance.  Hence, I decided I'd install or import the semantic appliance 
> into web2py.  Would that be correct?
> Anyway, I thought I'd start with the semantic appliance and use 
> that to build the demo tutorial apps from the course on Pluralsight.  Then 
> I'd go and do the 
> markup mappings (using the Python Decorators ) so as to have an easy 
> solution for creating web sites with semantic markup.  There was one 
> problem though, and that
> was with the place where I would import a csv file (or perhaps some other 
> file).  Unfortunately, in the Admin area, when using this appliance, there 
> was no button for upload.
> There is an option to export from web2py but not import.  
>Getting data into the application is going to be important.  I 
> wonder if anyone else has noticed this problem.  It didn't appear that the 
> theme was just covering that
> button or link. 
>
> Two other quick questions (maybe 3):  
>  1) Does each appliance have to live in its own app - I ask 
> this as I was seeing appliances that would be great to use together.  There 
> might be a need for 
> overlap and sharing of data - meaning for example, having a Contacts 
> appliance, and the Semantic Appliance along with a blog would be nice to 
> have in one
> app as a great head-start on a project.
>  2) I was thinking that alternatively, I could check out the 
> plugins to  meet this kind of challenge.  Unfortunately, I couldn't find 
> any listing of web2py plugins.  Unless they are
> listed or collected with the appliances.
>
> As an aside, slightly off topic, it appears that there are no triple 
> stores implemented in Python.  One of my first Semantic Web programming 
> books was called "Programming the
> Semantic Web,"  which uses Python for development.  I know that python can 
> send SPARQL requests and do other things with triple stores written in other
> languages, e.g. Java.  I know I can use  the python module rdflib to send 
> SPARQL queries.  This may not be an issue of the language used to create a 
> triple store, but it would be
> fun to use a triple store database as the database for a python app.  Has 
> anyone done this?
> Thanks,
> Forgive me for going off on that tangent in the last paragraph...  I hope 
> I didn't lose anyone's attention or understanding as to what I am asking
> by including two questions and then going off and asking an unrelated 
> question.
> Thanks,
> Bruce
>

-- 
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/d/optout.


[web2py] Re: Can someone tell me stepwise how to upload web2py app on pythonanywhere after buying the domain?

2015-12-18 Thread Massimo Di Pierro
No. I strongly recommend not using godaddy. They charge more then others. 
They make it very hard to transfer the domains to others. They tend to 
charge users for services they do no need.

Almost any other domain registrar is better. I use gkg.net but I know there 
are many other and some are even cheaper. 

Massimo

On Monday, 14 December 2015 12:10:05 UTC-6, RAGHIB R wrote:
>
> Is buying domain from godaddy ok? How do I use that domain in 
> pythonanywhere after that and does pythonanywhere give hosting facilities?
>

-- 
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/d/optout.


[web2py] Re: The Almighty Form

2015-12-18 Thread Alfonso Serra

>
> you should instead hide the errors, and then you could add your own via 
> server-side DOM manipulation.
>

But how do i do that if i dont know when errors has happened?. 
Currently the form gets automatic markup when is instantiated and later on 
its modified when process is called.
But this is like executing the view before the controller.
Wouldnt be better to serialize the form just once, when xml() is called?, 
even perfomace wise since nothings gets serialized until its droped into a 
view.

Either i have to go back to my workaround or rearrange the SQLFORM code so 
gets serialized at the end of its lifespan, like it should, in my opinion.

So far ive overriden def xml(self) to something like 
return form.custom.begin +  self.createform(xfields=None) + form.custom.end

Ive to deal with some issues like xfields but i hope it will work. 
I appreciate your opinion about this matter.

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/d/optout.


[web2py] Re: Can web2py app be hosted on any other host other than pythonanywhere?

2015-12-18 Thread Massimo Di Pierro
To elaborate. 

Pyhton frameworks can run on any host that has python installed and a WSGI 
connector to the web server. If you have root access you can install a web 
server yourself (apahe, nginx, gunicorn, whatever) and configure it to 
connect to web2py. This means any dedicated VPS can run web2py like any 
other python framework.

What is special about PythonAnywhere is that they are the only hosting 
service who understood what makes web2py special and take advantage of it: 
the web based IDE called "admin". This means that they have a one-click 
button that installs web2py on their server for you and gives you direct 
access to admin, thus saving you the work and without requiring you to got 
through some custom interface like other hosting do.

Massimo





On Monday, 14 December 2015 13:13:28 UTC-6, Anthony wrote:
>
> On Monday, December 14, 2015 at 1:49:25 PM UTC-5, RAGHIB R wrote:
>>
>> If yes, where else?
>>
>
> Any VPS (e.g., Digital Ocean, Linode), Paas (e.g., Heroku, Google App 
> Engine), Iaas (e.g., AWS, Rackspace), and even shared hosting (e.g., 
> WebFaction). In other words, *anywhere*.
>
> 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/d/optout.


[web2py] Re: How to render with Auth.wiki and not with MARKMIN?

2015-12-18 Thread Massimo Di Pierro
web2py does not provide that functionality. It would be nice to add it.

On Tuesday, 15 December 2015 07:44:45 UTC-6, mweissen wrote:
>
> A new problem:
>
> I have a wiki with some pages, containing pictures (with the @-syntax) 
> and some environment-functions (with @{f:1,2,3}-syntax). It works well and 
> I am very satisfied.
>
> Now I want to put all these pages together, e.g. for a printed version.
> No problem to concatante all the wiki_page.body to a new string - let's 
> call this string "book".
>
> But I understand, markmin(book) does not understand the @-notation. 
> *I need to make the wiki render the "book". Is it possible?*
>
> 2015-11-06 8:13 GMT+01:00 Martin Weissenboeck :
>
>> One additional question:
>>
>> auth.wiki understands a page with some "@{myfunktion:1,2,3}" calls.
>> And I want to include pictures with something like "[[Description 
>> @///static/mypicture.png center]]".
>> How can I create a pdf-file using all the @-features?
>>
>> 2015-11-04 15:57 GMT+01:00 Martin Weissenboeck :
>>
>>> Thank you very much - this solves my problem: I want to use these files 
>>> in a wiki.
>>> It has not been clear for me whether "@args" will be resolved first 
>>> or "[[...]]".
>>>
>>> 2015-11-04 15:31 GMT+01:00 Massimo Di Pierro >> >:
>>>
 MARKMIN itself does not mess with paths. It just render the markup to 
 HTML. Paths are framework/application/routes dependent therefore there 
 cannot be a generic syntax in markmin that works in every case. The same 
 problem happens when the hostname changes.

 In auth.wiki we solve the problem by allowing this syntax: @args 
 where @[hostname]/[app]/[controller]/[function]/[args] and each part [...] 
 can be omitted. if omitted, it is put in by the server when generating the 
 response, before markmin is rendered.


 On Tuesday, 3 November 2015 01:58:46 UTC-6, mweissen wrote:
>
> I want to show a picture in a markmin file.
> This is my markmin text:
>
> [[Description /myapp/static/mypicture.png center]]
>
>
> Works fine, but if I want to use the same text in another application 
> I have to change it to
>  
>
> ​[[Description /myotherapp/static/mypicture.png center]]​
>
>
> It is possible to use something generic like  ./static/mypicture.png ?
>
> Regards, Martin
>
>
>
>>
>>
>
>
> -- 
> Mit freundlichen Grüßen / With kind regards 
> Martin Weissenböck
> Gregor-Mendel-Str. 37, 1190 Wien
> Austria / European Union
>
>

-- 
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/d/optout.


[web2py] Re: new feature - fabfile - please check it

2015-12-18 Thread Massimo Di Pierro
Oops. I just read this, after I posted 2.13.1. When you refactor scripts, 
feel free to move it to there.

On Tuesday, 15 December 2015 08:21:58 UTC-6, Niphlod wrote:
>
> IMHO it can be taken as a template but not as a provisioning tool unless 
> some strict checking on the environment is done beforehand.
>
>
> PS: let's keep the root clean 
>
> On Monday, December 14, 2015 at 10:43:25 PM UTC+1, mdipierro wrote:
>>
>> I included a fabfile in web2py which is derived from some work done by 
>> niphlod some time ago. 
>> Do you can setup a new server follows (requires pip install fabric): 
>>
>> cd web2py 
>>
>> fab -H root@host create_user:newuser   # create a new user, setup ssh 
>> keys, give sudo permissions 
>>
>> fab -H newuser@host  install_web2py  # install nginx, uwsgi, and web2py 
>>
>> fab -H newuser@host restart_webserver 
>>
>> cd applications/myapp 
>>
>> fab -H newuser@host deploy:myapp,all  #deploy a copy of the local app 
>>
>> fab -H newuser@host git_deploy:myapp,username/myapp # or deploy an app 
>> from github 
>>
>> fab -H newuser@host notify # notify users that system is going down 
>>
>> fab -H newuser@host down # disable the app and logout all users 
>>
>> fab -H newuser@host deploy:myapp # upgrate the app from local copy (only 
>> py, html, and static files) 
>>
>> fab -H newuser@host up # bring system up 
>>
>> fab -H newuser@host restore myapp-2015-12-12-19-30.zip # ouch! we messed 
>> up, restore previous version. 
>>
>> The -H is optional. It prompts for info if not passed. 
>> the appname “myapp” parameter is also option, defaults to the app of the 
>> folder in which you are. 
>> You can customize it as needed. 
>> You can also move this file at the level of an individual app folder and 
>> edit the env.hosts, env.user parameters so that it does not ask for -H ... 
>>
>> 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/d/optout.


[web2py] Re: How to debug a controller/function that hangs until timeout just when accessing specific db records?

2015-12-18 Thread Massimo Di Pierro
kudos for finding the solution yourself and posting the solution here.

On Tuesday, 15 December 2015 11:53:35 UTC-6, Lisandro wrote:
>
> I've found the problem: the view rendered by the function has an {{include 
> 'otherview.html'}} and that otherview.html had an error.
> What is strange is that web2py never throwed 500 error :/
>
> In my laptop I have the exact same configuration as in the server (that 
> is, nginx, uwsgi, same web2py version, same routes.py), and here in my 
> laptop it does throw the 500 error. Don't know why in the server hangs 
> until timeout.
>
> El martes, 15 de diciembre de 2015, 11:23:58 (UTC-3), Lisandro escribió:
>>
>> I'm pulling my hair off with this :P
>>
>> My app serves a news website. The database is in postgresql, and I'm 
>> using redis for caching resulting views.
>>
>> I have a controller/function that renders the view of an article.
>> Everything works great. In fact, I have an exact same copy of the app 
>> running for several websites. All of them are publishing articles 
>> correctly, no problem at all.
>>
>> Yesterday we installed a new website, that is, the same app. 
>> After publishing some articles, some of them are inaccessible: the 
>> browser just hangs until 504 gateway timeout is triggered (I'm using uwsgi 
>> with nginx).
>>
>> I already tried:
>> - flusing redis cache
>> - using cache.ram
>> - using no cache at all
>> - activated LOGGING=True in my wsgihandler.py
>>
>>
>> The server has a lot of available resources. Also, it's not a problem of 
>> nginx connections or uwsgi workers, as I said, the app still renders ok all 
>> the articles, except for some of them.
>>
>> I don't know where to look for more details. Nginx error log shows this:
>> 2015/12/15 11:17:28 [error] 26865#0: *1817630 upstream timed out (110: 
>> Connection timed out) while reading response header from upstream, client: 
>> 24.232.71.5, server: mydomain.com.ar, request: "GET 
>> /noticia/108/bbb-beta HTTP/1.1", upstream: 
>> "uwsgi://unix:///tmp/medios.socket", host: "mydomain.com.ar", referrer: "
>> http://mydomain.com.ar/";
>>
>> which is ok, considering the configuration. Basically, the error says 
>> that uwsgi didn't send a response to nginx within 60 seconds.
>> In the uwsgi log, I don't see any errors. It seems like web2py isn't 
>> responding with anything, but I don't know where to check what is web2py 
>> doing.
>>
>> If there is a senior developer, I wouldn't mind to contact by private and 
>> agree some price for the job. I really need to find the cause of the 
>> problem.
>>
>

-- 
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/d/optout.


[web2py] Re: How do I make users fill particular fields of the auth_user table later after signing up?

2015-12-18 Thread Massimo Di Pierro
My trick is this. Create an auth_user field like profile_completed which 
default to false. Then add somewhere in models:

if auth.user and not auth.user.filled_profile:
redirect(URL('default','user/profile'))



On Wednesday, 16 December 2015 04:34:46 UTC-6, aston.ri...@gmail.com wrote:
>
> For example, their profile pic have to be posted they  sign up. But they 
> are forced to fill everything in the beginning only. How to make them fill 
> certain fields only in the beginning? 
>

-- 
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/d/optout.


[web2py] Re: web2py as an API provider

2015-12-18 Thread Massimo Di Pierro
Tornado is mostly a web server. You can use tornado with web2py. In fact we 
use tornado in web2py in the  

gluon/contrib/websocket_messaging.py.


Of course web2py adds overhead because it parses the header, handles 
language preferences, sessions, database connections, templates. Etc. You 
would get the same overhead in tornado if you add those functionality.


If you build a minimalist webapp that does lots of caching and no (or rare) 
db connections, than tornado is faster.


Massimo





On Wednesday, 16 December 2015 09:02:38 UTC-6, desta wrote:
>
> I am thinking of using web2py to build a REST API project. I believe that 
> features like authentication and authorization will save me a lot of 
> development time and I will be able to focus on building the API. I already 
> know that web2py is a great and reliable platform but I would like to hear 
> your opinion whether web2py is suitable for a professional level API.
>
> I am wondering whether the overhead of using web2py as compared to using 
> Tornado for example will cause me problems in terms of performance. Another 
> thing that I consider is the updating. In one of my previous projects, a 
> web2py update 'broke' the application and if it was live it would have 
> caused me a long downtime.
>
> Thank you for reading and I am looking forward for your comments.
>

-- 
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/d/optout.


[web2py] Re: Can't use to download a file

2015-12-18 Thread Adrien
Oh ok thanks Anthony, i used that : 
clep

I didn't know i have to use the static folder to upload files, thx you :)

Le jeudi 17 décembre 2015 16:58:05 UTC+1, Anthony a écrit :
>
> On Thursday, December 17, 2015 at 9:34:33 AM UTC-5, Adrien wrote:
>>
>> Hi everyone,
>>
>> I'm trying to create a link to download files, but it doesn't work .. It 
>> redirect me like a simple link.
>>
>> This is what i'm using : 
>>
>> This file is default/index.html
>> clep
>>
>
> The only files web2py will serve directly via the file path are those in 
> the /static folder, and even then, you would not specify an OS file path 
> (including a ../) as the href -- you would instead generate a web2py URL 
> with "static" as the controller (e.g., URL('static', 'uploads/clep.pdf')).
>
> For files uploaded via a DAL upload field, you should use the 
> response.download() method. The scaffolding app includes a download() 
> function in the default.py controller that uses this method.
>
> In your case, it looks like you have manually put the clep.pdf file in the 
> /uploads folder, as it hasn't been renamed as it would be if uploaded via a 
> DAL upload field. To return such a file, you would instead have to use 
> response.stream(). To prevent a directory traversal attack, you would 
> probably also want to add a signature to the URL and add the 
> @auth.requires_signature() decorator to your download function (this will 
> prevent a malicious user from specifying any arbitrary file in the request 
> URL, as the signature will be associated with the particular file in the 
> link you create).
>
> Note, if the clep.pdf file is intended to be available to the public, just 
> put it in the /static folder.
>
> 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/d/optout.


[web2py] Re: Ordering a dropdown in SQLFORM alphabetically

2015-12-18 Thread Massimo Di Pierro
should this be?

db.mentors.auth_user_id.requires = IS_IN_DB(db, 'auth_user.id', 
'%(first_name)s', orderby = db.auth_user.first_name)

On Wednesday, 16 December 2015 17:29:21 UTC-6, Evan Caldwell wrote:
>
> I tried:
> db.mentors.auth_user_id.requires = IS_IN_DB(db, 'auth_user.id', '%(name)s'
> , orderby = db.auth_user.first_name)
> but it had no effect. I read on another question about building and 
> ordering a set and then using IS_IN_SET on that but I'm not sure how to go 
> about doing that; can I do a query right below my mentor table definition 
> in the model? Sorry for being such a noob.
>
>
> On Wednesday, December 16, 2015 at 12:48:10 PM UTC-7, Niphlod wrote:
>>
>> a proper IS_IN_DB with the correct orderby in models should be the 
>> easiest way to go.
>>
>> On Wednesday, December 16, 2015 at 8:33:06 PM UTC+1, Evan Caldwell wrote:
>>>
>>>
>>> I am having a hard time ordering a dropdown in a SQLFORM alphabetically.
>>>
>>> In my model:
>>> db.define_table('departments',
>>> Field('name', notnull=True, unique=True),
>>> Field('college_id','reference college', label='College'),
>>> Field('department_rep_user_id','reference auth_user', 
>>> label='Department Representative'),
>>> auth.signature,
>>> format='%(name)s')
>>>
>>> db.define_table('mentors',
>>> Field('auth_user_id', 'reference auth_user', unique=True),
>>> Field('department_id', 'reference departments', label='Department'),
>>> auth.signature,
>>> format=repr_mentor_table)
>>>
>>> db.define_table('abstracts',
>>> Field('title', notnull=True, unique=True),
>>> Field('college_id', 'reference college', label='College'),
>>> Field('department_id', 'reference departments', label='Abstract 
>>> Department'),
>>> Field('mentor_id', 'reference mentors', label='Mentor'),
>>> Field('classes_id', 'reference classes', label='Class', comment="If 
>>> your abstract is connected to a specific class (perhaps as a class 
>>> project), select your class. Otherwise, select 'Does not apply'"),
>>> Field('session_id', 'reference sessions', label='Session'),
>>> Field('presentation_format_id', 'reference presentation_formats', 
>>> label='Presentation Format'),
>>> Field('body','text'),
>>> Field('attatchment', 'upload'),
>>> Field('location_id', 'reference locations', label='Location'),
>>> Field('conference_id', 'reference conferences', label='Conference'),
>>> Field('presentation_time', 'time', notnull=False, 
>>> requires=IS_TIME(), label='Presentation Time'),
>>> Field('booth_space', label='Booth Space'),
>>> Field('initial_approval', 'boolean', label='Initial Approval', 
>>> default=None),
>>> Field('final_approval', 'boolean', label='Final Approval', 
>>> default=None),
>>> Field('competing_status', 'boolean', label='Competing Status', 
>>> default=None),
>>> auth.signature,
>>> format='%(title)s',
>>> singular="Abstract",
>>> plural="Abstracts",
>>> )
>>>
>>> In the controller
>>> def abstracts():
>>> response.title = "Abstracts"
>>>
>>> def get_primary_author(abstract_row):
>>> author_row = db(
>>> (db.abstract_author.primary_author==True) &
>>> (db.abstract_author.abstract_id==abstract_row.id) &
>>> (db.abstract_author.auth_user_id==db.auth_user.id)
>>> ).select(
>>> db.auth_user.first_name,
>>> db.auth_user.last_name).first()
>>> return author_row.first_name + ' ' + author_row.last_name
>>>
>>> def abstracts_body_represent(body, row):
>>> sanitized = str(rcwc_sanitizer(body))
>>>
>>> # This is really fragile. For some reason the grid isn't 
>>> enforcing
>>> # maxtextlength if the represent is called.
>>> if len(request.args) == 1: # not on the grid page
>>> sanitized = "{0}...".format(sanitized[:100])
>>> return XML(sanitized) # If this returns a string it isn't used
>>>
>>> db.abstracts.body.represent = abstracts_body_represent
>>>
>>> grid = SQLFORM.smartgrid(
>>> db.abstracts,
>>> user_signature=False,
>>> searchable=True,
>>> linked_tables=['abstract_author'],
>>> links=[
>>> {"header": "Primary Author", "body":get_primary_author},
>>> ],
>>> links_placement="left",
>>> paginate=75,
>>> )
>>>
>>> return locals()
>>>
>>> When I go to create a new abstract in the abstracts table the dropdown 
>>> for Mentors (mentor_id field) is not alphabetically ordered. Can this be 
>>> accomplished in the model or would I need to work it out in the controller?
>>>
>>>

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

[web2py] Re: web2py instant admin

2015-12-18 Thread Varun Talikoti
Hi Kevin. Could you fix this issue? I'd be thankful to you if you could 
give me any leads on this.

Thanks
Varun Talikoti

On Wednesday, July 25, 2012 at 5:43:34 AM UTC+5:30, Kevin Miller wrote:
>
> Hi all, 
>
> Anyone using web2py instant admin?
> I have a problem with the css. I have installed the plugin its functional, 
> but its not picking up the CSS.
> Any reason?
>
> Thanks very much.
>
> Kevin
>

-- 
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/d/optout.


[web2py] Re: Select list:reference fields in one database query

2015-12-18 Thread Massimo Di Pierro
yes and no. It is not efficient and it is not an alternative to joins. Yes 
it is convenient and a little smart than you think. For example:

*row.product*

is an Reference object (extends integer) and there is no nested query.

*row.product.name *

now this does a nested query and remembers it

*row.product.vendor*

No more query because it remembers the previous query.

*row.product.vendor.name *

Here you have another nested query

*row.product.categories*

this is a list of references so there is no nested query only a lost of 
reference objects. The query happens when you do

*row.product.categories[0].name*

etc.

On Sunday, 13 December 2015 07:09:23 UTC-6, Robin Manoli wrote:
>
> Is there a way to select a set of fields and corresponding list:reference 
> fields in one query?
>
> I have these three tables:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *db.define_table( 'product',Field( 'name' ),Field( 'categories', 
> 'list:reference category' ),Field( 'vendor', 'reference vendor' 
> ), )db.define_table( 'vendor',Field( 'name' ),)db.define_table( 
> 'category',Field( 'name' ),)*
> Now I can select all products with correspoding vendors in one query such 
> as:
>
> *query = (db.product.id  > 0) & (db.**product.**vendor 
> == db.*
>
>
> *vendor.id)rows = db( query ).select()*I access product as *row.product* 
> and vendor as *row.vendor*
> I can also access *row.product.categories*, but doesn't that mean each 
> product creates a unique mysql query? How to make it efficient?
>
>
>

-- 
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/d/optout.


[web2py] Re: Scheduler worker name

2015-12-18 Thread Gael Princivalle
I've set a scheduler in a new application and tasks are running.

So probably there's a problem when a app comes from a previous web2py 
version.
Anyway I think it can be resolved deleting the scheduler and create it 
again, but I've tried to:
Killing the worker - Ok
Delete Scheduler Ko

When I delete the scheduler.py file from admin web2py creates it again.

How can I delete the scheduler?

Thanks, regards.

Il giorno giovedì 17 dicembre 2015 21:40:36 UTC+1, Gael Princivalle ha 
scritto:
>
> Thanks Niphlod.
>
> >So, here it is the breakdown of the possible issues:
> >- are tasks QUEUED or ASSIGNED ?
> QUEUED. But if I set the net run time to now + 2 minutes I can check that 
> task don't run.
> Status options don't have ASSIGNED.
>
> >If they are QUEUED, either they can't be executed yet (i.e. start_time in 
> the future) or tasks are queued with a group_name that can't be processed 
> by a worker . 
> Main group for all.
>
> *>Check #1: there should be a scheduler_task row with group_name "in" 
> scheduler_worker group_names*
> >- if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker is 
> running or workers can't agree on who is "the ticker".
> Well worker is running and main is the group_name.
>
> *>Check #2 (there should be a scheduler_worker with is_ticker = True)*
> Yes it have.
>
> Check is complete. I think I will cancel the scheduler and create it 
> again. Thanks for your help.
>
> Il giorno giovedì 17 dicembre 2015 21:21:56 UTC+1, Niphlod ha scritto:
>>
>> I thought more people liked to see the code : I find myself explaining 
>> scheduler internals more often than I'd like to :P
>>
>> soo. worker names worker names are used to identify a worker 
>> process (it's enforced as unique in the model)...
>> I'll reply to some ideal "FAQ" questions
>> - Why worker names are important ? Because tasks ASSIGNED to a 
>> worker_name (assigned_worker_name in scheduler_task) get processed by 
>> that worker, and that worker only
>> - Who chooses worker names ? the worker itself. It does so concatenating 
>> the hostname and the PID, which results in a good (and unique) way to 
>> identify a process.
>> - Who chooses that task "foo" gets processed by worker "bar" ? A worker. 
>> It's when tasks from QUEUED go to the ASSIGNED status... The worker that 
>> does this is "the ticker". The ticker is "elected" with a dumb (and slow) - 
>> but reliable - algorithm among workers: it's the only one that can "assign" 
>> tasks (either to itself or to other workers). The only thing that blocks a 
>> ticker to assign tasks to a worker is the group_name.
>>
>> So, here it is the breakdown of the possible issues:
>> - are tasks QUEUED or ASSIGNED ? If they are QUEUED, either they can't be 
>> executed yet (i.e. start_time in the future) or tasks are queued with a 
>> group_name that can't be processed by a worker . 
>> *Check #1: there should be a scheduler_task row with group_name "in" 
>> scheduler_worker group_names*
>> - if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker is 
>> running or workers can't agree on who is "the ticker". 
>> *Check #2 (there should be a scheduler_worker with is_ticker = True)*
>> That should be it.
>>
>>
>> Note: if tasks are ASSIGNED to a worker that isn't there anymore (i.e. is 
>> dead or, in your case, you changed hosting facility) it's not an issue. Any 
>> worker, periodically, checks if ALL other workers are alive (and kicking) 
>> and if a worker isn't kicking it's removed from the scheduler_worker table 
>> AND all tasks ASSIGNED to it gets redistributed among live workers. This in 
>> addition to the ticker redistributing tasks every once in a while if 
>> they're ready to be executed but not executed yet (it can, and it does 
>> happen, that a worker is busy processing a long-running task while there 
>> are other tasks ready to be processed (by other workers). Every worker gets 
>> a fair chance of doing something useful instead of sleeping)
>>
>> On Thursday, December 17, 2015 at 9:02:11 PM UTC+1, Gael Princivalle 
>> wrote:
>>>
>>> Hello to all.
>>>
>>> I've migrate my webfaction hosting to another webfaction hosting that run 
>>> CentOS 7 (before it was a previous version of CentOS).
>>> I was running web2py 2.9.12, now I have web2py 2.12.3.
>>>
>>> I've got a strange problem with the scheduler.
>>>
>>> Workers are in the db, they run, they are assigned to tasks, but tasks 
>>> don't run.
>>> When I've created new workers tasks have not take automatically the 
>>> worker name. I've put all worker names by myself.
>>>
>>> Perhaps the problem is due to the worker names.
>>> In the previous hosting they were like that:
>>> s18060957#14459
>>>
>>> And now they have the webserver name:
>>> web490.webfaction.com#12949
>>>
>>> web2py seems to codify the webserver name, but in this new configuration 
>>> it don't.
>>> Is it why Scheduler don't run tasks?
>>> How I can resolve that?
>>>
>>> Thanks, regards.
>>>
>>

-- 
Resources:
- http://w

[web2py] Re: Scheduler worker name

2015-12-18 Thread Niphlod


On Friday, December 18, 2015 at 10:45:22 AM UTC+1, Gael Princivalle wrote:
>
> I've set a scheduler in a new application and tasks are running.
>
> So probably there's a problem when a app comes from a previous web2py 
> version.
>

as long as you let migration happen, no issues whatsoever.
 

> Anyway I think it can be resolved deleting the scheduler and create it 
> again, but I've tried to:
> Killing the worker - Ok
> Delete Scheduler Ko
>
> When I delete the scheduler.py file from admin web2py creates it again.
>
> How can I delete the scheduler?
>

delete what ? the istantiation ? 
 

>
> Thanks, regards.
>
> Il giorno giovedì 17 dicembre 2015 21:40:36 UTC+1, Gael Princivalle ha 
> scritto:
>>
>> Thanks Niphlod.
>>
>> >So, here it is the breakdown of the possible issues:
>> >- are tasks QUEUED or ASSIGNED ?
>> QUEUED. But if I set the net run time to now + 2 minutes I can check that 
>> task don't run.
>> Status options don't have ASSIGNED.
>>
>> >If they are QUEUED, either they can't be executed yet (i.e. start_time 
>> in the future) or tasks are queued with a group_name that can't be 
>> processed by a worker . 
>> Main group for all.
>>
>> *>Check #1: there should be a scheduler_task row with group_name "in" 
>> scheduler_worker group_names*
>> >- if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker is 
>> running or workers can't agree on who is "the ticker".
>> Well worker is running and main is the group_name.
>>
>> *>Check #2 (there should be a scheduler_worker with is_ticker = True)*
>> Yes it have.
>>
>> Check is complete. I think I will cancel the scheduler and create it 
>> again. Thanks for your help.
>>
>> Il giorno giovedì 17 dicembre 2015 21:21:56 UTC+1, Niphlod ha scritto:
>>>
>>> I thought more people liked to see the code : I find myself explaining 
>>> scheduler internals more often than I'd like to :P
>>>
>>> soo. worker names worker names are used to identify a worker 
>>> process (it's enforced as unique in the model)...
>>> I'll reply to some ideal "FAQ" questions
>>> - Why worker names are important ? Because tasks ASSIGNED to a 
>>> worker_name (assigned_worker_name in scheduler_task) get processed by 
>>> that worker, and that worker only
>>> - Who chooses worker names ? the worker itself. It does so concatenating 
>>> the hostname and the PID, which results in a good (and unique) way to 
>>> identify a process.
>>> - Who chooses that task "foo" gets processed by worker "bar" ? A worker. 
>>> It's when tasks from QUEUED go to the ASSIGNED status... The worker that 
>>> does this is "the ticker". The ticker is "elected" with a dumb (and slow) - 
>>> but reliable - algorithm among workers: it's the only one that can "assign" 
>>> tasks (either to itself or to other workers). The only thing that blocks a 
>>> ticker to assign tasks to a worker is the group_name.
>>>
>>> So, here it is the breakdown of the possible issues:
>>> - are tasks QUEUED or ASSIGNED ? If they are QUEUED, either they can't 
>>> be executed yet (i.e. start_time in the future) or tasks are queued with a 
>>> group_name that can't be processed by a worker . 
>>> *Check #1: there should be a scheduler_task row with group_name "in" 
>>> scheduler_worker group_names*
>>> - if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker is 
>>> running or workers can't agree on who is "the ticker". 
>>> *Check #2 (there should be a scheduler_worker with is_ticker = True)*
>>> That should be it.
>>>
>>>
>>> Note: if tasks are ASSIGNED to a worker that isn't there anymore (i.e. 
>>> is dead or, in your case, you changed hosting facility) it's not an issue. 
>>> Any worker, periodically, checks if ALL other workers are alive (and 
>>> kicking) and if a worker isn't kicking it's removed from the 
>>> scheduler_worker table AND all tasks ASSIGNED to it gets redistributed 
>>> among live workers. This in addition to the ticker redistributing tasks 
>>> every once in a while if they're ready to be executed but not executed yet 
>>> (it can, and it does happen, that a worker is busy processing a 
>>> long-running task while there are other tasks ready to be processed (by 
>>> other workers). Every worker gets a fair chance of doing something useful 
>>> instead of sleeping)
>>>
>>> On Thursday, December 17, 2015 at 9:02:11 PM UTC+1, Gael Princivalle 
>>> wrote:

 Hello to all.

 I've migrate my webfaction hosting to another webfaction hosting that 
 run CentOS 7 (before it was a previous version of CentOS).
 I was running web2py 2.9.12, now I have web2py 2.12.3.

 I've got a strange problem with the scheduler.

 Workers are in the db, they run, they are assigned to tasks, but tasks 
 don't run.
 When I've created new workers tasks have not take automatically the 
 worker name. I've put all worker names by myself.

 Perhaps the problem is due to the worker names.
 In the previous hosting they were like that:
 s18060957#

[web2py] Re: Scheduler worker name

2015-12-18 Thread Gael Princivalle
>delete what ? the istantiation ? 

Delete the scheduler.py file from models and all scheduler tables.
How can I do it?

Il giorno venerdì 18 dicembre 2015 10:48:23 UTC+1, Niphlod ha scritto:
>
>
>
> On Friday, December 18, 2015 at 10:45:22 AM UTC+1, Gael Princivalle wrote:
>>
>> I've set a scheduler in a new application and tasks are running.
>>
>> So probably there's a problem when a app comes from a previous web2py 
>> version.
>>
>
> as long as you let migration happen, no issues whatsoever.
>  
>
>> Anyway I think it can be resolved deleting the scheduler and create it 
>> again, but I've tried to:
>> Killing the worker - Ok
>> Delete Scheduler Ko
>>
>> When I delete the scheduler.py file from admin web2py creates it again.
>>
>> How can I delete the scheduler?
>>
>
> delete what ? the istantiation ? 
>  
>
>>
>> Thanks, regards.
>>
>> Il giorno giovedì 17 dicembre 2015 21:40:36 UTC+1, Gael Princivalle ha 
>> scritto:
>>>
>>> Thanks Niphlod.
>>>
>>> >So, here it is the breakdown of the possible issues:
>>> >- are tasks QUEUED or ASSIGNED ?
>>> QUEUED. But if I set the net run time to now + 2 minutes I can check 
>>> that task don't run.
>>> Status options don't have ASSIGNED.
>>>
>>> >If they are QUEUED, either they can't be executed yet (i.e. start_time 
>>> in the future) or tasks are queued with a group_name that can't be 
>>> processed by a worker . 
>>> Main group for all.
>>>
>>> *>Check #1: there should be a scheduler_task row with group_name "in" 
>>> scheduler_worker group_names*
>>> >- if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker is 
>>> running or workers can't agree on who is "the ticker".
>>> Well worker is running and main is the group_name.
>>>
>>> *>Check #2 (there should be a scheduler_worker with is_ticker = True)*
>>> Yes it have.
>>>
>>> Check is complete. I think I will cancel the scheduler and create it 
>>> again. Thanks for your help.
>>>
>>> Il giorno giovedì 17 dicembre 2015 21:21:56 UTC+1, Niphlod ha scritto:

 I thought more people liked to see the code : I find myself explaining 
 scheduler internals more often than I'd like to :P

 soo. worker names worker names are used to identify a 
 worker process (it's enforced as unique in the model)...
 I'll reply to some ideal "FAQ" questions
 - Why worker names are important ? Because tasks ASSIGNED to a 
 worker_name (assigned_worker_name in scheduler_task) get processed by 
 that worker, and that worker only
 - Who chooses worker names ? the worker itself. It does so 
 concatenating the hostname and the PID, which results in a good (and 
 unique) way to identify a process.
 - Who chooses that task "foo" gets processed by worker "bar" ? A 
 worker. It's when tasks from QUEUED go to the ASSIGNED status... The 
 worker 
 that does this is "the ticker". The ticker is "elected" with a dumb (and 
 slow) - but reliable - algorithm among workers: it's the only one that can 
 "assign" tasks (either to itself or to other workers). The only thing that 
 blocks a ticker to assign tasks to a worker is the group_name.

 So, here it is the breakdown of the possible issues:
 - are tasks QUEUED or ASSIGNED ? If they are QUEUED, either they can't 
 be executed yet (i.e. start_time in the future) or tasks are queued with a 
 group_name that can't be processed by a worker . 
 *Check #1: there should be a scheduler_task row with group_name "in" 
 scheduler_worker group_names*
 - if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker is 
 running or workers can't agree on who is "the ticker". 
 *Check #2 (there should be a scheduler_worker with is_ticker = True)*
 That should be it.


 Note: if tasks are ASSIGNED to a worker that isn't there anymore (i.e. 
 is dead or, in your case, you changed hosting facility) it's not an issue. 
 Any worker, periodically, checks if ALL other workers are alive (and 
 kicking) and if a worker isn't kicking it's removed from the 
 scheduler_worker table AND all tasks ASSIGNED to it gets redistributed 
 among live workers. This in addition to the ticker redistributing tasks 
 every once in a while if they're ready to be executed but not executed yet 
 (it can, and it does happen, that a worker is busy processing a 
 long-running task while there are other tasks ready to be processed (by 
 other workers). Every worker gets a fair chance of doing something useful 
 instead of sleeping)

 On Thursday, December 17, 2015 at 9:02:11 PM UTC+1, Gael Princivalle 
 wrote:
>
> Hello to all.
>
> I've migrate my webfaction hosting to another webfaction hosting that 
> run CentOS 7 (before it was a previous version of CentOS).
> I was running web2py 2.9.12, now I have web2py 2.12.3.
>
> I've got a strange problem with the scheduler.
>
> Workers are in the db

[web2py] Re: Scheduler worker name

2015-12-18 Thread Niphlod
scheduler tables can be dropped manually
deleting scheduler.py also.
But I still don't think that it's the way to fix the issue you're facing.

On Friday, December 18, 2015 at 11:22:57 AM UTC+1, Gael Princivalle wrote:
>
> >delete what ? the istantiation ? 
>
> Delete the scheduler.py file from models and all scheduler tables.
> How can I do it?
>
> Il giorno venerdì 18 dicembre 2015 10:48:23 UTC+1, Niphlod ha scritto:
>>
>>
>>
>> On Friday, December 18, 2015 at 10:45:22 AM UTC+1, Gael Princivalle wrote:
>>>
>>> I've set a scheduler in a new application and tasks are running.
>>>
>>> So probably there's a problem when a app comes from a previous web2py 
>>> version.
>>>
>>
>> as long as you let migration happen, no issues whatsoever.
>>  
>>
>>> Anyway I think it can be resolved deleting the scheduler and create it 
>>> again, but I've tried to:
>>> Killing the worker - Ok
>>> Delete Scheduler Ko
>>>
>>> When I delete the scheduler.py file from admin web2py creates it again.
>>>
>>> How can I delete the scheduler?
>>>
>>
>> delete what ? the istantiation ? 
>>  
>>
>>>
>>> Thanks, regards.
>>>
>>> Il giorno giovedì 17 dicembre 2015 21:40:36 UTC+1, Gael Princivalle ha 
>>> scritto:

 Thanks Niphlod.

 >So, here it is the breakdown of the possible issues:
 >- are tasks QUEUED or ASSIGNED ?
 QUEUED. But if I set the net run time to now + 2 minutes I can check 
 that task don't run.
 Status options don't have ASSIGNED.

 >If they are QUEUED, either they can't be executed yet (i.e. start_time 
 in the future) or tasks are queued with a group_name that can't be 
 processed by a worker . 
 Main group for all.

 *>Check #1: there should be a scheduler_task row with group_name "in" 
 scheduler_worker group_names*
 >- if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker 
 is running or workers can't agree on who is "the ticker".
 Well worker is running and main is the group_name.

 *>Check #2 (there should be a scheduler_worker with is_ticker = True)*
 Yes it have.

 Check is complete. I think I will cancel the scheduler and create it 
 again. Thanks for your help.

 Il giorno giovedì 17 dicembre 2015 21:21:56 UTC+1, Niphlod ha scritto:
>
> I thought more people liked to see the code : I find myself explaining 
> scheduler internals more often than I'd like to :P
>
> soo. worker names worker names are used to identify a 
> worker process (it's enforced as unique in the model)...
> I'll reply to some ideal "FAQ" questions
> - Why worker names are important ? Because tasks ASSIGNED to a 
> worker_name (assigned_worker_name in scheduler_task) get processed by 
> that worker, and that worker only
> - Who chooses worker names ? the worker itself. It does so 
> concatenating the hostname and the PID, which results in a good (and 
> unique) way to identify a process.
> - Who chooses that task "foo" gets processed by worker "bar" ? A 
> worker. It's when tasks from QUEUED go to the ASSIGNED status... The 
> worker 
> that does this is "the ticker". The ticker is "elected" with a dumb (and 
> slow) - but reliable - algorithm among workers: it's the only one that 
> can 
> "assign" tasks (either to itself or to other workers). The only thing 
> that 
> blocks a ticker to assign tasks to a worker is the group_name.
>
> So, here it is the breakdown of the possible issues:
> - are tasks QUEUED or ASSIGNED ? If they are QUEUED, either they can't 
> be executed yet (i.e. start_time in the future) or tasks are queued with 
> a 
> group_name that can't be processed by a worker . 
> *Check #1: there should be a scheduler_task row with group_name "in" 
> scheduler_worker group_names*
> - if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker 
> is running or workers can't agree on who is "the ticker". 
> *Check #2 (there should be a scheduler_worker with is_ticker = True)*
> That should be it.
>
>
> Note: if tasks are ASSIGNED to a worker that isn't there anymore (i.e. 
> is dead or, in your case, you changed hosting facility) it's not an 
> issue. 
> Any worker, periodically, checks if ALL other workers are alive (and 
> kicking) and if a worker isn't kicking it's removed from the 
> scheduler_worker table AND all tasks ASSIGNED to it gets redistributed 
> among live workers. This in addition to the ticker redistributing tasks 
> every once in a while if they're ready to be executed but not executed 
> yet 
> (it can, and it does happen, that a worker is busy processing a 
> long-running task while there are other tasks ready to be processed (by 
> other workers). Every worker gets a fair chance of doing something useful 
> instead of sleeping)
>
> On Thursday, December 17, 2015 at 9:02

[web2py] Re: Scheduler worker name

2015-12-18 Thread Gael Princivalle
>scheduler tables can be dropped manually
Done

>deleting scheduler.py also.
Done

>But I still don't think that it's the way to fix the issue you're facing.
Well I'm not able to understand which is this problem, as when I create a 
scheduler in a new app tasks are running.
For the moment creating a new scheduler is my better idea, if you have a 
better one thanks.

Anyway now I've got this error when I try to open the scheduler table, for 
example scheduler_task.
My db string have now migrate=True, fake_migrate_all=True.
My only other idea is rebuild all the app starting from a new one, but if I 
can resolve it in a shorter way I prefer.

Traceback (most recent call last):
  File 
"/home/tasko/webapps/w2p_2_12_3/web2py/applications/hydrover_oleodinamica/controllers/appadmin.py",
 line 238, in select
nrows = db(query).count()
  File 
"/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/objects.py", 
line 1992, in count
return db._adapter.count(self.query,distinct)
  File 
"/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/base.py",
 line 1311, in count
self.execute(self._count(query, distinct))
  File 
"/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/postgres.py",
 line 360, in execute
return BaseAdapter.execute(self, *a, **b)
  File 
"/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/base.py",
 line 1378, in execute
return self.log_execute(*a, **b)
  File 
"/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/base.py",
 line 1372, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
ProgrammingError: relation "scheduler_task" does not exist
LINE 1: SELECT count(*) FROM "scheduler_task" WHERE ("scheduler_task...




Il giorno venerdì 18 dicembre 2015 11:58:15 UTC+1, Niphlod ha scritto:
>
> scheduler tables can be dropped manually
> deleting scheduler.py also.
> But I still don't think that it's the way to fix the issue you're facing.
>
> On Friday, December 18, 2015 at 11:22:57 AM UTC+1, Gael Princivalle wrote:
>>
>> >delete what ? the istantiation ? 
>>
>> Delete the scheduler.py file from models and all scheduler tables.
>> How can I do it?
>>
>> Il giorno venerdì 18 dicembre 2015 10:48:23 UTC+1, Niphlod ha scritto:
>>>
>>>
>>>
>>> On Friday, December 18, 2015 at 10:45:22 AM UTC+1, Gael Princivalle 
>>> wrote:

 I've set a scheduler in a new application and tasks are running.

 So probably there's a problem when a app comes from a previous web2py 
 version.

>>>
>>> as long as you let migration happen, no issues whatsoever.
>>>  
>>>
 Anyway I think it can be resolved deleting the scheduler and create it 
 again, but I've tried to:
 Killing the worker - Ok
 Delete Scheduler Ko

 When I delete the scheduler.py file from admin web2py creates it again.

 How can I delete the scheduler?

>>>
>>> delete what ? the istantiation ? 
>>>  
>>>

 Thanks, regards.

 Il giorno giovedì 17 dicembre 2015 21:40:36 UTC+1, Gael Princivalle ha 
 scritto:
>
> Thanks Niphlod.
>
> >So, here it is the breakdown of the possible issues:
> >- are tasks QUEUED or ASSIGNED ?
> QUEUED. But if I set the net run time to now + 2 minutes I can check 
> that task don't run.
> Status options don't have ASSIGNED.
>
> >If they are QUEUED, either they can't be executed yet (i.e. 
> start_time in the future) or tasks are queued with a group_name that 
> can't 
> be processed by a worker . 
> Main group for all.
>
> *>Check #1: there should be a scheduler_task row with group_name "in" 
> scheduler_worker group_names*
> >- if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker 
> is running or workers can't agree on who is "the ticker".
> Well worker is running and main is the group_name.
>
> *>Check #2 (there should be a scheduler_worker with is_ticker = True)*
> Yes it have.
>
> Check is complete. I think I will cancel the scheduler and create it 
> again. Thanks for your help.
>
> Il giorno giovedì 17 dicembre 2015 21:21:56 UTC+1, Niphlod ha scritto:
>>
>> I thought more people liked to see the code : I find myself 
>> explaining scheduler internals more often than I'd like to :P
>>
>> soo. worker names worker names are used to identify a 
>> worker process (it's enforced as unique in the model)...
>> I'll reply to some ideal "FAQ" questions
>> - Why worker names are important ? Because tasks ASSIGNED to a 
>> worker_name (assigned_worker_name in scheduler_task) get processed 
>> by that worker, and that worker only
>> - Who chooses worker names ? the worker itself. It does so 
>> concatenating the hostname and the PID, which results in a good (and 
>> unique) way to identify a process.
>> - Who chooses that task "foo" gets processed by 

[web2py] Re: The Almighty Form

2015-12-18 Thread Anthony
On Friday, December 18, 2015 at 3:14:38 AM UTC-5, Alfonso Serra wrote:
>
> you should instead hide the errors, and then you could add your own via 
>> server-side DOM manipulation.
>>
>
> But how do i do that if i dont know when errors has happened?.
>

After validation, if there are errors, then you will find them in 
form.errors.
 

> Currently the form gets automatic markup when is instantiated and its 
> modified later on when process is called.
> But this is like executing the view before the controller.
> Wouldnt be better to serialize the form just once, when xml() is called?, 
> even perfomance wise since nothings gets serialized until its droped into a 
> view.
>

The form is only serialized into HTML once -- when you do {{=form}} in the 
view. The server-side *DOM* of the form is created when the form is 
instantiated, but it is not serialized to HTML at that point. The reason 
the DOM is created when the form is instantiated is so validators (and 
other attributes) can be attached to the appropriate elements when the form 
is defined. This is necessary with FORM because there is no DAL model 
associated with the form, so the form elements themselves must store these 
attributes. Because SQLFORM is built on top of FORM, it uses the same 
mechanism.
 

> Either i have to go back to my workaround {{=mystyle(form)}} or rearrange 
> the SQLFORM code so gets serialized at the end of its lifespan, like it 
> should, in my opinion.
>

The problem is not that the form gets serialized before the view is 
executed (it doesn't), but that the errors are added during the 
serialization process, so there is no opportunity to customize them (short 
of excluding them altogether and adding your own errors to the DOM after 
validation but before serialization). This should be improved.
 

> So far ive overriden "def xml(self):" to something like 
> return form.custom.begin +  self.createform(xfields=None) + form.custom.end
>

I'm not sure it's worth bothering with that. If you need completely custom 
markup, the {{=mystyle(form)}} solution is a reasonable approach.

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/d/optout.


[web2py] Re: Scheduler worker name

2015-12-18 Thread Niphlod
when you dropped tables, did you remember to delete the corresponding 
*.table files from the databases/ folder ?

On Friday, December 18, 2015 at 12:47:38 PM UTC+1, Gael Princivalle wrote:
>
> >scheduler tables can be dropped manually
> Done
>
> >deleting scheduler.py also.
> Done
>
> >But I still don't think that it's the way to fix the issue you're facing.
> Well I'm not able to understand which is this problem, as when I create a 
> scheduler in a new app tasks are running.
> For the moment creating a new scheduler is my better idea, if you have a 
> better one thanks.
>
> Anyway now I've got this error when I try to open the scheduler table, for 
> example scheduler_task.
> My db string have now migrate=True, fake_migrate_all=True.
> My only other idea is rebuild all the app starting from a new one, but if 
> I can resolve it in a shorter way I prefer.
>
> Traceback (most recent call last):
>   File 
> "/home/tasko/webapps/w2p_2_12_3/web2py/applications/hydrover_oleodinamica/controllers/appadmin.py",
>  line 238, in select
> nrows = db(query).count()
>   File 
> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/objects.py", 
> line 1992, in count
> return db._adapter.count(self.query,distinct)
>   File 
> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/base.py",
>  line 1311, in count
> self.execute(self._count(query, distinct))
>   File 
> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/postgres.py",
>  line 360, in execute
> return BaseAdapter.execute(self, *a, **b)
>   File 
> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/base.py",
>  line 1378, in execute
> return self.log_execute(*a, **b)
>   File 
> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/base.py",
>  line 1372, in log_execute
> ret = self.cursor.execute(command, *a[1:], **b)
> ProgrammingError: relation "scheduler_task" does not exist
> LINE 1: SELECT count(*) FROM "scheduler_task" WHERE ("scheduler_task...
>
>
>
>
> Il giorno venerdì 18 dicembre 2015 11:58:15 UTC+1, Niphlod ha scritto:
>>
>> scheduler tables can be dropped manually
>> deleting scheduler.py also.
>> But I still don't think that it's the way to fix the issue you're facing.
>>
>> On Friday, December 18, 2015 at 11:22:57 AM UTC+1, Gael Princivalle wrote:
>>>
>>> >delete what ? the istantiation ? 
>>>
>>> Delete the scheduler.py file from models and all scheduler tables.
>>> How can I do it?
>>>
>>> Il giorno venerdì 18 dicembre 2015 10:48:23 UTC+1, Niphlod ha scritto:



 On Friday, December 18, 2015 at 10:45:22 AM UTC+1, Gael Princivalle 
 wrote:
>
> I've set a scheduler in a new application and tasks are running.
>
> So probably there's a problem when a app comes from a previous web2py 
> version.
>

 as long as you let migration happen, no issues whatsoever.
  

> Anyway I think it can be resolved deleting the scheduler and create it 
> again, but I've tried to:
> Killing the worker - Ok
> Delete Scheduler Ko
>
> When I delete the scheduler.py file from admin web2py creates it again.
>
> How can I delete the scheduler?
>

 delete what ? the istantiation ? 
  

>
> Thanks, regards.
>
> Il giorno giovedì 17 dicembre 2015 21:40:36 UTC+1, Gael Princivalle ha 
> scritto:
>>
>> Thanks Niphlod.
>>
>> >So, here it is the breakdown of the possible issues:
>> >- are tasks QUEUED or ASSIGNED ?
>> QUEUED. But if I set the net run time to now + 2 minutes I can check 
>> that task don't run.
>> Status options don't have ASSIGNED.
>>
>> >If they are QUEUED, either they can't be executed yet (i.e. 
>> start_time in the future) or tasks are queued with a group_name that 
>> can't 
>> be processed by a worker . 
>> Main group for all.
>>
>> *>Check #1: there should be a scheduler_task row with group_name "in" 
>> scheduler_worker group_names*
>> >- if tasks SHOULD be ASSIGNED but remain on QUEUED status, no worker 
>> is running or workers can't agree on who is "the ticker".
>> Well worker is running and main is the group_name.
>>
>> *>Check #2 (there should be a scheduler_worker with is_ticker = True)*
>> Yes it have.
>>
>> Check is complete. I think I will cancel the scheduler and create it 
>> again. Thanks for your help.
>>
>> Il giorno giovedì 17 dicembre 2015 21:21:56 UTC+1, Niphlod ha scritto:
>>>
>>> I thought more people liked to see the code : I find myself 
>>> explaining scheduler internals more often than I'd like to :P
>>>
>>> soo. worker names worker names are used to identify a 
>>> worker process (it's enforced as unique in the model)...
>>> I'll reply to some ideal "FAQ" questions
>>> - Why worker names are important ? Because tasks ASSIGNED 

[web2py] Re: Scheduler worker name

2015-12-18 Thread Gael Princivalle
No I don't.

But now I have:
Dropped all tables in the database folder
Delete all scheduler tables in the postgress database.
Delete the scheduler
Create the scheduler.
I still have the same db error, for example for workers:

SELECT count(*) FROM "scheduler_worker" WHERE ("scheduler_wo...

table files are created but not for scheduler tables
scheduler tables in postgress db are not created.

Do you know why?

Il giorno venerdì 18 dicembre 2015 15:48:06 UTC+1, Niphlod ha scritto:
>
> when you dropped tables, did you remember to delete the corresponding 
> *.table files from the databases/ folder ?
>
> On Friday, December 18, 2015 at 12:47:38 PM UTC+1, Gael Princivalle wrote:
>>
>> >scheduler tables can be dropped manually
>> Done
>>
>> >deleting scheduler.py also.
>> Done
>>
>> >But I still don't think that it's the way to fix the issue you're facing.
>> Well I'm not able to understand which is this problem, as when I create a 
>> scheduler in a new app tasks are running.
>> For the moment creating a new scheduler is my better idea, if you have a 
>> better one thanks.
>>
>> Anyway now I've got this error when I try to open the scheduler table, 
>> for example scheduler_task.
>> My db string have now migrate=True, fake_migrate_all=True.
>> My only other idea is rebuild all the app starting from a new one, but if 
>> I can resolve it in a shorter way I prefer.
>>
>> Traceback (most recent call last):
>>   File 
>> "/home/tasko/webapps/w2p_2_12_3/web2py/applications/hydrover_oleodinamica/controllers/appadmin.py",
>>  line 238, in select
>> nrows = db(query).count()
>>   File 
>> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/objects.py", 
>> line 1992, in count
>> return db._adapter.count(self.query,distinct)
>>   File 
>> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/base.py",
>>  line 1311, in count
>> self.execute(self._count(query, distinct))
>>   File 
>> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/postgres.py",
>>  line 360, in execute
>> return BaseAdapter.execute(self, *a, **b)
>>   File 
>> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/base.py",
>>  line 1378, in execute
>> return self.log_execute(*a, **b)
>>   File 
>> "/home/tasko/webapps/w2p_2_12_3/web2py/gluon/packages/dal/pydal/adapters/base.py",
>>  line 1372, in log_execute
>> ret = self.cursor.execute(command, *a[1:], **b)
>> ProgrammingError: relation "scheduler_task" does not exist
>> LINE 1: SELECT count(*) FROM "scheduler_task" WHERE ("scheduler_task...
>>
>>
>>
>>
>> Il giorno venerdì 18 dicembre 2015 11:58:15 UTC+1, Niphlod ha scritto:
>>>
>>> scheduler tables can be dropped manually
>>> deleting scheduler.py also.
>>> But I still don't think that it's the way to fix the issue you're facing.
>>>
>>> On Friday, December 18, 2015 at 11:22:57 AM UTC+1, Gael Princivalle 
>>> wrote:

 >delete what ? the istantiation ? 

 Delete the scheduler.py file from models and all scheduler tables.
 How can I do it?

 Il giorno venerdì 18 dicembre 2015 10:48:23 UTC+1, Niphlod ha scritto:
>
>
>
> On Friday, December 18, 2015 at 10:45:22 AM UTC+1, Gael Princivalle 
> wrote:
>>
>> I've set a scheduler in a new application and tasks are running.
>>
>> So probably there's a problem when a app comes from a previous web2py 
>> version.
>>
>
> as long as you let migration happen, no issues whatsoever.
>  
>
>> Anyway I think it can be resolved deleting the scheduler and create 
>> it again, but I've tried to:
>> Killing the worker - Ok
>> Delete Scheduler Ko
>>
>> When I delete the scheduler.py file from admin web2py creates it 
>> again.
>>
>> How can I delete the scheduler?
>>
>
> delete what ? the istantiation ? 
>  
>
>>
>> Thanks, regards.
>>
>> Il giorno giovedì 17 dicembre 2015 21:40:36 UTC+1, Gael Princivalle 
>> ha scritto:
>>>
>>> Thanks Niphlod.
>>>
>>> >So, here it is the breakdown of the possible issues:
>>> >- are tasks QUEUED or ASSIGNED ?
>>> QUEUED. But if I set the net run time to now + 2 minutes I can check 
>>> that task don't run.
>>> Status options don't have ASSIGNED.
>>>
>>> >If they are QUEUED, either they can't be executed yet (i.e. 
>>> start_time in the future) or tasks are queued with a group_name that 
>>> can't 
>>> be processed by a worker . 
>>> Main group for all.
>>>
>>> *>Check #1: there should be a scheduler_task row with group_name 
>>> "in" scheduler_worker group_names*
>>> >- if tasks SHOULD be ASSIGNED but remain on QUEUED status, no 
>>> worker is running or workers can't agree on who is "the ticker".
>>> Well worker is running and main is the group_name.
>>>
>>> *>Check #2 (there should be a scheduler_worker with is_ticker = 
>>> True)*

[web2py] Re: Can someone tell me stepwise how to upload web2py app on pythonanywhere after buying the domain?

2015-12-18 Thread Ron Chatterjee
If I have a domain registered through godaddy, I can use python anywhere 
web2py app with that domain name in go daddy or I will need to transfer the 
domain?



On Friday, December 18, 2015 at 3:10:04 AM UTC-5, Massimo Di Pierro wrote:
>
> No. I strongly recommend not using godaddy. They charge more then others. 
> They make it very hard to transfer the domains to others. They tend to 
> charge users for services they do no need.
>
> Almost any other domain registrar is better. I use gkg.net but I know 
> there are many other and some are even cheaper. 
>
> Massimo
>
> On Monday, 14 December 2015 12:10:05 UTC-6, RAGHIB R wrote:
>>
>> Is buying domain from godaddy ok? How do I use that domain in 
>> pythonanywhere after that and does pythonanywhere give hosting facilities?
>>
>

-- 
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/d/optout.


[web2py] Re: Can someone tell me stepwise how to upload web2py app on pythonanywhere after buying the domain?

2015-12-18 Thread Ron Chatterjee
Got my answer through this link:

https://www.pythonanywhere.com/forums/topic/3422/



On Friday, December 18, 2015 at 11:30:20 AM UTC-5, Ron Chatterjee wrote:
>
> If I have a domain registered through godaddy, I can use python anywhere 
> web2py app with that domain name in go daddy or I will need to transfer the 
> domain?
>
>
>
> On Friday, December 18, 2015 at 3:10:04 AM UTC-5, Massimo Di Pierro wrote:
>>
>> No. I strongly recommend not using godaddy. They charge more then others. 
>> They make it very hard to transfer the domains to others. They tend to 
>> charge users for services they do no need.
>>
>> Almost any other domain registrar is better. I use gkg.net but I know 
>> there are many other and some are even cheaper. 
>>
>> Massimo
>>
>> On Monday, 14 December 2015 12:10:05 UTC-6, RAGHIB R wrote:
>>>
>>> Is buying domain from godaddy ok? How do I use that domain in 
>>> pythonanywhere after that and does pythonanywhere give hosting facilities?
>>>
>>

-- 
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/d/optout.


[web2py] Re: how to wrap an already existing input element in a new div in web2py

2015-12-18 Thread Val K
if you mean  custom view of SQLFORM you can try something like this:
def your_controller()
...
   form=SQLFORM(...) # or SQLFORM.factory
   ...
   form.process()
   ...
   # creating view - must be after form.process() 

   fcw = form.custom.widget # see web2py book
   fcl = form.custom.label
  
   v_div = DIV() # main container 
   v_div.append(STYLE( 'table>tbody>tr>td {height:40px;}'  ))

   tbl = TABLE(_class='table table-bordered table-hover')
   tbl.append(TR( fcl.field_1 , fcw.field_1  )) # - pair  label/input
   tbl.append(TR( fcl.field_2 , fcw.field_2  ))
   
   fcw.field_1['_style']='background-color:gray' 
 
   v_div.append(tbl)

   v_div.append(form.custom.submit)
   v_div.append(form.custom.end)
   
   return  dict(v=v_div)



On Thursday, December 17, 2015 at 9:12:00 AM UTC+3, Sujata Aghor wrote:
>
>
> how to wrap an already existing input element in a new div in web2py
>

-- 
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/d/optout.


[web2py] Re: Pre-populated Forms

2015-12-18 Thread Val K
If your app has a create-controller (I believe it has), you can just add to 
it some code like this:

def  your_create_controller():

   templ_rec_id =  request.args(0) # means request like 
'http://.../your_create_controller/123'  123 - id of existing record
   # notice that 
'http://.../your_create_controller' 
will work as usual!
   if  templ_rec_id: # pre-populate form 
   rec = db.product(templ_rec_id)
   if rec:
for f in your_fields_list: # [db.product.product_name, 
db.product.product_type', ...]
f.default = rec[f.name]
 
# that's all!

   



On Wednesday, December 16, 2015 at 10:00:35 AM UTC+3, Anthony Smith wrote:
>
> Hi, 
> Not really as new to this and working my way through it slowly, but best I 
> keep on searching 
>
> cheers
>
> Anthony
>
> On Tuesday, 15 December 2015 05:19:30 UTC+11, villas wrote:
>>
>> By 'prototype' I believe he means the record which you wish to use as a 
>> 'template'.
>>
>> 1. Find your 'template' record which will be used for setting the default 
>> values of the fields in the new record.
>> 2. Set the field.default accordingly.
>> 3. Do not pass a record to SQLFORM.  If you do,  it will update that 
>> record.  It is presumed that you will wish to create a new record.
>>
>> Hope that helps to clarify ValK's response.
>> All the best.
>>
>>
>> On Sunday, 13 December 2015 17:53:36 UTC, Anthony Smith wrote:
>>>
>>> Hi Val,
>>>
>>> Thanks for your reply, but unable to find any about get prototype record 
>>> in the book.
>>>
>>> Do you have an examples 
>>>
>>> Thanks
>>>
>>> Anthony
>>>
>>> On Saturday, 12 December 2015 06:03:26 UTC+11, Val K wrote:

 1. get prototype record
 2. overwrite  field.default  with corresponding prototype value  
 3. don't pass record to SQLFORM 

 On Monday, December 7, 2015 at 7:15:46 AM UTC+3, Anthony Smith wrote:
>
> Hi All, 
>
> I have a products table:
>  db.define_table('product',
> Field('product_name'),
> Field('active_ingredient'),
> Field('batch_no'),
> Field('expiry_date','date'),
> Field('product_type', 
> requires=IS_IN_SET(PRODUCTTYPES),default= PRODUCTTYPES[0]),
> Field('withholding_period','integer'),
> Field('ESI_withholding','integer'),
> Field('qty','integer'),
> Field('date_purchased','date', default = request.now),
> Field('purchased_from', 
> requires=IS_IN_DB(db,'company.company_name','%(company_name)s')),
> (auth.signature),
> format='%(product_name)s %(batch_no)s')
>
> I can edit the product with the following controller:
> def edit_product():
> product_id = request.args(0,cast=int)
> product = db.product(product_id) or error()
> if not product.created_by==me:
> product.created_by.writable = True
> else:
> product.created_by.writable = False
> form = SQLFORM(db.product,product,
>showid=False,
>
> deletable=(product.created_by==me)).process(onsuccess=auth.archive)
> if form.accepted:
> session.flash="Edit Successful"
> redirect(URL('products'))
> return locals()
>
> At times I need to add new products but only some of the fields change 
> E.G. batch_no, expiry_date, and supplier. 
> In short if need to add similar item that I already have in the 
> products table 
>
>
> thanks 
>
> 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/d/optout.


[web2py] Re: Can't use to download a file

2015-12-18 Thread Massimo Di Pierro
To be clear. We are not talking about Field('...','upload') type of files. 
It appears these are static files you uploaded via admin, therefore they 
are in static/. Files uploaded via forms, go where where you configure them 
to go, generally in uploads/ and access can be restricted using auth.

Field('junk','upload',uploadfolder='whereyoulike',authorization=function 
record: return True or False))

On Friday, 18 December 2015 02:36:37 UTC-6, Adrien wrote:
>
> Oh ok thanks Anthony, i used that : 
> 
> clep
> I didn't know i have to use the static folder to upload files, thx you :)
>
> Le jeudi 17 décembre 2015 16:58:05 UTC+1, Anthony a écrit :
>>
>> On Thursday, December 17, 2015 at 9:34:33 AM UTC-5, Adrien wrote:
>>>
>>> Hi everyone,
>>>
>>> I'm trying to create a link to download files, but it doesn't work .. It 
>>> redirect me like a simple link.
>>>
>>> This is what i'm using : 
>>>
>>> This file is default/index.html
>>> clep
>>>
>>
>> The only files web2py will serve directly via the file path are those in 
>> the /static folder, and even then, you would not specify an OS file path 
>> (including a ../) as the href -- you would instead generate a web2py URL 
>> with "static" as the controller (e.g., URL('static', 'uploads/clep.pdf')
>> ).
>>
>> For files uploaded via a DAL upload field, you should use the 
>> response.download() method. The scaffolding app includes a download() 
>> function in the default.py controller that uses this method.
>>
>> In your case, it looks like you have manually put the clep.pdf file in 
>> the /uploads folder, as it hasn't been renamed as it would be if uploaded 
>> via a DAL upload field. To return such a file, you would instead have to 
>> use response.stream(). To prevent a directory traversal attack, you would 
>> probably also want to add a signature to the URL and add the 
>> @auth.requires_signature() decorator to your download function (this will 
>> prevent a malicious user from specifying any arbitrary file in the request 
>> URL, as the signature will be associated with the particular file in the 
>> link you create).
>>
>> Note, if the clep.pdf file is intended to be available to the public, 
>> just put it in the /static folder.
>>
>> 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/d/optout.


[web2py] Re: web2py instant admin

2015-12-18 Thread Massimo Di Pierro
Can you check the come js console? There should be logs. Perhaps the path 
is wrong of the css is not there.

On Tuesday, 24 July 2012 19:13:34 UTC-5, Kevin Miller wrote:
>
> Hi all, 
>
> Anyone using web2py instant admin?
> I have a problem with the css. I have installed the plugin its functional, 
> but its not picking up the CSS.
> Any reason?
>
> Thanks very much.
>
> Kevin
>

-- 
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/d/optout.


[web2py] add or use jsPDf in web2py

2015-12-18 Thread anthonys650
I'm new to the web2py. How can I add the jsPDF 
https://github.com/MrRio/jsPDF so I can have a button to create the HTML 
page to PDF?  Also looking to have and existing pdf merge to the new output 
pdf file.

-- 
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/d/optout.


[web2py] 2016 PyCon Portland

2015-12-18 Thread Julio F. Schwarzbeck
Winter is coming, and after that, PyCon in May 2016..

We need a web2py presence there! - What are the steps to make Massimo a 
figure in the event?? - Suggestions?

-- 
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/d/optout.


[web2py] Re: $100 reward to get a simple web2py app runnnig on GAE with Google Cloud SQL

2015-12-18 Thread Tom Campbell
Thank you! Soon as I get back I can't wait!

On Saturday, December 12, 2015 at 7:05:04 PM UTC-8, Tom Campbell wrote:
>
> I want to get a minimal web2py app running on Google Application Engine, 
> using Google Cloud SQL as the backing store. Have not succeeded. Obviously 
> because I have a much bigger app running locally and want to get that up 
> and running.
>
> If anyone can show me how to do this via Skype, a well-written text file, 
> tin can on a string, whatever, I'd happily pay $100 via PayPal, check, or 
> credit card. It will be a tiny web2py app that I write and the catch is 
> you'll have to sit with me online until I repeat the process once. I'm in 
> Seattle time, so GMT-8.
>
>
>
>

-- 
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/d/optout.