[web2py] Re: update database right from view?

2014-07-10 Thread Brian M
Maria, if you really want to you can build the entire form in the view with 
good old HTML. 

   1. An example set of "sentence", "meaning" and word "forms" may be 
   helpful - sounds like you're probably doing some sort of translation thing 
   or maybe it is a quiz?
   2. You'll need to add  tags to what you've included in your 
   example; just the fields and the submit button aren't enough
   3. you need to give your  a name attribute so you can refer to 
   the field later when processing the submission in the controller
  - You'll want to do your naming such that you can figure out which 
  text each returned  field value is actually referring to. It 
sounds 
  like you're going to have multiple on a page so I'd suggest naming them 
  with a format like ... so that 
  later in your controller you can loop through all the fields submitted, 
  they should be in request.post_vars, and parse back out exactly what text 
  in the database the chosen word form goes to
   4. In your sample code every single  is going to have value="cc" 
   you want  so the value is different for each 
   option
   5. You do not need a  after each  (and when you do 
   actually need a break use the self closing  form)
   6. Remember to VALIDATE the incoming data to make sure that it is 
   actually legitimate! If you use FORM() this is taken care of for you, 
   without it it is up to you to make sure that the text ID provided is 
   actually in the database and that the chosen word form is actually a valid 
   choice for that particular text.

~Brian

On Wednesday, July 9, 2014 4:26:37 PM UTC-5, Maria Levchenko wrote:
>
> Sorry for novice question, but I can't handle it myself.
>
> Is there any possibility to update database from view without creating a 
> form in controller?
> I have a table in database with fields:
> - sentence (a sentence)
> - meaning (one word)
> - forms (list of words)
>
> And I have to ask user to select one word from "forms" that connect to 
> "meaning" (and show him a whole sentence).
>
> This is my view:
> {{for row in texts:}}
> {{=row.sentences}}: {{=row.meaning}}
> {{for ff in row.forms:}}
> {{if len(ff)>0:}}
>{{c=ff.split()}}
>  {{for cc in c:}} {{=cc}}  
> {{pass}}
> {{pass}}
> {{pass}}
> {{pass}}
>
> 
>
> So i have several "select" fields on page and one button "submit".
> I want to insert in database (or update the rows) (with user's click on 
> button): sentence - meaning - selected form (from list).
> Can I do it or it's imposible?
>

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


[web2py] Re: How do I iterate over imported methods in a list?

2014-07-10 Thread Rufus


On Thursday, July 10, 2014 12:17:25 PM UTC-4, Maurice Waka wrote:
>
> in my web2py app, i created this code that works well in python shell.
>
> python modules:
> #The methods work in such a way that a user inputs an equation query to 
> get an answer. If it is an addition, method1 works it out, the same to 
> other methods being invoked to performing different codes
>
> def method1():# to do additions
> name = input('Please Enter equation here: ').lower()
> if '1 + 1':
> answer = code
> return answer
>
> def method2():# to do subtractions
> name = input('Please Enter equation here: ').lower()
> if '1 - 1':
> answer = code
> return answer
>
>
> in the controller, I imported the methods as follows. There are many more 
> methods than these shown
>
> from applications .. import method1
> from applications .. import method2
> from applications .. import method3
> from applications .. import method4
>
> method1 = method1
> method1 = method2
> method1 = method3
> method1 = method4
>
> G0 = [method1, method2, method3, m3thod4]
>
> def Foo():
> code..
> for (func) in G0:
> return func()
>
> The problem is that only method1 which is at position[0] in the list is 
> invoked and not other methods. I want to randomly call any method when a 
> user inputs any query.
>

It is very difficult to see what you are trying to accomplish in those 
functions.  But if your intent is to run through multiple functions, 
returning
results, one way is with "yield":

def runfuncs():
for func in g0:
yield(func())

for result in runfuncs():
print "result: ",result


