[web2py] Re: Custom formstyle for auth

2016-10-27 Thread Niphlod
you can code your own formstyle and pass it to formstyle (or set the global 
response.formstyle). On top of accepting what's included in web2py as a 
string, it accepts a callable for "bring your own".

On Tuesday, October 25, 2016 at 4:52:12 PM UTC+2, Marko Seppälä wrote:
>
> Hi,
>
> I'm trying to set custom form styles for auth, like register or login 
> form. I would like to set completely new formstyle function for that, so 
> that it's easy to use over and over again just setting formstyle = 
> my_formstyle in appconfig.ini.
>
> How I could do that? I can use formstyle_bootstrap3_inline_factory 
> from sqlhtml.py as a starting point for my own function. But where should I 
> put that function? And how to tell web2py where to look for that function? 
> Obviously I don't want to touch original source code.
>
> 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: CouchDB support

2016-10-27 Thread Niphlod
couchdb support is experimental. to "enable" it, you must use the source 
version and install the 'couchdb' module using pip to make it available to 
web2py.

On Tuesday, October 25, 2016 at 7:06:09 AM UTC+2, Robert F wrote:
>
> Still on the learning curve regarding Web2py but would like to know how to 
> use the CouchDB DAL interface. CouchDB is mentioned in the support docs but 
> does not appear during start up in list of database adapters found. For 
> example I get:
>
> Database drivers available:  psycopg2, pymysql, imaplib, MySQLdb, sqlite3, 
> pyodbc
>
>
>
> Looked at the PyDAL code base and CouchDB support appears to be present 
> but just is not detected/enabled. (import not found) I have tried both 
> binary and source distributions.
>
> What steps do I need to do to enable CouchDB or any other non-standard 
> adapter not listed during startup?
>
> Any indications on how mature adapter is.  
>
>
>

-- 
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: Grid export csv

2016-10-24 Thread Niphlod
never ever pull web2py AND pydal master's  and merge (unless you really 
know what you're doing). When using "master", at most, use web2py's one, 
which has the correct pointers to pydal's specific commits.

Any commit later than 15aug should work fine ^_^

On Friday, October 21, 2016 at 10:54:31 PM UTC+2, Bartosz Baranowski wrote:
>
> Niphlod,
>
> I am using latest web2py and pydal from master branches. Any idea where is 
> the fix? Could you please direct me to the commit?
>
> W dniu środa, 3 sierpnia 2016 12:51:56 UTC-7 użytkownik Niphlod napisał:
>>
>> should be already fixed on master, anyway if you're in a hurry, set 
>> entity_quoring=False on the DAL line to make it work again (long story 
>> short, DAL now quotes everything by default and not every cog in the wheel 
>> was expecting that)
>>
>> On Monday, August 1, 2016 at 1:51:54 PM UTC+2, Kostas M wrote:
>>>
>>> I have the same problem with the CSV, HTML, TSV export buttons. The 
>>> Ticket for the CSV is pasted below. The problem at least with the csv 
>>> export button seems to be with the REGEX_TABLE_DOT_FIELD. Normally, this 
>>> constant is defined in regex.py as:
>>>
>>> REGEX_TABLE_DOT_FIELD = re.compile('^(\w+)\.([^.]+)$')
>>>
>>> and previous web2py versions used it.
>>>
>>> However, now it takes the REGEX_TABLE_DOT_FIELD definition from the 
>>> base.py:
>>>
>>> obj.REGEX_TABLE_DOT_FIELD = re.compile(
>>> r'^' + quot % regex_ent + r'\.' + quot % regex_ent + r'$')
>>>
>>>
>>> which is a totally different regex and it doesn't match with the table 
>>> field names...
>>>
>>>
>>> Ticket ID 
>>>
>>> 127.0.0.1.2016-08-01.14-36-35.a05a56c8-5b22-42c3-a3e3-385322b5f0fe
>>>  Version 
>>> web2py™ Version 2.14.5-stable+timestamp.2016.04.14.03.26.16 
>>> Python Python 2.7.6: /home/kmouts/Envs/prolims2_venv/bin/python2.7 
>>> (prefix: /home/kmouts/Envs/prolims2_venv) Traceback 
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>> 13.
>>> 14.
>>> 15.
>>> 16.
>>> 17.
>>> 18.
>>> 19.
>>> 20.
>>> 21.
>>> 22.
>>>
>>> Traceback (most recent call last):
>>>   File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/restricted.py", 
>>> line 227, in restricted
>>> exec ccode in environment
>>>   File 
>>> "/home/kmouts/PycharmProjects/prolims2/web2py/applications/prolims2/controllers/muser.py"
>>>  <http://127.0.0.1:8000/admin/default/edit/prolims2/controllers/muser.py>, 
>>> line 187, in 
>>>   File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/globals.py", 
>>> line 417, in 
>>> self._caller = lambda f: f()
>>>   File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/tools.py", line 
>>> 4258, in f
>>> return action(*a, **b)
>>>   File 
>>> "/home/kmouts/PycharmProjects/prolims2/web2py/applications/prolims2/controllers/muser.py"
>>>  <http://127.0.0.1:8000/admin/default/edit/prolims2/controllers/muser.py>, 
>>> line 49, in my_analyses
>>> exportclasses=dict(csv_with_hidden_cols=False, 
>>> tsv_with_hidden_cols=False)
>>>   File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/sqlhtml.py", 
>>> line 3102, in smartgrid
>>> user_signature=user_signature, **kwargs)
>>>   File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/sqlhtml.py", 
>>> line 2473, in grid
>>> raise HTTP(200, oExp.export(), **response.headers)
>>>   File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/sqlhtml.py", 
>>> line 3514, in export
>>> self.rows.export_to_csv_file(s, represent=True)
>>>   File 
>>> "/home/kmouts/Envs/prolims2_venv/local/lib/python2.7/site-packages/pydal/objects.py",
>>>  line 2446, in export_to_csv_file
>>> row.append(record._extra[col])
>>>   File 
>>> "/home/kmouts/Envs/prolims2_venv/local/lib/python2.7/site-packages/pydal/objects.py",
>>>  line 91, in __getattr__
>>> raise AttributeError
>>> AttributeError
>>>
>>>
>>>

-- 
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: Randomly stuck web2py

2016-10-24 Thread Niphlod
see the log to trace any DDos attempts (or stuck requests )

On Friday, October 21, 2016 at 10:54:32 PM UTC+2, Wasim Baig wrote:
>
> Been using web2py for sometime now, thank you all for making life so easy.
>
> We use stock web2py src on debian 8, with Rocket and mysql and start them 
> in screen.
>
> Frequently my web2py process get stuck. Ctrl-C won't kill it, we end up 
> Ctrl-Z it, and then kill -9 pid.
>
> For example, 
>
> root 13387  0.8  0.4 1131328 156496 pts/63 Sl+  Oct18   7:12 python2.7 
> web2py.py -d /var/run/web2py_localhost_8000.pid -a XXX --interfaces=
> 127.0.0.1:8000 
> root 13421  0.0  0.4 1109424 143336 pts/8  Sl   Oct18   0:39 python2.7 
> web2py.py -d /var/run/web2py_8000.pid -a XXX 
> --interfaces=148.251.132.230:8000:/etc/ssl/private/batuni_pk.key:/etc/ssl/private/batuni_pk.crt
>  
> --ca-cert=/etc/ssl/private/AddTrustExternalCARoot.crt 
> --ca-cert=/etc/ssl/private/COMODORSAAddTrustCA.crt 
> --ca-cert=/etc/ssl/private/COMODORSADomainValidationSecureServerCA.crt 
> --ca-cert=/etc/ssl/private/batuni_pk.ca-bundle
>
>
> Of these two processes, the one on localhost continues to respond fine, 
> but the one on public IP was stuck.
> Nothing in the logs that I can see point to a problem. 
>
> What can I do to troubleshoot this?
>
> -wasim 
>

-- 
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: tasks hierarchy

2016-10-24 Thread Niphlod
you should use "Jobs" for that.

any task queued that needs another task to be executed before it should be 
linked with

thejob.add_deps(dependant, parent)

in your case:
- cat3 is dependant from cat2 
- cat2 is dependant from cat1

read more using the https://github.com/niphlod/w2p_scheduler_tests test app.

On Sunday, October 23, 2016 at 11:44:12 AM UTC+2, Pierre wrote:
>
> Hi,
>
> Suppose a batch of tasks of 3 categories such that *cat1 >  cat2 >  cat3*  
> and a group of sheduler's processes to perform these as soon as they are 
> queued.
>
> How do i instruct workers to pick cat1 tasks first and then cat2 tasks 
> (only if no cat1 task is present in the queue) and finally cat3 tasks (if 
> no cat1 & cat2 tasks are queued) ?
>

-- 
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 create a front end for an external API?

2016-10-20 Thread Niphlod
before wanting something that helps you implementing something do you 
have a minimal idea of what you want to happen with your API ?

On Thursday, October 20, 2016 at 12:41:34 AM UTC+2, greenpoise wrote:
>
> RESTFUL API I meant to write
>
>
>
>
>
>
> On Wednesday, October 19, 2016 at 2:42:52 PM UTC-7, greenpoise wrote:
>>
>> First, I am new to API. I did read and went through the web2py book 
>> section of API but I am still a bit lost. Is there a good example for this? 
>> Am I asking/searching the right way?
>>
>>
>> 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: How to cleanly pass FPDF output object to os Download/Save dialogue box

2016-10-17 Thread Niphlod
halt. downloading is something the browser can decide. opening the saved 
file is something your operating system does.
The browser can only send the response which gives the user a choice 
between saving and opening directly the file.
If the user chooses "open" instead of "save" ... nothing can prevent that.

-- 
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: it it possible to loop through field names and set "readable = False" conditional if field is empty?

2016-10-17 Thread Niphlod
so 

record = thesingle_record_from_the_table

for f in db.table.fields:
if record[f] is None:
db.table[f].readable = False



On Monday, October 17, 2016 at 9:18:49 PM UTC+2, Alex Glaros wrote:
>
> I left this part out.  Should only be one record. 
>
> specificAddressID = db(db.Address.super_object_fk == 
> specificSuperObjectID).select(db.Address.id,limitby = (0,1)).first().id 
>

-- 
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: it it possible to loop through field names and set "readable = False" conditional if field is empty?

2016-10-17 Thread Niphlod
readable is on the Field (i.e. column) so what happens if row 1 has 
column a,b,c == None and row 2 has a,c,d  == None ?

On Monday, October 17, 2016 at 9:11:24 PM UTC+2, Alex Glaros wrote:
>
> Would like to loop through columns in a set object and set readable = 
> False if the field has no data in it
>
> something like:
>
> [setattr(f, 'readable', False) for f in db.Address if specificAddress.
> f.name == None]
>
> (the set above is created with this line: specificAddress = 
> db.Address(specificAddressID)
>
> thanks
>
> Alex Glaros
>
>

-- 
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: problem with start_time of the scheduler

2016-10-17 Thread Niphlod
BTW: please start adapting your code to use mysched.queue_task() 
instead of db.scheduler_task.insert(...) . 
Next releases could change the format of the scheduler_task table and only 
the queue_task method is the supported one (i.e. will handle eventual 
corner-cases that won't be possible using db.scheduler_task.insert()) 

-- 
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: problem with start_time of the scheduler

2016-10-17 Thread Niphlod
the bug has already been fixed in trunk. 
You can copy/paste the scheduler.py file from master if you want it solved, 
or either pass next_run_time equal to start_time to make things work the 
way they were.

On Sunday, October 16, 2016 at 8:30:23 AM UTC+2, mweissen wrote:
>
> Thank you, but start_time has a value.
> start_time is a paramter of the surrounding function.
> I have tested it with 
> task_name = task_name + str(start_time)
> and therefore I have written start_time != None
>
> 2016-10-15 19:59 GMT+02:00 Dave S :
>
>>
>>
>> On Saturday, October 15, 2016 at 6:27:33 AM UTC-7, mweissen wrote:
>>>
>>> It seems that the start_time parameter in a scheduler_task record does 
>>> not work correctly.
>>>
>>> For example:
>>>
>>> I add a record to scheduler_task which should start the function 
>>> "smsEmailAussenden" (means "send the email") at 16:00 
>>>
>>> I expect the email to be sended at 16:00, but it starts immediately. At 
>>> 14:45 all is done...
>>>
>>> I use this code to add a new task. All names without a value are 
>>> parameters of the function containing this statement. start_time != None
>>>
>>>tasknr = db.scheduler_task.insert(
>>> status='QUEUED',
>>> application_name='secure',
>>> task_name=task_name, 
>>> function_name='smsEmailAussenden',
>>> args = dumps([aussendungNr]),
>>> vars={},
>>> enabled=True,
>>> start_time=start_time or datetime.datetime.now(),
>>>
>>
>> So if start_time hasn't been set anywhere in your queuing code, it runs 
>> now.
>> The start_time value on the right side is a (local) variable, not the 
>> previous value of the parameter.
>>
>>  
>>
>>> stop_time=stop_time or 
>>> (datetime.datetime.now()+timedelta(days=1)),
>>>
>> repeats=1,
>>> retry_failed=1, 
>>> period=800, 
>>> timeout=200,
>>> )
>>>
>>> Some months ago this code worked without problems.
>>> What has changed inside the scheduler?
>>>
>>>
>> The scheduler has been stable across a couple of releases, I think.  My 
>> once-a-day code has been working very well for several months.
>>
>> /dps
>>
>>
>>  
>>
>>> Id: 913997 
>>> Application Name: 
>>> Task Name: 
>>> Group Name: 
>>> Status: QUEUEDRUNNINGCOMPLETEDFAILEDTIMEOUTSTOPPEDEXPIRED 
>>> Function Name: checkschedulerentlassenSendengetstatus1idmauswertung
>>> kontrollemailmitteilungmahnungparse_emailparse_pushemail
>>> rundschreibenSendensendeprotokollSendensendprotsendrssmsEmailAussenden
>>> test 
>>> Uuid: 
>>> Args: 
>>> × 
>>> × 
>>>
>>> Vars: 
>>> × 
>>> × 
>>>
>>> Enabled: 
>>> Start Time: 
>>> Next Run Time: 
>>> Stop Time: 
>>> Repeats: 0=unlimited
>>> Retry Failed: -1=unlimited
>>> Period: seconds
>>> Prevent Drift: Cron-like start_times between runs
>>> Timeout: seconds
>>> Sync Output: update output every n sec: 0=never
>>> Times Run: 
>>> Times Failed: 
>>> Last Run Time: 
>>> Assigned Worker Name: 
>>>
>>>
>>> Any ideas?
>>> 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: Help with App memory usage

2016-10-14 Thread Niphlod
try using psycopg2 on the prod env too. pg8000 (especially the one shipped 
with web2py in the latest stable, which was quite old) can exhibit memory 
leaks (or, for better saying, a premature optimization resulted in an 
"evil" usage of the memory for the way web2py uses pg8000).

On Friday, October 14, 2016 at 8:21:21 PM UTC+2, dan...@betanetweb.com 
wrote:
>
> On my development environment i am using psycopg2 in production pg8000, 
> and im not using db cache anywhere
>
>
> El viernes, 14 de octubre de 2016, 10:07:43 (UTC-5), Paolo Valleri 
> escribió:
>>
>> Which driver are you using for postgres? Are you using cache in models?
>> Try to figure out if there are controllers using more memory than others.
>>
>>
>> On Friday, October 14, 2016 at 4:03:20 AM UTC+2, Anthony wrote:
>>>
>>> That's a lot of code to review. You're probably going to have to do some 
>>> digging and narrow it down for us. I did see one problem, though:
>>>
>>> class IS_BARCODE_AVAILABLE(object): 
>>> T = current.T
>>>
>>> You can't use current in a class attribute (for the same reason it can't 
>>> be used at the top level of a module -- it's value will be fixed at the 
>>> first import, though it is a thread-local object that should change with 
>>> every request).
>>>
>>> Anthony
>>>
>>> On Thursday, October 13, 2016 at 9:28:44 PM UTC-4, dan...@betanetweb.com 
>>> wrote:

 Hello im an developing an opensource POS (link 
 ) using web2py, 
 everything is fine except that on my development environment and in a 
 production server, my app memory usage grows without limits, it does not 
 crash the server however sometimes i get python MemoryError's, things like 
 error: 
 unpack_from requires a buffer of at least 5 bytes 
  or postgres memory 
 errors in the production server, in my development environment i see the 
 memory grow by 3 to 6 MB for every request, i dont know what is causing 
 this behavior, i am not using caching. any help appreciated.

>>>

-- 
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: from apache to nginx

2016-10-14 Thread Niphlod
in-process I think it's a no-go, as nginx just doesn't know how to 
interpret python in the same process as apache does.
http_auth_request together with http_access though can help, as you should 
be able to code an handler that returns either 200 or 403 instead of 
true/false . 
Check http://nginx.org/en/docs/http/ngx_http_auth_request_module.html

On Friday, October 14, 2016 at 3:50:05 AM UTC+2, Massimo Di Pierro wrote:
>
> Does anybody here know how port these links to Nginx?
>
>
> 
>
>ScriptAlias /bin/ "/whatever/cgi-bin/"
>
>
>
>  WSGIAccessScript  /whatever/access.wsgi
>
>
>
> 
>
>
> They basically say that some URLs /whatever/cgi-bin point to legacy 
> cgi-bin scripts but before executing the scripts it should pass the 
> environment vars and the header info to the access.wsgi python script to 
> ask for access permission. This allows me to have a web2py app that links 
> the legacy scripts and because on the same domain, the client passes the 
> session cookie, the access.wsgi code retrieves the session cookie and check 
> permissions.
>
>
> The script looks like this:
>
>
> def allow_access(environ,host):
>
>  # get credentials from environ, ask web2py is user is authorized and 
> return true/false
>
>
> I am happy to rewrite the script but the question is whether nginx 
> provides an equivalent mechanism. I cannot find one.
>
>
> 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: appadmin/ccache and dict in cache.disk

2016-10-07 Thread Niphlod
definitely a bug. a PR is on the way.

On Friday, October 7, 2016 at 8:49:45 PM UTC+2, Niphlod wrote:
>
> ok, it's valid syntax. will investigate...
>
> On Friday, October 7, 2016 at 7:04:51 PM UTC+2, MDSIII wrote:
>>
>> cval = dict(request.vars)
>> cval.update(request.vars)
>> cache.ram('agent',
>>  lambda: cache.disk('agent', lambda :cval, time_expire = 0),
>>  time_expire = 0)
>>
>> I realize this is sort of rediculous code but it shows all assignment 
>> operations to the object "cval" that happen before it is written to cache.
>>
>>
>> On Friday, October 7, 2016 at 4:12:22 AM UTC-7, Niphlod wrote:
>>>
>>> how do you store a dict in cache.disk ?
>>>
>>> On Friday, October 7, 2016 at 8:59:34 AM UTC+2, MDSIII wrote:
>>>>
>>>> When I store a dict in cache.disk and then request 
>>>> /appadmin/ccache I'm getting a key error:
>>>>
>>>> Traceback (most recent call last):
>>>>   File "C:\repos\TCL\web2py\gluon\restricted.py", line 227, in 
>>>> restricted
>>>> exec ccode in environment
>>>>   File 
>>>> "C:\repos\TCL\web2py\applications\timecardlynx\controllers/appadmin.py", 
>>>> line 703, in 
>>>> 
>>>>   File "C:\repos\TCL\web2py\gluon\globals.py", line 412, in 
>>>> self._caller = lambda f: f()
>>>>   File 
>>>> "C:\repos\TCL\web2py\applications\timecardlynx\controllers/appadmin.py", 
>>>> line 469, in ccache
>>>> disk['hits'] = value[1]['hit_total'] - value[1]['misses']
>>>> KeyError: 'hit_total'
>>>>
>>>> Is this known?
>>>>
>>>

-- 
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: appadmin/ccache and dict in cache.disk

2016-10-07 Thread Niphlod
ok, it's valid syntax. will investigate...

On Friday, October 7, 2016 at 7:04:51 PM UTC+2, MDSIII wrote:
>
> cval = dict(request.vars)
> cval.update(request.vars)
> cache.ram('agent',
>  lambda: cache.disk('agent', lambda :cval, time_expire = 0),
>  time_expire = 0)
>
> I realize this is sort of rediculous code but it shows all assignment 
> operations to the object "cval" that happen before it is written to cache.
>
>
> On Friday, October 7, 2016 at 4:12:22 AM UTC-7, Niphlod wrote:
>>
>> how do you store a dict in cache.disk ?
>>
>> On Friday, October 7, 2016 at 8:59:34 AM UTC+2, MDSIII wrote:
>>>
>>> When I store a dict in cache.disk and then request 
>>> /appadmin/ccache I'm getting a key error:
>>>
>>> Traceback (most recent call last):
>>>   File "C:\repos\TCL\web2py\gluon\restricted.py", line 227, in restricted
>>> exec ccode in environment
>>>   File 
>>> "C:\repos\TCL\web2py\applications\timecardlynx\controllers/appadmin.py", 
>>> line 703, in 
>>> 
>>>   File "C:\repos\TCL\web2py\gluon\globals.py", line 412, in 
>>> self._caller = lambda f: f()
>>>   File 
>>> "C:\repos\TCL\web2py\applications\timecardlynx\controllers/appadmin.py", 
>>> line 469, in ccache
>>> disk['hits'] = value[1]['hit_total'] - value[1]['misses']
>>> KeyError: 'hit_total'
>>>
>>> Is this known?
>>>
>>

-- 
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: appadmin/ccache and dict in cache.disk

2016-10-07 Thread Niphlod
how do you store a dict in cache.disk ?

On Friday, October 7, 2016 at 8:59:34 AM UTC+2, MDSIII wrote:
>
> When I store a dict in cache.disk and then request 
> /appadmin/ccache I'm getting a key error:
>
> Traceback (most recent call last):
>   File "C:\repos\TCL\web2py\gluon\restricted.py", line 227, in restricted
> exec ccode in environment
>   File 
> "C:\repos\TCL\web2py\applications\timecardlynx\controllers/appadmin.py", 
> line 703, in 
> 
>   File "C:\repos\TCL\web2py\gluon\globals.py", line 412, in 
> self._caller = lambda f: f()
>   File 
> "C:\repos\TCL\web2py\applications\timecardlynx\controllers/appadmin.py", 
> line 469, in ccache
> disk['hits'] = value[1]['hit_total'] - value[1]['misses']
> KeyError: 'hit_total'
>
> Is this known?
>

-- 
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: set individual action's transaction mode

2016-10-05 Thread Niphlod


On Tuesday, October 4, 2016 at 8:18:57 PM UTC+2, Pierre wrote:
>
> oh great i see
> so the two apis speak the same language but they don't communicate ?
>

they do perfectly integrate: the only way it's possible and the way it's 
more natural.
 

> never mindbut better be prudent
>
> thanks Niphlod
>
>
> hopefully  everything is under control :)  Have you seen the movie 
> melancholia by lars von trier ?
>