-- 
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-RPC calls within controller functions

2014-07-10 Thread lyn2py
Thanks for your response Matheus!

no authentication… is there somewhere I can read up on this? I tried 
searching around google for answers, and ran into using "id", but no idea 
how that works, it appears that the id is automatically included. It's 
working on command line, the exact same commands, but not inside the 
controller function.

Had me wondering if I am using JSON-RPC correctly?

I guess what I need is an example of JSON-RPC working within a controller's 
function… 



On Wednesday, July 9, 2014 9:58:23 PM UTC+8, Matheus Cardoso wrote:
>
> There is any authentication on that? If yes, you should try something like 
> this:
>
> server = ServerProxy('http://'+ ws_user + ':' + ws_pass + '
> @127.0.0.1:8000/app22/default/call/jsonrpc 
> ')
>
> And If you created by yourself the WS through web2py, make sure that you 
> put the decorator on your service function "load". Besides, try (this time 
> is a guess, ok?) return your "result" variable instead of locals().
>
> On Tuesday, July 8, 2014 7:41:44 AM UTC-3, lyn2py wrote:
>>
>> I'm wanting to get JSON RPC to work within web2py controller functions, 
>> without using pyjamas (which is the example provided in the book)
>>
>> This is my code for the JSON RPC call:
>> def test_call():
>> from gluon.contrib.simplejsonrpc import ServerProxy
>> service = ServerProxy('
>> http://127.0.0.1:8000/app22/default/call/jsonrpc')
>> result = service.load(1000)
>> return locals()
>>
>> (1) Running it within web2py controller functions = It returns an error: 
>> ValueError: No JSON object could be decoded
>>
>> (2) Running it in the browser =  
>> http://127.0.0.1:8000/app22/default/call/jsonrpc/load/1000 it runs into 
>> the same error as (1).
>>
>> (3) Running it in command prompt = it works like a charm.
>>
>> How do I get it to work within web2py controller functions? 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.


Re: [web2py] Re: AWS Elastic Beanstalk installation Recipe

2014-07-10 Thread Diogo Munaro
It's working now with '3º fail' that I describe.

I'm using fake_migrate_all with previews version and migrate with new 
version

Thx for all helpers!

Em quarta-feira, 9 de julho de 2014 19h00min33s UTC-3, Diogo Munaro 
escreveu:
>
> I'm with some problems here... I really hate .table files.
>
> That's my deploy routine:
>
>1. download web2py from src
>2. get my application from git and put inside web2py
>3. remove some unused folders
>4. backup my database
>5. migrate my database structure with python web2py.py -S app -M -R 
>anyscript.py *(that's the point!!)*
>6. if ok, finished, else restore backup and last code
>
> 5 is my problem. I have a database structure and a lot of data but new 
> code come with new table structure (that needs database migration). So I 
> have some "fails":
>
>- If I maintain .table files into databases folder on localhost, than 
>the hash is different from production hash (because connection is 
>different). Solution: rename .table files for new db._uri_hash (It's not 
> so 
>beautiful)
>- If I set migrate=False I need to do migrations setting sql into my 
>mysql database (not good and I'm doing by now).
>- If I not mantain .table files I need fake_migrate from previews 
>deploy and than migrate. Looks good but need a lot of extra work and I 
>don't know if it work.
>
> What's the best way? Are there new suggestions?
>

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


Re: [web2py] Easy to Understand SQLFORM.grid Custom Search

2014-07-10 Thread peter
Thanks for this Joe, and it is an interesting approach. However I find the 
approach I used

https://groups.google.com/forum/#!searchin/web2py/sqlform.grid$20search/web2py/9_1ECdKHKUo/8OISg7o8OVIJ

Somewhat easier to understand. Your approach is more novel however. 

Peter

-- 
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: CKeditor in a loaded component

2014-07-10 Thread Leonel Câmara
I have it working fine using the latest ckeditor web2py plugin. What seems 
to be happening here is that ckeditor isn't actually being associated with 
your field's textarea for some reason.

-- 
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: random lambda error

2014-07-10 Thread Júlia Rizza
I misunderstood it, but it's clear now. Thank you Anthony!

Em quinta-feira, 10 de julho de 2014 00h58min22s UTC-3, Anthony escreveu:
>
> If you just want to specify a URL for redirect, you can do so without the 
> lambda:
>
> auth.settings.on_failed_authentication = URL('painel', 'index')
>
> However, if you do define a lambda (or any callable), it should accept an 
> argument.
>
> Anthony
>
> On Wednesday, July 9, 2014 9:31:17 PM UTC-4, Júlia Rizza wrote:
>>
>> I've completely forgot about the on_failed_authentication, sorry.
>>
>> *models/db.py*
>> auth.settings.on_failed_authentication = lambda: redirect(URL('painel', 
>> 'index'))
>>
>> (web2py version 2.8.2-stable)
>>
>>
>> Em quarta-feira, 9 de julho de 2014 21h31min19s UTC-3, Anthony escreveu:
>>>
>>> Did you change auth.settings.on_failed_authentication from its default 
>>> value?
>>>
>>> On Wednesday, July 9, 2014 8:11:25 PM UTC-4, Júlia Rizza wrote:

 Hello,

 I have an app runing in production on Apache and sometimes when 
 navigating over it I receive a ticket with a lambda error. It happens 
 ramdomly in a way that I wasn't able to predict what was causing it: 
 already ocurred in a function called dashboard, in another called invite 
 and some others. But the fact is that I do not call lambda in none of 
 them. 
 I only use lambda two times:

 *models/validators.py*
 db.board.slug.compute = lambda row: IS_SLUG()(row.title)[0]

 *controllers/painel.py | function: board()*
 try:
 int(request.args(1))
 user = db(db.auth_user.username == request.args(0)).select().first()
 board = db((db.board.created_by == user.id)&(db.board.id == 
 request.args(1))).select().first()
 except ValueError:
 user = db(db.auth_user.username == request.args(0)).select().first()
 board = db((db.board.created_by == user.id)&(db.board.slug == 
 request.args(1))).select().first()
 except TypeError:
 raise HTTP(404, T('No board specified!'))

 text_type = db(db.text_type.board == board.id).select()
 url_type = db(db.url_type.board == board.id).select()
 image_type = db(db.image_type.board == board.id).select()
 video_type = db(db.video_type.board == board.id).select()

 merged_records = itertools.chain(text_type, url_type, image_type, 
 video_type)
 contents = sorted(merged_records, key=lambda record: 
 record['topic_position'])

 The ticket *traceback* is:
  () takes no arguments (1 given)

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.

 Traceback (most recent call last):
   File "/home/www-data/web2py/gluon/restricted.py", line 217, in restricted
 exec ccode in environment
   File "/home/www-data/web2py/applications/cachola/controllers/painel.py" 
 , line 
 519, in 
   File "/home/www-data/web2py/gluon/globals.py", line 372, in 
 self._caller = lambda f: f()
   File "/home/www-data/web2py/gluon/tools.py", line 3229, in f
 '?_next=' + urllib.quote(next))
   File "/home/www-data/web2py/gluon/tools.py", line 91, in call_or_redirect
 redirect(f(*args))
 TypeError: () takes no arguments (1 given)


 Can somebody help me to understand where is the problem?

>>>

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


[web2py] CKeditor in a loaded component

2014-07-10 Thread Jim S
Has anyone gotten CKeditor working in a textarea in a loaded component?

When I try it, it keeps telling me the field is null even if I have text in 
it.

It works fine for me in textareas outside of a component.  I had the same 
result whether I used the CKeditor web2py plugin or just integrated it into 
my code on my own.

Any thoughts/experience?

Is there a different editor that works better in this instance?  I also 
tried TinyMCE but that didn't like the ajax reloading on error.  I couldn't 
get it to re-initialize the editor because it thought the editor was 
already initialized.

-Jim

-- 
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] Easy to Understand SQLFORM.grid Custom Search

2014-07-10 Thread Vinicius Assef
Really good.

How about updating the web2pyslices version, too? ;-)

On Thu, Jul 10, 2014 at 1:09 PM, JoeCodeswell  wrote:
> Dear web2py-users,
>
> I have written a recipe to customize the SQLFORM.grid search WITHOUT the
> need to specify a custom search_widget and so needing to read & understand
> the clever web2py implementation source code.
>
> The maintained link to the recipe is here on joecodeswell.wordpress.com. An
> older version is available on web2pyslices.com.
>
> Thanks for a GREAT framework and a GREAT community.
>
> Love and peace,
>
> Joe
>
> --
> 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.

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


[web2py] Re: How do I iterate over imported methods in a list?

2014-07-10 Thread Anthony

>
> method1 = method1
> method1 = method2
> method1 = method3
> method1 = method4
>

Why do you make four assignments to the same variable? 

G0 = [method1, method2, method3, m3thod4]
>
> def Foo():
> code..
> for (func) in G0:
> return func()
>
> The problem is that only method1 which is at position[0] in the list is 
> invoked and not other methods. I want to randomly call any method when a 
> user inputs any query.
>

Your function returns within the first loop iteration, so of course it only 
runs the first method. What are you really trying to do?

Anthony
 

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


[web2py] How do I iterate over imported methods in a list?

2014-07-10 Thread Maurice Waka
in my web2py app, i created this code that works well in python shell.

python modules:
#The methods work in such a way that a user inputs an equation query to get 
an answer. If it is an addition, method1 works it out, the same to other 
methods being invoked to performing different codes

def method1():# to do additions
name = input('Please Enter equation here: ').lower()
if '1 + 1':
answer = code
return answer

def method2():# to do subtractions
name = input('Please Enter equation here: ').lower()
if '1 - 1':
answer = code
return answer


in the controller, I imported the methods as follows. There are many more 
methods than these shown

from applications .. import method1
from applications .. import method2
from applications .. import method3
from applications .. import method4

method1 = method1
method1 = method2
method1 = method3
method1 = method4

G0 = [method1, method2, method3, m3thod4]

def Foo():
code..
for (func) in G0:
return func()

The problem is that only method1 which is at position[0] in the list is 
invoked and not other methods. I want to randomly call any method when a 
user inputs any query.

-- 
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] Easy to Understand SQLFORM.grid Custom Search

2014-07-10 Thread JoeCodeswell
Dear web2py-users,

I have written a recipe to customize the SQLFORM.grid search WITHOUT the 
need to specify a custom search_widget and so needing to read & understand 
the clever web2py implementation source code.

The maintained link to the recipe is here on joecodeswell.wordpress.com 
.
 
An older version is available on web2pyslices.com 

.

Thanks for a GREAT framework and a GREAT community.

Love and peace,

Joe

-- 
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: Broken ajax links in component

2014-07-10 Thread Ian W. Scott
I found the culprit. The ajax links were in a list with the bootstrap 
classes "nav nav-tabs". In bootstrap 3 the tabs js was choking on the url 
when an item was clicked.

On Thursday, July 10, 2014 6:57:51 AM UTC-4, Ian W. Scott wrote:
>
> I'm not running jquery 1.9. It's version 1.10.2. But I can try 1.11 and 
> see what happens.
>
> On Thursday, July 10, 2014 6:32:27 AM UTC-4, Leonel Câmara wrote:
>>
>> Have you tried updating jquery to 1.11 this seems like a known jquery 1.9 
>> bug.
>>
>

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


[web2py] Re: Broken ajax links giving "unrecognized expression" error

2014-07-10 Thread Ian W. Scott
I found the culprit! The links were in a list with the bootstrap classes 
"nav nav-tabs". Because of that the bootstrap js was trying to use the link 
url to show a tab, but it was the wrong format. The implementation of 
bootstrap tabs must have changed between versions 2 and 3 enough that my 
ajax links could work before but now choked the bootstrap js.