-- 
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: set individual action's transaction mode

2016-10-04 Thread Niphlod
it's because DBAPI opens a new transaction the same way web2py does.

On Monday, October 3, 2016 at 1:54:20 PM UTC+2, Pierre wrote:
>
> ok, understood.
> now let's go back to the basic situation of a single transaction. you 
> suggest I should discard posgresql transaction parameters in the first 
> place ? why is that so ? Is it because this feature isn't supported in 
> web2py  or for a different reason ?
>
> I am not sure yet but I might need to serialize some actions/tasks. These 
> sql commands were specifically engineered to address the race condition 
> issue so why do you want me to reinvent the wheel ?  
>
>
> *Oh yea i can see it now. !...the tunnel [EXIT] or 
> maybe this is just a miragei see someone wearing a gas mask*
> .
>

-- 
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 - response.render no longer working

2016-10-03 Thread Niphlod
hum. Trunk has been recently updated in the management of caching code for 
controllers and views  wonder if this is related to that.

On Monday, October 3, 2016 at 5:15:18 AM UTC+2, Brian M wrote:
>
> OK, so I've had multiple scheduled tasks running for years that use 
> response.render('path/to/template.html', dict(var= 'something')) to help 
> build email bodies and it has been working perfectly. Now when I try to 
> upgrade to the latest web2py trunk (was on 2.13.4 - yeah I'm a bit behind) 
> all that has stopped working.  Below is the error I'm getting
> File "C:\FMSC Webapps\web2py_master\gluon\globals.py", line 437, in render
> self._view_environment.update(self._vars)
> AttributeError: 'NoneType' object has no attribute 'update'
>
> Why isn't this working anymore? Has some backwards compatibility breaking 
> change been made to the scheduler environment? Any advice would be much 
> appreciated.
>
> -Brian
>
> PS. I've seen 
> https://groups.google.com/forum/#!searchin/web2py/response.render$20scheduler|sort:relevance/web2py/UsUvODL07zs/HrcCsxQcCQAJ
>  
> which would seem related but I'm unable to get it working by just adding 
> from gluon.template import render
>

-- 
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: Under Scheduler request.is_scheduler is None rather than True - Why?

2016-10-03 Thread Niphlod
can you please file a bug on https://github.com/web2py/web2py/issues ? I'd 
like to keep track of it and fix ASAP

On Monday, October 3, 2016 at 5:45:21 AM UTC+2, Brian M wrote:
>
> Is there a reason why when something is run under the scheduler 
> request.is_scheduler = None rather than True? When you access 
> request.is_scheduler from outside of the scheduler you get False as one 
> would expect. The current None value seems strange/non-intuitive.
> #this won't work
> if request.is_scheduler:
>#do special scheduler stuff
>
> #To really know if you're running under the scheduler you must use this 
> which makes no sense
> if request.is_scheduler == None:
>#do special scheduler stuff
>  
>
> This has been the case for a while and is still happening with the latest 
> git trunk
>
>
>
>

-- 
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: set individual action's transaction mode

2016-10-01 Thread Niphlod
a transaction is live from the first command you execute AFTER the first 
commit() or rollback(). Web2py automatically commit() at the end of a 
request, or rollback() in case an error occurred.
Everything runs separated in each thread (which means every thread runs its 
own transaction) and - usually - web2py maps a single thread on a single 
request.
Even an ajax request from the same page runs in a separate transaction.
Everything is consistent in the smallest "frame" http can assure: a web 
request/response cycle.
Everything that runs in separate processes can't share the same transaction.
When you queue you task in the controller, the action of queueing runs in 
the same transaction of the request that posted the form.
When the action is executed in the scheduler, which is an external process, 
it runs in its own transaction, completely decoupled from the web ones.

So, again, don't even think to fiddle with postgresql parameters or try to 
make two python processes to work in the same transaction: it's a no-go.

You need to redesign your app's workflow to coincide with your mind-model 
of what should happen. Welcome to coder's world ^_^

On Friday, September 30, 2016 at 11:56:11 PM UTC+2, Pierre wrote:
>
>
> what's are the situations where I can't survive a transaction ?  do you 
> mean queueing tasks in a controller function ?
>
> how do I work this out  in a single process action? 
>
>
>
>
>
>
>
>
>
>
>
>
>

-- 
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: set individual action's transaction mode

2016-09-30 Thread Niphlod
tl;dr you can't . You ABSOLUTELY can't survive a transaction in different 
processes. If you need to control concurrency, implement your own "lock" in 
the app (i.e. using a "light" record in a table).

On Friday, September 30, 2016 at 7:30:30 PM UTC+2, Pierre wrote:
>
> Hi,
>
> it's late and the race (condition) goes on.
> trying to define a concurrency control strategy, my idea is (1) to have 
> global defaults transaction mode parameters in the posgresql. config file 
> and (2) to depart from these when action/transaction is read-only. Howewer 
> it's not clear how to achieve (2) since I don't fully understand how w2p 
> manages transactions. The way to do that in postgresql reference doc is to 
> issue a BEGIN or START TRANSACTION sql command followed by the transaction 
> mode  (isolation level, read/write mode,deferrable mode). There's another 
> possiblity that consists in using  current transaction uid (sql command: 
> SET TRANSACTION SNAPSHOT). how do I go with this ? how do I get current 
> transaction uid. Where do I have to place the sql command to set individual 
> transaction mode parameters?
>

-- 
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 do 2 step verification authentication????

2016-09-29 Thread Niphlod
I think he's referring to two-step verification

On Thursday, September 29, 2016 at 8:05:11 PM UTC+2, Dave S wrote:
>
>
>
> On Wednesday, September 28, 2016 at 12:13:05 PM UTC-7, prashant joshi 
> wrote:
>>
>> how configure email??
>> i do according to the book but it not work...
>>
>> please anyone tell me another method???
>>
>
> If you''re using gmail, getting around  2-step authentication involves 
> having the account app-enabled (or something like that).  The usual 
> recommendation is to use another email provider for your app.  Some free 
> ones have been mentioned in the group; Massimo has a favorite he posted 
> about once or twice.
>
>
> /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/d/optout.


[web2py] Re: How to restrict access to a public webservice using a key?

2016-09-29 Thread Niphlod
everything in auth has underlying defaults to have an entity (usually, the 
user) to authenticate. if it's not authenticated, then it's usually 
redirected to the login page. see auth.requires signature in deep if you 
want to use it as a standard "block this if this condition isn't met" 
style-decorator.

On Thursday, September 29, 2016 at 3:28:05 PM UTC+2, Lisandro wrote:
>
> Thanks Niphlod, nice and clean solution. 
> I was trying to just that, but I was trying to validate that token using 
> the decorator @auth.requires(lambda: validate_token()) for the call() 
> method, but it always returned a 303 code. I also tried with a custom 
> decorator, with no luck.
> Anyway, your suggested solution is more than enough for me, so I'll 
> proceed with that.
>
> Thank you both for your time!
>
> Best regards,
> Lisandro.
>
> El miércoles, 28 de septiembre de 2016, 18:42:04 (UTC-3), Niphlod escribió:
>>
>> jwt is the emerging standard for apis and such, but if the usage is 
>> all-internal, why don't you just start simple and do
>>
>>
>> if request.vars.token not in ('xa', 'bbxb', 'cc'):
>>  raise HTTP(403)
>>
>>  ?
>>
>> On Wednesday, September 28, 2016 at 2:15:19 PM UTC+2, Marlysson Silva 
>> wrote:
>>>
>>> This is what you need:
>>>
>>> http://web2py.readthedocs.io/en/latest/tools.html#gluon.tools.Auth.jwt
>>>
>>> Json Web Token , communications to services "rest" .. I think that 
>>> facilitates your work
>>>
>>> Em quarta-feira, 28 de setembro de 2016 08:57:59 UTC-3, Lisandro 
>>> escreveu:
>>>>
>>>> Hi there!
>>>> I have a web2py app that implements a JSON-RPC public webservice, over 
>>>> HTTPS.
>>>> It's public as it doesn't require user and password to authenticate.
>>>>
>>>> However, the webservice is only consumed by a set of other applications 
>>>> that I manage.
>>>> So I would like those apps to use a key in order to connect to the 
>>>> webservice.
>>>> I'm trying to do such thing with a custom decorator, but I can't make 
>>>> it work.
>>>>
>>>> This is what I have:
>>>>
>>>> from gluon.tools import Service
>>>>
>>>>
>>>> service = Service()
>>>>
>>>>
>>>> def validate_key():
>>>> return True
>>>>
>>>>
>>>> @auth.requires(lambda: validate_key())
>>>> def call():
>>>> session.forget()
>>>> return service()
>>>>
>>>>
>>>> @service.jsonrpc
>>>> def test():
>>>> return 'test ok'
>>>>
>>>>
>>>>
>>>> But when I try to connect to the webservice, I receive this error:
>>>>
>>>> ProtocolError: >>> OTHER>
>>>>
>>>>
>>>> I'm not sure if what I'm tying to do is possible in that way. 
>>>> I know that I can apply the @auth.requires_login() decorator to the 
>>>> call() method, but that would force me to create users for every app using 
>>>> the webservice, and that's not wat I want. I would like to simply generate 
>>>> a key for every app that needs to use the webservice, and then ask the 
>>>> applications to use that key (either in the call to connect to the 
>>>> webservice, or in every call to any method of the webservice).
>>>>
>>>> What would be the correct approach?
>>>> Thanks in advance.
>>>> Regards, 
>>>> Lisandro.
>>>>
>>>

-- 
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 processes cooperation issue

2016-09-29 Thread Niphlod
ha: yep, the logic is totally flawed. You can't be sure your task has been 
correctly processed just by queueing it. The task DOESN'T obviously run in 
the same transaction the webpage displaying the form is.

On Thursday, September 29, 2016 at 5:54:20 PM UTC+2, Pierre wrote:
>
> very confusing situation
> problem has been addressed long time ago:
>
>
> https://groups.google.com/forum/?fromgroups#!topicsearchin/web2py/race$20condition;context-place=forum/web2py/web2py/Z581Pk3RCYI/web2py/Z581Pk3RCYI
>
> what I observe is that transaction logic doesn't work as expected in the 
> following circonstance :
>
> *controller:*
>
> def func():
>   form = SQLFORM(db.taba,...)
>   if form.process().accepted:
>   scheduler.queue_task(tska,..),
>   redirect(URL(...)
>   elif form.errors:
>.
>.
>   else:
>return dict(form=form)
>
> if task tska raises an exception (violate unique key constraint) there's 
> no roll-back and still I get a new record in db.taba
>
> Is there a generic approach to deal with such overhead problems ?  i am 
> starting to worry a lot...where's the tunnel exit ?
>

-- 
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 processes cooperation issue

2016-09-28 Thread Niphlod
the POV of this question is wrong. Scheduler processes do what you ask them 
to do, without nothing else added.
The same thing you observe would happen if you try to execute your tasks 
manually. It just seems that what you are asking them to do violates your 
model (i.e. either you had already a row with fa=something in the table OR 
you asked more than one task to insert fa=something in the table, which 
would, at the 2nd run, fail as expected)

On Wednesday, September 28, 2016 at 10:13:10 PM UTC+2, Dave S wrote:
>
>
>
> On Wednesday, September 28, 2016 at 3:58:10 AM UTC-7, Pierre wrote:
>>
>> Hi ,
>>
>>
>> I noticed an unexpected behaviour when running two scheduler processes.
>>
>>
>> The situation is this :
>>
>>
>> A db  with a table  like :
>>
>>
>> db.define_table('taba',
>>  Field('fa', unique=True, requires = IS_NOT_IN_DB(db,'taba.fa')), 
>>  Field('fb'))
>>
>>
>>
>> a task (same function different args) distributed to the processes which 
>> contains a :
>>
>>
>> ret = db.taba.validate_and_insert(fa='something', fb='somethingelse')
>>
>>
>> this generates an exception like so :
>>
>>
>> File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 737, in 
>> validate_and_insert 
>>  response.id = self.insert(**new_fields) 
>>  File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 712, in 
>> insert 
>>  ret = self._db._adapter.insert(self, self._listify(fields)) 
>>  File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 739, 
>> in insert 
>>
>>  raise e 
>> IntegrityError: duplicate key value violates unique constraint 
>> "taba_fa_key" 
>>
>> DETAIL: Key (fa)=(something) already exists. 
>>
>>
>>
>> and task fails
>>
>>
>> This doesn't happen when running a single scheduler process so I guess 
>> the two scheduler processes collide(….they try to write the same value to 
>> the db at the same time……)
>>
>>
>> how do I fix this ? Why can't the two processes cooperate ? Am I limited 
>> to running a single sched process ?
>>
>
> What do you mean by 2 sched processes?  Are you calling 
> schedule=Scheduler(db, migrate=False)
> twice?  I don't think you're supposed to do that.
>
> There can be a variable number of workers, and ISTR that the default is 4.
>
> If you aren't instantiating twice, then the next question is how are you 
> queuing your tasks?  Are you queuing tasks from a controller?  From a 
> script?
>
> /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/d/optout.


[web2py] Re: How to restrict access to a public webservice using a key?

2016-09-28 Thread Niphlod
jwt is the emerging standard for apis and such, but if the usage is 
all-internal, why don't you just start simple and do


if request.vars.token not in ('xa', 'bbxb', 'cc'):
 raise HTTP(403)

 ?

On Wednesday, September 28, 2016 at 2:15:19 PM UTC+2, Marlysson Silva wrote:
>
> This is what you need:
>
> http://web2py.readthedocs.io/en/latest/tools.html#gluon.tools.Auth.jwt
>
> Json Web Token , communications to services "rest" .. I think that 
> facilitates your work
>
> Em quarta-feira, 28 de setembro de 2016 08:57:59 UTC-3, Lisandro escreveu:
>>
>> Hi there!
>> I have a web2py app that implements a JSON-RPC public webservice, over 
>> HTTPS.
>> It's public as it doesn't require user and password to authenticate.
>>
>> However, the webservice is only consumed by a set of other applications 
>> that I manage.
>> So I would like those apps to use a key in order to connect to the 
>> webservice.
>> I'm trying to do such thing with a custom decorator, but I can't make it 
>> work.
>>
>> This is what I have:
>>
>> from gluon.tools import Service
>>
>>
>> service = Service()
>>
>>
>> def validate_key():
>> return True
>>
>>
>> @auth.requires(lambda: validate_key())
>> def call():
>> session.forget()
>> return service()
>>
>>
>> @service.jsonrpc
>> def test():
>> return 'test ok'
>>
>>
>>
>> But when I try to connect to the webservice, I receive this error:
>>
>> ProtocolError: 
>>
>>
>> I'm not sure if what I'm tying to do is possible in that way. 
>> I know that I can apply the @auth.requires_login() decorator to the 
>> call() method, but that would force me to create users for every app using 
>> the webservice, and that's not wat I want. I would like to simply generate 
>> a key for every app that needs to use the webservice, and then ask the 
>> applications to use that key (either in the call to connect to the 
>> webservice, or in every call to any method of the webservice).
>>
>> What would be the correct approach?
>> Thanks in advance.
>> Regards, 
>> Lisandro.
>>
>

-- 
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: Error in redis_cache.py after upgrading web2py to last stable version

2016-09-28 Thread Niphlod
see the other thread. accessing redis through an ssl channel just encrypts 
the traffic from your frontend to the redis instance: it has nothing to do 
with how a user accesses your app (i.e. https or http). 

On Wednesday, September 28, 2016 at 9:42:28 PM UTC+2, Lisandro wrote:
>
> I think I know what's going on.
> I've found this post from Niphlod regarding new redis cache:
>
> https://groups.google.com/forum/#!searchin/web2py/redis$20unavailable$20instance%7Csort:relevance/web2py/x1CCFWflmV8/POdMQmcYEgAJ
>
> There he says: "...want to connect to redis through ssl (previously 
> unavailable)? pass the relevant ssl, ssl_keyfile, etc etc etc to RConn"
>
> My app is served with nginx through HTTPS, so I think I would have to pass 
> those parameters to RConn.
> Does anyone have a working example about that?
>
>
>
> El miércoles, 28 de septiembre de 2016, 12:54:13 (UTC-3), Lisandro 
> escribió:
>>
>> I was using an old web2py version 
>> (2.10.3-stable+timestamp.2015.04.02.21.42.07), but today I've updated to 
>> the last stable (2.14.6-stable+timestamp.2016.05.10.00.21.47).
>>
>> I've seen that in the new version of redis_cache the usage has changed. 
>> Before it was like this:
>>
>> from gluon.contrib.redis_cache import RedisCache
>> cache.redis = RedisCache('localhost:6379', with_lock=True)
>>
>>
>> But now, accordingly to the module documentation, it should be like this:
>>
>> from gluon.contrib.redis_cache import RedisCache
>> from gluon.contrib.redis_utils import RConn
>> rconn = RConn('localhost', 6379)
>> cache.redis = RedisCache(redis_conn=rconn, with_lock=True)
>>
>>
>> I've made that changes, and *it does work ok when I use web2py embedded 
>> webserver, but when I stop web2py's server and try to access the app 
>> (served through nginx), it can't connect to redis*.
>> I'm lost there :/
>>
>>
>>
>>
>> El miércoles, 28 de septiembre de 2016, 11:52:22 (UTC-3), Marlysson Silva 
>> escribió:
>>>
>>> Try look whether a instance of Redis return a type of redis , it is like 
>>> that redis connection are failing and returning a string intead redis 
>>> object. I Think.
>>>
>>> Em quarta-feira, 28 de setembro de 2016 11:24:10 UTC-3, Lisandro 
>>> escreveu:
>>>>
>>>> Hi there! 
>>>> Recently I've updated web2py to the last stable 
>>>> version 2.14.6-stable+timestamp.2016.05.10.00.21.47
>>>>
>>>>
>>>> ERROR:web2py:Traceback (most recent call last):
>>>>   File "/home/gonguinguen/medios/gluon/restricted.py", line 227, in 
>>>> restricted
>>>> exec ccode in environment
>>>>   File "/home/gonguinguen/medios/applications/webmedios/models/0.py", 
>>>> line 19, in 
>>>> cache.redis = RedisCache('localhost:6379', with_lock=True)
>>>>   File "/home/gonguinguen/medios/gluon/contrib/redis_cache.py", line 
>>>> 90, in RedisCache
>>>> with_lock=with_lock, fail_gracefully=fail_gracefully))
>>>>   File "/home/gonguinguen/medios/gluon/contrib/redis_cache.py", line 
>>>> 126, in __init__
>>>> self._release_script = register_release_lock(self.r_server)
>>>>   File "/home/gonguinguen/medios/gluon/contrib/redis_utils.py", line 
>>>> 69, in register_release_lock
>>>> rtn = conn.register_script(_LUA_RELEASE_LOCK)
>>>> AttributeError: 'str' object has no attribute 'register_script'
>>>>
>>>>
>>>> Any ideas on how to solve it?
>>>> I'm a bit lost. I've tried instantiating RedisCache with_lock=False but 
>>>> the error is the same.
>>>>
>>>> Thanks in advance!
>>>> Regards,
>>>> Lisandro.
>>>>
>>>

-- 
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 redis_tools, new redis-backed scheduler

2016-09-28 Thread Niphlod
first and foremost, ssl connection with redis and https have absolutely no 
relation.
you can get every combination of the matrix:
- http with std redis
- http with ssl redis
- https with std redis
- https with ssl redis

Redis server doesn't offer anything as ssl is concerned. Redis service 
providers though use something like stunnel to create an encrypted channel 
to connect to redis, and redis-py (the official, underlying library) 
supports it.
What you can pass to redis-py you can now pass to RConn (so, if you want to 
connect to redis through an ssl channel because your service provider 
require you to do so, you can pass 
ssl_keyfile,ssl_certfile,ssl_cert_reqs,ssl_ca_certs, etc etc etc)