Maybe this is something we should keep in mind as people migrate from 
bootstrap 2 to 3.

Anyway, thanks for your willingness to help Niphlod.


On Wednesday, July 9, 2014 5:57:39 PM UTC-4, Ian W. Scott wrote:
>
> Some ajax links that used to work have just broken and I'm not sure where 
> to start in debugging. The links target a load component on the page (using 
> cid) and they have started throwing this error:
>
> Syntax error, unrecognized expression: 
>> /paideia/plugin_listandedit/edit.load/word_forms/546?orderby=id&tablename=word_forms
>
>
> The "unrecognized expression" is simply the url from the link. I've tried 
> re-downloading the web2py source and updating web2py.js but neither seems 
> to help. The only thing I've done that could have broken it is update to 
> bootstrap3 using the package put together by Paolo Caruccio. But I don't 
> know enough about web2py.js to guess where a conflict might lie. 
>
> Any suggestions? 
>

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


Re: [web2py] Recompute all instances of a computed field

2014-07-10 Thread Fabiano Almeida
Hi Johann,

I recently update manually compute field. You have presented a better way,
and still counter to monitor the process. Very nice!

Congratulations!

Fabiano.


2014-07-10 10:39 GMT-03:00 Johann Spies :

> Sorry, I sent it before finishing
>
>
> #!/usr/bin/python
> # -*- coding: utf-8 -*-
> rows = db(db.urlop.id > 0).select(db.urlop.ilosc_dni,
> db.termin_od, db.termin_do)
> howmany = len(rows)
> busy_with = 0
> for row in rows:
>  busywith += 1
>  print 'busy with %d of %d' % (busywith, howmany)
>  row.update_record(ulosc_dni = db.urlop.ulosc_dni.compute(row))
> db.commit()
>
>
> Regards
> Johann
>
>> --
>> Because experiencing your loyal love is better than life itself,
>> my lips will praise you.  (Psalm 63:3)
>>
>
>
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
> --
> 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.
>

-- 
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] Recompute all instances of a computed field

2014-07-10 Thread Johann Spies
Sorry, I sent it before finishing

#!/usr/bin/python
# -*- coding: utf-8 -*-
rows = db(db.urlop.id > 0).select(db.urlop.ilosc_dni,
db.termin_od, db.termin_do)
howmany = len(rows)
busy_with = 0
for row in rows:
 busywith += 1
 print 'busy with %d of %d' % (busywith, howmany)
 row.update_record(ulosc_dni = db.urlop.ulosc_dni.compute(row))
db.commit()


Regards
Johann

> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>



-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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] Recompute all instances of a computed field

2014-07-10 Thread Johann Spies
Try:

#!/usr/bin/python
# -*- coding: utf-8 -*-
rows = db(db.urlop.id > 0).select(db.urlop.ilosc_dni,db.termin_od,
db.termin_do)
howmany = len(rows)
busy_with = 0
for row in rows:
 busywith += 1
 print 'busy with %d of %d' % (busywith, howmany)




On 19 June 2014 18:29, Tomasz Sokołowski  wrote:

> Hello
>
> Recently I have upgraded the function dni_urlopu() which is used in a
> computed field in the table "urlop".
> How can I recompute/refresh all instances of already existing records
> which where not properly compute
> because of error in previous version of function "dni_urlopu()"
>
> Best regards,
> Tomek
>
>
> def dni_urlopu(termin_od, termin_do):
> return workdays.networkdays(termin_od, termin_do,
> [datetime.date(year=2014,month=01,day=01),
>
> datetime.date(year=2014,month=01,day=06),
>
> datetime.date(year=2014,month=04,day=21),
>
> datetime.date(year=2014,month=05,day=01),
>
> datetime.date(year=2014,month=06,day=19),
>
> datetime.date(year=2014,month=07,day=15),
>
> datetime.date(year=2014,month=11,day=11),
>
> datetime.date(year=2014,month=12,day=25),
>
> datetime.date(year=2014,month=12,day=26)])
>
> db.define_table('urlop',
> Field('user_id', db.auth_user, default=auth.user_id, writable=True,
> label='Pracownik' ),
> Field('urlop_typ', 'string',  requires=IS_IN_SET(URLOP_SET),
> label='Rodzaj urlopu'),
> Field('termin_od', 'date', label='Termin od'),
> Field('termin_do', 'date', label='Termin do'),
> Field('ilosc_dni', compute=lambda r: dni_urlopu(r['termin_od'],
> r['termin_do']), label='Ilość dni'),
> Field('uzasadnienie_urlop', 'text', label='Uzasadnienie'),
> Field('status', requires=IS_IN_SET(STATUS_SET), default=STATUS_SET[0],
> label='Status'),
> auth.signature)
>
>
>  --
> 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.
>