On Wednesday, September 28, 2016 at 9:57:38 PM UTC+2, Lisandro wrote:
>
> Hi there.
> Is there any working example using ssl to connect to redis?
>
> My web2py app is served through HTTPS since some time ago (using an old 
> web2py version). 
> Today I've tried to update web2py to the last stable version, and I've 
> noticed all this awesome improvements to redis cache. 
> However, the way to use it has changed, so I need to modify my code. I've 
> been able to get it to work **without** https. But when I use https, my app 
> just can't connect to redis.
>
> I've seen that RConn class receives several arguments regarding ssl. But 
> I'm not sure how to use them.
> If my app is served through HTTPS, do I need to pass those parameters to 
> RConn? Do I need to generate those certificates locally? 
> If that's the case, is there any example that can help me?
>
>
> Thanks in advance!
> Regards, 
> Lisandro
>
>
>
> El sábado, 2 de enero de 2016, 20:44:15 (UTC-3), Niphlod escribió:
>>
>> Once PR1158 <https://github.com/web2py/web2py/pull/1158>gets merged 
>> web2py will have a preferred way to use redis. It's through the new 
>> gluon.contrib.redis_utils "RConn".
>> Some redis libraries are coming along and redis-py, while maintaining a 
>> solid "#1 position" among them, could be one day in #2.
>> Moreover, connection parameters passed to redis have been added and it's 
>> been almost impossible to keep web2py's modules that use redis in sync. 
>> It'd have meant to lock a particular release of redis-py to a particular 
>> release of web2py's contrib redis_* modules.
>> Seen that and issue#958 <https://github.com/web2py/web2py/issues/958>, a 
>> refactor was needed. Better late than ever, the refactor is here.
>>
>> This bring BREAKING changes for the next version of web2py. Anyone using 
>> gluon.contrib.redis_cache and/or gluon.contrib.redis_session will need to 
>> alter app's code to match the new behaviour.
>> Basically now every module in web2py that uses redis needs (and should, 
>> for new modules you may want to contrib) to have a redis_conn parameter 
>> that takes a redis instance. That redis instance can be provided out of the 
>> box - tuned for the unique environment of web2py - with
>>
>> from gluon.contrib.redis_utils import RConn
>> rconn = RConn()
>>
>> now, RConn takes ALL parameters and passes them unchanged down the pipe 
>> directory to redis.StrictRedis .
>>
>> This means that any parameter that was used to connect to redis for those 
>> modules isn't there anymore.
>> Specifically, if you had a redis instance available at 10.0.0.10 on port 
>> , your instantiation of RedisCache was similar to
>>
>> from gluon.contrib.redis_cache import RedisCache
>> cache.redis = RedisCache('10.0.0.10:',debug=True)
>>
>> from here on, it'll be instead
>>
>> from gluon.contrib.redis_utils import RConn
>> from gluon.contrib.redis_cache import RedisCache
>> rconn = RConn(host='10.0.0.10', port=)
>> cache.redis = RedisCache(redis_conn=rconn,debug=True)
>>
>> want to connect to redis through ssl (previously unavailable)? pass the 
>> relevant ssl, ssl_keyfile, etc etc etc to RConn.
>>
>> You can also reuse the rconn object as if it was a redis.StrictRedis 
>> instance in your app's code. Everything will work fine. Just use a sane key 
>> prefix (all modules use "w2p") in order to avoid conflicts. redis_cache, 
>> redis_session and redis_scheduler (and your app) can use a single RConn 
>> instance without issues.
>>
>> Was this only a refactor ? Nope!
>> There is also a new (not so shiny, 'cause - guilty as charged - I'm using 
>> it for 10 months in production now) redis-backed scheduler. 
>> Of course it's experimental (as everything in contrib) but it's not 
>> untested (all w2p_scheduler_tests 
>> <http://github.com/niphlod/w2p_scheduler_tests

[web2py] Re: AppConfig and % interpolation

2016-09-27 Thread Niphlod
yep, ATM I'd go for rawconfigparser but someone asked for interpolation 
 so we have two distinct "paths" . Just need to rule out one ^_^

On Tuesday, September 27, 2016 at 6:56:10 PM UTC+2, Ivan wrote:
>
> escaping % with % solves the problem
> however I think it would be better to not force the user to escape each % 
> in a .ini file
>
> the exception comes from the ConfigParser python module (more 
> precisely SafeConfigParser) used in AppConfig
> maybe a better solution is to use RawConfigParser that doesn't interpolate 
> at all
>
>
> Il giorno martedì 27 settembre 2016 17:30:21 UTC+2, Niphlod ha scritto:
>>
>> hum. did you try excaping the % with % , which means basically having %% 
>> instead of % ?
>>
>> On Tuesday, September 27, 2016 at 4:15:45 PM UTC+2, Ivan wrote:
>>>
>>> I don't want to interpolate.
>>> I have an option with a % inside and the AppConfig raises an exception.
>>>
>>

-- 
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: AppConfig and % interpolation

2016-09-27 Thread Niphlod
hum. did you try excaping the % with % , which means basically having %% 
instead of % ?

On Tuesday, September 27, 2016 at 4:15:45 PM UTC+2, Ivan wrote:
>
> I don't want to interpolate.
> I have an option with a % inside and the AppConfig raises an exception.
>

-- 
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: AppConfig and % interpolation

2016-09-27 Thread Niphlod
and it's correct that it does, as it can work with json with doesn't have 
any interpolation facilities. if you want to interpolate, for the moment, 
use your app's code.

On Tuesday, September 27, 2016 at 3:43:24 PM UTC+2, Ivan wrote:
>
> If the .ini file contains an option with a % (eg a password), the 
> AppConfig class raise an InterpolationSyntaxError exception.
>
>

-- 
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 task runs before it is supposed to run

2016-09-21 Thread Niphlod
BTW: it has been merged . You can safely take scheduler.py from master and 
overwrite your own if you want to avid specifying next_run_time

On Wednesday, September 21, 2016 at 5:57:44 PM UTC+2, Bernardo Leon wrote:
>
> Niphlod I will use postgresql in production and your solution as well. 
> Thank you for helping me! ;)
>
> El miércoles, 21 de septiembre de 2016, 2:33:30 (UTC-5), Niphlod escribió:
>>
>> that error is due - mostly - when the backend is too much pressured (i.e. 
>> you're using sqlite, or too many workers, or a too low heatbeat)
>>
>> this is the fix  https://github.com/web2py/web2py/pull/1453 . you can 
>> subscribe to it to know when it'll be merged.
>>
>> On Tuesday, September 20, 2016 at 5:38:08 PM UTC+2, Bernardo Leon wrote:
>>>
>>> Thank you for your reply. Can you reply this thread when the fix is 
>>> published?
>>>
>>> I don't know if this is related to the same bug but in my worker process 
>>> terminal I have this message:
>>>
>>> ERROR:web2py.scheduler.cedia-Satellite-L55-C#18606:error popping 
>>> tasks
>>>
>>> why do I have this error? Thanks.
>>>
>>> El lunes, 19 de septiembre de 2016, 13:37:05 (UTC-5), Niphlod escribió:
>>>>
>>>> sorry, a bug slipped in. In the wait for the fix, please use 
>>>> next_run_time in addition to start_time.
>>>>
>>>> On Monday, September 19, 2016 at 6:27:28 PM UTC+2, Bernardo Leon wrote:
>>>>>
>>>>> Hi, I am trying to run tasks in the future based on a time the user 
>>>>> specifies but as soon as the task is queued it is executed, what am I 
>>>>> doing 
>>>>> wrong?
>>>>>
>>>>> I am using web2py Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
>>>>>
>>>>> This is my model.db (part of it)
>>>>>
>>>>> db = DAL('sqlite://recomendadorexpertos.db')
>>>>>
>>>>> db.define_table('topicos',
>>>>>Field('curso', 'reference cursos'),
>>>>>Field('nombre', 'string', required=True, length=512),
>>>>>Field('palabras_clave', 'text', readable=False, 
>>>>> required=True, length=2048),
>>>>>Field('fecha_inicio_identificacion', 'date', 
>>>>> required=True, comment=T('Indica la fecha desde la cual se empezará a 
>>>>> buscar expertos.')),
>>>>>Field('fecha_fin_identificacion', 'date', 
>>>>> required=True, comment=T('Indica la fehca en la cual se publicarán las 
>>>>> recomendaciónes de expertos.')),
>>>>>Field('fecha_fin_publicacion', 'date', 
>>>>> comment=T('Indica la fecha hasta cuando se publicaran las recomendaciones 
>>>>> de expertos (opcional)')),
>>>>>Field('timestamp_get_tweets_etiquetado', 'datetime', 
>>>>> readable=False, writable=False), #Para mostrar al usuario desde cuando se 
>>>>> estan descargando tweets para etiquetado.
>>>>>Field('link_descarga_tweets_etiquetado', 'string', 
>>>>> readable=False, writable=False, length=2048),
>>>>>Field('upload_archivo_etiquetado', 'upload', 
>>>>> length=524288, 
>>>>> uploadfolder='/var/www/web2py/applications/RecomendadorExpertos/archivos_etiquetados/',
>>>>>  
>>>>> autodelete=True, comment=T('Primero inicie el proceso de descarga de 
>>>>> tweets 
>>>>> para este topico, descargue el archivo para etiquetado, etiquetelo y 
>>>>> subalo 
>>>>> aqui.'), label=T('Subir archivo etiquetado'), readable=False), #Cambiar 
>>>>> el 
>>>>> nombre del archivo que suba a [nombre_topico].csv
>>>>>Field('path_modelo', 'string', readable=False, 
>>>>> writable=False, length=2048), #Ruta del modelo entrenado
>>>>>Field('topico_configurado_completamente', 'integer', 
>>>>> readable=True, writable=False, default=1, 
>>>>> represent=representTopicoConfigurado), #Sirve para mostrar un check alado 
>>>>> del archivo subido una vez terminado de generarse el modelo, para que el 
>>>>> profesor sepa que ya esta todo bien.
>>>>>Field('id_scheduler_task_descarga_tweets', 'integer', 
>>>>> readable=False, writable=False),
>>>>&

[web2py] Re: Off topic (1) what data warehouse with w2p data and (2) survey: which ones are you using?

2016-09-21 Thread Niphlod
postgresql is fairly supported. on top of the usual suspects, qlikview and 
tableau are really great, if you can spend some money.

On Wednesday, September 21, 2016 at 7:21:37 PM UTC+2, Alex Glaros wrote:
>
> Using Postgres to store web2py transactional data. Any advice regarding 
> data warehouse choice in terms of ease of data transfer, compatibility, 
> etc.  
>
> If their roles are  so separate that compatibility is not relevant, am 
> still curious regarding:
>
>- What people are using and would like to hear about working examples. 
>- What method are you using to migrate data to the DW: Migration 
>script, Talend, etc.?
>
> The use case is government DW for business data analytics and 
> client-controlled/created reports.
>
> thanks
>
> Alex Glaros
>

-- 
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: scaling web2py

2016-09-21 Thread Niphlod
I saw a relatively/mostly related issue on the repo and so I feel I should 
give an answer...

web2py is a web framework: we're not in the business of managing processes 
nor webservers. We're in the business of realizing an app that does what 
you want in response to a web request.
For development purposes (and relatively small deployments) web2py includes 
a single process threaded webserver, that is rocket.

NOBODY says that you MUST run web2py under rocket. For all matter and 
purposes, in production we (or, for better saying, people who manage 
production-grade environments) highly encourage uwsgi + nginx on unix and 
fastcgi+iis on windows.

web2py is compatible with the wsgi standards which ATM is the only largely 
accepted way to run python web-serving apps. Usually frontends are I/O 
bound and not CPU bound: threading is the best choice there, so the rocket 
threaded webserver is just a matter of providing a "sane default".

web2py's scheduler is just something you can offload CPU (or long-running) 
tasks to an external process. Webservers DO enforce a timeout on each and 
every request (again, it's  a matter of "sane defaults" on their end) and 
so the "pattern" of having a facility that offloads those kind of things to 
"something else" has gained traction.

web2py (and the scheduler) just adhere to "standards" and "sane defaults". 
I wouldn't be startled by the statement "should my web-serving process 
consume 1/10th of the CPU resources given to external processes" because 
the role of the web-serving process is reacting to user inputs. If the 
reaction is a web-page, usually the time taken to generate the page is far 
less than the time it takes to transfer it (or, for better saying, the time 
web2py spends in rendering the page is far less than the time taken to 
retrieve results from the db and shipping that result to the user's 
browser). If the reaction of a user input is to calculate the prime numbers 
from 10^56 to 10^101 ... well, you need to ship that work elsewhere because 
running it inside a web-serving app would only mean forcing the user 
waiting for a reply way too much.

Back to the "how should web2py be handled". you can choose whatever you 
like, according to your own app's needs and number of users (or, again for 
better saying, number of requests to serve per second): USUALLY you'd want 
something like uwsgi+nginx or iis+fastcgi to do the heavy work of spawning 
web2py processes as needed and having those serve the needs of the users 
requesting pages. They do an excellent job and provide nice facilities 
(like buffering) to make everything as speedier as possible.
Long running tasks can OPTIONALLY be handled by an external process (like 
the scheduler) to avoid hitting the "sane limits" defaults imposed by the 
majority of webservers (like that a request should be handled in AT MOST 60 
seconds, which, if you reeeally think it through, is a RALLY long time 
to wait for whatever webpage the user asks for).

 

-- 
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 task runs before it is supposed to run

2016-09-21 Thread Niphlod
that error is due - mostly - when the backend is too much pressured (i.e. 
you're using sqlite, or too many workers, or a too low heatbeat)

this is the fix  https://github.com/web2py/web2py/pull/1453 . you can 
subscribe to it to know when it'll be merged.

On Tuesday, September 20, 2016 at 5:38:08 PM UTC+2, Bernardo Leon wrote:
>
> Thank you for your reply. Can you reply this thread when the fix is 
> published?
>
> I don't know if this is related to the same bug but in my worker process 
> terminal I have this message:
>
> ERROR:web2py.scheduler.cedia-Satellite-L55-C#18606:error popping tasks
>
> why do I have this error? Thanks.
>
> El lunes, 19 de septiembre de 2016, 13:37:05 (UTC-5), Niphlod escribió:
>>
>> sorry, a bug slipped in. In the wait for the fix, please use 
>> next_run_time in addition to start_time.
>>
>> On Monday, September 19, 2016 at 6:27:28 PM UTC+2, Bernardo Leon wrote:
>>>
>>> Hi, I am trying to run tasks in the future based on a time the user 
>>> specifies but as soon as the task is queued it is executed, what am I doing 
>>> wrong?
>>>
>>> I am using web2py Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
>>>
>>> This is my model.db (part of it)
>>>
>>> db = DAL('sqlite://recomendadorexpertos.db')
>>>
>>> db.define_table('topicos',
>>>Field('curso', 'reference cursos'),
>>>Field('nombre', 'string', required=True, length=512),
>>>Field('palabras_clave', 'text', readable=False, 
>>> required=True, length=2048),
>>>Field('fecha_inicio_identificacion', 'date', 
>>> required=True, comment=T('Indica la fecha desde la cual se empezará a 
>>> buscar expertos.')),
>>>Field('fecha_fin_identificacion', 'date', required=True, 
>>> comment=T('Indica la fehca en la cual se publicarán las recomendaciónes de 
>>> expertos.')),
>>>Field('fecha_fin_publicacion', 'date', comment=T('Indica 
>>> la fecha hasta cuando se publicaran las recomendaciones de expertos 
>>> (opcional)')),
>>>Field('timestamp_get_tweets_etiquetado', 'datetime', 
>>> readable=False, writable=False), #Para mostrar al usuario desde cuando se 
>>> estan descargando tweets para etiquetado.
>>>Field('link_descarga_tweets_etiquetado', 'string', 
>>> readable=False, writable=False, length=2048),
>>>Field('upload_archivo_etiquetado', 'upload', 
>>> length=524288, 
>>> uploadfolder='/var/www/web2py/applications/RecomendadorExpertos/archivos_etiquetados/',
>>>  
>>> autodelete=True, comment=T('Primero inicie el proceso de descarga de tweets 
>>> para este topico, descargue el archivo para etiquetado, etiquetelo y subalo 
>>> aqui.'), label=T('Subir archivo etiquetado'), readable=False), #Cambiar el 
>>> nombre del archivo que suba a [nombre_topico].csv
>>>Field('path_modelo', 'string', readable=False, 
>>> writable=False, length=2048), #Ruta del modelo entrenado
>>>Field('topico_configurado_completamente', 'integer', 
>>> readable=True, writable=False, default=1, 
>>> represent=representTopicoConfigurado), #Sirve para mostrar un check alado 
>>> del archivo subido una vez terminado de generarse el modelo, para que el 
>>> profesor sepa que ya esta todo bien.
>>>Field('id_scheduler_task_descarga_tweets', 'integer', 
>>> readable=False, writable=False),
>>>Field('id_scheduler_task_identificacion_expertos', 
>>> 'integer', readable=False, writable=False),
>>>Field('id_scheduler_task_publicacion_expertos', 
>>> 'integer', readable=False, writable=False))
>>>
>>>
>>> This is my Scheduler.py
>>>
>>> def task_iniciar_descarga_tweets(row):
>>> return 'descarga de tweets terminada'
>>>
>>> def task_iniciar_identificacion_expertos(nombre_topico):
>>> return 'identificacion de expertos terminada'
>>>
>>> def task_publicar_expertos(nombre_topico):
>>> return 'publicacion de expertos terminada'
>>>
>>> dbScheduler = DAL('sqlite://scheduler.db')
>>> scheduler = Scheduler(dbScheduler, 
>>> tasks={'task_iniciar_descarga_tweets':task_iniciar_descarga_tweets,
>>>   
>>> 'task_iniciar_identificacion_expertos':task_iniciar_identificacion_expertos,
>>>   

[web2py] Re: scheduler and long tasks

2016-09-19 Thread Niphlod
nope. Technically, tasks are queued as long as the "outer" thingy (be it 
whatever) get all of the pending transactions committed (a task IS queued 
when the corresponding "insert" is committed to the database).
Every task gets processed according by the usual rules, but if you want 
coordination among them (i.e. task 5 needs to be executed after task 7), 
you can code a "coordinator" task (i.e. that waits for 5 to be completed 
before queuing task 7) or use the included JobGraph factory.

On Monday, September 19, 2016 at 9:07:31 PM UTC+2, Pierre wrote:
>
>
> so far works :)
>
> is there any restriction to queueing_task inside of a task ?
> is every task independant from the other tasks ?  (any hierarchical 
> relation between "inner tasks" and "outer tasks" ?)
>
>

-- 
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 task runs before it is supposed to run

2016-09-19 Thread Niphlod
sorry, a bug slipped in. In the wait for the fix, please use next_run_time 
in addition to start_time.

On Monday, September 19, 2016 at 6:27:28 PM UTC+2, Bernardo Leon wrote:
>
> Hi, I am trying to run tasks in the future based on a time the user 
> specifies but as soon as the task is queued it is executed, what am I doing 
> wrong?
>
> I am using web2py Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
>
> This is my model.db (part of it)
>
> db = DAL('sqlite://recomendadorexpertos.db')
>
> db.define_table('topicos',
>Field('curso', 'reference cursos'),
>Field('nombre', 'string', required=True, length=512),
>Field('palabras_clave', 'text', readable=False, 
> required=True, length=2048),
>Field('fecha_inicio_identificacion', 'date', required=True, 
> comment=T('Indica la fecha desde la cual se empezará a buscar expertos.')),
>Field('fecha_fin_identificacion', 'date', required=True, 
> comment=T('Indica la fehca en la cual se publicarán las recomendaciónes de 
> expertos.')),
>Field('fecha_fin_publicacion', 'date', comment=T('Indica la 
> fecha hasta cuando se publicaran las recomendaciones de expertos 
> (opcional)')),
>Field('timestamp_get_tweets_etiquetado', 'datetime', 
> readable=False, writable=False), #Para mostrar al usuario desde cuando se 
> estan descargando tweets para etiquetado.
>Field('link_descarga_tweets_etiquetado', 'string', 
> readable=False, writable=False, length=2048),
>Field('upload_archivo_etiquetado', 'upload', length=524288, 
> uploadfolder='/var/www/web2py/applications/RecomendadorExpertos/archivos_etiquetados/',
>  
> autodelete=True, comment=T('Primero inicie el proceso de descarga de tweets 
> para este topico, descargue el archivo para etiquetado, etiquetelo y subalo 
> aqui.'), label=T('Subir archivo etiquetado'), readable=False), #Cambiar el 
> nombre del archivo que suba a [nombre_topico].csv
>Field('path_modelo', 'string', readable=False, 
> writable=False, length=2048), #Ruta del modelo entrenado
>Field('topico_configurado_completamente', 'integer', 
> readable=True, writable=False, default=1, 
> represent=representTopicoConfigurado), #Sirve para mostrar un check alado 
> del archivo subido una vez terminado de generarse el modelo, para que el 
> profesor sepa que ya esta todo bien.
>Field('id_scheduler_task_descarga_tweets', 'integer', 
> readable=False, writable=False),
>Field('id_scheduler_task_identificacion_expertos', 
> 'integer', readable=False, writable=False),
>Field('id_scheduler_task_publicacion_expertos', 'integer', 
> readable=False, writable=False))
>
>
> This is my Scheduler.py
>
> def task_iniciar_descarga_tweets(row):
> return 'descarga de tweets terminada'
>
> def task_iniciar_identificacion_expertos(nombre_topico):
> return 'identificacion de expertos terminada'
>
> def task_publicar_expertos(nombre_topico):
> return 'publicacion de expertos terminada'
>
> dbScheduler = DAL('sqlite://scheduler.db')
> scheduler = Scheduler(dbScheduler, 
> tasks={'task_iniciar_descarga_tweets':task_iniciar_descarga_tweets,
>   
> 'task_iniciar_identificacion_expertos':task_iniciar_identificacion_expertos,
>   
> 'task_publicar_expertos':task_publicar_expertos})
>
>
> And this is my default.py controller (part of it)
>
> @auth.requires_login()
> def onCreateTopico(form):
> row_task_iniciar_identificacion = 
> scheduler.queue_task('task_iniciar_identificacion_expertos', 
> pvars={'nombre_topico':form.vars.nombre}, 
> start_time=datetime.datetime.combine(form.vars.fecha_inicio_identificacion, 
> datetime.time.min), 
> stop_time=datetime.datetime.combine(form.vars.fecha_fin_identificacion, 
> datetime.time.min), retry_failed=3)
>
> row_task_iniciar_publicacion = 
> scheduler.queue_task('task_publicar_expertos', 
> pvars={'nombre_topico':form.vars.nombre}, 
> start_time=datetime.datetime.combine(form.vars.fecha_fin_identificacion, 
> datetime.time.min), retry_failed=3)
> 
> db(db.topicos.id==form.vars.id
> ).update(id_scheduler_task_identificacion_expertos=
> row_task_iniciar_identificacion.id, 
> id_scheduler_task_publicacion_expertos=row_task_iniciar_publicacion.id)
> db.commit()
>
> For instance, if I queue the task "task_iniciar_identificacion_expertos" 
> with a future start_time the worker executes this task inmediately, how can 
> I set the worker to execute this task in the future?
>
> 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 

[web2py] Re: replaced by × in url

2016-09-19 Thread Niphlod
what version are you using ? can you try starting a shell and doing this ?

>>> URL(vars=dict(loc='foo', timestamp='bar'))


my output is 
'/welcome/default/index?loc=foo=bar'



On Monday, September 19, 2016 at 3:31:17 PM UTC+2, Gael Princivalle wrote:
>
> Hello.
>
> When I build this URL:
> url = URL('/maps/api/timezone/json', scheme='https', host='
> maps.googleapis.com', vars=dict(key='mykey', location=str(events_latitude) 
> + ',' + str(events_longitude), timestamp=str(today_UTC_timestamp)))
>
> "" is replaced by "×":
>
>
> https://maps.googleapis.com/mtbconnection/f_ajax/maps/api/timezone/json?key=mykey=45.4%2C7.41
> ×tamp=1474291274.04
>
> For location & is ok.
>
> I've tried also to concatenate strings, using ascii with chr(38), the 
> result is the same.
>
> Someones have a solution?
>
> 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] booking/event calendar

2016-09-18 Thread Niphlod
Go for fullcalendar

-- 
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] scheduler and long tasks

2016-09-18 Thread Niphlod
You can have a task that selects and groups and queues for each group the task 
that processes the atom.

-- 
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: avoiding duplicate field names

2016-09-16 Thread Niphlod
the query is right, but *requires=* *require *- excuse the repetition - a 
validator, not a query (those nifty IS_LENGTH() thingies)



On Friday, September 16, 2016 at 5:18:30 AM UTC+2, Alex Glaros wrote:
>
> are there any simple mistakes in this syntax or am I approaching it wrong?
>
> my_current_role_names = db(db.Role.role_owner_organization_FK == 
> specificOrganizationID)._select(db.Role.role_name) 
> db.Role.role_name.requires = ~db.Role.role_name.belongs(
> my_current_role_names)
>
>
> thanks
>
> Alex Glaros
>
>  Validation error, field:role_name (NOT 
> (Role.role_name IN (SELECT Role.role_name FROM Role WHERE 
> (Role.role_owner_organization_FK = 7 'exceptions.Exception'>(Validation error, field:role_name (NOT 
> (Role.role_name IN (SELECT Role.role_name FROM Role WHERE 
> (Role.role_owner_organization_FK = 7)
>
> Code listing
>
> 1862.
> 1863.
> 1864.
> 1865.
> 1866.
> 1867.
>
> 1868.
> 1869.
> 1870.
> 1871.
>
> (value, errors) = validator(value)
> except:
> import traceback
> print traceback.format_exc()
> msg = "Validation error, field:%s %s" % (name,validator)
> raise Exception(msg)
>
> if errors is not None:
> self.vars[name] = value
> self.errors[name] = errors
> break
>
>

-- 
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: Need help to understand (and reproduce) this error

2016-09-13 Thread Niphlod
this is the only proper way, and it relies on the underlying driver 
implementation.

On Tuesday, September 13, 2016 at 5:08:30 PM UTC+2, Lisandro wrote:
>
> Thank you Niphlod.
> I've seen that db.executesql receives the "placeholders" argument in order 
> to do the escaping.
> I've modified my code to this:
>
> def search():
> results = db.executesql('SELECT * FROM contenido WHERE tsv @@ 
> plainto_tsquery(%s)', placeholders=[request.vars.q])
> return dict(results=results)
>
> *Can you confirm that this is the proper way to do it? *
> I couldn't find much documentation about that, just this:
>
>- http://web2py.com/books/default/chapter/29/6#executesql
>- 
>
> https://groups.google.com/forum/#!searchin/web2py/executesql$20placeholders$20escape%7Csort:relevance/web2py/kblhrTsVW6M/2vJ_afgty34J
>
>
> Thanks in advance!
>
>
>
> El martes, 13 de septiembre de 2016, 6:51:55 (UTC-3), Niphlod escribió:
>>
>> app/controller/function=everythingyoucanthinkof .
>>
>> NEVER . EVER. EVER. build queries without proper escaping.
>>
>> On Monday, September 12, 2016 at 3:12:50 PM UTC+2, Lisandro wrote:
>>>
>>> Hi there!
>>> I have a simple view with a form (with GET method), in order to allow my 
>>> visitors to do some search. 
>>> The controller/function that processes the get is this:
>>>
>>> def search():
>>> session.forget(response)
>>> query = "tsv @@ plainto_tsquery('%s')" % request.vars.q
>>> total = db.executesql('SELECT COUNT(*) FROM contenido WHERE %s' % 
>>> query)
>>> results = db(query).select()
>>> return dict(results=results)
>>>
>>> As you can see, I use a tsv field to implement postgresql full text 
>>> search. The funcion is working ok.
>>> But *yesterday, I had an attack attempt*, or something like that.  In 
>>> just one hour, some robot sent a lot of queries to that URL, putting 
>>> "garbage" in the "q" parameter.
>>>
>>> How did I notice that? Well, *in just one hour around 500 error tickets 
>>> were created* in the /errors folder. All the errors have this form:
>>>
>>>- unterminated quoted string at or near 
>>>"'../../../../../../../../../../windows/win.ini" LINE 1: ...tsv @@ 
>>>plainto_tsquery('../../../... ^
>>>- unterminated quoted string at or near 
>>>"'1some_inexistent_file_with_long_name" LINE 1: ...tsv @@ 
>>>plainto_tsquery('1some_ine... ^ 
>>>- unterminated quoted string at or near 
>>>"'../../../../../../../../../../etc/passwd" LINE 1: ...tsv @@ 
>>>plainto_tsquery('../../../... ^ 
>>>- invalid byte sequence for encoding "UTF8": 0xf0 0x20 0x20 0xf0
>>>- invalid byte sequence for encoding "UTF8": 0xf6 0x22 0x20 0x6f
>>>- invalid byte sequence for encoding "UTF8": 0xa0
>>>
>>>
>>> *I've already tried to use the search form with those query strings, but 
>>> I cannot reproduce the error.*
>>> *How could the robot send those bytes to the query function?*
>>>
>>> Of course I can add a try: except: block, however I was wondering how to 
>>> reproduce the error, I wasn't able to do it.
>>> Any help will be appreciated.
>>>
>>> Thanks in advance!
>>> Regards, 
>>> Lisandro.
>>>
>>

-- 
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: JSON getting the series data into view

2016-09-13 Thread Niphlod
definitely something is going on with your setup: did you play with routes 
? 

the default scheme includes the app name right after the host name, and 
that's why you got the example with /app/controller/function.

On Tuesday, September 13, 2016 at 5:38:11 PM UTC+2, Aydin wrote:
>
> @Niphlod and Brian:
> Sorry that was my mistake, I mixed up the codes.
> the actual code was:
>
> 

[web2py] Re: JSON getting the series data into view

2016-09-13 Thread Niphlod
then please check with whoever wrote 

"""

function(data){series: [{
type: 'area',
name: 'Response(kW)',
data: data
}] 

"""

PS: may I suggest that you'd need to call /app/default/getdata*.json *that 
sets automatically also the correct content-type for json ?

On Tuesday, September 13, 2016 at 1:39:19 PM UTC+2, Aydin wrote:
>
> Im sure it has to do with my code not web2py.
> Yes in the browser i did /app/default/getdata and it returned correctly 
> [[1,2],[2,3]].
> By the way i import json and also use @service.json.
>

-- 
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: Need help to understand (and reproduce) this error

2016-09-13 Thread Niphlod
app/controller/function=everythingyoucanthinkof .

NEVER . EVER. EVER. build queries without proper escaping.

On Monday, September 12, 2016 at 3:12:50 PM UTC+2, Lisandro wrote:
>
> Hi there!
> I have a simple view with a form (with GET method), in order to allow my 
> visitors to do some search. 
> The controller/function that processes the get is this:
>
> def search():
> session.forget(response)
> query = "tsv @@ plainto_tsquery('%s')" % request.vars.q
> total = db.executesql('SELECT COUNT(*) FROM contenido WHERE %s' % 
> query)
> results = db(query).select()
> return dict(results=results)
>
> As you can see, I use a tsv field to implement postgresql full text 
> search. The funcion is working ok.
> But *yesterday, I had an attack attempt*, or something like that.  In 
> just one hour, some robot sent a lot of queries to that URL, putting 
> "garbage" in the "q" parameter.
>
> How did I notice that? Well, *in just one hour around 500 error tickets 
> were created* in the /errors folder. All the errors have this form:
>
>- unterminated quoted string at or near 
>"'../../../../../../../../../../windows/win.ini" LINE 1: ...tsv @@ 
>plainto_tsquery('../../../... ^
>- unterminated quoted string at or near 
>"'1some_inexistent_file_with_long_name" LINE 1: ...tsv @@ 
>plainto_tsquery('1some_ine... ^ 
>- unterminated quoted string at or near 
>"'../../../../../../../../../../etc/passwd" LINE 1: ...tsv @@ 
>plainto_tsquery('../../../... ^ 
>- invalid byte sequence for encoding "UTF8": 0xf0 0x20 0x20 0xf0
>- invalid byte sequence for encoding "UTF8": 0xf6 0x22 0x20 0x6f
>- invalid byte sequence for encoding "UTF8": 0xa0
>
>
> *I've already tried to use the search form with those query strings, but I 
> cannot reproduce the error.*
> *How could the robot send those bytes to the query function?*
>
> Of course I can add a try: except: block, however I was wondering how to 
> reproduce the error, I wasn't able to do it.
> Any help will be appreciated.
>
> Thanks in advance!
> Regards, 
> Lisandro.
>

-- 
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: Turbolinks?

2016-09-13 Thread Niphlod
everything works perfectly fine with pjax-like libraries. What's the issue 
you're facing ?

On Monday, September 12, 2016 at 10:51:47 PM UTC+2, Dave S wrote:
>
>
>
> On Monday, September 12, 2016 at 1:21:20 PM UTC-7, pbreit wrote:
>>
>> Does Python or Web2py have anything like Turbolinks? Has anyone used 
>> anything like https://github.com/Easyfood/pageAccelerator or 
>> http://instantclick.io with web2py with any success? Good idea?
>>
>
> Links to excerpts from a couple of previous pjax discussions:
>
> <URL:https://groups.google.com/d/msg/web2py/RHwErNSdu6M/-rozimgeCQAJ>
> <URL:https://groups.google.com/d/msg/web2py/OYy6pOMJzB0/ANFhQy93BAAJ>
>
> Sounds interesting, and things that Niphlod likes I would consider to have 
> a good recommendation.
>
> /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/d/optout.


[web2py] Re: GAE integration is MASSIVELY broken again (in multiple ways in multiple versions)

2016-09-13 Thread Niphlod
I absolutely love when the most used by big guys backend seems to fail for 
the most basic reasons...is someone really using web2py on GAE or it's just 
for show ?

On Tuesday, September 13, 2016 at 9:02:19 AM UTC+2, webm...@trytha.com 
wrote:
>
> First, sometime around the 2.13 or 2.14 change, the password reset feature 
> stopped working, as I detail here:  
> https://groups.google.com/forum/?pli=1#!topic/web2py/YndwuzoEypw
>
> And today I decided to try out the latest version (2.15.x based on 
> changelog) from Git to see if you all had maybe fixed it, but using a 
> completely fresh install from Git made it so my local GAE environment can't 
> even access the DB for some reason.  For reference, I was previously using 
> web2py version 2.14.6, which has a working DAL connection but the password 
> recovery doesn't work.  The associated DAL version is 16.03.  Here is the 
> error when trying to connect to the DB (app name and id are obfuscated):
>
> ERROR2016-09-13 06:31:57,189 restricted.py:171] Traceback (most recent 
> call last):
>
>   File "/home/www-data/web2py/gluon/restricted.py", line 220, in restricted
>
> exec(ccode, environment)
>
>   File "/home/www-data/web2py/applications//models/db.py", line 
> 73, in 
>
> db = DAL('google:sql://:live/', migrate=True) # 
> DEBUG REVIEW: Turn off after migrations.
>
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 170, 
> in __call__
>
> obj = super(MetaDAL, cls).__call__(*args, **kwargs)
>
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 475, 
> in __init__
>
> "Failure to connect, tried %d times:\n%s" % (attempts, tb)
>
> RuntimeError: Failure to connect, tried 5 times:
>
> Traceback (most recent call last):
>
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 455, 
> in __init__
>
> self._adapter = adapter(**kwargs)
>
>   File 
> "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 
> 40, in __call__
>
> obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
>
>   File 
> "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/google.py", line 
> 40, in __init__
>
> super(GoogleSQL, self).__init__(*args, **kwargs)
>
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 373, in __init__
>
> super(SQLAdapter, self).__init__(*args, **kwargs)
>
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 51, in __init__
>
> self._initialize_(do_connect)
>
>   File 
> "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/google.py", line 
> 49, in _initialize_
>
> super(MySQL, self)._initialize_(do_connect)
>
>   File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 64, in _initialize_
>
> self._find_work_folder()
>
>   File 
> "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/google.py", line 
> 44, in _find_work_folder
>
> super(GoogleSQL)._find_work_folder()
>
> AttributeError: 'super' object has no attribute '_find_work_folder'
>
>
> Version 2.12.2 has neither of these problems.  Please help!  I want to use 
> the latest versions!
>

-- 
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: JSON getting the series data into view

2016-09-13 Thread Niphlod
did you check if your js is working before blaming web2py ?

On Tuesday, September 13, 2016 at 3:46:52 AM UTC+2, Aydin wrote:
>
> The methods to get the data in the view of web2py does not seem working. I 
> used the method mentioned in 
> http://web2py.com/books/default/chapter/29/10/services which is
>
> 

[web2py] Re: as_list AttributeError: 'dict' object has no attribute 'myLabel'

2016-09-12 Thread Niphlod
as list returns a proper dictionary, not a list of Row objects. At this 
point, as_list() in your code is superflous. But if you want to use it, you 
then have to access "myLabel" as row['myLabel']

On Monday, September 12, 2016 at 10:11:46 AM UTC+2, Annet wrote:
>
> I have the following query:
>
> rows = 
> db(db.ntw_edge_label_set.vertexID==vertexID).select(db.ntw_edge_label_set.myLabel).as_list()
>
> which returns:
>
> [{'myLabel': 'NASM Personal Trainers'}, {'myLabel': 'Traineeship'}] 
>
> when I try:
>
> labelList = [row.myLabel for row in rows]
>
> I get the following error:
>
> File "/Users/iannet/web2py/applications/com/controllers/network.py" 
> , line 
> 270, in network_out
> labelList = [row.myLabel for row in rows]
> AttributeError: 'dict' object has no attribute 'myLabel'
>
>
> I don't see why this error occurs. What I want is:
>
> ['NASM Personal Trainers', 'Traineeship']
>
>
> Kind regards,
>
> Annet
>
>
>
>
>

-- 
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: why request.vars are added an additional key “records” with null value when I used the sqlform.grid?

2016-09-12 Thread Niphlod
it's to hold selected lines, I think. Anyway, you should use 
request.get_vars to get your data (since your method is "get"). Also, 
please note that the grid is coded in such a way that the grid is the sole 
"manager" of the request/response cycle, so fiddling in the same page with 
your own pieces of code may result in issues.

On Monday, September 12, 2016 at 8:37:13 AM UTC+2, Yibing Liu wrote:
>
>
> My web2py version is 2.14.6.
>
> I define a form in myview.html
>
>`
> 
> 
> 
> 
> ` 
>
>  In my default controler function 'index' I want to deal with the 
> request.vars passed from html.It works fine. Then I add a 
> form=SQLFORM.grid(query) to my function, I find that the request.vars are 
> added an additional key "records" with null value when the sqlform.grid() 
> line is executed. So I debug into the source code, I find the line 2479 in 
> sqlhtml.py is
>
> elif not request.vars.records: request.vars.records = []
>
> After the above line excuted my request.vars was added an additional 
> key "records" with null value. My questions are,
>
> 1.How can I prevent adding the "record" key to my request.vars?
>
> 2.What's the purpose of the code
>
> elif not request.vars.records: request.vars.records = []
>

-- 
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 task_id assigned to multiple workers

2016-09-08 Thread Niphlod
what driver are you using to connect to mssql ? and what are the properties 
of the database ? (sp_helpdb dbname).
seems rather strange that a box that handles "over 20k a second" can't 
stand the pressure of an additional 20 (without the "k").

On Tuesday, September 6, 2016 at 5:19:30 PM UTC+2, Jason Solack wrote:
>
> we're handing over 20k a second, the odd thing is if i move the scheduler 
> to mysql the deadlocks stop.  The mysql box is much lower specs and we only 
> use for internal stuff so i don't want that to be final solution.  As far 
> as load balancing i'm refering to our actualy webserver.  We load balance 
> on 3 machines, and each machine has 3 worker processes running on it.  it 
> seems that those web2py processes lock the table and cause deadlocks
>
> On Tuesday, August 30, 2016 at 3:37:41 PM UTC-4, Niphlod wrote:
>>
>> if 24cores 200+ GB RAM is the backend, how many transactions per second 
>> is that thing handling ? 
>> I saw lots of ultrabeefy servers that were poorly configured, hence did 
>> have poor performances, but it'd be criminal to blame on the product in 
>> that case (also, one the person who configured it). 
>>
>> I run 10 workers on 3 frontends backed by a single 2cpu 4GB RAM mssql 
>> backend and have no issue at all, so, network connectivity hiccups aside, 
>> sizing shouldn't be a problem. 
>> Since we're talking my territory here (I'm a DBA in real life), my 
>> backend doesn't sweat with 1k batchreq/sec.
>> To put theory into real data, 10 idle workers consume roughly 18 
>> batchreq/sec with the default heartbeat. And from 5 to 10 transactions/sec. 
>> That's less than 1% of "pressure".
>>
>> You're referring here and there "when we are load balancing the 
>> server"... are you talking about the server where workers live or the 
>> server that holds the database ?
>>
>> On Tuesday, August 30, 2016 at 6:03:56 PM UTC+2, Jason Solack wrote:
>>>
>>> the machine is plenty big (24 cores and over 200gb of RAM)... another 
>>> note, when we use mysql on a weaker machine the deadlocks go away, so i 
>>> feel that this must be something related to MSSQL. Also it only happens 
>>> when we are load balancing hte server.   
>>>
>>> we have it set up so each of the 3 machines is running 4 workers. they 
>>> all have the same group name, is that the proper way to configure on a load 
>>> balanced setup?
>>>
>>> On Tuesday, August 30, 2016 at 11:48:42 AM UTC-4, Niphlod wrote:
>>>>
>>>> when the backend has orrible performances :D
>>>> 12 workers with the default heartbeat are easily taken care by a dual 
>>>> core 4GB RAM backend (without anything beefy on top of that).
>>>>
>>>> On Tuesday, August 30, 2016 at 5:41:01 PM UTC+2, Jason Solack wrote:
>>>>>
>>>>> So after more investigation we are seeing that our load balanced 
>>>>> server with processes runnin on all three machines are causing a lot of 
>>>>> deadlocks in MSSQL. Have you seen that before?
>>>>>
>>>>> On Friday, August 19, 2016 at 2:40:35 AM UTC-4, Niphlod wrote:
>>>>>>
>>>>>> yep. your worker setup clearly can't stably be connected to your 
>>>>>> backend.
>>>>>>
>>>>>> On Thursday, August 18, 2016 at 7:41:38 PM UTC+2, Jason Solack wrote:
>>>>>>>
>>>>>>> so after some digging what i'm seeing is the sw.insert(...) is not 
>>>>>>> committing and the mybackedstatus is None, this happens 5 times and 
>>>>>>> then 
>>>>>>> the worker appears and almost instantly disappers.  There are no 
>>>>>>> errors.  i 
>>>>>>> tried manually doing a db.executesql but i'm having trouble getting 
>>>>>>> self.w_stats converted to something i can insert via sql.
>>>>>>>
>>>>>>> another things i'm noticing is my "distribution" in w_stats is 
>>>>>>> None...
>>>>>>>
>>>>>>> Any ideas as to why this is happening?
>>>>>>>
>>>>>>> On Thursday, August 18, 2016 at 12:21:26 PM UTC-4, Jason Solack 
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> doing that now, what i'm seeing is some problems here:
>>>>>>>>
>>>>>>>> # record heartbeat
>>>>>>>>   

[web2py] Re: queue_task :: trouble with quoted json strings for pvars and args

2016-09-08 Thread Niphlod
queue_task just does json.dumps(vars)

https://github.com/web2py/web2py/blob/master/gluon/scheduler.py#L1483

the field is defined as 'text'

https://github.com/web2py/web2py/blob/master/gluon/scheduler.py#L813

IMHO it's an issue with the oracle driver.

On Thursday, September 8, 2016 at 8:14:49 PM UTC+2, Dave S wrote:
>
>
>
> On Thursday, September 8, 2016 at 6:27:15 AM UTC-7, Erwn Ltmann wrote:
>>
>> Hi Dave,
>>
>> thx for your response. I'm sorry, but it doesn't helps me. My problem 
>> concerning the usage of scheduler_task queueing. The web2py scheduler 
>> transforms automatically the dictionary parameter 'pvars' into a string 
>> represented JSON in order to save this value as VARCHAR2(512) into the vars 
>> column of database (oracle) table scheduler_task. So far so good. But IMHO 
>> with unnecessary quotes at begin and end. The scheduler part of web2py 
>> tried to read scheduler records and fails because this (damn) extra quotes.
>>
>> E.
>>
>>
> I don't use Oracle and I don't have JSON arguments for tasks (yet), so I 
> can't tell you if the "problem" is with the queue_task() call or with the 
> Oracle driver.  Niphlod is the Scheduler authority, having done the rewrite 
> of it.  I'm not sure who our local Oracle expert is.
>
> Does the error occur when you access vars[0] from your task (launched by 
> the Scheduler?)  Or does it occur when the Scheduler is trying to start up 
> your task?  Also, *are you accessing the Scheduler tables directly?  I 
> don't think you should be doing that* ... for one thing, that's an 
> implementation detail that's not an official API and is subject to change.  
> And I don't think it's needed, as your launched task is passed the args.
>
> /dps
> (edited for m-fassis)
>
>
> On Thursday, September 8, 2016 at 4:01:37 AM UTC+2, Dave S wrote:
>>>
>>>
>>>
>>> On Wednesday, September 7, 2016 at 5:30:49 PM UTC-7, Erwn Ltmann wrote:
>>>>
>>>> Hi, 
>>>>
>>>> I'm used to create a new task for example: 
>>>>
>>>> scheduler.queue_task( 
>>>>   "a_task", 
>>>>   pvars = dict(csid=row.id, csname=row.name, action=row.action), 
>>>>   ... 
>>>> ) 
>>>>
>>>> In the past (version 2.10.1), everything was fine. Within the current 
>>>> version (2.14.6) I have some trouble. See this code for example: 
>>>>
>>>> for row in db(db.scheduler_task.group_name == "agents").select( 
>>>> db.scheduler_task.ALL): 
>>>>  ... 
>>>>  pvars = json.loads(row.vars) 
>>>>
>>>> ... will raise this exception: 
>>>>
>>>>   ... 
>>>>   File "/usr/local/lib/python2.7/json/decoder.py", line 384, in 
>>>> raw_decode 
>>>> raise ValueError("No JSON object could be decoded") 
>>>> ValueError: No JSON object could be decoded 
>>>>
>>>> The reason is a quoted string in column 'VARS' in table 
>>>> 'SCHEDULER_TASK' (no quotes in web2py's old version 2.10.1). 
>>>>
>>>> A new value for 'VARS' with quotes for example: 
>>>>
>>>> '{"action": "script", "csname": "list", "csid": 121}' 
>>>>
>>>> I can skip the quotes with a trick: 
>>>>
>>>> pvars = json.loads(row.vars[1:-1]) 
>>>>
>>>> But, it is not a general solution. The same problem appears for column 
>>>> 'ARGS' in scheduler.py when I process the tasks: 
>>>>
>>>>   File "/export/home/armadm/dev01/release/web2py/gluon/scheduler.py", 
>>>> line 311, in executor 
>>>> args = _decode_list(loads(task.args)) 
>>>>   File "/usr/local/lib/python2.7/json/__init__.py", line 338, in loads 
>>>> return _default_decoder.decode(s) 
>>>>   File "/usr/local/lib/python2.7/json/decoder.py", line 366, in decode 
>>>> obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 
>>>>   File "/usr/local/lib/python2.7/json/decoder.py", line 384, in 
>>>> raw_decode 
>>>> raise ValueError("No JSON object could be decoded") 
>>>> ValueError: No JSON object could be decoded 
>>>>
>>>> I use Oracle as database: 
>>>>
>>>> SQL> desc scheduler_task 
>>>>  Name  Null?Type 
>>>>  

[web2py] Re: app slow on pythonanywhere

2016-09-05 Thread Niphlod
I think I said it at least 5 times (and there's the book 
).
 
Each option has its own environment. And everything follows a logic.

A) migrate on DAL sets a default for migrate for all tables (i.e. migrate 
on table wins)
B) migrate_enabled=False on DAL sets migrate=False for all tables, EVEN for 
tables with migrate=True (i.e. migrate_enabled=False wins over migrate=True 
on tables)
C) fake_migrate on tables enables fake migrations for tables with 
migrate=True (i.e. migrate=False and fake_migrate=True doesn't enable fake 
migrations)
D) fake_migrate_all sets fake_migrate=True on all tables

that being said, usual rules apply. 
- In production, don't waste CPU on migrations. Either set migrate=False on 
all tables, or migrate=False on DAL, or don't explicitly define migrate for 
both DAL and table and set migrate_enabled=False as a failsafe.
- no need ever to fake_migrate, unless, in a development history with 
version 1-->2-->3 of a table, you migrated manually from 1 to 2 and want 
web2py to migrate automatically to 3 (meaning: to sync the version 2 of the 
model with the hand-made change on the backend you fake_migrate it, and 
then you can let web2py migrate from 2 to 3)  

If you come up with a different clean database, to let the app create all 
tables, you need to let tables migrate. It means that you need to:
- check that no table has explicit migrate=False
- set migrate=True on DAL (that overrides the default for each table)
- hit appadmin once
- re-disable migrations

If you come up with a new table (or a new column on an existing table):
- check that that table has explicit migrate=True
- leave migrate=False on DAL (that ovverrides the default for each table, 
minus the one you want to migrate)
- hit appadmin once
- remove the explicit migrate=True from the table

etc etc etc

On Monday, September 5, 2016 at 11:27:01 PM UTC+2, Ron Chatterjee wrote:
>
> migrate_enabled  = false
> migrate  = false
> fake_migrate = false
> fake_migrate_all = false
>
>
> These settings are only if we don't need to update the database and use 
> the current database. We can use these settings in the deploy mode. Am I 
> correct? In other words, if I delete the entire database and reinstall the 
> app, all these flags needs to be true. Isnt? What if in the case that we 
> have a new table and we want to keep rest of the database intact? sought of 
> in between.  
>
> On Monday, September 5, 2016 at 11:25:12 AM UTC-4, Scott Hunter wrote:
>>
>> I found the problem; migrations weren't being disabled because, while I 
>> had the correct settings in appconfig.ini, they were not being used 
>> properly in creating the db object.
>>
>> - Scott
>>
>> On Saturday, September 3, 2016 at 1:01:39 PM UTC-4, Scott Hunter wrote:
>>>
>>> I have an app which runs *much* slower than expected on pythonanywhere.
>>>
>>> I enabled the profiler, and one thing stood out: on pythonanywhere, the 
>>> function the most time was spent in, by far, is fcntl.flock from inside 
>>> portalocker while loading the models.  In fact, when run locally, 
>>> portalocker isn't even being called: it goes straight from save_dbt to 
>>> cPickle.dump.
>>>
>>> Is there some configuration specific to web2py that might address this, 
>>> or is it something I should take up w/ the people at PA?
>>>
>>> - Scott
>>>
>>

-- 
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: Deploy with postgresql

2016-09-05 Thread Niphlod
it's one of the two: either migrations are turned off, or are turned on and 
you have .table files in the databases/ folder (that tell web2py "hey, 
tables are already there!")

On Monday, September 5, 2016 at 11:04:42 PM UTC+2, Morganti wrote:
>
> Hi,
>
> I checked an the migrations are enabled! I dont know where is the problem. 
> I checked to try to create the tables directly in postgresql and it is 
> running normal. But, using web2py...
>
> Thanks
>
> Em segunda-feira, 5 de setembro de 2016 13:11:04 UTC-3, Niphlod escreveu:
>>
>> appadmin shows the tables you DEFINED in the model. 
>> If there aren't real table on the backend to "sustain" those models, you 
>> get the error. 
>> You need to let web2py create the tables in your fresh database (enable 
>> migrations, hit appadmin at least once, then disable migrations for 
>> production use).
>>
>>
>> On Monday, September 5, 2016 at 12:17:18 PM UTC+2, Morganti wrote:
>>>
>>> Hi!
>>>
>>> In appadmin the tables are there but, checking in pgadmin3 them aren´t 
>>> there. Looks like they were not being created. But, the database is created 
>>> and I am able to create tables directly in pgadmin even prompt from ubuntu.
>>>
>>> I reinstall everything and got the problem again. 
>>>
>>> Thank you very much!
>>> BR
>>>
>>>
>>> Em segunda-feira, 5 de setembro de 2016 04:33:49 UTC-3, Niphlod escreveu:
>>>>
>>>> seemingly no response was given to a simple "how many records are 
>>>> there". sure the tables have been created ?
>>>>
>>>> On Sunday, September 4, 2016 at 3:55:54 PM UTC+2, Morganti wrote:
>>>>>
>>>>> Hi people!
>>>>>
>>>>> I just almost in go-live. So, I tried to create a Postgresql database 
>>>>> and starting to configure some config tables for my appliacation, but I 
>>>>> had 
>>>>> the error below.
>>>>>
>>>>> Traceback (most recent call last):
>>>>>   File 
>>>>> "/home/andre/Dropbox/Projetos/web2py/applications/87k/controllers/appadmin.py",
>>>>>  line 249, in select
>>>>> nrows = db(query, ignore_common_filters=True).count()
>>>>>   File 
>>>>> "/home/andre/Dropbox/Projetos/web2py/gluon/packages/dal/pydal/objects.py",
>>>>>  line 2010, in count
>>>>> return db._adapter.count(self.query, distinct)
>>>>>   File 
>>>>> "/home/andre/Dropbox/Projetos/web2py/gluon/packages/dal/pydal/adapters/base.py",
>>>>>  line 1322, in count
>>>>> return self.cursor.fetchone()[0]
>>>>> IndexError: list index out of range
>>>>>
>>>>> Thanks
>>>>> Best regards
>>>>> André
>>>>>
>>>>>
>>>>>

-- 
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: File widget traduction

2016-09-05 Thread Niphlod
start with the basic: inspect the source code of the page. Then go back to 
how the widget is built. Then to the translations.

On Monday, September 5, 2016 at 9:28:25 PM UTC+2, Gael Princivalle wrote:
>
> I would like to cry. Now it's translated, but I don't know why.
>
>
> Il giorno lunedì 5 settembre 2016 18:08:52 UTC+2, Niphlod ha scritto:
>>
>> if your custom widget doesn't have T() it can't be translated. if your 
>> custom widget GETS translated, it's browser's fault. if you have T() but 
>> nothing in specific language file, how can web2py translate it ?
>>
>> On Saturday, September 3, 2016 at 11:07:06 AM UTC+2, Gael Princivalle 
>> wrote:
>>>
>>> Hello.
>>>
>>> I've add in a custom form this field:
>>> {{=form_event.custom.widget.cover_image}}
>>>
>>> Language still English.
>>> 'Browse...' and 'No file selected.' don't appear in it.py.
>>>
>>>
>>>
>>> Probably I have to add the T() to both text in this widget. How can I do 
>>> it?
>>>
>>> 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: Deploy with postgresql

2016-09-05 Thread Niphlod
appadmin shows the tables you DEFINED in the model. 
If there aren't real table on the backend to "sustain" those models, you 
get the error. 
You need to let web2py create the tables in your fresh database (enable 
migrations, hit appadmin at least once, then disable migrations for 
production use).


On Monday, September 5, 2016 at 12:17:18 PM UTC+2, Morganti wrote:
>
> Hi!
>
> In appadmin the tables are there but, checking in pgadmin3 them aren´t 
> there. Looks like they were not being created. But, the database is created 
> and I am able to create tables directly in pgadmin even prompt from ubuntu.
>
> I reinstall everything and got the problem again. 
>
> Thank you very much!
> BR
>
>
> Em segunda-feira, 5 de setembro de 2016 04:33:49 UTC-3, Niphlod escreveu:
>>
>> seemingly no response was given to a simple "how many records are there". 
>> sure the tables have been created ?
>>
>> On Sunday, September 4, 2016 at 3:55:54 PM UTC+2, Morganti wrote:
>>>
>>> Hi people!
>>>
>>> I just almost in go-live. So, I tried to create a Postgresql database 
>>> and starting to configure some config tables for my appliacation, but I had 
>>> the error below.
>>>
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/andre/Dropbox/Projetos/web2py/applications/87k/controllers/appadmin.py",
>>>  line 249, in select
>>> nrows = db(query, ignore_common_filters=True).count()
>>>   File 
>>> "/home/andre/Dropbox/Projetos/web2py/gluon/packages/dal/pydal/objects.py", 
>>> line 2010, in count
>>> return db._adapter.count(self.query, distinct)
>>>   File 
>>> "/home/andre/Dropbox/Projetos/web2py/gluon/packages/dal/pydal/adapters/base.py",
>>>  line 1322, in count
>>> return self.cursor.fetchone()[0]
>>> IndexError: list index out of range
>>>
>>> Thanks
>>> Best regards
>>> André
>>>
>>>
>>>

-- 
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: File widget traduction

2016-09-05 Thread Niphlod
if your custom widget doesn't have T() it can't be translated. if your 
custom widget GETS translated, it's browser's fault. if you have T() but 
nothing in specific language file, how can web2py translate it ?

On Saturday, September 3, 2016 at 11:07:06 AM UTC+2, Gael Princivalle wrote:
>
> Hello.
>
> I've add in a custom form this field:
> {{=form_event.custom.widget.cover_image}}
>
> Language still English.
> 'Browse...' and 'No file selected.' don't appear in it.py.
>
>
>
> Probably I have to add the T() to both text in this widget. How can I do 
> it?
>
> 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: Deploy with postgresql

2016-09-05 Thread Niphlod
seemingly no response was given to a simple "how many records are there". 
sure the tables have been created ?

On Sunday, September 4, 2016 at 3:55:54 PM UTC+2, Morganti wrote:
>
> Hi people!
>
> I just almost in go-live. So, I tried to create a Postgresql database and 
> starting to configure some config tables for my appliacation, but I had the 
> error below.
>
> Traceback (most recent call last):
>   File 
> "/home/andre/Dropbox/Projetos/web2py/applications/87k/controllers/appadmin.py",
>  line 249, in select
> nrows = db(query, ignore_common_filters=True).count()
>   File 
> "/home/andre/Dropbox/Projetos/web2py/gluon/packages/dal/pydal/objects.py", 
> line 2010, in count
> return db._adapter.count(self.query, distinct)
>   File 
> "/home/andre/Dropbox/Projetos/web2py/gluon/packages/dal/pydal/adapters/base.py",
>  line 1322, in count
> return self.cursor.fetchone()[0]
> IndexError: list index out of range
>
> Thanks
> Best regards
> André
>
>
>

-- 
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: profanity filter

2016-09-01 Thread Niphlod
definitely the way to go if you can, and I'd also add to learn about 
virtualenv as soon as you can.

for simple packages you may also place their source into site-packages on 
the web2py root dir (works even with the binaries)
Profanity doesn't depend on 3rd party packages, and the source code is in 
tar.gz with a standard structure... once you dig into it you end up in a 
folder containing setup.py. What you'd need to do is to copy the folder 
holding the source (that is the one at the same level of setup.py called 
"profanity") into site-packages (it's __init__.py should be in 
site-packages/profanity).

e.g. for profanity, the content of 
profanity-1.1.tar.gz/dist/profanity-1.1.tar/profanity-1.1/profanity/

should go into 

site-packages/profanity


On Thursday, September 1, 2016 at 6:24:42 PM UTC+2, Alex Glaros wrote:
>
> okay, I forgot have to use the web2py source distribution to install 
>

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


Re: [web2py] Cannot Create Table Named "Items" - Already Exists

2016-09-01 Thread Niphlod
items isn't a roblem for check_reserved.

On Thursday, September 1, 2016 at 10:14:47 PM UTC+2, Richard wrote:
>
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=reserved+word#Reserved-keywords
>
> Do you have it in your connection string?
>
> You should be notified that it a mysql reserved word...
>
> If not... Have you change database? New empty database sound like you 
> restart database from scratch... web2py keep track of migration of models 
> you have to migrate=false fake_migrate=true then back to migrate=true to 
> allow web2py to sync with the database...
>
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=fake_migrate#migrate--fake_migrate
>
> Richard
>
> On Thu, Sep 1, 2016 at 3:52 PM, Brian Boatright  > wrote:
>
>> Is "items" a keyword for Python or Web2py? I'm using mysql and having 
>> web2py models file define a new table named "items" but it gives me an 
>> error that says the table already exists. 
>>
>> If I change the name of the table to something like "items2" in the 
>> models.py file it works.
>>
>> The mysql database is empty of tables before this is run and I've 
>> confirmed there is no items table before it tries to run the models.py 
>> file. I can create a table manually named items so it isn't specific to 
>> MySQL database. 
>>
>> Thanks for any help. 
>>
>> -- 
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: [web2py] Best way to pre-populate a database on start-up

2016-08-31 Thread Niphlod
same deal, "different" organization. 
With an external script you can't call that function if not from an 
external process. 
Having it in a separated controller incurs in None performance-penalties 
(having it in a standard controller has None to a handful of ms penalty 
when that controller is hit for another function)... and you can offload 
the task, e.g., to the scheduler.

On Wednesday, August 31, 2016 at 2:33:15 PM UTC+2, Manuele wrote:
>
> Il 30/08/16 21:40, Niphlod ha scritto: 
> > +1 for Dave . 
> > 
> > with isempty() in a model you're executing a query for each and every 
> > request for absolutely NO REASON. 
>
> I usually create a script directory and put there scripts with commands 
> to be performed only once, such in the case of pre-populating or more in 
> general of application initialization with the sintax: 
>
> $ python web2py.py -S myapp -M -R applications/myapp/scripts/myscript.py 
>
> in case of model is not needed (and it's not the case of pre-population) 
> you can even not use the -M option. 
>
> Do you think it could be a good way to suggest? 
>
> Cheers 
>
>
> Manuele 
>
>

-- 
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: Locating Table Definitions in a Module

2016-08-31 Thread Niphlod
versus having them in the model ? imho it's not worth the effort. 
migrate=False, lazy_tables and conditional models SHOULD get you very far 
without this kind of complications.

On Wednesday, August 31, 2016 at 8:54:35 PM UTC+2, Scott Hunter wrote:
>
> Is there any benefit to putting the code to define the database tables in 
> a function that has been defined in a module, but gets called from a model, 
> performance-wise?
>
> - Scott Hunter
>

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


Re: [web2py] Best way to pre-populate a database on start-up

2016-08-30 Thread Niphlod
fabfile ATM is a show-off, and we can't put in there code related to an app 
which doesn't exist :P
We can't pin each and every thread a "useful" information is written, as I 
really don't see how 40 pinned threads will contribute to web2py's 
knowledge for - and especially - newbies.


IMHO at most it should land on the book (deployment chapter), which 
everyone is highly encouraged to contribute, and doesn't need any 
python-web2py superpower to do so.



On Tuesday, August 30, 2016 at 9:54:26 PM UTC+2, Richard wrote:
>
> To be added to the fabfile.py of web2py maybe?!
>
> On Tue, Aug 30, 2016 at 3:53 PM, Richard Vézina  > wrote:
>
>> Don't have privileges, but this is a good thread and should be marked as 
>> informative somehow...
>>
>> Richard
>>
>> On Tue, Aug 30, 2016 at 2:24 PM, Dave S > > wrote:
>>
>>>
>>>
>>> On Tuesday, August 30, 2016 at 6:58:43 AM UTC-7, Richard wrote:

 Seems alright do you have issue with this? I would put a blank line 
 between model definition and the "if isempty()".

 I production, once the system get initialize you should remove those 
 populating fixture to save execution time as the get execute at each 
 request.

 What could wizely do is put all the populating fixtures in a models 
 file or controller file function that you delete or comment out once you 
 populate you empty new database instance. Putting it in a function 
 controller file wouldn't requires you to delete them as you will never 
 call 
 this controller file later on and if can by mistake it will not do 
 anything. But depend of the size  fo the populated data set the call of a 
 function could lead to a time out from the web server which prevent 
 completion of populating data. So you have to evaluate if it has chance or 
 not to complete properly. You can split the populating process into a 
 couple of function call so yo don't reach time out.


>>> Or give the function a dummy argument 
>>> def func(dummy=True):
>>>...
>>>
>>>
>>>  and then invoke it with -S from the command line.  This parallels 
>>> Niphlod's advice for setting up the initial copy of a recurring task.  (The 
>>> dummy arg keeps the function from being exposed as a URL.)
>>>
>>> Good luck

 Richard


>>> /dps
>>>
>>>  
>>>


 On Tue, Aug 30, 2016 at 9:34 AM, Ben Lawrence  
 wrote:

> At the moment to pre-populate a database, I place this in the db.py 
> model file:
>
> db.define_table('color',
> Field('name','string'),
> Field('code','string'),
> format='%(name)s')
> if db(db.color).isempty():
> # create instance of table
> for k,v in 
> dict(lime="#00FF00",red="#FF",black="#00",orange="#FFA500",\
> blue="#FF", yellow="#00", fuchsia="#FF00FF", 
> aqua="#00",\
> maroon="#80", green="#008000", navy="#80", 
> olive="#808000",\
> purple="#800080", teal="#008080", gray="#808080", 
> silver="#C0C0C0").items():
> db.color.insert(name=k,code=v)
>
>
>
> I wonder if this is the best way to pre-populate a database?
>
> thanks,
> Ben
>
> -- 
> 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+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

 -- 
>>> 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+un...@googlegroups.com .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

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


Re: [web2py] Best way to pre-populate a database on start-up

2016-08-30 Thread Niphlod
+1 for Dave .

with isempty() in a model you're executing a query for each and every 
request for absolutely NO REASON.

This are activities that needs to be carried on on a post-deployment 
fire-only-when-needed scenario, and outside the web environment.

On Tuesday, August 30, 2016 at 8:24:53 PM UTC+2, Dave S wrote:
>
>
>
> On Tuesday, August 30, 2016 at 6:58:43 AM UTC-7, Richard wrote:
>>
>> Seems alright do you have issue with this? I would put a blank line 
>> between model definition and the "if isempty()".
>>
>> I production, once the system get initialize you should remove those 
>> populating fixture to save execution time as the get execute at each 
>> request.
>>
>> What could wizely do is put all the populating fixtures in a models file 
>> or controller file function that you delete or comment out once you 
>> populate you empty new database instance. Putting it in a function 
>> controller file wouldn't requires you to delete them as you will never call 
>> this controller file later on and if can by mistake it will not do 
>> anything. But depend of the size  fo the populated data set the call of a 
>> function could lead to a time out from the web server which prevent 
>> completion of populating data. So you have to evaluate if it has chance or 
>> not to complete properly. You can split the populating process into a 
>> couple of function call so yo don't reach time out.
>>
>>
> Or give the function a dummy argument 
> def func(dummy=True):
>...
>
>
>  and then invoke it with -S from the command line.  This parallels 
> Niphlod's advice for setting up the initial copy of a recurring task.  (The 
> dummy arg keeps the function from being exposed as a URL.)
>
> Good luck
>>
>> Richard
>>
>>
> /dps
>
>  
>
>>
>>
>> On Tue, Aug 30, 2016 at 9:34 AM, Ben Lawrence  wrote:
>>
>>> At the moment to pre-populate a database, I place this in the db.py 
>>> model file:
>>>
>>> db.define_table('color',
>>> Field('name','string'),
>>> Field('code','string'),
>>> format='%(name)s')
>>> if db(db.color).isempty():
>>> # create instance of table
>>> for k,v in 
>>> dict(lime="#00FF00",red="#FF",black="#00",orange="#FFA500",\
>>> blue="#FF", yellow="#00", fuchsia="#FF00FF", 
>>> aqua="#00",\
>>> maroon="#80", green="#008000", navy="#80", 
>>> olive="#808000",\
>>> purple="#800080", teal="#008080", gray="#808080", 
>>> silver="#C0C0C0").items():
>>> db.color.insert(name=k,code=v)
>>>
>>>
>>>
>>> I wonder if this is the best way to pre-populate a database?
>>>
>>> thanks,
>>> Ben
>>>
>>> -- 
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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 task_id assigned to multiple workers

2016-08-30 Thread Niphlod
if 24cores 200+ GB RAM is the backend, how many transactions per second is 
that thing handling ? 
I saw lots of ultrabeefy servers that were poorly configured, hence did 
have poor performances, but it'd be criminal to blame on the product in 
that case (also, one the person who configured it). 

I run 10 workers on 3 frontends backed by a single 2cpu 4GB RAM mssql 
backend and have no issue at all, so, network connectivity hiccups aside, 
sizing shouldn't be a problem. 
Since we're talking my territory here (I'm a DBA in real life), my backend 
doesn't sweat with 1k batchreq/sec.
To put theory into real data, 10 idle workers consume roughly 18 
batchreq/sec with the default heartbeat. And from 5 to 10 transactions/sec. 
That's less than 1% of "pressure".

You're referring here and there "when we are load balancing the server"... 
are you talking about the server where workers live or the server that 
holds the database ?

On Tuesday, August 30, 2016 at 6:03:56 PM UTC+2, Jason Solack wrote:
>
> the machine is plenty big (24 cores and over 200gb of RAM)... another 
> note, when we use mysql on a weaker machine the deadlocks go away, so i 
> feel that this must be something related to MSSQL. Also it only happens 
> when we are load balancing hte server.   
>
> we have it set up so each of the 3 machines is running 4 workers. they all 
> have the same group name, is that the proper way to configure on a load 
> balanced setup?
>
> On Tuesday, August 30, 2016 at 11:48:42 AM UTC-4, Niphlod wrote:
>>
>> when the backend has orrible performances :D
>> 12 workers with the default heartbeat are easily taken care by a dual 
>> core 4GB RAM backend (without anything beefy on top of that).
>>
>> On Tuesday, August 30, 2016 at 5:41:01 PM UTC+2, Jason Solack wrote:
>>>
>>> So after more investigation we are seeing that our load balanced server 
>>> with processes runnin on all three machines are causing a lot of deadlocks 
>>> in MSSQL. Have you seen that before?
>>>
>>> On Friday, August 19, 2016 at 2:40:35 AM UTC-4, Niphlod wrote:
>>>>
>>>> yep. your worker setup clearly can't stably be connected to your 
>>>> backend.
>>>>
>>>> On Thursday, August 18, 2016 at 7:41:38 PM UTC+2, Jason Solack wrote:
>>>>>
>>>>> so after some digging what i'm seeing is the sw.insert(...) is not 
>>>>> committing and the mybackedstatus is None, this happens 5 times and then 
>>>>> the worker appears and almost instantly disappers.  There are no errors.  
>>>>> i 
>>>>> tried manually doing a db.executesql but i'm having trouble getting 
>>>>> self.w_stats converted to something i can insert via sql.
>>>>>
>>>>> another things i'm noticing is my "distribution" in w_stats is None...
>>>>>
>>>>> Any ideas as to why this is happening?
>>>>>
>>>>> On Thursday, August 18, 2016 at 12:21:26 PM UTC-4, Jason Solack wrote:
>>>>>>
>>>>>> doing that now, what i'm seeing is some problems here:
>>>>>>
>>>>>> # record heartbeat
>>>>>>mybackedstatus = db(sw.worker_name == self
>>>>>> .worker_name).select().first()
>>>>>>if not mybackedstatus:
>>>>>>sw.insert(status=ACTIVE, worker_name=self.worker_name,
>>>>>>  first_heartbeat=now, last_heartbeat=now,
>>>>>>  group_names=self.group_names,
>>>>>>  worker_stats=self.w_stats)
>>>>>>self.w_stats.status = ACTIVE
>>>>>>self.w_stats.sleep = self.heartbeat
>>>>>>mybackedstatus = ACTIVE
>>>>>>
>>>>>> mybackedstatus is consistently coming back as "None" i'm guessing 
>>>>>> there is an error somewhere in that try block and the db commit is being 
>>>>>> rolled back
>>>>>>
>>>>>> i'm using MSSQL and nginx... currently upgrading web2py to see it 
>>>>>> continues
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thursday, August 18, 2016 at 10:44:28 AM UTC-4, Niphlod wrote:
>>>>>>>
>>>>>>> turn on workers debugging level and grep for errors.
>>>>>>>
>>>>>>> On Thursday, August 18, 2016 at 4:38:31 PM UTC+2, Jason Solack wrote:
>&g

[web2py] Re: scheduler task_id assigned to multiple workers

2016-08-30 Thread Niphlod
when the backend has orrible performances :D
12 workers with the default heartbeat are easily taken care by a dual core 
4GB RAM backend (without anything beefy on top of that).

On Tuesday, August 30, 2016 at 5:41:01 PM UTC+2, Jason Solack wrote:
>
> So after more investigation we are seeing that our load balanced server 
> with processes runnin on all three machines are causing a lot of deadlocks 
> in MSSQL. Have you seen that before?
>
> On Friday, August 19, 2016 at 2:40:35 AM UTC-4, Niphlod wrote:
>>
>> yep. your worker setup clearly can't stably be connected to your backend.
>>
>> On Thursday, August 18, 2016 at 7:41:38 PM UTC+2, Jason Solack wrote:
>>>
>>> so after some digging what i'm seeing is the sw.insert(...) is not 
>>> committing and the mybackedstatus is None, this happens 5 times and then 
>>> the worker appears and almost instantly disappers.  There are no errors.  i 
>>> tried manually doing a db.executesql but i'm having trouble getting 
>>> self.w_stats converted to something i can insert via sql.
>>>
>>> another things i'm noticing is my "distribution" in w_stats is None...
>>>
>>> Any ideas as to why this is happening?
>>>
>>> On Thursday, August 18, 2016 at 12:21:26 PM UTC-4, Jason Solack wrote:
>>>>
>>>> doing that now, what i'm seeing is some problems here:
>>>>
>>>> # record heartbeat
>>>>mybackedstatus = db(sw.worker_name == self
>>>> .worker_name).select().first()
>>>>if not mybackedstatus:
>>>>sw.insert(status=ACTIVE, worker_name=self.worker_name,
>>>>  first_heartbeat=now, last_heartbeat=now,
>>>>  group_names=self.group_names,
>>>>  worker_stats=self.w_stats)
>>>>self.w_stats.status = ACTIVE
>>>>self.w_stats.sleep = self.heartbeat
>>>>mybackedstatus = ACTIVE
>>>>
>>>> mybackedstatus is consistently coming back as "None" i'm guessing 
>>>> there is an error somewhere in that try block and the db commit is being 
>>>> rolled back
>>>>
>>>> i'm using MSSQL and nginx... currently upgrading web2py to see it 
>>>> continues
>>>>
>>>>
>>>>
>>>> On Thursday, August 18, 2016 at 10:44:28 AM UTC-4, Niphlod wrote:
>>>>>
>>>>> turn on workers debugging level and grep for errors.
>>>>>
>>>>> On Thursday, August 18, 2016 at 4:38:31 PM UTC+2, Jason Solack wrote:
>>>>>>
>>>>>> I think we have this scenario happening:
>>>>>>
>>>>>>
>>>>>> https://groups.google.com/forum/#%21searchin/web2py/task_id%7csort:relevance/web2py/AYH5IzCIEMo/hY6aNplbGX8J
>>>>>>
>>>>>> our workers seems to be restarting quickly and we're trying to figure 
>>>>>> out why
>>>>>>
>>>>>> On Thursday, August 18, 2016 at 3:55:55 AM UTC-4, Niphlod wrote:
>>>>>>>
>>>>>>> small recap...a single worker is tasked with assigning tasks 
>>>>>>> (the one with is_ticker=True) and then that task is picked up only by 
>>>>>>> the 
>>>>>>> assigned worker (you can see it on the 
>>>>>>> scheduler_task.assigned_worker_name 
>>>>>>> column of the task). 
>>>>>>> There's no way the same task (i.e. a scheduler_task "row") is 
>>>>>>> executed while it is RUNNING (i.e. processed by some worker).
>>>>>>> The process running the task is stored also in 
>>>>>>> scheduler_run.worker_name.
>>>>>>>
>>>>>>> <tl;dr> you shouldn't EVER have scheduler_run records with the same 
>>>>>>> task_id and 12 different worker_name all in the RUNNING status.
>>>>>>>
>>>>>>> For a single task to be processed by ALL 12 workers at the same 
>>>>>>> time... is quite impossible, if everything is running smoothly. And 
>>>>>>> frankly 
>>>>>>> I can't fathom any scenario in which it is possible.
>>>>>>>
>>>>>>>
>>>>>>> On Wednesday, August 17, 2016 at 6:25:41 PM UTC+2, Jason Solack 
>>>>>>> wrote:
>

[web2py] Re: TAG helper and unnamed argument

2016-08-29 Thread Niphlod
whoops, forget what I said. Apparently any attribute without a specific 
value is syntactically equivalent to "".
So, @Kirill, there's no way but ending up with _pubdate='' will give you a 
syntactically equivalent markup.

Unless I'm reading w3c spec wrong, in that case feel free to correct me.

On Monday, August 29, 2016 at 11:37:53 PM UTC+2, Niphlod wrote:
>
> ATM "False" or "None" don't have the corresponding attribute inserted. 
> There's no way to generate an attribute without value.
>
> BTW: that is definitely not a good example as it's not HTML5 valid syntax. 
> A better one could have been 
>
> http://n.example.org/rfc4287;>
>hi
> 
>
>
> @mdipierro: any thoughts about this ? If I'm not mistaken, the offending 
> line is from #L936 
> <https://github.com/web2py/web2py/blob/master/gluon/html.py#L936> to #L947 
> <https://github.com/web2py/web2py/blob/master/gluon/html.py#L947> ... 
> maybe _pubdate=None should result in an empty attribute ?
> BTW2: the referenced page <http://www.web2py.com/init/default/examples>with 
> the new style is a pain to read.
>
> On Monday, August 29, 2016 at 9:44:59 PM UTC+2, Kirill Shatalaev wrote:
>>
>>
>> So, how to do some like:
>>
>> 1 day ago
>>
>>
>> I tried:
>>
>>
>> TAG.time('1 day ago', _pubdate=True,
>>  _datetime=str(datetime.year) + '-' + '%02d' % datetime.month + '-' + '%02d' 
>> % datetime.day)
>>
>>
>> And got:
>>
>>
>> 1 day ago
>>
>>
>> Here I can read:
>>
>> http://www.web2py.com/init/default/examples
>>
>>
>> "attributes without value like "READONLY" can be created with the argument 
>> "_readonly=ON"."
>>
>>
>> But not _pubdate=True, nor _pubdate=ON (wich is deprecated and just an alias 
>> for True according to chapter 5) does not work for me and generates 
>> pubdate="pubdate".
>>
>>
>>
>>
>>
>>
>>

-- 
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: TAG helper and unnamed argument

2016-08-29 Thread Niphlod
ATM "False" or "None" don't have the corresponding attribute inserted. 
There's no way to generate an attribute without value.

BTW: that is definitely not a good example as it's not HTML5 valid syntax. 
A better one could have been 

http://n.example.org/rfc4287;>
   hi



@mdipierro: any thoughts about this ? If I'm not mistaken, the offending 
line is https://github.com/web2py/web2py/blob/master/gluon/html.py#L936
BTW2: the referenced page with 
the new style is a pain to read.

On Monday, August 29, 2016 at 9:44:59 PM UTC+2, Kirill Shatalaev wrote:
>
>
> So, how to do some like:
>
> 1 day ago
>
>
> I tried:
>
>
> TAG.time('1 day ago', _pubdate=True,
>  _datetime=str(datetime.year) + '-' + '%02d' % datetime.month + '-' + '%02d' 
> % datetime.day)
>
>
> And got:
>
>
> 1 day ago
>
>
> Here I can read:
>
> http://www.web2py.com/init/default/examples
>
>
> "attributes without value like "READONLY" can be created with the argument 
> "_readonly=ON"."
>
>
> But not _pubdate=True, nor _pubdate=ON (wich is deprecated and just an alias 
> for True according to chapter 5) does not work for me and generates 
> pubdate="pubdate".
>
>
>
>
>
>
>

-- 
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: Help with Patterns

2016-08-29 Thread Niphlod
are you talking about a general idea for the api ? I'd use 'all' ...

On Monday, August 29, 2016 at 2:41:16 AM UTC+2, Diego Marinho wrote:
>
> I have this pattern:
>
>
> "/jobs/year-start/{jobs.year_start.year}/amount-range-id/{jobs.amount_range_id}/neighbourhood-id/{jobs.neighbourhood_id}"
>
> I have tree fields that im using to filter the 'jobs' table. How can i 
> make those filters optional? 
>
> Let's say i want to use only two of the tree possible filters. What can i 
> send instead of the id to say that i want all data concerning that field?  
>

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


Re: [web2py] Re: I am trying to login from Phonegap app into my web2py app, what's wrong here?

2016-08-29 Thread Niphlod
technically though USERNAME is clear. so you need to query for username and 
just match the password with the crypted value.

On Monday, August 29, 2016 at 3:05:20 AM UTC+2, Massimo Di Pierro wrote:
>
> This cannot be done. It is a feature not a bug. The purpose of the salt in 
> the hashed password is to prevent brute force attacks to the database. What 
> you are doing is the brute force attack.
>
> The only way to do it is to select all records. Loop one by one and 
> compare them with 
>
> encpwd = 
> CRYPT(digest_alg='pbkdf2(1000,20,sha512)')(request.vars.password)[0])
> for row in db(..).select(): 
> if row.password == encpwd: 
>
> I guess this is a ever more brute force attack It will be slow but may 
> work on small databases.
>
>
>
>
> On Sunday, 28 August 2016 08:39:06 UTC-5, Steve Joe wrote:
>>
>> db((db.auth_user.username == request.vars.username) & 
>> (db.auth_user.password == 
>> CRYPT(digest_alg='pbkdf2(1000,20,sha512)')(request.vars.password)[0])).select()
>> this doesn't work at all too.
>>
>> On Saturday, August 27, 2016 at 5:44:53 PM UTC+5:30, Kiran Subbaraman 
>> wrote:
>>>
>>> The book can help you: 
>>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Logical-operators
>>> You need to use the right operator in your query
>>> You can also use the web2py debugger to figure out how your code works 
>>> and values returned, at runtime.
>>>
>>> 
>>> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>>>
>>> On Sat, 27-08-2016 2:50 PM, Steve Joe wrote:
>>>
>>> Anyone there? Anthony?
>>>
>>> On Friday, August 26, 2016 at 7:38:40 PM UTC+5:30, Steve Joe wrote: 
>>>>
>>>> *db(db.auth_user.username == request.vars.username and 
>>>> db.auth_user.password == CRYPT(request.vars.password)).select()*
>>>>
>>>>
>>>> *if db(db.auth_user.username == request.vars.username and 
>>>> db.auth_user.password == 
>>>> CRYPT(digest_alg='md5')(request.vars.password)[0]).select(): * 
>>>>
>>>> Both of them don't work either. 
>>>>
>>>> On Friday, August 26, 2016 at 7:30:41 PM UTC+5:30, Niphlod wrote: 
>>>>>
>>>>> fortunately the password doesn't get stored in plain text on web2py :D 
>>>>> You need to apply CRYPT() before comparing. Read more about that on the 
>>>>> book.
>>>>>
>>>>> On Friday, August 26, 2016 at 3:31:54 PM UTC+2, Steve Joe wrote: 
>>>>>>
>>>>>> IN PHONEGAP: 
>>>>>>
>>>>>> https://#someurl#.
>>>>>> pythonanywhere.com/welcome/phonegap/login">
>>>>>>   username:
>>>>>>   
>>>>>>   
>>>>>>   Password:
>>>>>>   
>>>>>>   
>>>>>>   
>>>>>> 
>>>>>>
>>>>>>
>>>>>> IN WEB2PY:
>>>>>>
>>>>>> def login():
>>>>>> k="false"
>>>>>> if db(db.auth_user.username == request.vars.username and 
>>>>>> db.auth_user.password == request.vars.password).select():
>>>>>> k="true"
>>>>>> return locals()
>>>>>>
>>>>>> and in view I can see:
>>>>>>
>>>>>>  false 
>>>>>> which means I got k as false.
>>>>>>
>>>>>> The username and pasword are correct according to my database but I 
>>>>>> can't login. What should I do?
>>>>>>
>>>>> -- 
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>

-- 
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: I am trying to login from Phonegap app into my web2py app, what's wrong here?

2016-08-26 Thread Niphlod
fortunately the password doesn't get stored in plain text on web2py :D You 
need to apply CRYPT() before comparing. Read more about that on the book.

On Friday, August 26, 2016 at 3:31:54 PM UTC+2, Steve Joe wrote:
>
> IN PHONEGAP:
>
> https://#someurl#.pythonanywhere.com/welcome/phonegap/login
> ">
>   username:
>   
>   
>   Password:
>   
>   
>   
> 
>
>
> IN WEB2PY:
>
> def login():
> k="false"
> if db(db.auth_user.username == request.vars.username and 
> db.auth_user.password == request.vars.password).select():
> k="true"
> return locals()
>
> and in view I can see:
>
>  false 
> which means I got k as false.
>
> The username and pasword are correct according to my database but I can't 
> login. What should I do?
>

-- 
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: Getting only the latest "version" in a query of items with versions.

2016-08-25 Thread Niphlod
you're thinking with a human mind instead of thinking on how a database 
works... with sets of data.

How can you ask a database to return a single set grouped by something and 
at the same time as for granular records??? 
When you use groupby, you can just ask for granular records of the columns 
you grouped for AND aggregates on every other (min, max, count, sum, avg, 
count distinct, etc).

id--name--variety
1--apple--fruit
2--pear--fruit
3--salad--vegetable
4--spinach--vegetable
5--spinach--vegetable

Let's answer "Please, tell me how many varieties I hold"... 
Two. You can have 2 lines back if you group by variety. No more, no less.
"Ok, database, tell me how many of each variety I have"
Always two lines, no more, no less. In addition to variety, you ask for the 
count of each.

count--variety
2--fruit
3--vegetable

"Ok, database, tell me how many names there are for each variety"
Always two lines. In addition, you ask for the count distinct of fruits

count distinct--variety
2--fruit
2--vegetable

In set theory, THERE'S no way to ask for the id of the original row if 
you're grouping by something.

However, you can nest queries (or use windowing functions, that ATM aren't 
in pydal) to first ask the database to group, and then select a record that 
matches the grouped property plus the aggregate you chose, like "the row in 
the group that has that variety and has the last id (which is max())".

the first set would be
max(id)--variety
2--fruit
5--vegetable

and the second a join to the original, returning 

2--pear--fruit
5--spinach--vegetable

so you can have the latest version_date for each item_id (which 
correspond to max(version_date) for each group), but you can't ask for 
anything more which isn't an aggregate, like the item name, in a single 
shot. At least without resorting to more complicated queries.

On Thursday, August 25, 2016 at 7:52:23 AM UTC+2, Encompass solutions wrote:
>
> I suppose your right, but I was a little thrown, by the:
> max(variable_here)
> That was mentioned was not the solution at all, I kept looking for ways to 
> use max as a function.
> My issue now, is that the group by doesn't like me getting all the tables 
> I want in the return.
> BR,
> Jason Brower
>
> On Thursday, August 25, 2016 at 8:36:58 AM UTC+3, Dave S wrote:
>>
>>
>>
>> On Wednesday, August 24, 2016 at 10:29:09 PM UTC-7, Encompass solutions 
>> wrote:
>>>
>>> Does this seem sensible?  It seems to work with my initial tests.
>>>
>>> latest_versions = db(  (db.item.id == db.item_version.artifact_id) &
>>> (db.item_version.id > 0)
>>> 
>>> ).select(db.item.ALL,db.item_version.version_date.max(), groupby=
>>> db.item.id)
>>>
>>> the .max() feature, at least what I found, was totally undocumented.
>>>
>>
>> Totally?
>> You mean, there isn't 
>>
>> > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len
>> >
>>
>> ?
>>
>> We should have an example database as part of the documentation with a 
>>> collection of examples around it so we can all relate better. :/
>>>
>>>
>> Examples in book, using it on severity of logged events.
>>
>> /dps
>>  
>>
>>> On Monday, August 22, 2016 at 10:52:55 AM UTC+3, Encompass solutions 
>>> wrote:

 Consider the following pseudo model.

 item
  ->name = "string"

 version
  ->item_id =  item.id
  ->version_date = "datetime"


 While I can easily create a collection of the item with it's versions.
 all_items = db((db.item.id > 0) & (db.version.item_id == db.item.id
 )).select(orderby=db.item.name | db.version.version_date)

 How do get just all items with just the latest version of each item 
 without having to do this
 items = []
 current_id = all_items.first().item.id 
 for thing in all_items:
 if thing.item.id != current_id:
 current_id = thing.item.id
 items.append(thing)

 It seems a bit silly and heavy to be doing this especially since my 
 data could get quite large.  I imaging the database has some way to do 
 this, just never learned how.

 Ideas on how this could be done?

 BR,
 Jason Brower



-- 
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: uploads of large files

2016-08-25 Thread Niphlod
You can't offload the upload to a task in a separate process: there would 
be no socket to munge the data in :D
Use modern js solutions to return information to the user for multiple 
uploads and a custom action and use a real webserver in front of web2py 
(read: nginx) that will buffer the input before passing it to web2py.

On Thursday, August 25, 2016 at 12:51:04 PM UTC+2, Mirek Zvolský wrote:
>
> I heard much about timeout of web request (like 60s) and about the need to 
> use scheduler if the action is slow.
> But I'am not sure about large file uploads.
>
> Is the file send to the server during http request or when I ask .read() 
> (or .value) in the controller? Should I take care about time of the action?
> And: how to give info to the user about the running upload?
>
> 1)
> What if I use standard Web2py upload fields in forms?
>
> 2)
> What if I use ?
> I think there is no built in support for this in Web2py, so I have this in 
> view and handle it in the controller so:
> if request.vars.fldname:
>   for f in request.vars.fldname:
> fn = f.filename.lower()
> with open(os.path.join(uploadfolder, fn), 'w') as fw:
>   fw.write(f.value)
>

-- 
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: ProgrammingError: column "worker_stats__tmp" is of type json but expression is of type text

2016-08-25 Thread Niphlod
if you get any error with __tmp is because you didn't drop tables on the 
backend AND .table files before hitting the app with migrate=True.

On Thursday, August 25, 2016 at 6:53:07 PM UTC+2, Ben Lawrence wrote:
>
> Hi Niphlod,
> I deleted all the scheduler tables , created a new database and then 
> rebooted with DAL(..migrate=True..) yet still get this error
> column "worker_stats__tmp" is of type json but expression is of type text'
>
> using postgresql 9.4 on raspberry pi.
> In 
> http://stackoverflow.com/questions/32501027/casting-text-type-column-to-json-type-in-postgresql
> there is a mention of recasting. If this is a solution, would you know how 
> I can incorporate this into web2py?
> thanks,
> Ben
>
>
> On Wednesday, May 27, 2015 at 12:53:40 PM UTC-7, Niphlod wrote:
>>
>> Please drop the scheduler_worker table from the database and remove the 
>> file *_scheduler_worker.table from the databases/ folder of your 
>> application, then set migrate to True (a single request with migrate=True 
>> will suffice). The table will be recreated properly and the error will go 
>> away.
>>
>> The error comes from the fact that the adapter chooses "at connection 
>> time" the "nicest" column type to play with based on the backend version. 
>> The definition of the scheduler_worker table has a "json" Field, that on 
>> postgresql 9.3 maps to a "json" column, while on 9.1 was a "text" column, 
>> hence the misbehaviour if you don't drop and re-create the table.
>>
>>

-- 
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: Getting only the latest "version" in a query of items with versions.

2016-08-23 Thread Niphlod
what you want is the latest version for each item_id . That is the row 
having the greatest version_date if you divide your dataset for each 
item_id.

that is what groupby item_id does. and what max(version_date) does too.

On Tuesday, August 23, 2016 at 11:05:52 AM UTC+2, Encompass solutions wrote:
>
> This document doesn't mention your method or using max()
>
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum-avg-min-max-and-len
>
> Or I don't understand how you would do it.
> Could you provide greater detail on how to build that query?
> BR,
> Jason
>
> On Monday, August 22, 2016 at 10:52:55 AM UTC+3, Encompass solutions wrote:
>>
>> Consider the following pseudo model.
>>
>> item
>>  ->name = "string"
>>
>> version
>>  ->item_id =  item.id
>>  ->version_date = "datetime"
>>
>>
>> While I can easily create a collection of the item with it's versions.
>> all_items = db((db.item.id > 0) & (db.version.item_id == db.item.id
>> )).select(orderby=db.item.name | db.version.version_date)
>>
>> How do get just all items with just the latest version of each item 
>> without having to do this
>> items = []
>> current_id = all_items.first().item.id 
>> for thing in all_items:
>> if thing.item.id != current_id:
>> current_id = thing.item.id
>> items.append(thing)
>>
>> It seems a bit silly and heavy to be doing this especially since my data 
>> could get quite large.  I imaging the database has some way to do this, 
>> just never learned how.
>>
>> Ideas on how this could be done?
>>
>> BR,
>> Jason Brower
>>
>>

-- 
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 make repository on github for windows users?

2016-08-23 Thread Niphlod
you download git for windows and do the same exact thing as in linux

On Tuesday, August 23, 2016 at 6:02:17 AM UTC+2, Dmitri Ermolaev wrote:
>
> What steeps?

-- 
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: Limit string length in DAL

2016-08-22 Thread Niphlod
to my knowledge, the general rule for validators is that if you have 
multiple requirements, you should pass a list.
That being said, the are "special" validator, like IS_EMPTY_OR, that take a 
validator as an argument.

Goes without saying (it quite translates well), that 
IS_EMPTY_OR(IS_LENGTH(8)) EITHER accepts nothing or a string shorter than 8 
chars.
Now, the "deal". How would you consider a field in a form that is not 
filled ? None or '' ?

IS_NOT_EMPTY() prevents an empty input.

it's not clear what you want, but I guess something got cleared with my 
previous comments.
Also, validators ONLY apply when you use them: forms, 
validate_and_insert(), validate_and_update(), etc. Using validators only is 
perfectly fine if you let the app validate each and every input.
length=123 enforces the underlying column to be of that length, but if you 
want meaningful errors, you need to use validators anyways.  

On Monday, August 22, 2016 at 5:54:29 PM UTC+2, Ron Chatterjee wrote:
>
> In other words, if I do this: 
>
> IS_EMPTY_OR(IS_LENGTH(8))
>
> It prevents longer length string but the empty field is inserted as None. 
> I want to prevent both.
>
>
> On Monday, August 22, 2016 at 10:54:08 AM UTC-4, Ron Chatterjee wrote:
>>
>> Two question, if you don't mind.
>>
>> (1) requires = IS_NOT_EMPTY(IS_LENGTH(64)) Or requires = 
>> IS_EMPTY_OR(IS_LENGTH(64)) Doesn't work. In other words, if I want to limit 
>> the string field entry but also want requires not empty, how to go about it?
>>
>> (2) for my sql, do I still need length = 64 (or 255 etc)? Its redundant 
>> when I define IS_LENGTH(64) or do I need both?
>>
>>
>>
>>
>> On Monday, August 22, 2016 at 7:49:42 AM UTC-4, Niphlod wrote:
>>>
>>> requires=IS_LENGTH(64) will limit insertion upon validation. the 
>>> "length" attribute gets translated, wherever possibile, to backend-specific 
>>> syntaxes.
>>>
>>> On Sunday, August 21, 2016 at 4:21:22 AM UTC+2, billy...@gmail.com 
>>> wrote:
>>>>
>>>> How we limit string length in DAL? It seems length = 64 doesn't work. 
>>>>
>>>

-- 
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 invoke recurring Scheduler task

2016-08-22 Thread Niphlod
"""What I am not clear on is the best way to invoke this code so that only 
one copy of the task is created"""

if you need what you asked, that is the way to do it. You asked for a piece 
of code that ensures a task is queued but only that one.
My solution to the "problem" is having a piece of code that does that, but 
it doesn't do at each and every request.

if you put anywhere in a controller something like

def this_queues_the_task(a=None):
   code that checks if it's already there and in case it queues it 
(or it alerts you, or whatever)

you will be sure that nobody can use it when hitting , e.g., 
/app/controller/this_queues_the_task because it is "protected" by an 
argument (web2py exposes only functions without args or kwargs) but you 
can call it from the shell

web2py.py -M -S app/controller/this_queues_the_task

without issues. You can then use that call whenever you want, from wherever 
you want, and live happily knowing that your task is there.


Summing up, the real deal is that there's no way to monitor something you 
don't trust without having something that monitors it that you trust.
Choose whatever tool (or person) and method (or procedure) you like, but 
there's really no way around it.

On Monday, August 22, 2016 at 2:13:03 PM UTC+2, Scott Hunter wrote:
>
> What is a "protected controller"?  It sounds like I need a recurring task 
> to monitor my recurring task ("recurring tasks all the way down").
>
> - Scott
>
> On Monday, August 22, 2016 at 7:47:07 AM UTC-4, Niphlod wrote:
>>
>> just queue the task in a protected controller that checks before 
>> inserting if another instance has been already queued and call that 
>> protected controller once in a while (i.e. once per day)
>>
>> On Monday, August 22, 2016 at 3:10:44 AM UTC+2, Scott Hunter wrote:
>>>
>>> The book seems pretty clear about the call to use to start a recurring 
>>> task.  
>>>
>>> What I am not clear on is the best way to invoke this code so that only 
>>> one copy of the task is created (assuming the scheduler machinery will 
>>> handle making sure that it keeps recurring).
>>>
>>> - Scott
>>>
>>

-- 
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 recreate Scheduler tables?

2016-08-22 Thread Niphlod
mysched = Scheduler(., migrate=True)

On Monday, August 22, 2016 at 3:17:24 PM UTC+2, Tito Garrido wrote:
>
> I have upgraded from 2.5.1 to the latest version but seems that the 
> scheduler tables had changed... I have dropped the old ones and now I am 
> trying to set web2py to recreate it.
>
> If I try to enable migrate it complains about some tables that already 
> exists... how to circunvent the tables that are already created and create 
> just scheduler tables?
>
> Regards,
>
> Tito
>
> -- 
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>

-- 
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: Limit string length in DAL

2016-08-22 Thread Niphlod
requires=IS_LENGTH(64) will limit insertion upon validation. the "length" 
attribute gets translated, wherever possibile, to backend-specific syntaxes.

On Sunday, August 21, 2016 at 4:21:22 AM UTC+2, billy...@gmail.com wrote:
>
> How we limit string length in DAL? It seems length = 64 doesn't work. 
>

-- 
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 invoke recurring Scheduler task

2016-08-22 Thread Niphlod
just queue the task in a protected controller that checks before inserting 
if another instance has been already queued and call that protected 
controller once in a while (i.e. once per day)

On Monday, August 22, 2016 at 3:10:44 AM UTC+2, Scott Hunter wrote:
>
> The book seems pretty clear about the call to use to start a recurring 
> task.  
>
> What I am not clear on is the best way to invoke this code so that only 
> one copy of the task is created (assuming the scheduler machinery will 
> handle making sure that it keeps recurring).
>
> - Scott
>

-- 
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: Getting only the latest "version" in a query of items with versions.

2016-08-22 Thread Niphlod
max(version_date) . group by item.id 

On Monday, August 22, 2016 at 9:52:55 AM UTC+2, Encompass solutions wrote:
>
> Consider the following pseudo model.
>
> item
>  ->name = "string"
>
> version
>  ->item_id =  item.id
>  ->version_date = "datetime"
>
>
> While I can easily create a collection of the item with it's versions.
> all_items = db((db.item.id > 0) & (db.version.item_id == db.item.id
> )).select(orderby=db.item.name | db.version.version_date)
>
> How do get just all items with just the latest version of each item 
> without having to do this
> items = []
> current_id = all_items.first().item.id 
> for thing in all_items:
> if thing.item.id != current_id:
> current_id = thing.item.id
> items.append(thing)
>
> It seems a bit silly and heavy to be doing this especially since my data 
> could get quite large.  I imaging the database has some way to do this, 
> just never learned how.
>
> Ideas on how this could be done?
>
> BR,
> Jason Brower
>
>

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


Re: [web2py] LDAP authentication and user creation

2016-08-22 Thread Niphlod
see the source and adapt to your likings: web2py is not going to become an 
LDAP inventory automatically...studying LDAP is not bad per se: you'll find 
its query syntax pretty much in every 3rd party tool that integrates with 
LDAP for some kind of reason.

On Friday, August 19, 2016 at 4:23:14 PM UTC+2, Marvix wrote:
>
> Hello to all. 
> I tried LDAP authentication and all work flawless. 
>
> As an user logs in, the relative user entry is created in the web2py user 
> table. That's great.
>
> But sometimes it would be usefull to have the user in the table before his 
> first login. 
>
> So, would be great for some user, says an administrator, to have a form 
> where he can insert the username of a generic user, web2py checks if the 
> user exists in the LDAP server and then add him in the web2py table.
>
> is there a way?
>
> I'm creating a sort of inventory application for our company.  So I would 
> like, for the administrator of the inventory, to associate a good to a 
> collegue that maybe hasn't yet logged in the system.
>
> Thanks, Marvi
>
>
>
>

-- 
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 does web2py save JSON fields?

2016-08-19 Thread Niphlod
why don't you just pass request.vars without quoting and unquoting 
anyway, json is always utf-8 encoded. that's the difference you're seeing.

On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:
>
> Hi,im starting a new post because i found that JSON fields change data as 
> they are saved.
> So repeating again the problem posted before
>
>
> My model
> db.define_table('responses',
> Field('f1'),
> Field('allresponses','json'))
>
> My controller
> def getit():
> ret={}
> for x in request.vars:
>db.responses.insert(f1=urllib.unquote(x))
>ret[urllib.unquote(x)]=request.vars[x];
> db.responses.insert(allresponses=ret)
>
> i get in my request.vars
>
> {'Timestamp': '8/19/2016 9:54:44', 
> 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade': 'sss'}
>
> after executing the controller code,when i look at  table responses i see 
> in allresponses field
> {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00 
> \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}
>
> but field f1 is correct
> "Sistema de Gestão de Qualidade"
>
> So how can i deal with this?
> This is just a test but i will get many keys in request vars and so a json 
> field would be better but need to solve this issue.
>
> Regards
> António
>
>

-- 
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 task_id assigned to multiple workers

2016-08-19 Thread Niphlod
yep. your worker setup clearly can't stably be connected to your backend.

On Thursday, August 18, 2016 at 7:41:38 PM UTC+2, Jason Solack wrote:
>
> so after some digging what i'm seeing is the sw.insert(...) is not 
> committing and the mybackedstatus is None, this happens 5 times and then 
> the worker appears and almost instantly disappers.  There are no errors.  i 
> tried manually doing a db.executesql but i'm having trouble getting 
> self.w_stats converted to something i can insert via sql.
>
> another things i'm noticing is my "distribution" in w_stats is None...
>
> Any ideas as to why this is happening?
>
> On Thursday, August 18, 2016 at 12:21:26 PM UTC-4, Jason Solack wrote:
>>
>> doing that now, what i'm seeing is some problems here:
>>
>> # record heartbeat
>>mybackedstatus = db(sw.worker_name == self
>> .worker_name).select().first()
>>if not mybackedstatus:
>>sw.insert(status=ACTIVE, worker_name=self.worker_name,
>>  first_heartbeat=now, last_heartbeat=now,
>>  group_names=self.group_names,
>>  worker_stats=self.w_stats)
>>self.w_stats.status = ACTIVE
>>self.w_stats.sleep = self.heartbeat
>>mybackedstatus = ACTIVE
>>
>> mybackedstatus is consistently coming back as "None" i'm guessing there 
>> is an error somewhere in that try block and the db commit is being rolled 
>> back
>>
>> i'm using MSSQL and nginx... currently upgrading web2py to see it 
>> continues
>>
>>
>>
>> On Thursday, August 18, 2016 at 10:44:28 AM UTC-4, Niphlod wrote:
>>>
>>> turn on workers debugging level and grep for errors.
>>>
>>> On Thursday, August 18, 2016 at 4:38:31 PM UTC+2, Jason Solack wrote:
>>>>
>>>> I think we have this scenario happening:
>>>>
>>>>
>>>> https://groups.google.com/forum/#%21searchin/web2py/task_id%7csort:relevance/web2py/AYH5IzCIEMo/hY6aNplbGX8J
>>>>
>>>> our workers seems to be restarting quickly and we're trying to figure 
>>>> out why
>>>>
>>>> On Thursday, August 18, 2016 at 3:55:55 AM UTC-4, Niphlod wrote:
>>>>>
>>>>> small recap...a single worker is tasked with assigning tasks (the 
>>>>> one with is_ticker=True) and then that task is picked up only by the 
>>>>> assigned worker (you can see it on the 
>>>>> scheduler_task.assigned_worker_name 
>>>>> column of the task). 
>>>>> There's no way the same task (i.e. a scheduler_task "row") is executed 
>>>>> while it is RUNNING (i.e. processed by some worker).
>>>>> The process running the task is stored also in 
>>>>> scheduler_run.worker_name.
>>>>>
>>>>> <tl;dr> you shouldn't EVER have scheduler_run records with the same 
>>>>> task_id and 12 different worker_name all in the RUNNING status.
>>>>>
>>>>> For a single task to be processed by ALL 12 workers at the same 
>>>>> time... is quite impossible, if everything is running smoothly. And 
>>>>> frankly 
>>>>> I can't fathom any scenario in which it is possible.
>>>>>
>>>>>
>>>>> On Wednesday, August 17, 2016 at 6:25:41 PM UTC+2, Jason Solack wrote:
>>>>>>
>>>>>> I only see the task_id in the scheduler_run table, it seems to be 
>>>>>> added as many times as it can while the run is going... a short run will 
>>>>>> add just 2 of the workers and stop adding them once the initial run is 
>>>>>> completed
>>>>>>
>>>>>> On Wednesday, August 17, 2016 at 11:15:52 AM UTC-4, Niphlod wrote:
>>>>>>>
>>>>>>> task assignment is quite "beefy" (sadly, or fortunately in your 
>>>>>>> case, it favours consistence vs speed) : I don't see any reason why a 
>>>>>>> single task gets picked up by ALL of the 12 workers at the same time if 
>>>>>>> the 
>>>>>>> backend isn't lying (i.e. slaves not replicating master data), if 
>>>>>>> your 
>>>>>>> mssql is "single", there shouldn't absolutely be those kind of 
>>>>>>> problems...
>>>>>>>
>>>>>>> Are you sure all are crunching t

[web2py] Re: scheduler task_id assigned to multiple workers

2016-08-18 Thread Niphlod
turn on workers debugging level and grep for errors.

On Thursday, August 18, 2016 at 4:38:31 PM UTC+2, Jason Solack wrote:
>
> I think we have this scenario happening:
>
>
> https://groups.google.com/forum/#%21searchin/web2py/task_id%7csort:relevance/web2py/AYH5IzCIEMo/hY6aNplbGX8J
>
> our workers seems to be restarting quickly and we're trying to figure out 
> why
>
> On Thursday, August 18, 2016 at 3:55:55 AM UTC-4, Niphlod wrote:
>>
>> small recap...a single worker is tasked with assigning tasks (the one 
>> with is_ticker=True) and then that task is picked up only by the assigned 
>> worker (you can see it on the scheduler_task.assigned_worker_name column of 
>> the task). 
>> There's no way the same task (i.e. a scheduler_task "row") is executed 
>> while it is RUNNING (i.e. processed by some worker).
>> The process running the task is stored also in scheduler_run.worker_name.
>>
>> <tl;dr> you shouldn't EVER have scheduler_run records with the same 
>> task_id and 12 different worker_name all in the RUNNING status.
>>
>> For a single task to be processed by ALL 12 workers at the same time... 
>> is quite impossible, if everything is running smoothly. And frankly I can't 
>> fathom any scenario in which it is possible.
>>
>>
>> On Wednesday, August 17, 2016 at 6:25:41 PM UTC+2, Jason Solack wrote:
>>>
>>> I only see the task_id in the scheduler_run table, it seems to be added 
>>> as many times as it can while the run is going... a short run will add just 
>>> 2 of the workers and stop adding them once the initial run is completed
>>>
>>> On Wednesday, August 17, 2016 at 11:15:52 AM UTC-4, Niphlod wrote:
>>>>
>>>> task assignment is quite "beefy" (sadly, or fortunately in your case, 
>>>> it favours consistence vs speed) : I don't see any reason why a single 
>>>> task 
>>>> gets picked up by ALL of the 12 workers at the same time if the backend 
>>>> isn't lying (i.e. slaves not replicating master data), if your mssql 
>>>> is 
>>>> "single", there shouldn't absolutely be those kind of problems...
>>>>
>>>> Are you sure all are crunching the same exact task (i.e. same task id 
>>>> and uuid) ?
>>>>
>>>> On Wednesday, August 17, 2016 at 2:47:11 PM UTC+2, Jason Solack wrote:
>>>>>
>>>>> I'm using nginx and MSSQL for the db
>>>>>
>>>>> On Wednesday, August 17, 2016 at 3:11:11 AM UTC-4, Niphlod wrote:
>>>>>>
>>>>>> nothing in particular. what backend are you using ?
>>>>>>
>>>>>> On Tuesday, August 16, 2016 at 8:35:17 PM UTC+2, Jason Solack wrote:
>>>>>>>
>>>>>>> task = scheduler.queue_task(tab_run, 
>>>>>>> pvars=dict(tab_file_name=tab_file_name, the_form_file=the_form_file), 
>>>>>>> timeout=60 * 60 * 24, sync_output=2, immediate=False, 
>>>>>>> group_name=scheduler_group_name)
>>>>>>>
>>>>>>> anything look amiss here?
>>>>>>>
>>>>>>> On Tuesday, August 16, 2016 at 2:14:38 PM UTC-4, Dave S wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tuesday, August 16, 2016 at 9:38:09 AM UTC-7, Jason Solack wrote:
>>>>>>>>>
>>>>>>>>> Hello all, i am having a situation where my scheduled jobs are 
>>>>>>>>> being picked up by multiple workers.  My last task was picked up by 
>>>>>>>>> all 12 
>>>>>>>>> workers and is crushing the machines.  This is a load balanced 
>>>>>>>>> machine with 
>>>>>>>>> 3 machine and 4 workers on each machine.  has anyone experienced 
>>>>>>>>> something 
>>>>>>>>> like this?
>>>>>>>>>
>>>>>>>>> Thanks for your help in advance!
>>>>>>>>>
>>>>>>>>> jason
>>>>>>>>>
>>>>>>>>
>>>>>>>> What does your queue_task() code look like?
>>>>>>>>
>>>>>>>> /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/d/optout.


[web2py] Re: scheduler task_id assigned to multiple workers

2016-08-18 Thread Niphlod
small recap...a single worker is tasked with assigning tasks (the one 
with is_ticker=True) and then that task is picked up only by the assigned 
worker (you can see it on the scheduler_task.assigned_worker_name column of 
the task). 
There's no way the same task (i.e. a scheduler_task "row") is executed 
while it is RUNNING (i.e. processed by some worker).
The process running the task is stored also in scheduler_run.worker_name.

<tl;dr> you shouldn't EVER have scheduler_run records with the same task_id 
and 12 different worker_name all in the RUNNING status.

For a single task to be processed by ALL 12 workers at the same time... is 
quite impossible, if everything is running smoothly. And frankly I can't 
fathom any scenario in which it is possible.


On Wednesday, August 17, 2016 at 6:25:41 PM UTC+2, Jason Solack wrote:
>
> I only see the task_id in the scheduler_run table, it seems to be added as 
> many times as it can while the run is going... a short run will add just 2 
> of the workers and stop adding them once the initial run is completed
>
> On Wednesday, August 17, 2016 at 11:15:52 AM UTC-4, Niphlod wrote:
>>
>> task assignment is quite "beefy" (sadly, or fortunately in your case, it 
>> favours consistence vs speed) : I don't see any reason why a single task 
>> gets picked up by ALL of the 12 workers at the same time if the backend 
>> isn't lying (i.e. slaves not replicating master data), if your mssql is 
>> "single", there shouldn't absolutely be those kind of problems...
>>
>> Are you sure all are crunching the same exact task (i.e. same task id and 
>> uuid) ?
>>
>> On Wednesday, August 17, 2016 at 2:47:11 PM UTC+2, Jason Solack wrote:
>>>
>>> I'm using nginx and MSSQL for the db
>>>
>>> On Wednesday, August 17, 2016 at 3:11:11 AM UTC-4, Niphlod wrote:
>>>>
>>>> nothing in particular. what backend are you using ?
>>>>
>>>> On Tuesday, August 16, 2016 at 8:35:17 PM UTC+2, Jason Solack wrote:
>>>>>
>>>>> task = scheduler.queue_task(tab_run, 
>>>>> pvars=dict(tab_file_name=tab_file_name, the_form_file=the_form_file), 
>>>>> timeout=60 * 60 * 24, sync_output=2, immediate=False, 
>>>>> group_name=scheduler_group_name)
>>>>>
>>>>> anything look amiss here?
>>>>>
>>>>> On Tuesday, August 16, 2016 at 2:14:38 PM UTC-4, Dave S wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tuesday, August 16, 2016 at 9:38:09 AM UTC-7, Jason Solack wrote:
>>>>>>>
>>>>>>> Hello all, i am having a situation where my scheduled jobs are being 
>>>>>>> picked up by multiple workers.  My last task was picked up by all 12 
>>>>>>> workers and is crushing the machines.  This is a load balanced machine 
>>>>>>> with 
>>>>>>> 3 machine and 4 workers on each machine.  has anyone experienced 
>>>>>>> something 
>>>>>>> like this?
>>>>>>>
>>>>>>> Thanks for your help in advance!
>>>>>>>
>>>>>>> jason
>>>>>>>
>>>>>>
>>>>>> What does your queue_task() code look like?
>>>>>>
>>>>>> /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/d/optout.


[web2py] Re: High worker count in scheduler_worker table

2016-08-18 Thread Niphlod
550.000 means 550.000 processes have been started. 
In 2 weeks, if math is right, there are 20.160 minutes. your workers are 
starting and diying way too much 

On Wednesday, August 17, 2016 at 9:24:41 PM UTC+2, Jason Solack wrote:
>
> Hello all, this may be typical, but i'm trying to determine if there is an 
> issue with the frequency of my workers dropping out of my scheduler_worker 
> table.  At this point my app has been in development for about 2 week and 
> the ids of my workers are abou 550,000.  Meaning that these rows have been 
> reinserted about 550,000 times.  Does that seem high or is that typical of 
> an application utilizing the scheduler.
>  
> Thanks
>
> jason
>

-- 
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 task_id assigned to multiple workers

2016-08-17 Thread Niphlod
task assignment is quite "beefy" (sadly, or fortunately in your case, it 
favours consistence vs speed) : I don't see any reason why a single task 
gets picked up by ALL of the 12 workers at the same time if the backend 
isn't lying (i.e. slaves not replicating master data), if your mssql is 
"single", there shouldn't absolutely be those kind of problems...

Are you sure all are crunching the same exact task (i.e. same task id and 
uuid) ?

On Wednesday, August 17, 2016 at 2:47:11 PM UTC+2, Jason Solack wrote:
>
> I'm using nginx and MSSQL for the db
>
> On Wednesday, August 17, 2016 at 3:11:11 AM UTC-4, Niphlod wrote:
>>
>> nothing in particular. what backend are you using ?
>>
>> On Tuesday, August 16, 2016 at 8:35:17 PM UTC+2, Jason Solack wrote:
>>>
>>> task = scheduler.queue_task(tab_run, 
>>> pvars=dict(tab_file_name=tab_file_name, the_form_file=the_form_file), 
>>> timeout=60 * 60 * 24, sync_output=2, immediate=False, 
>>> group_name=scheduler_group_name)
>>>
>>> anything look amiss here?
>>>
>>> On Tuesday, August 16, 2016 at 2:14:38 PM UTC-4, Dave S wrote:
>>>>
>>>>
>>>>
>>>> On Tuesday, August 16, 2016 at 9:38:09 AM UTC-7, Jason Solack wrote:
>>>>>
>>>>> Hello all, i am having a situation where my scheduled jobs are being 
>>>>> picked up by multiple workers.  My last task was picked up by all 12 
>>>>> workers and is crushing the machines.  This is a load balanced machine 
>>>>> with 
>>>>> 3 machine and 4 workers on each machine.  has anyone experienced 
>>>>> something 
>>>>> like this?
>>>>>
>>>>> Thanks for your help in advance!
>>>>>
>>>>> jason
>>>>>
>>>>
>>>> What does your queue_task() code look like?
>>>>
>>>> /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/d/optout.


[web2py] Re: Bug?: Spanish formatted dates won't store on database(english ones do)

2016-08-17 Thread Niphlod
you're overriding the default IS_DATETIME() validator attached to datetime 
with IS_NOT_EMPTY() ... that's the reason it's not working.

On Wednesday, August 17, 2016 at 1:51:08 AM UTC+2, Luciano Laporta Podazza 
wrote:
>
> Hello,
>
> I'm working on a simple case file project and realized that working with 
> english date format has no issues but if I use spanish ones(taking 
> advantage of internacionalization) they don't get stored on database.
>
> Here is my controller:
> @auth.requires_login()
> def index():
> """
> example action using the internationalization operator T and flash
> rendered by views/default/index.html or views/generic.html
>
>
> if you need a simple wiki simply replace the two lines below with:
> return auth.wiki()
> """
> form = SQLFORM.smartgrid(db.case_file)
> return dict(form=form)
>
> Here is my model:
>
> db.define_table('case_file',
> Field('auth_user_id', db.auth_user),
> Field('case_file_number', 'integer', label=T("Case Number"), requires=
> IS_NOT_EMPTY()),
> Field('case_file_code', 'integer', label=T("Case Code"), requires=
> IS_NOT_EMPTY()),
> Field('case_file_letter', 'string', label=T("Case Letter"), requires=
> IS_NOT_EMPTY()),
> Field('case_file_year', 'date', label=T("Case Year"), requires=
> IS_NOT_EMPTY()),
> Field('case_file_subject', 'string', label=T("Case Subject"), requires
> =IS_NOT_EMPTY()),
> )
>
>
> db.define_table('case_file_history',
> Field('case_file_id', db.case_file),
> Field('created_by', 'string', label=T("Created By"), requires=
> IS_NOT_EMPTY()),
> Field('case_file_ingress', 'date', label=T("Case Ingress"), requires=
> IS_NOT_EMPTY()),
> Field('case_file_egress', 'date', label=T("Case Egress"), requires=
> IS_NOT_EMPTY()),
> Field('case_file_to', 'string', label=T("Case To"), requires=
> IS_NOT_EMPTY()),
> Field('case_file_status', 'string', label=T("Case Status"), requires=
> IS_NOT_EMPTY()),
> )
>
>
> To recreate this issue, create a new project, use my code and set your 
> browser to spanish. It won't store any field of date type on database, but 
> if browser is set up in english language, it will.
>
> I'm using web2py 2.14.6-stable+timestamp.2016.05.10.00.21.47 on Mac OS X 
> El Capitan and sqlite or mysql(issue repeats on both databases).
>
> Any help will be appreciated. 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: db.executesql() is taking 10 times longer than it should to run a query in Web2py

2016-08-17 Thread Niphlod
sure that timings aren't affected by the first query rather than the last ?

I mean
rows = db(db.Word.normalform == aword.normalform).select(db.Word.id 
)



On Wednesday, August 17, 2016 at 1:51:08 AM UTC+2, junde...@launchpnt.com 
wrote:
>
> Greetings.  db.executesql() is taking 10 times longer than it should to 
> run a query in Web2py, and I can’t figure out why.  This is causing a huge 
> bottleneck in my application.
>
>
> In the example below, the Web2py times are all over the map, ranging from 
> 10ms to 500ms, whereas the query runs consistenty in about 30ms in pgAdmin 
> III on the same server.
>
>
> Yes, there’s 27 million rows in the table Word2Word, but so what?  There’s 
> an index on every column, and as I said, the query runs consistently in 
> pgAdmin III.  See also the query plan below.
>
>
> Four Core 2 CPUs, 16 GB RAM, nobody on this server but me.
>
>
> I need help.  I’m completely stumped.  If this requires a paid expert we 
> can probably accommodate that if we can get an answer.
>
>
> Love Web2py.   Thanks,
>
>
> John D. Underhill
>
> Senior Web Developer
>
> Vocabulary Systems, Inc.
>
> -
>
> Web2py 2.14.3-stable+timestamp.2016.03.26.23.02.02
>
> Running on Apache/2.4.7 (Ubuntu), Python 2.7.6
>
> Postgres 9.3.13
>
> -
>
> . . . 
> rows = db(db.Word.normalform == aword.normalform).select(db.Word.id)
> . . .
> sql = "SELECT Word.normalform, Word.frequency, Word2Word.relscore "
> sql = sql + "FROM Word2Word INNER JOIN Word ON (Word2Word.word2 = Word.id) 
> "
> sql = sql + "WHERE ((Word2Word.word1 = " + str(rows[0].id) + ") AND "
> sql = sql + "(Word.frequency >= " + str(freqlower) + ") AND 
> (Word.frequency <= " + str(frequpper) + ")) "
> sql = sql + "ORDER BY Word2Word.relscore DESC LIMIT " + str(howmany * 3) + 
> ";"
> rows = db.executesql(sql, as_dict=True, colnames=['Word.normalform', 
> 'Word.frequency', 'Word2Word.relscore'])
> . . .
> for x in db._timings:
> logger.debug(str(x))
>
>
> -
>
> 2016-08-09 01:25:13,072  -  DEBUG  -  (u"SELECT  Word.id FROM Word WHERE 
> (Word.normalform = 'american');", 0.002079010009765625)
>
> 2016-08-09 01:25:13,072  -  DEBUG  -  (u'SELECT Word.normalform, 
> Word.frequency, Word2Word.relscore FROM Word2Word INNER JOIN Word ON 
> (Word2Word.word2 = Word.id) WHERE ((Word2Word.word1 = 132) AND 
> (Word.frequency >= 45) AND (Word.frequency <= 65)) ORDER BY 
> Word2Word.relscore DESC LIMIT 15;', 0.23161005973815918)
>
> 2016-08-09 01:25:13,073  -  DEBUG  -  (u"SELECT  Word.id FROM Word WHERE 
> (Word.normalform = 'prospect');", 0.002025842259766)
>
> 2016-08-09 01:25:13,073  -  DEBUG  -  (u'SELECT Word.normalform, 
> Word.frequency, Word2Word.relscore FROM Word2Word INNER JOIN Word ON 
> (Word2Word.word2 = Word.id) WHERE ((Word2Word.word1 = 2201) AND 
> (Word.frequency >= 45) AND (Word.frequency <= 65)) ORDER BY 
> Word2Word.relscore DESC LIMIT 15;', 0.5044560432434082)
>
> 2016-08-09 01:25:13,074  -  DEBUG  -  (u"SELECT  Word.id FROM Word WHERE 
> (Word.normalform = 'learn');", 0.0010268688201904297)
>
> 2016-08-09 01:25:13,074  -  DEBUG  -  (u'SELECT Word.normalform, 
> Word.frequency, Word2Word.relscore FROM Word2Word INNER JOIN Word ON 
> (Word2Word.word2 = Word.id) WHERE ((Word2Word.word1 = 312) AND 
> (Word.frequency >= 45) AND (Word.frequency <= 65)) ORDER BY 
> Word2Word.relscore DESC LIMIT 15;', 0.009122133255004883)
>
> 2016-08-09 01:25:13,075  -  DEBUG  -  (u"SELECT  Word.id FROM Word WHERE 
> (Word.normalform = 'edge');", 0.0021839141845703125)
>
> 2016-08-09 01:25:13,075  -  DEBUG  -  (u'SELECT Word.normalform, 
> Word.frequency, Word2Word.relscore FROM Word2Word INNER JOIN Word ON 
> (Word2Word.word2 = Word.id) WHERE ((Word2Word.word1 = 918) AND 
> (Word.frequency >= 45) AND (Word.frequency <= 65)) ORDER BY 
> Word2Word.relscore DESC LIMIT 15;', 0.22762799263000488)
>
> 2016-08-09 01:25:13,076  -  DEBUG  -  (u"SELECT  Word.id FROM Word WHERE 
> (Word.normalform = 'measure');", 0.0020809173583984375)
>
> 2016-08-09 01:25:13,077  -  DEBUG  -  (u'SELECT Word.normalform, 
> Word.frequency, Word2Word.relscore FROM Word2Word INNER JOIN Word ON 
> (Word2Word.word2 = Word.id) WHERE ((Word2Word.word1 = 581) AND 
> (Word.frequency >= 45) AND (Word.frequency <= 65)) ORDER BY 
> Word2Word.relscore DESC LIMIT 15;', 0.47495388984680176)
>
> -
>
>
> 
>
>
> 
>
>
>

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

[web2py] Re: Speeding up scheduler assignment time

2016-08-17 Thread Niphlod
redis. 
also, 1 second heartbeat with a moderate number of workers needs a very 
responsive backend.

On Monday, August 15, 2016 at 4:31:44 PM UTC+2, Jason Solack wrote:
>
> Hell all, i'm currently leveraging the scheduler to do some data 
> processing and i'm finding it takes 5-10 seconds for my task to be 
> assigned.  I'm running MSSQL and have immediate set to false (i was getting 
> some deadlock errors).  Even when immediate was set to True it was taking 
> 5-10 seconds for the job to be assigned.  My heartbeat is set to 1 
> second... any other settings i could change that would speed up assignment?
>
> Thank you in advance,
>
> Jason
>

-- 
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 task_id assigned to multiple workers

2016-08-17 Thread Niphlod
nothing in particular. what backend are you using ?

On Tuesday, August 16, 2016 at 8:35:17 PM UTC+2, Jason Solack wrote:
>
> task = scheduler.queue_task(tab_run, 
> pvars=dict(tab_file_name=tab_file_name, the_form_file=the_form_file), 
> timeout=60 * 60 * 24, sync_output=2, immediate=False, 
> group_name=scheduler_group_name)
>
> anything look amiss here?
>
> On Tuesday, August 16, 2016 at 2:14:38 PM UTC-4, Dave S wrote:
>>
>>
>>
>> On Tuesday, August 16, 2016 at 9:38:09 AM UTC-7, Jason Solack wrote:
>>>
>>> Hello all, i am having a situation where my scheduled jobs are being 
>>> picked up by multiple workers.  My last task was picked up by all 12 
>>> workers and is crushing the machines.  This is a load balanced machine with 
>>> 3 machine and 4 workers on each machine.  has anyone experienced something 
>>> like this?
>>>
>>> Thanks for your help in advance!
>>>
>>> jason
>>>
>>
>> What does your queue_task() code look like?
>>
>> /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/d/optout.


[web2py] Re: web2py in production mode and improving execution time

2016-08-12 Thread Niphlod
use --profiler_dir and then use runsnakerun to inspect.

On Thursday, August 11, 2016 at 4:57:38 PM UTC+2, Ron Chatterjee wrote:
>
> I use MATLAB a lot and they have something call profile. 
> http://www.mathworks.com/help/matlab/ref/profile.html
>
> That allows to profile an application based on execution time (for each 
> function/def) and it gives an alternative to figure out if any of the 
> modules need to be converted to C/C++ for speed improvement. The app I have 
> running using web2py seems slow and its getting bulky with added features 
> by the day. Wondering if there is anything similar to profile in 
> python/web2py we can use figure out what is draining the resources? Some of 
> those modules then may be can be converted to scala or C. Any thoughts?
>
> -Ron
>
>

-- 
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 access class variable in web2py like we do in flask?

2016-08-09 Thread Niphlod
The solution lies in knowing web2py's unique execution model (which is BY 
FAR different from Flask's) AND reading the source code. 
When faced with the same problem years ago, finding the solution (was 
already there, as it is now) made me a better coder, so I won't - on 
purpose - propose a cut solution. 

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


Re: [web2py] Re: Reading date from controller to view in web2py

2016-08-09 Thread Niphlod
the problem is not the resultset: it's how it's injected into the view

On Tuesday, August 9, 2016 at 8:28:23 PM UTC+2, Dave S wrote:
>
>
>
> On Tuesday, August 9, 2016 at 10:56:48 AM UTC-7, madhu nomula wrote:
>>
>> db.define_table('ActivityMapping', 
>> Field('mapping_id'), 
>> Field('resource_id',db.auth_user), 
>> Field('org_id',db.Organization), 
>> Field('solution_id',db.Solution), 
>> Field('activity_id',db.Activity), 
>> Field('activity_date','datetime', requires=IS_DATE()), 
>> Field('effort') 
>> ) 
>>
>>
> Thank you.  Which database engine are you connecting to?
>
> /dps
>  
>
>> On Tue, Aug 9, 2016 at 11:11 PM, Dave S  wrote: 
>> > 
>> > 
>> > On Tuesday, August 9, 2016 at 9:09:08 AM UTC-7, madhu nomula wrote: 
>> >> 
>> >> Hi, 
>> >> 
>> >> I am trying to read date output from controller, but I am getting 
>> value in 
>> >> View as decimal values: 
>> > 
>> > 
>> > Which DB backend are you using? 
>> > 
>> > Can you show your define_table() code? 
>> > 
>> > /dps 
>> > 
>> > 
>> >> 
>> >> 
>> >> controller Code: 
>> >> 
>> >>rowslistPeriod = db(( 
>> >> (db.AM.resource_id==db.auth_user.id)& 
>> >> 
>> >>   (db.auth_user.id==auth.user.id) 
>> >> 
>> ).select(db.auth_user.first_name,db.db.Solution.solution_code,db.Activity.activity_name,
>>  
>>
>> >> db.AM.effort, db.AM.activity_date) 
>> >> return dict(recordlistPeriod=rowslistPeriod 
>> >> 
>> >> 
>> >> View Code: 
>> >> 
>> >>  $(containerPreviousRecords).append('{{for x in recordlistPeriod:}}'); 
>> >> 
>> >> 
>> >>var ceffort= {{=x.AM.effort}}; 
>> >>  var cDate= {{=x.AM.activity_date.strftime("%m/%d/%Y")}}; 
>> >>  alert(cDate); 
>> >> 
>> >> 
>> >> - 
>> >> 
>> >> Here I am able to get number value (effort), when I am getting alert 
>> >> getting  x.AM.activity_date.strftime("%m/%d/%Y") values as 
>> >> decimal(0.0036789..) instead of Date. 
>> >> 
>> >> Please help me to get date. 
>> >> 
>> >> Thanks, 
>> >> MC 
>> > 
>> > -- 
>> > 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+un...@googlegroups.com. 
>> > For more options, visit https://groups.google.com/d/optout. 
>>
>

-- 
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: Get Distinct dates

2016-08-09 Thread Niphlod
database. 

On Tuesday, August 9, 2016 at 3:08:20 PM UTC+2, Marlysson Silva wrote:
>
> Backend: database or language programming?
>
> Em terça-feira, 9 de agosto de 2016 09:59:37 UTC-3, Niphlod escreveu:
>>
>> let the backend do set operations: it's by far faster than pure python 
>> (saves bandwith, too)
>>
>> On Tuesday, August 9, 2016 at 12:49:35 PM UTC+2, Marlysson Silva wrote:
>>>
>>> Use of a SET in list returned of result.
>>>
>>> Em segunda-feira, 8 de agosto de 2016 15:21:58 UTC-3, madhu nomula 
>>> escreveu:
>>>>
>>>> Hello,
>>>>
>>>> In  Web2py database we have date entries. Need to get distinct dates 
>>>> and bind to a dropdown control. But I am unable to get :
>>>>
>>>> Please find code below:
>>>> Controller:
>>>>  myrows = db((db.Act.org_id==db.organix.id)& (db.auth_user.id==
>>>> auth.user.id) ).select((db.MC.activity_date ))
>>>>
>>>> View:
>>>>
>>>> 
>>>>   {{for x in myrows:}}>>>  
>>>> value="{{=x.activity_date}}">{{=x.activity_date.strftime("%m/%d/%Y")}}{{pass}}
>>>>  
>>>> 
>>>>
>>>>
>>>>
>>>> Need to bind only distinct dates to this >>> Appreciate your help in advance.
>>>>
>>>> Regards,
>>>> MC
>>>>
>>>

-- 
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: Get Distinct dates

2016-08-09 Thread Niphlod
let the backend do set operations: it's by far faster than pure python 
(saves bandwith, too)

On Tuesday, August 9, 2016 at 12:49:35 PM UTC+2, Marlysson Silva wrote:
>
> Use of a SET in list returned of result.
>
> Em segunda-feira, 8 de agosto de 2016 15:21:58 UTC-3, madhu nomula 
> escreveu:
>>
>> Hello,
>>
>> In  Web2py database we have date entries. Need to get distinct dates and 
>> bind to a dropdown control. But I am unable to get :
>>
>> Please find code below:
>> Controller:
>>  myrows = db((db.Act.org_id==db.organix.id)& (db.auth_user.id==
>> auth.user.id) ).select((db.MC.activity_date ))
>>
>> View:
>>
>> 
>>   {{for x in myrows:}}>  
>> value="{{=x.activity_date}}">{{=x.activity_date.strftime("%m/%d/%Y")}}{{pass}}
>>  
>> 
>>
>>
>>
>> Need to bind only distinct dates to this > Appreciate your help in advance.
>>
>> Regards,
>> MC
>>
>

-- 
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: Ubuntu 16.04 - installation script stops

2016-08-09 Thread Niphlod
ahem. maybe a dos2unix first solves it.

On Tuesday, August 9, 2016 at 11:39:56 AM UTC+2, mweissen wrote:
>
> Thank you for this script. I am using a dedicted server from noez.de and 
> it is possible to choose one of a lot of operating systems. I have choosen 
> Ubuntu 16.04.
>
> I have tried:
> wget 
> https://gist.githubusercontent.com/niphlod/8a13025001363657f0201b2a15dad41c/raw/482fd6973d3c73c415c610dcaf64cd6d8327cfd2/web2py-on-ubuntu.sh
>
> chmod 755 web2py-on-ubuntu.sh
> ./web2py-on-ubuntu.sh
>
> I got an error message - these are the last lines:
>
> upstream web2py27 {
> server unix:///run/uwsgi/web2py27.socket;
> }
>
> server {
> listen  80;
> server_name $hostname;
>
> # static serving
> include /etc/nginx/conf.d/web2py/serve_static.conf;
> include /etc/nginx/conf.d/web2py/serve_web2py27.conf;
> }
> server {
> listen 443 default_server ssl;
> server_name $hostname;
> ssl_certificate /etc/nginx/ssl/web2py.crt;
> ssl_certificate_key /etc/nginx/ssl/web2py.key;
> ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
> ssl_prefer_server_ciphers on;
> ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
> ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
> ssl_session_cache shared:SSL:10m;
> ssl_session_tickets off; # Requires nginx >= 1.5.9
> ssl_stapling on; # Requires nginx >= 1.3.7
> ssl_stapling_verify on; # Requires nginx => 1.3.7
> resolver 8.8.8.8 8.8.4.4 valid=300s;
> resolver_timeout 5s;
> ssl_dhparam /etc/ssl/certs/dhparam.pem;
> ## remove only if you know what youre doing
> ./web2py-on-ubuntu.sh: line 116: include: command not found
> ./web2py-on-ubuntu.sh: line 117: include: command not found
> ./web2py-on-ubuntu.sh: line 139: } >/etc/nginx/sites-available/web2py27
>
> ln -s /etc/nginx/sites-available/web2py27 /etc/nginx/sites-enabled/web2py27
> rm /etc/nginx/sites-enabled/default
> cd /etc/ssl/certs
> openssl dhparam -out dhparam.pem 4096
> mkdir /etc/nginx/ssl
> cd /etc/nginx/ssl
>
> if [ "$nocertificate" -eq 0 ]
> then
>   openssl req -x509 -newykey rsa:2048 -nodes -keyout web2py.key -out 
> web2py.crt -days 1780
>   chmod 400 web2py.key
>   openssl x509 -noout -fingerprint -text < web2py.crt > web2py.info
> fi
> # Prepare folders for uwsgi
> sudo mkdir /etc/uwsgi
> sudo mkdir /etc/uwsgi/vassals
>
>
> #uWSGI Emperor
> echo [Unit]: No such file or directory
> ./web2py-on-ubuntu.sh: line 140: Description: command not found
> ./web2py-on-ubuntu.sh: line 141: After: command not found
> ./web2py-on-ubuntu.sh: line 142: [Service]: command not found
> ./web2py-on-ubuntu.sh: line 143: ExecStart: command not found
> ./web2py-on-ubuntu.sh: line 144: RuntimeDirectory: command not found
> ./web2py-on-ubuntu.sh: line 145: Restart: command not found
> ./web2py-on-ubuntu.sh: line 146: KillSignal: command not found
> ./web2py-on-ubuntu.sh: line 147: Type: command not found
> ./web2py-on-ubuntu.sh: line 148: StandardError: command not found
> ./web2py-on-ubuntu.sh: line 149: NotifyAccess: command not found
> ./web2py-on-ubuntu.sh: line 150: [Install]: command not found
> ./web2py-on-ubuntu.sh: line 151: WantedBy: command not found
> ./web2py-on-ubuntu.sh: line 154:  > 
> /etc/systemd/system/emperor.uwsgi.service
> # Create configuration for emperor
> echo [uwsgi]: No such file or directory
> ./web2py-on-ubuntu.sh: line 155: emperor: command not found
> ./web2py-on-ubuntu.sh: line 156: uid: command not found
> ./web2py-on-ubuntu.sh: line 157: gid: command not found
> ./web2py-on-ubuntu.sh: line 160: >/etc/uwsgi/emperor.ini
> # Create configuration file /etc/uwsgi/web2py.ini
> echo [uwsgi]: No such file or directory
> ./web2py-on-ubuntu.sh: line 161: home: command not found
> ./web2py-on-ubuntu.sh: line 162: socket: command not found
> ./web2py-on-ubuntu.sh: line 163: pythonpath: command not found
> mount: mount point /=wsgihandler:application does not exist
> ./web2py-on-ubuntu.sh: line 165: processes: command not found
> ./web2py-on-ubuntu.sh: line 166: vacuum: command not found
> ./web2py-on-ubuntu.sh: line 167: master: command not found
> ./web2py-on-ubuntu.sh: line 168: harakiri: command not found
> ./web2py-on-ubuntu.sh: line 169: reload-mercy: command not found
> ./web2py-on-ubuntu.sh: line 170: cpu-affinity: command not found
> ./web2py-on-ubuntu.sh: line 171: stats: command not found
> ./web2py-on-ubuntu.sh: line 172: max-requests: command not found
> ./web2py-on-ubuntu.sh: line 173: limit-as: command not found
> ./web2py-on-ubuntu.sh: line 174: r

<    1   2   3   4   5   6   7   8   9   10   >