-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
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: Broken ajax links giving "unrecognized expression" error

2014-07-10 Thread Ian W. Scott
It'll take a bit of time, but I'll see what I can do.

On Thursday, July 10, 2014 8:37:31 AM UTC-4, Niphlod wrote:
>
> can you pack a minimal app to reproduce the issue ?
>
> On Thursday, July 10, 2014 12:54:03 PM UTC+2, Ian W. Scott wrote:
>>
>> Yes, it's in the browser's console, and it's targeting jquery.js line 3.
>>
>> On Thursday, July 10, 2014 6:02:18 AM UTC-4, Niphlod wrote:
>>>
>>> do this come up in the browser's console ? if yes, what line do they 
>>> target of what js file ?
>>>
>>> On Wednesday, July 9, 2014 11:57:39 PM UTC+2, Ian W. Scott wrote:

 Some ajax links that used to work have just broken and I'm not sure 
 where to start in debugging. The links target a load component on the page 
 (using cid) and they have started throwing this error:

 Syntax error, unrecognized expression: 
> /paideia/plugin_listandedit/edit.load/word_forms/546?orderby=id&tablename=word_forms


 The "unrecognized expression" is simply the url from the link. I've 
 tried re-downloading the web2py source and updating web2py.js but neither 
 seems to help. The only thing I've done that could have broken it is 
 update 
 to bootstrap3 using the package put together by Paolo Caruccio. But I 
 don't 
 know enough about web2py.js to guess where a conflict might lie. 

 Any suggestions? 

>>>

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


[web2py] Re: Broken ajax links giving "unrecognized expression" error

2014-07-10 Thread Niphlod
can you pack a minimal app to reproduce the issue ?

On Thursday, July 10, 2014 12:54:03 PM UTC+2, Ian W. Scott wrote:
>
> Yes, it's in the browser's console, and it's targeting jquery.js line 3.
>
> On Thursday, July 10, 2014 6:02:18 AM UTC-4, Niphlod wrote:
>>
>> do this come up in the browser's console ? if yes, what line do they 
>> target of what js file ?
>>
>> On Wednesday, July 9, 2014 11:57:39 PM UTC+2, Ian W. Scott wrote:
>>>
>>> Some ajax links that used to work have just broken and I'm not sure 
>>> where to start in debugging. The links target a load component on the page 
>>> (using cid) and they have started throwing this error:
>>>
>>> Syntax error, unrecognized expression: 
 /paideia/plugin_listandedit/edit.load/word_forms/546?orderby=id&tablename=word_forms
>>>
>>>
>>> The "unrecognized expression" is simply the url from the link. I've 
>>> tried re-downloading the web2py source and updating web2py.js but neither 
>>> seems to help. The only thing I've done that could have broken it is update 
>>> to bootstrap3 using the package put together by Paolo Caruccio. But I don't 
>>> know enough about web2py.js to guess where a conflict might lie. 
>>>
>>> Any suggestions? 
>>>
>>

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


Re: [web2py] Re: Virtual Fields in auth_user?

2014-07-10 Thread Fabiano Almeida
Hi Massimo,

I tried this:

auth.settings.extra_fields['auth_user']= [
...
Field('dept_grid', compute = lambda row:
Departamento[row['departamento_id']].nome if row['departamento_id'] else
None, label = 'Departamento'),
Field.Virtual('dept_name', lambda row:
Departamento[row.departamento_id].nome if row.departamento_id else None,
label = 'Departamento')]

The compute field work, the virtual field does not work. And the error by
calling the table in SQLFORM.grid:

AttributeError: 'Row' object has no attribute 'dept_name'


Can I use virtual field to display information from another table?

Thanks,

Fabiano.


2014-07-10 3:55 GMT-03:00 Massimo Di Pierro :

> auth.settings.extra_fields['auth_user'] = [Field.Virtual(), ... ]
>
>
> On Wednesday, 9 July 2014 13:14:14 UTC-5, Fabiano Almeida wrote:
>>
>> Hi again,
>>
>> It's possible insert virtual field in auth_user? how?
>>
>> thanks,
>>
>> Fabiano.
>>
>  --
> 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.
>

-- 
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: show_if belongs condition.second is set()

2014-07-10 Thread villas
Just found this bug too,  but coincidentally now see that a fix was 
committed only this morning in trunk.

I updated and now all OK.   

Thanks to sunny and others for reporting and fixing!



On Tuesday, 3 June 2014 15:41:13 UTC+1, sunny wrote:
>
> The following show_if condition gives me an "Not Implemented Error":
> auth_table_user.position.show_if = 
> auth_table_user.employee_type.belongs(('employee', 'external'))
>
> I fixed it for me, with the following change in sqlhtml.py 
> if cond.op.__name__ == 'BELONGS' and 
> isinstance(cond.second,(list,tuple)):
> to
> if cond.op.__name__ == 'BELONGS' and 
> isinstance(cond.second,(set,list,tuple)):
>
> Is this a bug, or is there a different notation for belongs?
> I tried 
> belongs('employee', 'external')
> belongs(('employee', 'external'))
> belongs(['employee', 'external'])
> cond.second is always a Set.
>

-- 
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: Broken ajax links in component

2014-07-10 Thread Ian W. Scott
I'm not running jquery 1.9. It's version 1.10.2. But I can try 1.11 and see 
what happens.

On Thursday, July 10, 2014 6:32:27 AM UTC-4, Leonel Câmara wrote:
>
> Have you tried updating jquery to 1.11 this seems like a known jquery 1.9 
> bug.
>

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


[web2py] Re: Broken ajax links in component

2014-07-10 Thread Ian W. Scott
Sorry for the double post of this question. My original post took several 
hours to appear, so I thought it hadn't gone through.

On Wednesday, July 9, 2014 3:31:33 PM UTC-4, Ian W. Scott wrote:
>
> I'm in the process of upgrading a site from bs2 to bs3 and I've run into 
> an unexpected (and possibly unrelated?) error. On one page I have links in 
> one component that are supposed to update another component. The links are 
> now broken and raise an error:
>
> Syntax error, unrecognized expression: 
>> /paideia/plugin_listandedit/edit.load/plugin_slider_decks/74?orderby=id&tablename=plugin_slider_decks
>>
>
> The "unrecognized expression" is simply the url that is supposed to be 
> loaded in the other component. The link that triggers this error looks like 
> this:
>
> > data-w2p_disable_with="default" data-w2p_method="GET" 
>> data-w2p_target="viewpane" 
>> href="/paideia/plugin_listandedit/edit.load/plugin_slider_decks/76?orderby=id&tablename=plugin_slider_decks">Asking
>>  
>> 'When' Questions 
>>
>
> So far I've tried updating the web2py.js file to the latest github 
> version, but that didn't change anything. I'm really mystified! 
>

-- 
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: Broken ajax links giving "unrecognized expression" error

2014-07-10 Thread Ian W. Scott
Yes, it's in the browser's console, and it's targeting jquery.js line 3.

On Thursday, July 10, 2014 6:02:18 AM UTC-4, Niphlod wrote:
>
> do this come up in the browser's console ? if yes, what line do they 
> target of what js file ?
>
> On Wednesday, July 9, 2014 11:57:39 PM UTC+2, Ian W. Scott wrote:
>>
>> Some ajax links that used to work have just broken and I'm not sure where 
>> to start in debugging. The links target a load component on the page (using 
>> cid) and they have started throwing this error:
>>
>> Syntax error, unrecognized expression: 
>>> /paideia/plugin_listandedit/edit.load/word_forms/546?orderby=id&tablename=word_forms
>>
>>
>> The "unrecognized expression" is simply the url from the link. I've tried 
>> re-downloading the web2py source and updating web2py.js but neither seems 
>> to help. The only thing I've done that could have broken it is update to 
>> bootstrap3 using the package put together by Paolo Caruccio. But I don't 
>> know enough about web2py.js to guess where a conflict might lie. 
>>
>> Any suggestions? 
>>
>

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


[web2py] Re: Broken ajax links in component

2014-07-10 Thread Leonel Câmara
Have you tried updating jquery 1.11 this seems like a known jquery 1.9 bug.

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


[web2py] Re: DAL Bug?

2014-07-10 Thread Leonel Câmara
But lyn2pi that's what the delete is doing (marking them inactive), my only 
peeve is with the count returned from the delete which in my opinion should 
be the number of rows marked inactive.

-- 
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: Broken ajax links giving "unrecognized expression" error

2014-07-10 Thread Niphlod
do this come up in the browser's console ? if yes, what line do they target 
of what js file ?

On Wednesday, July 9, 2014 11:57:39 PM UTC+2, Ian W. Scott wrote:
>
> Some ajax links that used to work have just broken and I'm not sure where 
> to start in debugging. The links target a load component on the page (using 
> cid) and they have started throwing this error:
>
> Syntax error, unrecognized expression: 
>> /paideia/plugin_listandedit/edit.load/word_forms/546?orderby=id&tablename=word_forms
>
>
> The "unrecognized expression" is simply the url from the link. I've tried 
> re-downloading the web2py source and updating web2py.js but neither seems 
> to help. The only thing I've done that could have broken it is update to 
> bootstrap3 using the package put together by Paolo Caruccio. But I don't 
> know enough about web2py.js to guess where a conflict might lie. 
>
> Any suggestions? 
>

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


[web2py] Re: How to create object of 'Storage' In class I created?

2014-07-10 Thread Niphlod
from gluon.storage import Storage


mydict = dict(a=1,b=1)
print mydict['a']
print mydict.a --> exception
mydict = Storage(mydict)
print mydict['a']
print mydict.a --> no exception




On Thursday, July 10, 2014 4:23:41 AM UTC+2, Omri Levy wrote:
>
> Hi ,
>
> I have created a class (that i put in models folder), and all it methods 
> returns complicated dictionaries.
> When I try to access these variables like Storage (foo.bar) I get the 
> following exception: 'dict' object has no attribute
>  I thought that all dictionaries are being converted automatically into 
> Storage, but i guess they don't.
> I've tried to wrap the return value with Storage constructor but then I 
> get an exception saying that there is no such thing as Storage.
>
> Can someone please enlighten me?
>
> Thanks ,
>
> Omri.
>

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