[web2py] fadeOut response.flash

2012-12-20 Thread Johann Spies
When I log in the flash telling me that I am logged in does not timeout
until I close it.

I want it to fade out after a period - say two seconds.  I have no clarity
on how to change this behaviour in web2py.js.

How do get the flash to fade out and set the timeout?

Regards
Johann

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

-- 





Re: [web2py] Re: No module named plural_rules, end emtpy db in DAL connection

2012-12-20 Thread Kostas M
The same warning appears:

In [1]: from gluon.dal import DAL,Field
WARNING:root:Unable to import plural rules: No module named plural_rules


>>
>>
>>

-- 





[web2py] widgets.checkboxes.widget INPUT inside LABLE

2012-12-20 Thread KMax
Hello,

  Using this widget=SQLFORM.widgets.checkboxes.widget for list of values 
gives the following html code:


Option1


Option2

While if INPUT reside inside LABLE it looks better (imho)

  Option1
 


  Option2


Same time this change might broke some compatibility. Maybe this behavior 
was made for some reason.
Community, please share your opinion.

Thanks,

-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2012-12-20 Thread Niphlod
perfect, Ccing Massimo on this final one.

Il giorno giovedì 20 dicembre 2012 00:16:25 UTC+1, Paolo ha scritto:
>
> Hi
> I was trying with the script that comes with the stable web2py. with the 
> one on dropbox I problem has gone. 
>
> Paolo 
>
>
> 2012/12/19 Niphlod >
>
>>
>> @Simone, an other improvement to the script could be to combine into a 
>>> single server the 80, and 443 to avoid duplicating configuration, as stated 
>>> here :
>>> http://nginx.org/en/docs/http/**configuring_https_servers.**
>>> html#single_http_https_server
>>> I don't had test this.
>>>
>>> Also, here the code for permanent redirection 
>>> server {
>>>   server_name $hostname;
>>>   listen  80;
>>>   return 301 http*s*://$hostname$request_uri; # NOTE: I am not sure for 
>>> $hostname here, because I didn't set hostname for my VM until now, as in 
>>> the example (URL below) we can use domainName.com instead if properly 
>>> configure in nginx
>>> ...
>>> }
>>>
>>>
>> People may want separate configs for http and https. The script objective 
>> is to have a working copy of web2py. If we start to follow such requests, 
>> we'd end up installing postgresql and redis too :P 
>>
>> @Paolo: try the script found at the dropbox link. If the same error 
>> happens I think we need the log of pip and a hand by Roberto on the 
>> specific error...
>>  
>> -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
>  Paolo
>  

-- 





[web2py] Re: web3py?

2012-12-20 Thread Arnon Marcus
Cool (!)

Do the HTML helpers support HTML5's " data-* " attributes?
Can that be used for javascriupt frameworks like Knockout.js or Angular.js ?

-- 





[web2py] ABS function inside DAL query

2012-12-20 Thread Pradeeshnarayan
In my web2py DAL query I want to calculate the absolute minimum value of a 
field. 

I am trying to convert this sql query to DAL (mysql database)
select MIN(ABS(field2)) from tbl_table where field1='abc';

I have tried like below, but not correct
result = 
db(db.tbl_table.field1==value).select(ABS(db.tbl_table.field2).min())

I would greatly appreciate any suggestions.


-- 





[web2py] how to decorate a function without using auth?

2012-12-20 Thread António Ramos
hello i have a function to be acessed only by users with an extra field F1
set to "F"

how to protect this function to not be used bu everyone?

what is the best way?

thank you
António

-- 





Re: [web2py] Re: help please

2012-12-20 Thread Aurelijus
yeah.. backup backup backup.. it's just that sometimes you forget to :(

Would it be wise to add some backup module to web2py admin? It could
default to 1 copy per day or smthing simillar. It would especially serve
Noobs :)


On Thu, Dec 20, 2012 at 12:27 AM, Derek  wrote:

> The data is gone. Let this be a reminder to all of you out there, back up
> your data and back it up often. Also, it's not backed up if you can't
> restore it, so test out restores as well.
>
>
> On Wednesday, December 19, 2012 9:08:47 AM UTC-7, LightDot wrote:
>>
>> First, make a couple of physical copies of the database and do not write
>> into it anymore. Then, working on a copy, you could try restoring /
>> extracting the data by using forensic tools, etc.
>>
>> I'm not aware of a straightforward sqlite restore tool, but there might
>> be one or two out there... I'm sure you're not the first to have such an
>> issue.
>>
>> I guess it comes down to the question of is it worth the time and effort.
>>
>> Regards,
>> Ales
>>
>>
>> On Wednesday, December 19, 2012 4:54:50 PM UTC+1, Aurelijus Useckas wrote:
>>>
>>> Yeah I know.. I have an old backup only :( me bad
>>>
>>>
>>> On Wed, Dec 19, 2012 at 5:51 PM, Mark  wrote:
>>>
 Do you have any kind of backup files for the database? Or, do your
 server/computer backup daily or weekly? If there are any backup files, you
 can restore the deleted data easily.

 Mark


 On Wednesday, December 19, 2012 8:21:27 AM UTC-5, Aurelijus Useckas
 wrote:
>
> I've deleted user information from auth_users and suddenly all my data
> (from other table views) disapears.. Yes, other tables are linked to this
> one. Specifically for info on updates and simillar...
>
> If I restore the same data in auth_users other table still doesn't
> show anything... I event reset the autoincrement and make it appear 
> totally
> identical.. still nothing :(
>
> did i mess up??? :(
>
  --




>>>
>>>  --
>
>
>
>

-- 





[web2py] Beware auth.enable_record_versioning

2012-12-20 Thread Cliff Kachinske
I just discovered that auth.enable_record_versioning will create archive 
tables for the archive tables if turned off and turned back on.

Not acceptable.

-- 





[web2py] Re: fadeOut response.flash

2012-12-20 Thread Paolo Caruccio
Maybe you'll find this 
discussion
 useful.


Il giorno giovedì 20 dicembre 2012 09:36:25 UTC+1, Johann Spies ha scritto:
>
> When I log in the flash telling me that I am logged in does not timeout 
> until I close it.
>
> I want it to fade out after a period - say two seconds.  I have no clarity 
> on how to change this behaviour in web2py.js.
>
> How do get the flash to fade out and set the timeout?
>
> Regards
> Johann
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>

-- 





Re: [web2py] Re: web2py 2.3.2 added "+ -" to some form elements

2012-12-20 Thread Daniele
Hmm I'm not sure how to open a ticket in google...sorry ~_~



On Dec 20, 2012, at 6:48 AM, howesc  wrote:

> ooops.  i added the - and didn't test the "only 1 row case".  i'll try and 
> create a patch tomorrow for it.
> 
> mind opening a ticket in google code?
> 
> thanks,
> 
> christian
> 
> On Tuesday, December 18, 2012 8:17:11 AM UTC-8, Daniele wrote:
>> 
>> The newest version of web2py has added some + and - clickable links to form 
>> elements so that it is possible to remove the element. However, if there is 
>> only one element and one clicks the "-", the form disappears and there's no 
>> way to get the form element back without refreshing the page.
>> 
>> I'll post an image so that you can see what it looks like.
>> 
>> I think this is a bug with the newest version because my code hasn't changed 
>> at all. There was only a "+" before...
> -- 
>  
>  
>  

-- 





Re: [web2py] Re: web2py 2.3.2 added "+ -" to some form elements

2012-12-20 Thread Paolo Caruccio
http://code.google.com/p/web2py/issues/list

Il giorno giovedì 20 dicembre 2012 15:31:56 UTC+1, Daniele ha scritto:
>
> Hmm I'm not sure how to open a ticket in google...sorry ~_~
>
>
>
> On Dec 20, 2012, at 6:48 AM, howesc > 
> wrote:
>
> ooops.  i added the - and didn't test the "only 1 row case".  i'll try and 
> create a patch tomorrow for it.
>
> mind opening a ticket in google code?
>
> thanks,
>
> christian
>
> On Tuesday, December 18, 2012 8:17:11 AM UTC-8, Daniele wrote:
>>
>> The newest version of web2py has added some + and - clickable links to 
>> form elements so that it is possible to remove the element. However, if 
>> there is only one element and one clicks the "-", the form disappears and 
>> there's no way to get the form element back without refreshing the page.
>>
>> I'll post an image so that you can see what it looks like.
>>
>> I think this is a bug with the newest version because my code hasn't 
>> changed at all. There was only a "+" before...
>>
>  -- 
>  
>  
>  
>
>

-- 





[web2py] Re: fadeOut response.flash

2012-12-20 Thread weheh
Look at the js named "web2py.js" which comes with the scaffolding. The 
flash function does not fadeout after time. You can add a function to this 
file (or modify the flash function) to timeout and fadeOut your flash as 
you choose.

On Thursday, December 20, 2012 4:36:25 PM UTC+8, Johann Spies wrote:
>
> When I log in the flash telling me that I am logged in does not timeout 
> until I close it.
>
> I want it to fade out after a period - say two seconds.  I have no clarity 
> on how to change this behaviour in web2py.js.
>
> How do get the flash to fade out and set the timeout?
>
> Regards
> Johann
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>

-- 





Re: [web2py] Re: No module named plural_rules, end emtpy db in DAL connection

2012-12-20 Thread Massimo Di Pierro
I will check this. Anyway, the warning is not a problem. It is just trying 
to import some pluralization libraries and does not find them in path. They 
are not used by the DAL anyway.

On Thursday, 20 December 2012 02:52:17 UTC-6, Kostas M wrote:
>
> The same warning appears:
>
> In [1]: from gluon.dal import DAL,Field
> WARNING:root:Unable to import plural rules: No module named plural_rules
>
>
>>>
>>>
>>>

-- 





[web2py] Re: widgets.checkboxes.widget INPUT inside LABLE

2012-12-20 Thread Massimo Di Pierro
I am not convinced this is the right fix. Does bootstrap suggest this? I do 
not think the input should be in the label. Perhaps there is an alternative 
fix using css?

On Thursday, 20 December 2012 03:08:01 UTC-6, KMax wrote:
>
> Hello,
>
>   Using this widget=SQLFORM.widgets.checkboxes.widget for list of values 
> gives the following html code:
>
> 
> Option1
>
> 
> Option2
>
> While if INPUT reside inside LABLE it looks better (imho)
> 
>   Option1
>  
>
> 
>   Option2
> 
>
> Same time this change might broke some compatibility. Maybe this behavior 
> was made for some reason.
> Community, please share your opinion.
>
> Thanks,
>
>

-- 





Re: [web2py] Re: new setup-web2py-nginx-uwsgi-ubuntu.sh

2012-12-20 Thread Massimo Di Pierro
please email me the patch of latest file when ready for inclusion.

On Thursday, 20 December 2012 03:18:20 UTC-6, Niphlod wrote:
>
> perfect, Ccing Massimo on this final one.
>
> Il giorno giovedì 20 dicembre 2012 00:16:25 UTC+1, Paolo ha scritto:
>>
>> Hi
>> I was trying with the script that comes with the stable web2py. with the 
>> one on dropbox I problem has gone. 
>>
>> Paolo 
>>
>>
>> 2012/12/19 Niphlod 
>>
>>>
>>> @Simone, an other improvement to the script could be to combine into a 
 single server the 80, and 443 to avoid duplicating configuration, as 
 stated 
 here :
 http://nginx.org/en/docs/http/**configuring_https_servers.**
 html#single_http_https_server
 I don't had test this.

 Also, here the code for permanent redirection 
 server {
   server_name $hostname;
   listen  80;
   return 301 http*s*://$hostname$request_uri; # NOTE: I am not sure 
 for $hostname here, because I didn't set hostname for my VM until now, as 
 in the example (URL below) we can use domainName.com instead if properly 
 configure in nginx
 ...
 }


>>> People may want separate configs for http and https. The script 
>>> objective is to have a working copy of web2py. If we start to follow such 
>>> requests, we'd end up installing postgresql and redis too :P 
>>>
>>> @Paolo: try the script found at the dropbox link. If the same error 
>>> happens I think we need the log of pip and a hand by Roberto on the 
>>> specific error...
>>>  
>>> -- 
>>>  
>>>  
>>>  
>>>
>>
>>
>>
>> -- 
>>  Paolo
>>  
>

-- 





[web2py] Re: web3py?

2012-12-20 Thread Massimo Di Pierro
They always did although the syntax is cumbersone

DIV('content',**{'data-something':'something value'})

On Thursday, 20 December 2012 04:16:54 UTC-6, Arnon Marcus wrote:
>
> Cool (!)
>
> Do the HTML helpers support HTML5's " data-* " attributes?
> Can that be used for javascriupt frameworks like Knockout.js or Angular.js 
> ?
>

-- 





[web2py] Re: ABS function inside DAL query

2012-12-20 Thread Massimo Di Pierro
OK. Ib trunk now:

db().select(db.tbl_table.field2.abs().min())


On Thursday, 20 December 2012 05:20:15 UTC-6, Pradeeshnarayan wrote:
>
> In my web2py DAL query I want to calculate the absolute minimum value of a 
> field. 
>
> I am trying to convert this sql query to DAL (mysql database)
> select MIN(ABS(field2)) from tbl_table where field1='abc';
>
> I have tried like below, but not correct
> result = 
> db(db.tbl_table.field1==value).select(ABS(db.tbl_table.field2).min())
>
> I would greatly appreciate any suggestions.
>
>
>

-- 





[web2py] Re: how to decorate a function without using auth?

2012-12-20 Thread Massimo Di Pierro
@requires(auth.user.F1=='F')
def yourfunction(...): 

On Thursday, 20 December 2012 06:40:09 UTC-6, Ramos wrote:
>
> hello i have a function to be acessed only by users with an extra field F1 
> set to "F"
>
> how to protect this function to not be used bu everyone?
>
> what is the best way?
>
> thank you
> António
>

-- 





[web2py] Re: Beware auth.enable_record_versioning

2012-12-20 Thread Massimo Di Pierro
I do not understand. Can you explain?

On Thursday, 20 December 2012 08:11:42 UTC-6, Cliff Kachinske wrote:
>
> I just discovered that auth.enable_record_versioning will create archive 
> tables for the archive tables if turned off and turned back on.
>
> Not acceptable.
>

-- 





[web2py] Re: web2py 2.3.2 added "+ -" to some form elements

2012-12-20 Thread Massimo Di Pierro
For now I have remove the "-" button.

On Wednesday, 19 December 2012 23:48:37 UTC-6, howesc wrote:
>
> ooops.  i added the - and didn't test the "only 1 row case".  i'll try and 
> create a patch tomorrow for it.
>
> mind opening a ticket in google code?
>
> thanks,
>
> christian
>
> On Tuesday, December 18, 2012 8:17:11 AM UTC-8, Daniele wrote:
>>
>> The newest version of web2py has added some + and - clickable links to 
>> form elements so that it is possible to remove the element. However, if 
>> there is only one element and one clicks the "-", the form disappears and 
>> there's no way to get the form element back without refreshing the page.
>>
>> I'll post an image so that you can see what it looks like.
>>
>> I think this is a bug with the newest version because my code hasn't 
>> changed at all. There was only a "+" before...
>>
>

-- 





Re: [web2py] Re: The book updates and status

2012-12-20 Thread Johann Spies
On 19 December 2012 19:11, Massimo Di Pierro wrote:

> It would help me if people could add to this thread some comments about:
>

- what needs clarification?
>

The request I mentioned in an earlier message (
https://groups.google.com/forum/?fromgroups=#!searchin/web2py/johann$20spies/web2py/s2tn5S_1la4/0inWrg4z14YJ
)


I repeat it here:

Can somebody please update the book's documentation about the grid. All the
arguments for using the grid are not covered in the book. There is no
documentation in the code for the grid options either.

e.g.  What is the content of  the dicts createargs, viewargs, editargs
supposed to be?

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

-- 





[web2py] Re: web3py?

2012-12-20 Thread Niphlod
correction, the _ in front is needed as always  
DIV('content',**{'_data-something':'something value'})

Il giorno giovedì 20 dicembre 2012 15:58:25 UTC+1, Massimo Di Pierro ha 
scritto:
>
> They always did although the syntax is cumbersone
>
> DIV('content',**{'data-something':'something value'})
>
> On Thursday, 20 December 2012 04:16:54 UTC-6, Arnon Marcus wrote:
>>
>> Cool (!)
>>
>> Do the HTML helpers support HTML5's " data-* " attributes?
>> Can that be used for javascriupt frameworks like Knockout.js or 
>> Angular.js ?
>>
>

-- 





[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-20 Thread Massimo Di Pierro
Sorry I do not have a good solution at the moment. Can you open a ticket 
about this so we'll will not forget. For now you may want to consider 
creating a database view and selecting from the view. You would need to 
create a model (readonly) to access the view.

On Wednesday, 19 December 2012 16:19:33 UTC-6, Mamisoa Andriantafika wrote:
>
> Best results to UNION I could have was using the mutex table trick:
> http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/
> with this syntax:
>
> exams_mutex = db().select(db.dataset1.ALL, db.dataset2.ALL, 
> left=[db.dataset1.on(db.mutex.i==0),db.dataset2.on(db.mutex.i==1)])
>
> Two problems left:
>
> 1- how to merge the 2 date columns
> 2- how to order then by date
>
> SQL answer is there:
>
> http://stackoverflow.com/questions/8245630/mysql-combine-two-date-fields-and-then-order-by
>
> SELECT
> [some info],
> GREATEST( ticket_date, ticket_history_date ) as latest_date
> FROM
> [tables and join]
> ORDER BY
> latest_date
>
>
> Is is possible using to process it using DAL?
>
> Le dimanche 16 décembre 2012 17:40:22 UTC+1, Mamisoa Andriantafika a 
> écrit :
>>
>> Sorry I still get: "Cannot | incompatible Rows objects".
>>
>> I'll change the field name "date" you are very right.
>>
>> Le dimanche 16 décembre 2012 15:49:57 UTC+1, Massimo Di Pierro a écrit :
>>>
>>> My bad. Thry this:
>>>
>>> fields1 = [db.dataset1.date, db.dataset1.param1, db.dateset1.patient_id]
>>> fields2 = [db.dataset2.date, db.dataset2.test1, db.dateset2.patient_id]
>>> rows = ( db(db.dataset1).select(*fields1) | 
>>> db(db.dataset2).select(*fields2) ).sort(lambda row: row.date)
>>>
>>> Mind that having a column called "date" will result in major headaches 
>>> in the future.
>>>
>>> On Sunday, 16 December 2012 03:15:46 UTC-6, Mamisoa Andriantafika wrote:

 Hi again,

 "|" seems not to work because the column numbers is different between 
 the 2 tables?


 Le samedi 15 décembre 2012 20:23:44 UTC+1, Massimo Di Pierro a écrit :
>
> If you have lots of records you may be able to do it with a database 
> view but that may be db specific.
>
> If you don't have too many records you can do:
>
> rows = ( db(db.dataset1).select() | db(db.dataset2).select() 
> ).sort(lambda row: row.date)
>
>
>
> On Saturday, 15 December 2012 08:43:35 UTC-6, Mamisoa Andriantafika 
> wrote:
>>
>> Hi,
>>
>> I have this db model:
>>
>> db.define_table('patients',
>> Field('name', 'string', length=32),
>> Field('firstname', 'string', length=32),
>> Field('dob', 'date'),
>> format='%(name)s')
>>
>> db.define_table('dataset1',
>> Field('date', 'date', length=32),
>> Field('param1', 'string', length=50),
>> Field('param2', 'string', length=50),
>> Field('patient_id', db.patients, writable=False, readable=False))
>>
>> db.define_table('dataset2',
>> Field('date', 'date', notnull=True),
>> Field('test1', 'text'),
>> Field('patient_id', db.patients, writable=False, readable=True))
>>
>> I'd like to show in one view, for 1 patient_id, all the corresponding 
>> dataset1 and dataset2 ordered by date.
>>
>> What query should I use? Do I have to use an intermediate table 
>> 'history' to record each activity in dataset1/2 to get a result?
>>
>> Thanks for help.
>>
>

-- 





[web2py] Re: upload from Edit page

2012-12-20 Thread Massimo Di Pierro
Can you explain what you are trying to accomplish and what your models are? 
I do not understand from the code.

On Tuesday, 18 December 2012 13:51:12 UTC-6, ArNew wrote:
>
> Hi Everyone,
>
> I need help urgently.
>
> In my application, I am have included upload fields in Create and edit 
> page. Through create page, it was very straight forward with:
> {{=form.custom.widget.attachment}} (View)
> Field('attachment','upload',uploadfolder=os.path.join(request.folder, 
> 'attachments')) (DAL). 
> if form.vars.attachment:
> form.vars.attachment_name = 
> request.vars.attachment.filename
> id = 
> thisdb.service_attachments.insert(**thisdb.service_attachments._filter_fields(form.vars))
>  
> .(Controller) And this works great.
>
> That with Edit page is not the same, as it is not about editing the 
> current image, but uploading more attachments. So I tried doing something 
> like this:
>
>  name="attachment" type="file" /> (view)
> if request.vars.attachment != '':
> form.vars.attachment = request.vars.attachment.file
> filename = request.vars.attachment.filename
> form.vars.attachment_name = filename
> id = 
> thisdb.service_attachments.insert(**thisdb.service_attachments._filter_fields(form.vars))
> This follows the very similar procedure of saving the encrypted version of 
> attachment name in the attachment field, but it changes the extension to 
> .txt for all the attachments. It saves the attachment as 
> service_attachments.attachment.b19d4ef38978e8e6.746d707437756c626f.txt 
> where as the orginal attachment is photo.JPG. So ideall it should save it 
> as  service_attachments.attachment.b19d4ef38978e8e6.746d707437756c626f.JPG. 
>
> Can anyone please help me with this?
>
>
>
>
>
>

-- 





[web2py] Re: Login manually

2012-12-20 Thread Massimo Di Pierro
If your data is not confidential, any chance you send me your application?

To me this looks like corrupted data in database as if the password field 
was at some pointed treated as type='list:string' and than changed back to 
type='password'. Is it possible?

Massimo

On Wednesday, 19 December 2012 11:28:15 UTC-6, Wonton wrote:
>
> Yes, of course. This is my ticket:
>
> Error ticket for "dianaappv1" Ticket ID 
>
> 127.0.0.1.2012-12-19.18-24-12.5d2b292c-7e9a-4281-a9f7-bb9aa17bbd0c
>  unsupported hash type 
> |pbkdf2(1000,20,sha512) Versión  web2py™ (2, 2, 1, 
> datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable')  Python Python 
> 2.7.1: /usr/bin/python  Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
> 28.
>
> Traceback (most recent call last):
>   File "/Applications/web2py/gluon/restricted.py", line 212, in restricted
> exec ccode in environment
>   File "/Applications/web2py/applications/dianaappv1/controllers/default.py" 
> ,
>  line 101, in 
>   File "/Applications/web2py/gluon/globals.py", line 188, in 
> self._caller = lambda f: f()
>   File "/Applications/web2py/applications/dianaappv1/controllers/default.py" 
> ,
>  line 27, in public_call
> return servicios_publicos()
>   File "/Applications/web2py/gluon/tools.py", line 4387, in __call__
> return self.serve_json(request.args[1:])
>   File "/Applications/web2py/gluon/tools.py", line 4197, in serve_json
> s = universal_caller(self.json_procedures[args[0]], *args[1:], **d)
>   File "/Applications/web2py/gluon/tools.py", line 3889, in universal_caller
> return f(**arg_dict)
>   File "/Applications/web2py/applications/dianaappv1/controllers/default.py" 
> ,
>  line 65, in login
> user = auth.login_bare(usuario, password)
>   File "/Applications/web2py/gluon/tools.py", line 1789, in login_bare
> if not user.registration_key and password == user[passfield]:
>   File "/Applications/web2py/gluon/validators.py", line 2636, in __eq__
> h = simple_hash(self.password, key, salt, digest_alg)
>   File "/Applications/web2py/gluon/utils.py", line 74, in simple_hash
> h = hashlib.new(digest_alg)
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py",
>  line 121, in __hash_new
> return __get_builtin_constructor(name)(string)
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py",
>  line 88, in __get_builtin_constructor
> raise ValueError('unsupported hash type %s' % name)
> ValueError: unsupported hash type |pbkdf2(1000,20,sha512)
>
>  Error snapshot [image: help]  
>
> (unsupported hash type 
> |pbkdf2(1000,20,sha512)) 
>
> inspect attributes 
>  Frames 
>
>-  
>
>*File /Applications/web2py/gluon/restricted.py in restricted at line 
>212* código argumentos variables 
> -  
>
>*File 
>/Applications/web2py/applications/dianaappv1/controllers/default.py in 
> at line 101* código argumentos variables 
> -  
>
>*File /Applications/web2py/gluon/globals.py in  at line 188* 
>código argumentos variables 
> -  
>
>*File 
>/Applications/web2py/applications/dianaappv1/controllers/default.py in 
>public_call at line 27* código argumentos variables 
> -  
>
>*File /Applications/web2py/gluon/tools.py in __call__ at line 4387* 
>código argumentos variables 
> -  
>
>*File /Applications/web2py/gluon/tools.py in serve_json at line 4197* 
>código argumentos variables 
> -  
>
>*File /Applications/web2py/gluon/tools.py in universal_caller at line 
>3889* código argumentos variables 
> -  
>
>*File 
>/Applications/web2py/applications/dianaappv1/controllers/default.py in 
>login at line 65* código argumentos variables 
> -  
>
>*File /Applications/web2py/gluon/tools.py in login_bare at line 1789* 
>código argumentos variables 
> -  
>
>*File /Applications/web2py/gluon/validators.py in __eq__ at line 2636* 
>código argumentos variables 
> -  
>
>*File /Applications/web2py/gluon/utils.py in simple_hash at line 74* 
>código argumentos variables 
> -  
>
>*File 
>
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py
>  
>in __hash_new at line 121* código argumentos variables 
> -  
>
>*File 
>
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py
>  
>in __get_builtin_constructor at line 88* código argumentos variables 
> Function argument list 
>
>(name='|pbkdf2(1000,20,sha512)')
> Code listing 
>
>83.

Re: [web2py] Re: The book updates and status

2012-12-20 Thread Massimo Di Pierro
Niphlod just did. We are working on merging the edits. It will be done 
today, together with lots of other edits.


On Thursday, 20 December 2012 00:43:49 UTC-6, Johann Spies wrote:
>
> On 19 December 2012 19:11, Massimo Di Pierro 
> 
> > wrote:
>
>> It would help me if people could add to this thread some comments about:
>>  
>
> - what needs clarification?
>>
>
> The request I mentioned in an earlier message (
> https://groups.google.com/forum/?fromgroups=#!searchin/web2py/johann$20spies/web2py/s2tn5S_1la4/0inWrg4z14YJ
> )
>
>
> I repeat it here:
>
> Can somebody please update the book's documentation about the grid. All 
> the arguments for using the grid are not covered in the book. There is no 
> documentation in the code for the grid options either.
>
> e.g.  What is the content of  the dicts createargs, viewargs, editargs 
> supposed to be?
>
> Regards
> Johann
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>

-- 





[web2py] Re: web3py?

2012-12-20 Thread Massimo Di Pierro
Oops. right. I wish there was a simple syntax but I cannot think about one. 

On Thursday, 20 December 2012 09:07:21 UTC-6, Niphlod wrote:
>
> correction, the _ in front is needed as always  
> DIV('content',**{'_data-something':'something value'})
>
> Il giorno giovedì 20 dicembre 2012 15:58:25 UTC+1, Massimo Di Pierro ha 
> scritto:
>>
>> They always did although the syntax is cumbersone
>>
>> DIV('content',**{'data-something':'something value'})
>>
>> On Thursday, 20 December 2012 04:16:54 UTC-6, Arnon Marcus wrote:
>>>
>>> Cool (!)
>>>
>>> Do the HTML helpers support HTML5's " data-* " attributes?
>>> Can that be used for javascriupt frameworks like Knockout.js or 
>>> Angular.js ?
>>>
>>

-- 





Re: [web2py] Interesting - Brython (python to javascript)

2012-12-20 Thread Massimo Di Pierro
Looks like this is too limited to be useful.

On Monday, 17 December 2012 01:08:41 UTC-6, viniciusban wrote:
>
> Brypthon doesn't support string interpolation, too. :-( 
>
> On Sun, Dec 16, 2012 at 6:40 PM, Arnon Marcus 
> > 
> wrote: 
> > From what I saw, it does not support many fundamental features of 
> python, 
> > like class-inheritance (class, classMethod) modules (__import__, from, 
> as), 
> > scope (globals, nonlocal) and parsing (exec, eval). I think these are 
> > trivial for python developement, and should have some kind of 
> design-pattern 
> > transpiling specification that it follows. 
> > I think CoffeeScript actually has many of these already implemented, as 
> is 
> > quite pythonic already in much of it's syntax - and is much closer to 
> > JavaScript in the first place and already has tons of tools for 
> denugging, 
> > client/server-side automatic-transpiling, bundled up in 
> > minification/compression algorythms, etc... 
> > 
> > It's a cool idea, and pyjammas has existed for a long time now, but is 
> > anyone seriously thinking about using that in production? 
> > 
> > I think as long as browsers don't have some kind of cross-language VMs, 
> or 
> > at least a PVM built-in/plugin, than with all the excitement, it will 
> remain 
> > useless. 
> > I mean, how do you debug this? 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





Re: [web2py] Re: how to decorate a function without using auth?

2012-12-20 Thread António Ramos
extra fields are available in my auth.user var  but they have "None"
instead of the real value

 so i create an extra function


def checkempreiteiro(user):
print auth.user.isempreiteiro  # *returns None*
record=db(db.auth_user.id==user).select()[0]
return record['isempreiteiro'] #*returns True*


@auth.requires_login()
@auth.requires(checkempreiteiro(auth.user_id)==True)




2012/12/20 Massimo Di Pierro 

> @requires(auth.user.F1=='F')
> def yourfunction(...): 
>
>
> On Thursday, 20 December 2012 06:40:09 UTC-6, Ramos wrote:
>>
>> hello i have a function to be acessed only by users with an extra field
>> F1 set to "F"
>>
>> how to protect this function to not be used bu everyone?
>>
>> what is the best way?
>>
>> thank you
>> António
>>
>  --
>
>
>
>

-- 





[web2py] Re: how to decorate a function without using auth?

2012-12-20 Thread Anthony
Note, should be @auth.requires(...).

Anthony

On Thursday, December 20, 2012 10:04:26 AM UTC-5, Massimo Di Pierro wrote:
>
> @requires(auth.user.F1=='F')
> def yourfunction(...): 
>
> On Thursday, 20 December 2012 06:40:09 UTC-6, Ramos wrote:
>>
>> hello i have a function to be acessed only by users with an extra field 
>> F1 set to "F"
>>
>> how to protect this function to not be used bu everyone?
>>
>> what is the best way?
>>
>> thank you
>> António
>>
>

-- 





[web2py] Re: fadeOut response.flash

2012-12-20 Thread Paolo Caruccio
If you are interested you could add this code:

  var flashBox = jQuery(".flash"), flashTimer;
  flashBox.click(function(){
  if (flashTimer) clearTimeout(flashTimer);
  flashBox.fadeOut(400, function(){jQuery(".flash").html('')});
  });
  flashTimer = setTimeout(function(){flashBox.fadeOut(400, function(){jQuery
(".flash").html('')});}, 8000);

inside the function web2py_ajax_init in static/js/web2py.js file (attached 
you'll find modified version for your personal usage. Please beware that it 
is related to the last trunk version of web2py and it could be incompatible 
with the version you are using currently).

By this code the flash message will close after 8 seconds if the user 
doesn't close it before.


Il giorno giovedì 20 dicembre 2012 15:31:38 UTC+1, Paolo Caruccio ha 
scritto:
>
> Maybe you'll find this 
> discussion
>  useful.
>
>
> Il giorno giovedì 20 dicembre 2012 09:36:25 UTC+1, Johann Spies ha scritto:
>>
>> When I log in the flash telling me that I am logged in does not timeout 
>> until I close it.
>>
>> I want it to fade out after a period - say two seconds.  I have no 
>> clarity on how to change this behaviour in web2py.js.
>>
>> How do get the flash to fade out and set the timeout?
>>
>> Regards
>> Johann
>>
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>

-- 





web2py.js
Description: JavaScript source


[web2py] Re: The book updates and status

2012-12-20 Thread Massimo Di Pierro
This is in:
http://web2py.com/books/default/chapter/29/07?search=SQLFORM.grid#SQLFORM.grid-and-SQLFORM.smartgrid
along with tons of other additions. :-)
I hope to make a first pdf draft by the end of next week.

Massimo

On Wednesday, 19 December 2012 20:53:25 UTC-6, Andrew W wrote:
>
> I'm happy to proof read.   Send it through when ready.
>
> Andrew W
>
> On Thursday, December 20, 2012 2:46:41 PM UTC+13, Anthony wrote:
>>
>> On Wednesday, December 19, 2012 5:56:48 PM UTC-5, Massimo Di Pierro wrote:
>>
>>> I have been going over that document. The things in gray were not in the 
>>> published 4th edition but are in the online version. 
>>>
>>
>> Make sure you click the link below -- it's an updated version of the 
>> original document. All the gray items were removed, and some newer items 
>> have been added (though some of them may already be in the book).
>>
>> Anthony
>>
>>  On Wednesday, 19 December 2012 14:15:46 UTC-6, Anthony wrote:
>>
>>> This document is a bit old, so some of the items may already have been 
 added: 
 https://docs.google.com/document/d/1yQy0F5HcxiecBOBLblrLmAAAsAK6sL37wSL527yssGk/edit
>>>
>>>

-- 





Re: [web2py] Re: how to decorate a function without using auth?

2012-12-20 Thread António Ramos
extra fields are available in my auth.user var  but they have "None"
instead of the real value

 so i create an extra function


def checkempreiteiro(user):
print auth.user.isempreiteiro  # *returns None*
record=db(db.auth_user.id==user).select()[0]
return record['isempreiteiro'] #*returns True*


@auth.requires_login()
@auth.requires(checkempreiteiro(auth.user_id)==True)



2012/12/20 Anthony 

> Note, should be @auth.requires(...).
>
> Anthony
>
>
> On Thursday, December 20, 2012 10:04:26 AM UTC-5, Massimo Di Pierro wrote:
>>
>> @requires(auth.user.F1=='F')
>> def yourfunction(...): 
>>
>> On Thursday, 20 December 2012 06:40:09 UTC-6, Ramos wrote:
>>>
>>> hello i have a function to be acessed only by users with an extra field
>>> F1 set to "F"
>>>
>>> how to protect this function to not be used bu everyone?
>>>
>>> what is the best way?
>>>
>>> thank you
>>> António
>>>
>>  --
>
>
>
>

-- 





[web2py] Re: widgets.checkboxes.widget INPUT inside LABLE

2012-12-20 Thread Paolo Caruccio
I think as Massimo said, but  W3C raccomandation on 
forms
 tells:

"To label a control, the label element is used; the label text and the 
control itself go inside the label element."

So KMax request should be acceptable



Il giorno giovedì 20 dicembre 2012 15:57:03 UTC+1, Massimo Di Pierro ha 
scritto:
>
> I am not convinced this is the right fix. Does bootstrap suggest this? I 
> do not think the input should be in the label. Perhaps there is an 
> alternative fix using css?
>
> On Thursday, 20 December 2012 03:08:01 UTC-6, KMax wrote:
>>
>> Hello,
>>
>>   Using this widget=SQLFORM.widgets.checkboxes.widget for list of values 
>> gives the following html code:
>>
>> 
>> Option1
>>
>> 
>> Option2
>>
>> While if INPUT reside inside LABLE it looks better (imho)
>> 
>>   Option1
>>  
>>
>> 
>>   Option2
>> 
>>
>> Same time this change might broke some compatibility. Maybe this behavior 
>> was made for some reason.
>> Community, please share your opinion.
>>
>> Thanks,
>>
>>

-- 





Re: [web2py] Re: how to decorate a function without using auth?

2012-12-20 Thread António Ramos
Now i have 2 problems.
Recap
1 -
print auth.user.isempreiteiro  # *returns None*
record=db(db.auth_user.id==auth.user_id).select()[0]
print  record['isempreiteiro'] #*returns True  "This is the real value"*
Why?

2 -
my decorated function in controller default works ok when user logged in

@auth.requires_login()
*#@auth.requires(checkempreiteiro(auth.user_id)==True) *
def inserttrab():
form = SQLFORM(db.trabalhador)
if form.accepts(request.vars, session):
session.flash = 'registo inserido com sucesso'
redirect(URL())
return dict(form=form)

but gives an error when the user does logout. logging out should redirect
to login page but the line

*#@auth.requires(checkempreiteiro(auth.user_id)==True) *
def inserttrab():
...

give a ticket with the error msg.

 File "C:\web2pyGit\web2py\gluon\dal.py", line 9170, in __getitem__

row = self.records[i]
IndexError: list index out of range



When i browse to index page the same error .Why?






thank you



2012/12/20 António Ramos 

> extra fields are available in my auth.user var  but they have "None"
> instead of the real value
>
>  so i create an extra function
>
>
> def checkempreiteiro(user):
> print auth.user.isempreiteiro  # *returns None*
> record=db(db.auth_user.id==user).select()[0]
> return record['isempreiteiro'] #*returns True*
>
>
> @auth.requires_login()
> @auth.requires(checkempreiteiro(auth.user_id)==True)
>
>
>
> 2012/12/20 Anthony 
>
>> Note, should be @auth.requires(...).
>>
>> Anthony
>>
>>
>> On Thursday, December 20, 2012 10:04:26 AM UTC-5, Massimo Di Pierro wrote:
>>>
>>> @requires(auth.user.F1=='F')
>>> def yourfunction(...): 
>>>
>>> On Thursday, 20 December 2012 06:40:09 UTC-6, Ramos wrote:

 hello i have a function to be acessed only by users with an extra field
 F1 set to "F"

 how to protect this function to not be used bu everyone?

 what is the best way?

 thank you
 António

>>>  --
>>
>>
>>
>>
>
>

-- 





[web2py] SQLFORM in html - Book example

2012-12-20 Thread Fabiano Faver
I tried the book example 
in http://web2py.com/books/default/chapter/29/07#SQLFORM-in-HTML
It's not working. I tried to use to sqlform.process from a html form using 
the way, but did not work. Then I tried exactly the same code on book and 
still did not work.
Its not validating the form, just flashing "fill the form" message.
Am I missing something?

-- 





[web2py] json service

2012-12-20 Thread Manuele Pesenti
trying to expose this simple controller I got the subsequent error... 
does anybody understand why?

the query runs perfectly inserted manually in a ipdb console...

@service.json
def mRender():

#import ipdb; ipdb.set_trace()
query = (db.plugin_lookout_fields.table_id==source_table_id)
res = db(query).select(db.plugin_lookout_fields.field_name, 
limitby=(1, 4, )).as_list()


return res

ERROR:Rocket.Errors.Thread-3:Unhandled Error when serving connection:
Traceback (most recent call last):

  File "/home/manuele/portali/web2py-2.2.1/gluon/rocket.py", line 1318, 
in run

self.run_app(conn)

  File "/home/manuele/portali/web2py-2.2.1/gluon/rocket.py", line 1840, 
in run_app

self.conn.sendall(b('0\r\n\r\n'))

  File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)

error: [Errno 32] Broken pipe

--





Re: [web2py] Re: how to decorate a function without using auth?

2012-12-20 Thread António Ramos
the first problem i solved with loggout then login


2?


2012/12/20 António Ramos 

> Now i have 2 problems.
> Recap
> 1 -
> print auth.user.isempreiteiro  # *returns None*
> record=db(db.auth_user.id==auth.user_id).select()[0]
> print  record['isempreiteiro'] #*returns True  "This is the real
> value"*
> Why?
>
> 2 -
> my decorated function in controller default works ok when user logged in
>
> @auth.requires_login()
> *#@auth.requires(checkempreiteiro(auth.user_id)==True) *
> def inserttrab():
> form = SQLFORM(db.trabalhador)
> if form.accepts(request.vars, session):
> session.flash = 'registo inserido com sucesso'
> redirect(URL())
> return dict(form=form)
>
> but gives an error when the user does logout. logging out should redirect
> to login page but the line
>
> *#@auth.requires(checkempreiteiro(auth.user_id)==True) *
> def inserttrab():
> ...
>
> give a ticket with the error msg.
>
>  File "C:\web2pyGit\web2py\gluon\dal.py", line 9170, in __getitem__
>
>
> row = self.records[i]
>
> IndexError: list index out of range
>
>
>
> When i browse to index page the same error .Why?
>
>
>
>
>
>
> thank you
>
>
>
> 2012/12/20 António Ramos 
>
>> extra fields are available in my auth.user var  but they have "None"
>> instead of the real value
>>
>>  so i create an extra function
>>
>>
>> def checkempreiteiro(user):
>> print auth.user.isempreiteiro  # *returns None*
>> record=db(db.auth_user.id==user).select()[0]
>> return record['isempreiteiro'] #*returns True*
>>
>>
>> @auth.requires_login()
>> @auth.requires(checkempreiteiro(auth.user_id)==True)
>>
>>
>>
>> 2012/12/20 Anthony 
>>
>>> Note, should be @auth.requires(...).
>>>
>>> Anthony
>>>
>>>
>>> On Thursday, December 20, 2012 10:04:26 AM UTC-5, Massimo Di Pierro
>>> wrote:

 @requires(auth.user.F1=='F')
 def yourfunction(...): 

 On Thursday, 20 December 2012 06:40:09 UTC-6, Ramos wrote:
>
> hello i have a function to be acessed only by users with an extra
> field F1 set to "F"
>
> how to protect this function to not be used bu everyone?
>
> what is the best way?
>
> thank you
> António
>
  --
>>>
>>>
>>>
>>>
>>
>>
>

-- 





Re: [web2py] Re: how to hide a field until another field is chosen using SQLFORM.smartgrid

2012-12-20 Thread Jim Kellas
Thanks Jose, that was too easy!

Jim

From:  Jose 
Reply-To:  
Date:  Wednesday, December 19, 2012 4:26 AM
To:  
Subject:  [web2py] Re: how to hide a field until another field is chosen
using SQLFORM.smartgrid



El martes, 11 de diciembre de 2012 21:50:07 UTC-3, JimK  escribió:
> I have a table defined with many columns but some are only relevant if a
> previous one is chosen.  How would I hide a field like this with
> SQLFORM.smartgrid?
> 
> model:
> db.define_table('t_schedule_frat_query',
> Field('f_recurring', type='boolean', notnull=True,
>   label=T('Recurring schedule?'),
> Field('f_schedule_frequency', type='string',
>   label=T('Schedule Frequency'),
> auth.signature,
> format='%(f_query_name)s',
> migrate=True)
> 
> controller:
> def foo():
> form = SQLFORM.smartgrid(db.t_frat_query)
> return locals()
> 
> view:
> default view
> 
> On the webpage, t_schedule_frat_query. f_schedule_frequency should only show
> up if t_schedule_frat_query. f_recurring is checked.  How would I do this?
> 
> 
> Jim

Hi Jim

maybe this [1] will help

Jose

[1] 
http://www.web2py.com/books/default/chapter/29/11#Conditional-fields-in-form
s 
-- 
 
 
 


-- 





Re: [web2py] Re: how to decorate a function without using auth?

2012-12-20 Thread Anthony
On Thursday, December 20, 2012 11:00:28 AM UTC-5, Ramos wrote:

> Now i have 2 problems.
> Recap
> 1 - 
> print auth.user.isempreiteiro  # *returns None*
> record=db(db.auth_user.id==auth.user_id).select()[0]
> print  record['isempreiteiro'] #*returns True  "This is the real 
> value"*
> Why?
>

Is isempreiteiro a virtual field or regular field? Is its value set after 
login (auth.user is stored in the session, so it won't be updated after 
login even if the record is updated)? If so, you can manually update 
auth.user when the record is updated.
 

>
> 2 - 
> my decorated function in controller default works ok when user logged in
>
> @auth.requires_login()   
> *#@auth.requires(checkempreiteiro(auth.user_id)==True) *
> def inserttrab():
> form = SQLFORM(db.trabalhador)
> if form.accepts(request.vars, session):
> session.flash = 'registo inserido com sucesso'
> redirect(URL())
> return dict(form=form)
>
> but gives an error when the user does logout. logging out should redirect 
> to login page but the line
>

Your checkempreiteiro() function does db(db.auth_user.id
==auth.user_id).select()[0], but if the user is not logged in, auth.user_id 
will be None, and the query will return no results -- so subscripting with 
[0] will produce an error. Instead, you can do db(db.auth_user.id
==auth.user_id).select().first(), which will return None if there are no 
records.

Also, note that by default, @auth.requires(...) already requires login, so 
you don't have to precede it with @auth.requires_login().

Finally, keep in mind that the condition within @auth.requires(...) will be 
executed on every request to that controller (even requests to other 
functions within the controller), so it is better to put the condition 
inside a lambda so it will only get executed when that specific function is 
called. Actually, in a case like this, you're probably better off putting a 
flag in the session so you don't have to repeat the db query on every 
request to that function.

Anthony

-- 





[web2py] Re: SQLFORM in html - Book example

2012-12-20 Thread Anthony
Did you add session=None to the call to .process()?

Anthony

On Thursday, December 20, 2012 11:22:32 AM UTC-5, Fabiano Faver wrote:
>
> I tried the book example in 
> http://web2py.com/books/default/chapter/29/07#SQLFORM-in-HTML
> It's not working. I tried to use to sqlform.process from a html form using 
> the way, but did not work. Then I tried exactly the same code on book and 
> still did not work.
> Its not validating the form, just flashing "fill the form" message.
> Am I missing something?
>

-- 





[web2py] Re: widgets.checkboxes.widget INPUT inside LABLE

2012-12-20 Thread Anthony
On Thursday, December 20, 2012 10:50:47 AM UTC-5, Paolo Caruccio wrote:

> I think as Massimo said, but  W3C raccomandation on 
> forms
>  tells:
>
> "To label a control, the label element is used; the label text and the 
> control itself go inside the label element."
>
> So KMax request should be acceptable
>

This appears to be how Bootstrap does it as well.

Anthony 

-- 





[web2py] Web2py vs Grails on VSCharts.com

2012-12-20 Thread António Ramos
i saw this page and link to share

http://vschart.com/compare/web2py/vs/grails

-- 





[web2py] Ver 2.3.2 changes the order models are loaded.

2012-12-20 Thread Jim Karsten
I have database tables defined in models/db.py. I have a 
controller-specific model defined in a models/client subdirectory. Ver 
2.3.2 loads the models in a different order from ver 2.2.1. 

Ver 2.2.1
models/0.py
models/db.py
models/clients/edit/db.py

Ver 2.3.2
models/0.py
models/clients/edit/db.py
models/db.py

The models/clients/edit/db.py depends on variables defined in modes/db.py 
so I get errors with Ver 2.3.2 

The sort=False argument was removed from the listdir call in this line of 
gluon/compileapp.py def run_models_in() 

models = listdir(path, '^\w+\.py$', 0, sort=False) # Ver 2.2.1 
models = listdir(path, '^\w+\.py$', 0)   # Ver 2.3.2 

If I restore that, it works again. 

The issue was discussed here: 
https://groups.google.com/d/topic/web2py/ZfI7K9jW45w/discussion 

In Ver 2.2.1, files in the models directory are first loaded in 
alphabetically order. Then each subfolder is handled in order, model files 
in subfolders are loaded in alphabetical order. In Ver 2.3.2, all models 
are sorted by path name and then loaded in that order. 

I can rename subfolders so they are loaded properly but before I change 
anything I'd like to make sure the effects of dropping sort=False were 
intended. 

-- 





[web2py] Re: Ver 2.3.2 changes the order models are loaded.

2012-12-20 Thread Anthony
That probably wasn't the right change. I think it should put the subfolders 
in alphabetical order and then run the files within each folder in 
alphabetical order (that's roughly how it worked prior to the change, but 
alphabetical ordering of the subfolders was not guaranteed).

Anthony

On Thursday, December 20, 2012 1:12:20 PM UTC-5, Jim Karsten wrote:
>
> I have database tables defined in models/db.py. I have a 
> controller-specific model defined in a models/client subdirectory. Ver 
> 2.3.2 loads the models in a different order from ver 2.2.1. 
>
> Ver 2.2.1
> models/0.py
> models/db.py
> models/clients/edit/db.py
>
> Ver 2.3.2
> models/0.py
> models/clients/edit/db.py
> models/db.py
>
> The models/clients/edit/db.py depends on variables defined in modes/db.py 
> so I get errors with Ver 2.3.2 
>
> The sort=False argument was removed from the listdir call in this line of 
> gluon/compileapp.py def run_models_in() 
>
> models = listdir(path, '^\w+\.py$', 0, sort=False) # Ver 2.2.1 
> models = listdir(path, '^\w+\.py$', 0)   # Ver 2.3.2 
>
> If I restore that, it works again. 
>
> The issue was discussed here: 
> https://groups.google.com/d/topic/web2py/ZfI7K9jW45w/discussion 
>
> In Ver 2.2.1, files in the models directory are first loaded in 
> alphabetically order. Then each subfolder is handled in order, model files 
> in subfolders are loaded in alphabetical order. In Ver 2.3.2, all models 
> are sorted by path name and then loaded in that order. 
>
> I can rename subfolders so they are loaded properly but before I change 
> anything I'd like to make sure the effects of dropping sort=False were 
> intended. 

-- 





[web2py] Re: widgets.checkboxes.widget INPUT inside LABLE

2012-12-20 Thread Paolo Caruccio
For completeness:

wrapping the input controls with label should be avoided when for the 
layout is used a table. In such case the label goes in one TD and the 
associated control in another TD.
Bootstrap, indeed, doesn't use table layout for the forms.


Il giorno giovedì 20 dicembre 2012 16:50:47 UTC+1, Paolo Caruccio ha 
scritto:
>
> I think as Massimo said, but  W3C raccomandation on 
> forms
>  tells:
>
> "To label a control, the label element is used; the label text and the 
> control itself go inside the label element."
>
> So KMax request should be acceptable
>
>
>
> Il giorno giovedì 20 dicembre 2012 15:57:03 UTC+1, Massimo Di Pierro ha 
> scritto:
>>
>> I am not convinced this is the right fix. Does bootstrap suggest this? I 
>> do not think the input should be in the label. Perhaps there is an 
>> alternative fix using css?
>>
>> On Thursday, 20 December 2012 03:08:01 UTC-6, KMax wrote:
>>>
>>> Hello,
>>>
>>>   Using this widget=SQLFORM.widgets.checkboxes.widget for list of values 
>>> gives the following html code:
>>>
>>> 
>>> Option1
>>>
>>> 
>>> Option2
>>>
>>> While if INPUT reside inside LABLE it looks better (imho)
>>> 
>>>   Option1
>>>  
>>>
>>> 
>>>   Option2
>>> 
>>>
>>> Same time this change might broke some compatibility. Maybe this 
>>> behavior was made for some reason.
>>> Community, please share your opinion.
>>>
>>> Thanks,
>>>
>>>

-- 





Re: [web2py] Re: web2py 2.3.2 added "+ -" to some form elements

2012-12-20 Thread Christian Foster Howes
ok, here is a patch against current *trunk*.  this should never allow 
you to remove the last item from the list.  note that when the list is 
empty (showing one field with no data) the + and - buttons appear to be 
no-op.


On 12/20/12 7:06 , Massimo Di Pierro wrote:

For now I have remove the "-" button.

On Wednesday, 19 December 2012 23:48:37 UTC-6, howesc wrote:


ooops.  i added the - and didn't test the "only 1 row case".  i'll try and
create a patch tomorrow for it.

mind opening a ticket in google code?

thanks,

christian

On Tuesday, December 18, 2012 8:17:11 AM UTC-8, Daniele wrote:


The newest version of web2py has added some + and - clickable links to
form elements so that it is possible to remove the element. However, if
there is only one element and one clicks the "-", the form disappears and
there's no way to get the form element back without refreshing the page.

I'll post an image so that you can see what it looks like.

I think this is a bug with the newest version because my code hasn't
changed at all. There was only a "+" before...







--



diff -r 4c55a243c4c2 gluon/sqlhtml.py
--- a/gluon/sqlhtml.py  Thu Dec 20 09:22:24 2012 -0600
+++ b/gluon/sqlhtml.py  Thu Dec 20 10:45:52 2012 -0800
@@ -263,18 +263,27 @@
 jQuery.fn.grow_input = function() {
   return this.each(function() {
 var ul = this;
-jQuery(ul).find(":text").after('+').keypress(function (e) { return (e.which == 
13) ? pe(ul) : true; }).next().click(function(){ pe(ul) });
+jQuery(ul).find(":text").after('+ -').keypress(function (e) { return (e.which == 
13) ? pe(ul, e) : true; }).next().click(function(e){ pe(ul, e) 
}).next().click(function(e){ rl(ul, e)});
   });
 };
 function pe(ul, e) {
   var new_line = ml(ul);
   rel(ul);
-  new_line.appendTo(ul);
+  if ($(e.target).parent().is(':visible')) {
+//make sure we didn't delete the element before we insert after
+new_line.insertAfter($(e.target).parent());
+  } else {
+//the line we clicked on was deleted, just add to end of list
+new_line.appendTo(ul);
+  }
   new_line.find(":text").focus();
   return false;
 }
 function rl(ul, e) {
-  jQuery(e.target).parent().remove();
+  if (jQuery(ul).children().length > 1) {
+//only remove if we have more than 1 item so the list is never empty
+$(e.target).parent().remove();
+  }
 }
 function ml(ul) {
   var line = jQuery(ul).find("li:first").clone(true);


Re: [web2py] Re: web2py 2.3.2 added "+ -" to some form elements

2012-12-20 Thread Christian Foster Howes
and here is the diff between the 2.3.2 release and the patch i made in 
case you want to apply it to gluon/sqlhtml.py in your environment.


sorry for the headache!

cfh

On 12/20/12 7:06 , Massimo Di Pierro wrote:

For now I have remove the "-" button.

On Wednesday, 19 December 2012 23:48:37 UTC-6, howesc wrote:


ooops.  i added the - and didn't test the "only 1 row case".  i'll try and
create a patch tomorrow for it.

mind opening a ticket in google code?

thanks,

christian

On Tuesday, December 18, 2012 8:17:11 AM UTC-8, Daniele wrote:


The newest version of web2py has added some + and - clickable links to
form elements so that it is possible to remove the element. However, if
there is only one element and one clicks the "-", the form disappears and
there's no way to get the form element back without refreshing the page.

I'll post an image so that you can see what it looks like.

I think this is a bug with the newest version because my code hasn't
changed at all. There was only a "+" before...







--



272c272,278
<   new_line.insertAfter(jQuery(e.target).parent());
---
>   if ($(e.target).parent().is(':visible')) {
> //make sure we didn't delete the element before we insert after
> new_line.insertAfter($(e.target).parent());
>   } else {
> //the line we clicked on was deleted, just add to end of list
> new_line.appendTo(ul);
>   }
277c283,286
<   jQuery(e.target).parent().remove();
---
>   if (jQuery(ul).children().length > 1) {
> //only remove if we have more than 1 item so the list is never empty
> $(e.target).parent().remove();
>   }


[web2py] Re: json service

2012-12-20 Thread Massimo Di Pierro
yes.

You are not supposed to return an iterable (in your case a list). web2py 
thinks you want to do streaming and will start looping over the iterable. 
This should change in web3py not we cannot change it in web2py.

Massimo

On Thursday, 20 December 2012 10:24:05 UTC-6, Manuele wrote:
>
> trying to expose this simple controller I got the subsequent error... 
> does anybody understand why? 
> the query runs perfectly inserted manually in a ipdb console... 
>
> @service.json 
> def mRender(): 
>
>  #import ipdb; ipdb.set_trace() 
>  query = (db.plugin_lookout_fields.table_id==source_table_id) 
>  res = db(query).select(db.plugin_lookout_fields.field_name, 
> limitby=(1, 4, )).as_list() 
>
>  return res 
>
> ERROR:Rocket.Errors.Thread-3:Unhandled Error when serving connection: 
> Traceback (most recent call last): 
>
>File "/home/manuele/portali/web2py-2.2.1/gluon/rocket.py", line 1318, 
> in run 
>  self.run_app(conn) 
>
>File "/home/manuele/portali/web2py-2.2.1/gluon/rocket.py", line 1840, 
> in run_app 
>  self.conn.sendall(b('0\r\n\r\n')) 
>
>File "/usr/lib/python2.7/socket.py", line 224, in meth 
>  return getattr(self._sock,name)(*args) 
>
> error: [Errno 32] Broken pipe 
>

-- 





Re: [web2py] Re: web2py 2.3.2 added "+ -" to some form elements

2012-12-20 Thread Christian Foster Howes

(my first try didn't post)

ok, here is a patch against current *trunk*.  this should never allow
you to remove the last item from the list.  note that when the list is
empty (showing one field with no data) the + and - buttons appear to be
no-op.

--



diff -r 4c55a243c4c2 gluon/sqlhtml.py
--- a/gluon/sqlhtml.py  Thu Dec 20 09:22:24 2012 -0600
+++ b/gluon/sqlhtml.py  Thu Dec 20 10:45:52 2012 -0800
@@ -263,18 +263,27 @@
 jQuery.fn.grow_input = function() {
   return this.each(function() {
 var ul = this;
-jQuery(ul).find(":text").after('+').keypress(function (e) { return (e.which == 
13) ? pe(ul) : true; }).next().click(function(){ pe(ul) });
+jQuery(ul).find(":text").after('+ -').keypress(function (e) { return (e.which == 
13) ? pe(ul, e) : true; }).next().click(function(e){ pe(ul, e) 
}).next().click(function(e){ rl(ul, e)});
   });
 };
 function pe(ul, e) {
   var new_line = ml(ul);
   rel(ul);
-  new_line.appendTo(ul);
+  if ($(e.target).parent().is(':visible')) {
+//make sure we didn't delete the element before we insert after
+new_line.insertAfter($(e.target).parent());
+  } else {
+//the line we clicked on was deleted, just add to end of list
+new_line.appendTo(ul);
+  }
   new_line.find(":text").focus();
   return false;
 }
 function rl(ul, e) {
-  jQuery(e.target).parent().remove();
+  if (jQuery(ul).children().length > 1) {
+//only remove if we have more than 1 item so the list is never empty
+$(e.target).parent().remove();
+  }
 }
 function ml(ul) {
   var line = jQuery(ul).find("li:first").clone(true);



[web2py] Re: Ver 2.3.2 changes the order models are loaded.

2012-12-20 Thread Massimo Di Pierro
I agree with Anthony. The fix was wrong. I will write a patch if he does 
not send me one first.

Massimo

On Thursday, 20 December 2012 12:12:20 UTC-6, Jim Karsten wrote:
>
> I have database tables defined in models/db.py. I have a 
> controller-specific model defined in a models/client subdirectory. Ver 
> 2.3.2 loads the models in a different order from ver 2.2.1. 
>
> Ver 2.2.1
> models/0.py
> models/db.py
> models/clients/edit/db.py
>
> Ver 2.3.2
> models/0.py
> models/clients/edit/db.py
> models/db.py
>
> The models/clients/edit/db.py depends on variables defined in modes/db.py 
> so I get errors with Ver 2.3.2 
>
> The sort=False argument was removed from the listdir call in this line of 
> gluon/compileapp.py def run_models_in() 
>
> models = listdir(path, '^\w+\.py$', 0, sort=False) # Ver 2.2.1 
> models = listdir(path, '^\w+\.py$', 0)   # Ver 2.3.2 
>
> If I restore that, it works again. 
>
> The issue was discussed here: 
> https://groups.google.com/d/topic/web2py/ZfI7K9jW45w/discussion 
>
> In Ver 2.2.1, files in the models directory are first loaded in 
> alphabetically order. Then each subfolder is handled in order, model files 
> in subfolders are loaded in alphabetical order. In Ver 2.3.2, all models 
> are sorted by path name and then loaded in that order. 
>
> I can rename subfolders so they are loaded properly but before I change 
> anything I'd like to make sure the effects of dropping sort=False were 
> intended. 

-- 





[web2py] Re: Beware auth.enable_record_versioning

2012-12-20 Thread Cliff Kachinske
To enable archiving, I added enable_record_versioning(db) = True to my 
models files.

I encountered the problems described in the two bug reports I submitted 
today on Google code.

At one point I thought it would help with isolating the problem if I turned 
off versioning, so I commented out the line enabling it.

When I uncommented the line, I found tables with names like 
"products_archive_archive."  These are archive tables for the archive 
tables.

I suppose if I repeated the sequence I would have tables with names like 
"products_archive_archive_archive."

On Thursday, December 20, 2012 10:05:25 AM UTC-5, Massimo Di Pierro wrote:
>
> I do not understand. Can you explain?
>
> On Thursday, 20 December 2012 08:11:42 UTC-6, Cliff Kachinske wrote:
>>
>> I just discovered that auth.enable_record_versioning will create archive 
>> tables for the archive tables if turned off and turned back on.
>>
>> Not acceptable.
>>
>

-- 





[web2py] Question about SQLFORM.grid - process a column before show it

2012-12-20 Thread Christian Espinoza
Hi, I'm wondering about if is possible process the values of a column to 
show the result on the grid instead of original value...
My Code:
(db_events.events.device_id == request.vars.id) &\
(db_events.events.event_datetime >= from) &\
(db_events.events.event_datetime <= to)

grid = SQLFORM.grid(query, editable=False, searchable=False, 
deletable=False,create=False,details=False )

With this code I get :
Id
C
odeT
ypeA
ctionD
ateLa
tLon
Vel
Dir
PFM
Age
Od
5742356612022462768EVENT22012-12-20 15:24:52-20.23496-70.1384814.48371732
18460843.005743356612022462768EVENT12012-12-20 15:25:58-20.23064-70.13754
16.0933363218461344.005744356612022462768EVENT12012-12-20 15:26:26-20.23049
-70.138616.0933293218461461.005745356612022462768EVENT12012-12-20 15:28:49
-20.22115-70.137746.43723253218462508.005746356612022462768EVENT02012-12-20 
15:29:11-20.22088-70.1394724.13953593218462702.005747356612022462768EVENT02012-12-20
 
15:31:17-20.21419-70.1389919.31163081218463458.005748356612022462768EVENT02012-12-20
 
15:34:16-20.21372-70.1469522.53022713218464303.005749356612022462768EVENT22012-12-20
 
15:36:17
I need change the Action column with the values of a Dic that I have:

Actions = { 0:'Quiet',1:'Running',2:'Fail'}

How can I show on SQLFORM.grid a 'Quiet' instead of a 0, a 'Running' 
instead a 1, an finally a 'Fail' instead a 2??

Greetings
Christian.

-- 





[web2py] Re: Ver 2.3.2 changes the order models are loaded.

2012-12-20 Thread Jim Karsten
Sounds good. Thanks guys

On Thursday, December 20, 2012 1:12:20 PM UTC-5, Jim Karsten wrote:
>
> I have database tables defined in models/db.py. I have a 
> controller-specific model defined in a models/client subdirectory. Ver 
> 2.3.2 loads the models in a different order from ver 2.2.1. 
>
> Ver 2.2.1
> models/0.py
> models/db.py
> models/clients/edit/db.py
>
> Ver 2.3.2
> models/0.py
> models/clients/edit/db.py
> models/db.py
>
> The models/clients/edit/db.py depends on variables defined in modes/db.py 
> so I get errors with Ver 2.3.2 
>
> The sort=False argument was removed from the listdir call in this line of 
> gluon/compileapp.py def run_models_in() 
>
> models = listdir(path, '^\w+\.py$', 0, sort=False) # Ver 2.2.1 
> models = listdir(path, '^\w+\.py$', 0)   # Ver 2.3.2 
>
> If I restore that, it works again. 
>
> The issue was discussed here: 
> https://groups.google.com/d/topic/web2py/ZfI7K9jW45w/discussion 
>
> In Ver 2.2.1, files in the models directory are first loaded in 
> alphabetically order. Then each subfolder is handled in order, model files 
> in subfolders are loaded in alphabetical order. In Ver 2.3.2, all models 
> are sorted by path name and then loaded in that order. 
>
> I can rename subfolders so they are loaded properly but before I change 
> anything I'd like to make sure the effects of dropping sort=False were 
> intended. 

-- 





Re: [web2py] Interesting - Brython (python to javascript)

2012-12-20 Thread Vinicius Assef
I agree.

On Thu, Dec 20, 2012 at 1:18 PM, Massimo Di Pierro
 wrote:
> Looks like this is too limited to be useful.
>
>
> On Monday, 17 December 2012 01:08:41 UTC-6, viniciusban wrote:
>>
>> Brypthon doesn't support string interpolation, too. :-(
>>
>> On Sun, Dec 16, 2012 at 6:40 PM, Arnon Marcus  wrote:
>> > From what I saw, it does not support many fundamental features of
>> > python,
>> > like class-inheritance (class, classMethod) modules (__import__, from,
>> > as),
>> > scope (globals, nonlocal) and parsing (exec, eval). I think these are
>> > trivial for python developement, and should have some kind of
>> > design-pattern
>> > transpiling specification that it follows.
>> > I think CoffeeScript actually has many of these already implemented, as
>> > is
>> > quite pythonic already in much of it's syntax - and is much closer to
>> > JavaScript in the first place and already has tons of tools for
>> > denugging,
>> > client/server-side automatic-transpiling, bundled up in
>> > minification/compression algorythms, etc...
>> >
>> > It's a cool idea, and pyjammas has existed for a long time now, but is
>> > anyone seriously thinking about using that in production?
>> >
>> > I think as long as browsers don't have some kind of cross-language VMs,
>> > or
>> > at least a PVM built-in/plugin, than with all the excitement, it will
>> > remain
>> > useless.
>> > I mean, how do you debug this?
>> >
>> > --
>> >
>> >
>> >
>
> --
>
>
>

-- 





[web2py] Re: Question about SQLFORM.grid - process a column before show it

2012-12-20 Thread Jim S
What does your model look like?

-Jim

On Thursday, December 20, 2012 2:15:20 PM UTC-6, Christian Espinoza wrote:
>
> Hi, I'm wondering about if is possible process the values of a column to 
> show the result on the grid instead of original value...
> My Code:
> (db_events.events.device_id == request.vars.id) &\
> (db_events.events.event_datetime >= from) &\
> (db_events.events.event_datetime <= to)
>
> grid = SQLFORM.grid(query, editable=False, searchable=False, 
> deletable=False,create=False,details=False )
>
> With this code I get :
> Id
> C
> odeT
> ypeA
> ctionD
> ateLa
> tLon
> Vel
> Dir
> PFM
> Age
> Od
> 5742356612022462768EVENT22012-12-20 15:24:52-20.23496-70.1384814.48371732
> 18460843.005743356612022462768EVENT12012-12-20 15:25:58-20.23064-70.13754
> 16.0933363218461344.005744356612022462768EVENT12012-12-20 15:26:26
> -20.23049-70.138616.0933293218461461.005745356612022462768EVENT12012-12-20 
> 15:28:49-20.22115-70.137746.43723253218462508.005746356612022462768EVENT02012-12-20
>  
> 15:29:11-20.22088-70.1394724.13953593218462702.005747356612022462768EVENT02012-12-20
>  
> 15:31:17-20.21419-70.1389919.31163081218463458.005748356612022462768EVENT02012-12-20
>  
> 15:34:16-20.21372-70.1469522.53022713218464303.005749356612022462768EVENT22012-12-20
>  
> 15:36:17
> I need change the Action column with the values of a Dic that I have:
>
> Actions = { 0:'Quiet',1:'Running',2:'Fail'}
>
> How can I show on SQLFORM.grid a 'Quiet' instead of a 0, a 'Running' 
> instead a 1, an finally a 'Fail' instead a 2??
>
> Greetings
> Christian.
>
>

-- 





Re: [web2py] Re: The book updates and status

2012-12-20 Thread Vinicius Assef
I can proof read and help amplifying some parts.

I'd like to act on DAL chapter, for instance.


On Thu, Dec 20, 2012 at 1:35 PM, Massimo Di Pierro
 wrote:
> This is in:
> http://web2py.com/books/default/chapter/29/07?search=SQLFORM.grid#SQLFORM.grid-and-SQLFORM.smartgrid
> along with tons of other additions. :-)
> I hope to make a first pdf draft by the end of next week.
>
> Massimo
>
>
> On Wednesday, 19 December 2012 20:53:25 UTC-6, Andrew W wrote:
>>
>> I'm happy to proof read.   Send it through when ready.
>>
>> Andrew W
>>
>> On Thursday, December 20, 2012 2:46:41 PM UTC+13, Anthony wrote:
>>>
>>> On Wednesday, December 19, 2012 5:56:48 PM UTC-5, Massimo Di Pierro
>>> wrote:

 I have been going over that document. The things in gray were not in the
 published 4th edition but are in the online version.
>>>
>>>
>>> Make sure you click the link below -- it's an updated version of the
>>> original document. All the gray items were removed, and some newer items
>>> have been added (though some of them may already be in the book).
>>>
>>> Anthony
>>>
>>>  On Wednesday, 19 December 2012 14:15:46 UTC-6, Anthony wrote:
>
> This document is a bit old, so some of the items may already have been
> added:
> https://docs.google.com/document/d/1yQy0F5HcxiecBOBLblrLmAAAsAK6sL37wSL527yssGk/edit
>
> --
>
>
>

-- 





[web2py] Re: Question about SQLFORM.grid - process a column before show it

2012-12-20 Thread Christian Espinoza
My Model for this App
db_events.define_table('events',
Field('devid', length=15, label='CODE'),
Field('type', length=15, label='Type'),
Field('index','integer', label='Action'),
Field('datetime','datetime', label='Date'),
Field('latitude','double', label='Lat'),
Field('longitude','double', label='Lon'),
Field('velocity','double', label='Vel'),
Field('heading', 'integer', label='Dir'),
Field('pfm','integer', label='PFM'),
Field('age','integer', label='Age'),
Field('odometer','double', label='Od')
)

-- 





[web2py] Re: widgets.checkboxes.widget INPUT inside LABLE

2012-12-20 Thread Anthony
Good point. It will probably have to depend on the formstyle used.

Anthony

On Thursday, December 20, 2012 1:57:16 PM UTC-5, Paolo Caruccio wrote:
>
> For completeness:
>
> wrapping the input controls with label should be avoided when for the 
> layout is used a table. In such case the label goes in one TD and the 
> associated control in another TD.
> Bootstrap, indeed, doesn't use table layout for the forms.
>
>
> Il giorno giovedì 20 dicembre 2012 16:50:47 UTC+1, Paolo Caruccio ha 
> scritto:
>>
>> I think as Massimo said, but  W3C raccomandation on 
>> forms
>>  tells:
>>
>> "To label a control, the label element is used; the label text and the 
>> control itself go inside the label element."
>>
>> So KMax request should be acceptable
>>
>>
>>
>> Il giorno giovedì 20 dicembre 2012 15:57:03 UTC+1, Massimo Di Pierro ha 
>> scritto:
>>>
>>> I am not convinced this is the right fix. Does bootstrap suggest this? I 
>>> do not think the input should be in the label. Perhaps there is an 
>>> alternative fix using css?
>>>
>>> On Thursday, 20 December 2012 03:08:01 UTC-6, KMax wrote:

 Hello,

   Using this widget=SQLFORM.widgets.checkboxes.widget for list of 
 values gives the following html code:

 
 Option1

 
 Option2

 While if INPUT reside inside LABLE it looks better (imho)
 
  Option1
  

 
  Option2
 

 Same time this change might broke some compatibility. Maybe this 
 behavior was made for some reason.
 Community, please share your opinion.

 Thanks,



-- 





Re: [web2py] Re: Question about SQLFORM.grid - process a column before show it

2012-12-20 Thread Jim Steil
Have you though about adding a table to define the relation between 'index'
and the text:

db_actions.define_table('actions',
Field(name, length=20, label='Action'))

Then modify db_events so field index looks like:

Field('index', db.actions, label='Action),

Table actions would then have three records,

Quiet
Running
Fail

This should then automatically display the right value - the only problem
is that it wouldn't guarantee that the index would be 0, 1, and 2.  It
would be whatever the primary key on the actions table worked out to be.

The other way to handle it would be to write a custom validator that
changed the numeric value as you mentioned.  I haven't done that before,
but heard it isn't that difficult.

-Jim

On Thu, Dec 20, 2012 at 2:45 PM, Christian Espinoza wrote:

> My Model for this App
> db_events.define_table('events',
> Field('devid', length=15, label='CODE'),
> Field('type', length=15, label='Type'),
> Field('index','integer', label='Action'),
> Field('datetime','datetime', label='Date'),
> Field('latitude','double', label='Lat'),
> Field('longitude','double', label='Lon'),
> Field('velocity','double', label='Vel'),
> Field('heading', 'integer', label='Dir'),
> Field('pfm','integer', label='PFM'),
> Field('age','integer', label='Age'),
> Field('odometer','double', label='Od')
> )
> --
>
>
>
>

-- 





Re: [web2py] Re: Question about SQLFORM.grid - process a column before show it

2012-12-20 Thread Niphlod
Disclaimer: not tested
why don't you just change the action Field to 

Field('action', requires=IS_IN_SET({ 0:'Quiet',1:'Running',2:'Fail'}))

On Thursday, December 20, 2012 10:23:07 PM UTC+1, Jim S wrote:
>
> Have you though about adding a table to define the relation between 
> 'index' and the text:
>
> db_actions.define_table('actions',
> Field(name, length=20, label='Action'))
>
> Then modify db_events so field index looks like:
>
> Field('index', db.actions, label='Action),
>
> Table actions would then have three records, 
>
> Quiet
> Running
> Fail
>
> This should then automatically display the right value - the only problem 
> is that it wouldn't guarantee that the index would be 0, 1, and 2.  It 
> would be whatever the primary key on the actions table worked out to be.
>
> The other way to handle it would be to write a custom validator that 
> changed the numeric value as you mentioned.  I haven't done that before, 
> but heard it isn't that difficult.
>
> -Jim
>
> On Thu, Dec 20, 2012 at 2:45 PM, Christian Espinoza 
> 
> > wrote:
>
>> My Model for this App
>> db_events.define_table('events',
>> Field('devid', length=15, label='CODE'),
>> Field('type', length=15, label='Type'),
>> Field('index','integer', label='Action'),
>> Field('datetime','datetime', label='Date'),
>> Field('latitude','double', label='Lat'),
>> Field('longitude','double', label='Lon'),
>> Field('velocity','double', label='Vel'),
>> Field('heading', 'integer', label='Dir'),
>> Field('pfm','integer', label='PFM'),
>> Field('age','integer', label='Age'),
>> Field('odometer','double', label='Od')
>> )
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: web3py?

2012-12-20 Thread Arnon Marcus
Pfff...

The creator of web2py says he wishes he could do web3py some other way, but 
can't...

Am I the only one that finds that funny? :)

web3py will end up however you wish it to end up as...

You can do whatever you want with it, as it's already inherently backwards 
incompatible (python 3.x), and is not even fully planned yet...

If anyone at any time could change things, it would be you guys and at this 
time...

How about putting auxiliary attributes "front and center"?
Data-* attributes are already a part of the standard of HTML5 and 
most-if-not-all browsers support them.

Single-Page apps are also not even considered a novelty anymore, and we're 
in a Renaissance of data-binding frameworks...

I mean, I guess I could do this:

def DATA(name, value):
return {('_data-' + name):str(value)}


Then:

DIV( "{{MyVar}}", **DATA( "ng-controller", "MyController" ) )
=>
DIV( "{{MyVar}}", **{ "_data-ng-controller": "MyController" } )
=>
{{MyVar}}

and:

DIV( "{{MyVar}}", **DATA( "bind", "text: MyVar" ) )
=>
DIV( "{{MyVar}}", **{ "_data-bind": "text: MyVar" } )
=>
{{MyVar}}


But hell, you can make the TAG classes able to receive DATA 
class-instances, that other people can sub-class/modify to implenet the 
interface for different frameworks.

A generic DATA class may look something like this:

class DATA:

namespace = ""

aggregate = False
seperator = ": "
delimiter = ", "

def __init__(self, **attrs):
self.attrs = dict(**attrs)
...

def parse( self ):
parsed = ""

if aggregatre:
parsed += 'data-' + ns + '="'
for k, v in items(self.attrs):
parsed += k + seperator + v + delimiter
parsed = parsed[:-len(delimiter)] + '"'
else:
ns  = namespace + '-' if namespace else ''
for k, v in items(self.attrs):
parsed += 'data-' + ns + k + '="' + v + '"'

return parsed  


And have your TAG classes do something like:

class :
def __init__(self, content, *vars, **args):
...
parsed = [ var.parsed() for var in *vars if isinstanceof(var, DATA) 
]
...

...


Angular guys may then do something like this:

DATA.namespace = "ng"
BUTTON( "Delete", DATA( click="destroy()", show="project._id".) )
=>
Delete

or:

class ngDATA( DATA ):
namespace = "ng"

+ 


Knockout guys could do this:

DATA.namespace = "bind"
DATA.aggregate = True
SELECT( "", DATA( options = "$root.availableMeals",
   value = "meal".
   optionsText = "'mealName'" ) )
=>


or:

class koDATA( DATA ):
namespace = "bind"
aggregated = False

+ 


What say you?

On Thursday, December 20, 2012 7:17:48 AM UTC-8, Massimo Di Pierro wrote:
>
> Oops. right. I wish there was a simple syntax but I cannot think about 
> one. 
>
> On Thursday, 20 December 2012 09:07:21 UTC-6, Niphlod wrote:
>>
>> correction, the _ in front is needed as always  
>> DIV('content',**{'_data-something':'something value'})
>>
>> Il giorno giovedì 20 dicembre 2012 15:58:25 UTC+1, Massimo Di Pierro ha 
>> scritto:
>>>
>>> They always did although the syntax is cumbersone
>>>
>>> DIV('content',**{'data-something':'something value'})
>>>
>>> On Thursday, 20 December 2012 04:16:54 UTC-6, Arnon Marcus wrote:

 Cool (!)

 Do the HTML helpers support HTML5's " data-* " attributes?
 Can that be used for javascriupt frameworks like Knockout.js or 
 Angular.js ?

>>>

-- 





[web2py] Re: web3py?

2012-12-20 Thread Anthony
On Thursday, December 20, 2012 5:02:45 PM UTC-5, Arnon Marcus wrote:

> Pfff...
>
> The creator of web2py says he wishes he could do web3py some other way, 
> but can't...
>

I don't think he said that. He wasn't talking about web3py at all -- this 
is in reference to web2py. He was just noting the Python limitation 
regarding the naming of function arguments (which the HTML helpers use as 
attribute names). If we want attribute names that are not legal Python 
function arguments, we either need to use the **{'attribute': 'value'} 
syntax or some other alternative way to pass in the attributes. You have 
proposed an alternative, but probably could have done so without the 
attitude.

Anthony

>

-- 





Re: [web2py] Re: Question about SQLFORM.grid - process a column before show it

2012-12-20 Thread villas
I guess you need to use:  actions.represent  as well.  


On Thursday, December 20, 2012 9:46:58 PM UTC, Niphlod wrote:
>
> Disclaimer: not tested
> why don't you just change the action Field to 
>
> Field('action', requires=IS_IN_SET({ 0:'Quiet',1:'Running',2:'Fail'}))
>
> On Thursday, December 20, 2012 10:23:07 PM UTC+1, Jim S wrote:
>>
>> Have you though about adding a table to define the relation between 
>> 'index' and the text:
>>
>> db_actions.define_table('actions',
>> Field(name, length=20, label='Action'))
>>
>> Then modify db_events so field index looks like:
>>
>> Field('index', db.actions, label='Action),
>>
>> Table actions would then have three records, 
>>
>> Quiet
>> Running
>> Fail
>>
>> This should then automatically display the right value - the only problem 
>> is that it wouldn't guarantee that the index would be 0, 1, and 2.  It 
>> would be whatever the primary key on the actions table worked out to be.
>>
>> The other way to handle it would be to write a custom validator that 
>> changed the numeric value as you mentioned.  I haven't done that before, 
>> but heard it isn't that difficult.
>>
>> -Jim
>>
>> On Thu, Dec 20, 2012 at 2:45 PM, Christian Espinoza 
>> wrote:
>>
>>> My Model for this App
>>> db_events.define_table('events',
>>> Field('devid', length=15, label='CODE'),
>>> Field('type', length=15, label='Type'),
>>> Field('index','integer', label='Action'),
>>> Field('datetime','datetime', label='Date'),
>>> Field('latitude','double', label='Lat'),
>>> Field('longitude','double', label='Lon'),
>>> Field('velocity','double', label='Vel'),
>>> Field('heading', 'integer', label='Dir'),
>>> Field('pfm','integer', label='PFM'),
>>> Field('age','integer', label='Age'),
>>> Field('odometer','double', label='Od')
>>> )
>>> -- 
>>>  
>>>  
>>>  
>>>
>>
>>

-- 





[web2py] Re: Web2py vs Grails on VSCharts.com

2012-12-20 Thread villas
"a very flexible, robust and easy to manage framework that put all other 
frameworks to shame"

+1  Right!

-- 





[web2py] Re: hello3.xml question

2012-12-20 Thread villas
Hi Lucas,
Yes, just make the generic_patterns as restrictive as poss;  it is there 
mainly for security.


On Thursday, December 20, 2012 4:16:29 AM UTC, lucas wrote:
>
> oh yeah, that worked absolutely great.  thank you so much.  so cool, data 
> can be stripped and sent so many different ways.  so sweet.  lucas
>

-- 





Re: [web2py] Re: Question about SQLFORM.grid - process a column before show it

2012-12-20 Thread Niphlod
my bad, sorry Christian.

myset = { 0:'Quiet',1:'Running',2:'Fail'}

Field('action', 'integer', 
 requires=IS_IN_SET(myset), 
 represent=lambda value, row: myset.get(value, None) 
 # or myset[value] if you are totally sure that myset contains all 
the possible values
 )


Tested !

On Friday, December 21, 2012 12:13:11 AM UTC+1, villas wrote:
>
> I guess you need to use:  actions.represent  as well.  
>
>
> On Thursday, December 20, 2012 9:46:58 PM UTC, Niphlod wrote:
>>
>> Disclaimer: not tested
>> why don't you just change the action Field to 
>>
>> Field('action', requires=IS_IN_SET({ 0:'Quiet',1:'Running',2:'Fail'}))
>>
>> On Thursday, December 20, 2012 10:23:07 PM UTC+1, Jim S wrote:
>>>
>>> Have you though about adding a table to define the relation between 
>>> 'index' and the text:
>>>
>>> db_actions.define_table('actions',
>>> Field(name, length=20, label='Action'))
>>>
>>> Then modify db_events so field index looks like:
>>>
>>> Field('index', db.actions, label='Action),
>>>
>>> Table actions would then have three records, 
>>>
>>> Quiet
>>> Running
>>> Fail
>>>
>>> This should then automatically display the right value - the only 
>>> problem is that it wouldn't guarantee that the index would be 0, 1, and 2. 
>>>  It would be whatever the primary key on the actions table worked out to be.
>>>
>>> The other way to handle it would be to write a custom validator that 
>>> changed the numeric value as you mentioned.  I haven't done that before, 
>>> but heard it isn't that difficult.
>>>
>>> -Jim
>>>
>>> On Thu, Dec 20, 2012 at 2:45 PM, Christian Espinoza 
>>> wrote:
>>>
 My Model for this App
 db_events.define_table('events',
 Field('devid', length=15, label='CODE'),
 Field('type', length=15, label='Type'),
 Field('index','integer', label='Action'),
 Field('datetime','datetime', label='Date'),
 Field('latitude','double', label='Lat'),
 Field('longitude','double', label='Lon'),
 Field('velocity','double', label='Vel'),
 Field('heading', 'integer', label='Dir'),
 Field('pfm','integer', label='PFM'),
 Field('age','integer', label='Age'),
 Field('odometer','double', label='Od')
 )
 -- 
  
  
  

>>>
>>>

-- 





[web2py] Re: web3py?

2012-12-20 Thread Arnon Marcus
LOL.. You got me all wrong! :)

I meant no disrespect, I adore Massimo!
Massimo - You Da Man!

I was just teasing a little, is all...
You know, the way he said that it could have sounded as if he was 
frustrated from not being able to change his own creation - it's like a 
clay-sculptor staring at his clay, saying "I wish I could mold that... 
A shame it's made out of clay..." :P

And this is a web3py thread, so I think I got the context right...

I know about the "-" problem not being able to get used within a 
function-argument-name, while being required as a tag-attribute-name by the 
HTML5 standard for full compliance.

I'm just saying: "So what?" Who's to say that the expected arguments in the 
HTML-helpers must be regular arguments? Client-side frameworks are already 
overloading/abusing/nesting this attribute like crazy anyway, so why not 
make a special class for it to begin with? It IS a special kind of 
argument, even by HTML5's standards, why not treat it as such? I mean, it's 
not like we're stuck with the helpers the way they are, Massimo just said 
here that he's going to add context-managers to them, and even back-port 
that to web2py... My proposal doesn't even have to necessarily break 
backward compatibility...


On Thursday, December 20, 2012 2:47:27 PM UTC-8, Anthony wrote:
>
> On Thursday, December 20, 2012 5:02:45 PM UTC-5, Arnon Marcus wrote:
>
>> Pfff...
>>
>> The creator of web2py says he wishes he could do web3py some other way, 
>> but can't...
>>
>
> I don't think he said that. He wasn't talking about web3py at all -- this 
> is in reference to web2py. He was just noting the Python limitation 
> regarding the naming of function arguments (which the HTML helpers use as 
> attribute names). If we want attribute names that are not legal Python 
> function arguments, we either need to use the **{'attribute': 'value'} 
> syntax or some other alternative way to pass in the attributes. You have 
> proposed an alternative, but probably could have done so without the 
> attitude.
>
> Anthony
>
>>

-- 





[web2py] Re: web3py?

2012-12-20 Thread Anthony
OK, thanks for clarifying. So, when you asked the 
questionabout 
using HTML5 "data-" attributes, you were asking about how they would 
be supported in web3py, not how they are currently supported in web2py, 
correct? I think Massimo was answering for web2py.

Anyway, there's nothing stopping us from making a change in web2py as well. 
Maintaining backward compatibility doesn't prevent additions to the API -- 
we just can't change any old behavior (i.e., old code should continue to 
work the same).

Anthony

On Thursday, December 20, 2012 7:23:23 PM UTC-5, Arnon Marcus wrote:
>
> LOL.. You got me all wrong! :)
>
> I meant no disrespect, I adore Massimo!
> Massimo - You Da Man!
>
> I was just teasing a little, is all...
> You know, the way he said that it could have sounded as if he was 
> frustrated from not being able to change his own creation - it's like a 
> clay-sculptor staring at his clay, saying "I wish I could mold that... 
> A shame it's made out of clay..." :P
>
> And this is a web3py thread, so I think I got the context right...
>
> I know about the "-" problem not being able to get used within a 
> function-argument-name, while being required as a tag-attribute-name by the 
> HTML5 standard for full compliance.
>
> I'm just saying: "So what?" Who's to say that the expected arguments in 
> the HTML-helpers must be regular arguments? Client-side frameworks are 
> already overloading/abusing/nesting this attribute like crazy anyway, so 
> why not make a special class for it to begin with? It IS a special kind of 
> argument, even by HTML5's standards, why not treat it as such? I mean, it's 
> not like we're stuck with the helpers the way they are, Massimo just said 
> here that he's going to add context-managers to them, and even back-port 
> that to web2py... My proposal doesn't even have to necessarily break 
> backward compatibility...
>
>
> On Thursday, December 20, 2012 2:47:27 PM UTC-8, Anthony wrote:
>>
>> On Thursday, December 20, 2012 5:02:45 PM UTC-5, Arnon Marcus wrote:
>>
>>> Pfff...
>>>
>>> The creator of web2py says he wishes he could do web3py some other way, 
>>> but can't...
>>>
>>
>> I don't think he said that. He wasn't talking about web3py at all -- this 
>> is in reference to web2py. He was just noting the Python limitation 
>> regarding the naming of function arguments (which the HTML helpers use as 
>> attribute names). If we want attribute names that are not legal Python 
>> function arguments, we either need to use the **{'attribute': 'value'} 
>> syntax or some other alternative way to pass in the attributes. You have 
>> proposed an alternative, but probably could have done so without the 
>> attitude.
>>
>> Anthony
>>
>>>

-- 





[web2py] Re: The book updates and status

2012-12-20 Thread Julien Courteau
I'm in for proof reading of the 5th edition.

-- 





[web2py] Re: Login manually

2012-12-20 Thread Wonton
If you don't mind I could send you my project to your email directly.

El jueves, 20 de diciembre de 2012 16:14:12 UTC+1, Massimo Di Pierro 
escribió:
>
> If your data is not confidential, any chance you send me your application?
>
> To me this looks like corrupted data in database as if the password field 
> was at some pointed treated as type='list:string' and than changed back to 
> type='password'. Is it possible?
>
> Massimo
>
> On Wednesday, 19 December 2012 11:28:15 UTC-6, Wonton wrote:
>>
>> Yes, of course. This is my ticket:
>>
>> Error ticket for "dianaappv1" Ticket ID 
>>
>> 127.0.0.1.2012-12-19.18-24-12.5d2b292c-7e9a-4281-a9f7-bb9aa17bbd0c
>>  unsupported hash type 
>> |pbkdf2(1000,20,sha512) Versión  web2py™ (2, 2, 1, 
>> datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable')  Python Python 
>> 2.7.1: /usr/bin/python  Traceback 
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>> 21.
>> 22.
>> 23.
>> 24.
>> 25.
>> 26.
>> 27.
>> 28.
>>
>> Traceback (most recent call last):
>>   File "/Applications/web2py/gluon/restricted.py", line 212, in restricted
>> exec ccode in environment
>>   File "/Applications/web2py/applications/dianaappv1/controllers/default.py" 
>> ,
>>  line 101, in 
>>   File "/Applications/web2py/gluon/globals.py", line 188, in 
>> self._caller = lambda f: f()
>>   File "/Applications/web2py/applications/dianaappv1/controllers/default.py" 
>> ,
>>  line 27, in public_call
>> return servicios_publicos()
>>   File "/Applications/web2py/gluon/tools.py", line 4387, in __call__
>> return self.serve_json(request.args[1:])
>>   File "/Applications/web2py/gluon/tools.py", line 4197, in serve_json
>> s = universal_caller(self.json_procedures[args[0]], *args[1:], **d)
>>   File "/Applications/web2py/gluon/tools.py", line 3889, in universal_caller
>> return f(**arg_dict)
>>   File "/Applications/web2py/applications/dianaappv1/controllers/default.py" 
>> ,
>>  line 65, in login
>> user = auth.login_bare(usuario, password)
>>   File "/Applications/web2py/gluon/tools.py", line 1789, in login_bare
>> if not user.registration_key and password == user[passfield]:
>>   File "/Applications/web2py/gluon/validators.py", line 2636, in __eq__
>> h = simple_hash(self.password, key, salt, digest_alg)
>>   File "/Applications/web2py/gluon/utils.py", line 74, in simple_hash
>> h = hashlib.new(digest_alg)
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py",
>>  line 121, in __hash_new
>> return __get_builtin_constructor(name)(string)
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py",
>>  line 88, in __get_builtin_constructor
>> raise ValueError('unsupported hash type %s' % name)
>> ValueError: unsupported hash type |pbkdf2(1000,20,sha512)
>>
>>  Error snapshot [image: help]  
>>
>> (unsupported hash type 
>> |pbkdf2(1000,20,sha512)) 
>>
>> inspect attributes 
>>  Frames 
>>
>>-  
>>
>>*File /Applications/web2py/gluon/restricted.py in restricted at line 
>>212* código argumentos variables 
>> -  
>>
>>*File 
>>/Applications/web2py/applications/dianaappv1/controllers/default.py in 
>> at line 101* código argumentos variables 
>> -  
>>
>>*File /Applications/web2py/gluon/globals.py in  at line 188* 
>>código argumentos variables 
>> -  
>>
>>*File 
>>/Applications/web2py/applications/dianaappv1/controllers/default.py in 
>>public_call at line 27* código argumentos variables 
>> -  
>>
>>*File /Applications/web2py/gluon/tools.py in __call__ at line 4387* 
>>código argumentos variables 
>> -  
>>
>>*File /Applications/web2py/gluon/tools.py in serve_json at line 4197* 
>>código argumentos variables 
>> -  
>>
>>*File /Applications/web2py/gluon/tools.py in universal_caller at line 
>>3889* código argumentos variables 
>> -  
>>
>>*File 
>>/Applications/web2py/applications/dianaappv1/controllers/default.py in 
>>login at line 65* código argumentos variables 
>> -  
>>
>>*File /Applications/web2py/gluon/tools.py in login_bare at line 1789* 
>>código argumentos variables 
>> -  
>>
>>*File /Applications/web2py/gluon/validators.py in __eq__ at line 2636* 
>>código argumentos variables 
>> -  
>>
>>*File /Applications/web2py/gluon/utils.py in simple_hash at line 74* 
>>código argumentos variables 
>> -  
>>
>>*File 
>>
>> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py
>>  
>>in __hash_new at line 121* código argumentos variables

[web2py] Web2Py and Ajax

2012-12-20 Thread Martijn Hermans
I've just started using web2py and have a question about ajax calls.

In my project a menu is defined (and build) in models/meny.py).
The menu is added to the response like this : response.menu = _menu()

In this way I can access the menu in my layout and that is exacly what I 
want, except...

when I am doing a ajax call. 

Is there a way to skip building my menu when I'm using a ajax call?



-- 





[web2py] Web2Py and Ajax

2012-12-20 Thread Martijn Hermans
When I handle a request in Web2Py it builds a menu in models/menu.py.
This behaviour is exactly what I want for a normal request, but I want to 
skip this, when I make an ajax-call.

Is this possible?

thx,

Martijn

-- 





[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-20 Thread Mamisoa Andriantafika
I finally found the solution using COALESCE to merge and order date columns:

exams_mutex = db().select(db.dataset1.date.coalesce(db.dataset2.date), db.
dataset1.ALL, db.dataset2.ALL, left=[db.dataset1.on(db.mutex.i==0),db.
dataset2.on(db.mutex.i==1)], orderby=db.dataset1.date.coalesce(db.dataset2.
date))

Mamisoa

Le jeudi 20 décembre 2012 16:08:34 UTC+1, Massimo Di Pierro a écrit :
>
> Sorry I do not have a good solution at the moment. Can you open a ticket 
> about this so we'll will not forget. For now you may want to consider 
> creating a database view and selecting from the view. You would need to 
> create a model (readonly) to access the view.
>
> On Wednesday, 19 December 2012 16:19:33 UTC-6, Mamisoa Andriantafika wrote:
>>
>> Best results to UNION I could have was using the mutex table trick:
>>
>> http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/
>> with this syntax:
>>
>> exams_mutex = db().select(db.dataset1.ALL, db.dataset2.ALL, 
>> left=[db.dataset1.on(db.mutex.i==0),db.dataset2.on(db.mutex.i==1)])
>>
>> Two problems left:
>>
>> 1- how to merge the 2 date columns
>> 2- how to order then by date
>>
>> SQL answer is there:
>>
>> http://stackoverflow.com/questions/8245630/mysql-combine-two-date-fields-and-then-order-by
>>
>> SELECT
>> [some info],
>> GREATEST( ticket_date, ticket_history_date ) as latest_date
>> FROM
>> [tables and join]
>> ORDER BY
>> latest_date
>>
>>
>> Is is possible using to process it using DAL?
>>
>> Le dimanche 16 décembre 2012 17:40:22 UTC+1, Mamisoa Andriantafika a 
>> écrit :
>>>
>>> Sorry I still get: "Cannot | incompatible Rows objects".
>>>
>>> I'll change the field name "date" you are very right.
>>>
>>> Le dimanche 16 décembre 2012 15:49:57 UTC+1, Massimo Di Pierro a écrit :

 My bad. Thry this:

 fields1 = [db.dataset1.date, db.dataset1.param1, db.dateset1.patient_id]
 fields2 = [db.dataset2.date, db.dataset2.test1, db.dateset2.patient_id]
 rows = ( db(db.dataset1).select(*fields1) | 
 db(db.dataset2).select(*fields2) ).sort(lambda row: row.date)

 Mind that having a column called "date" will result in major headaches 
 in the future.

 On Sunday, 16 December 2012 03:15:46 UTC-6, Mamisoa Andriantafika wrote:
>
> Hi again,
>
> "|" seems not to work because the column numbers is different between 
> the 2 tables?
>
>
> Le samedi 15 décembre 2012 20:23:44 UTC+1, Massimo Di Pierro a écrit :
>>
>> If you have lots of records you may be able to do it with a database 
>> view but that may be db specific.
>>
>> If you don't have too many records you can do:
>>
>> rows = ( db(db.dataset1).select() | db(db.dataset2).select() 
>> ).sort(lambda row: row.date)
>>
>>
>>
>> On Saturday, 15 December 2012 08:43:35 UTC-6, Mamisoa Andriantafika 
>> wrote:
>>>
>>> Hi,
>>>
>>> I have this db model:
>>>
>>> db.define_table('patients',
>>> Field('name', 'string', length=32),
>>> Field('firstname', 'string', length=32),
>>> Field('dob', 'date'),
>>> format='%(name)s')
>>>
>>> db.define_table('dataset1',
>>> Field('date', 'date', length=32),
>>> Field('param1', 'string', length=50),
>>> Field('param2', 'string', length=50),
>>> Field('patient_id', db.patients, writable=False, readable=False))
>>>
>>> db.define_table('dataset2',
>>> Field('date', 'date', notnull=True),
>>> Field('test1', 'text'),
>>> Field('patient_id', db.patients, writable=False, readable=True))
>>>
>>> I'd like to show in one view, for 1 patient_id, all the 
>>> corresponding dataset1 and dataset2 ordered by date.
>>>
>>> What query should I use? Do I have to use an intermediate table 
>>> 'history' to record each activity in dataset1/2 to get a result?
>>>
>>> Thanks for help.
>>>
>>

-- 





Re: [web2py] Re: web2py interactive shell in windows does not start the browser

2012-12-20 Thread Bhaskar Ramachandran
Thanks very much. This gives me a very good hold to understand web2py 
internals at my pace, understanding the internal workings step by step. 
Great!!.
Can someone explain the workflow in greater details than what is available 
in the web2py 4th edition (Chapter: THE CORE page 137). ?

One of you who have indepth understanding of the framework - if you could 
try to explain its internal process, Example of what i am looking for : 
What happens from the time someone makes a webpage request from the browser 
-- what objects are created in memory ... how the user inputs in forms are 
automatically processed by web2py,... how these objects are available to 
the user for modification through the controller code,... how the final 
response object is created and rendered as html back to the browser...

((For example, i was trying to set a break point in the view code 
layout.html, but this is never reached and i think this is because the view 
is not directly executed as it is html+python but some other web2py python 
code is text processing this view code and generating pure python code 
which then gets executed. This took quite some time and digging iinto 
the web2py book to figure out... Also , i am new to web development and 
don't have the correct basic instincts to yet know what to expect and what 
not :-))

I really want to understand more internal workings I am sure i will 
make use of the debugger and try to uncover these details one by one... But 
a documentation from the experts who created web2py would be of immense 
value to me and reduce my learning time 

I love web2py not just for its simplicity but more importantly for its 
wonderful support by people like you -- Thank you very much.

Regards,
Bhaskar



On Wednesday, December 19, 2012 10:18:44 PM UTC-6, rochacbruno wrote:
>
> FYK.
>
> I just tested the new WingIDE 4.1 with web2py for debugging and it is just 
> awesome!
>
> **maybe we can try to include this in the documentation
>
> Take a look at breakpoints, Stack data, debug probe and documentation on 
> the right panel!
>
> [image: Inline image 1]
>

-- 





[web2py] Re: Customizing auth login form but unable to set the form class name

2012-12-20 Thread Bhaskar Ramachandran
Hi Anthony,

   Your XML(form.custom..) command worked!!.* But simply writing the 
form statement in HTML did not .* I am customizing the auth.login() form 
here. In my default.py, i have dict(form=auth.login()) statement.
Now if i simply manually write a form in pure HTML in the view file, will 
web2py be able to map this form to the auth login form ?. Or do i need any 
form name to be specified ? This is the only form in my page.

Also, I am writing the form in the layout.html page and not index.html page 
because i want the login form to appear as part of my layout template 
itself for multiple pages so the user always sees the login form on top of 
the page until he decides to login. I assume writing this form in 
index.html or layout.html shouldn't make a difference.


On Wednesday, December 19, 2012 6:50:18 PM UTC-6, Anthony wrote:
>
> Sorry, I forgot this doesn't work with form.custom.begin, which is an XML 
> object rather than an HTML helper (because it includes only the opening 
> form tag). Instead, you could do this:
>
> {{=XML(form.custom.begin.replace('>', ' class="myclass">'))}}
>
> but it's probably more straightforward to just manually code the HTML:
>
>  "myclass">
>
> Anthony
>
> On Wednesday, December 19, 2012 6:38:42 PM UTC-5, Bhaskar Ramachandran 
> wrote:
>>
>> Hi Anthony,
>>
>>   I tried that earlier also but that code didn't seem to work. I say so 
>> because my html page still has that login form on the left side of the 
>> navigation bar and looking at the source code, i see the following:
>>  
>> No class is added.
>> If I replace the custom form with a hard coded form with class name in 
>> the > So, it looks like somehow those statements to set class name are 
>> overridden by something else. I have these statements after the custom 
>> begin and custom end block in my view file so this is the last thing that 
>> is done to the form before it is rendered. 
>>
>> I tried both your statements below and both of them didn't do anything. 
>> If you could also teach me how i can go and debug this situation, ( by 
>> looking at the form object in real time if possible to see how it gets 
>> modified during web2py execution on that page) it will help me in the long 
>> run... 
>>
>> Thanks! 
>> -Bhaskar
>>
>>
>> On Wednesday, December 19, 2012 11:09:48 AM UTC-6, Anthony wrote:
>>>
>>> form['_class'] = 'myclass'
>>>
>>> or
>>>
>>> form.update(_class='myclass')
>>>
>>> A form is an HTML helper object, just like any other HTML helper, so the 
>>> usual rules apply: 
>>> http://web2py.com/books/default/chapter/29/05#HTML-helpers
>>>
>>> Anthony
>>>
>>> On Tuesday, December 18, 2012 11:33:32 PM UTC-5, Bhaskar Ramachandran 
>>> wrote:

 As listed in the "view" code below, i am trying to customize the form 
 returned by auth.login(). Note that i have in my controller "return 
 dict(form=auth.login()). Then in the view code pasted below i am 
 customizing the login form.
 It seems to work fine except that i am unable to assign a class name to 
 this form. So my question is " How to set the class name for a form object 
 ?. There are posts in the mailing list to specify class name for elements 
 within the form object but i couldn't find one that explains how the class 
 name for the form object itself can be assinged. 
 Please let me know if my question needs more explanation. Thank you.
   {{
 if not auth.is_logged_in() :
   if not 'register' in auth.settings.
 actions_disabled:
form.add_button(T('Register'),URL(
 args='register'),_class='btn')
pass
if not 'request_reset_password' inauth
 .settings.actions_disabled:
  form.add_button(T('Lost Password'
 ),URL(args='request_reset_password'),_class='btn')
 pass 
  }}
 
 {{=form.custom.begin}}
>>> "/myscienceapp/default/register?_next=/default/index" style="margin-right: 
 10px">Sign Up
   
  >>> class="input-small" style="margin-right: 5px; border-radius: 5px 5px 5px 
 5px;" type="text" name="email" placeholder="Email"/>
 >>> ="margin-right: 2px; border-radius: 5px 5px 5px 5px;" type="password"name
 ="password" placeholder="Password"/>
   >>> style="margin-right: 
 5px; margin-bottom: 0px;border-radius: 5px 5px 5px 5px;" size="5" type=
 "submit" name="commit" value="Go!" />
>>> style="margin-right: 
 5px; margin-bottom: 16px;" type="checkbox" name="remember" value="1" />
   >>> style="margin-right: 
 10px;" for="user_remember_me">Rememb

[web2py] Re: Customizing auth login form but unable to set the form class name

2012-12-20 Thread Anthony

>
>Your XML(form.custom..) command worked!!.* But simply writing the 
> form statement in HTML did not .* I am customizing the auth.login() form 
> here. In my default.py, i have dict(form=auth.login()) statement.

Now if i simply manually write a form in pure HTML in the view file, will 
> web2py be able to map this form to the auth login form ?. Or do i need any 
> form name to be specified ? This is the only form in my page.
>

I was only suggesting doing that first line manually, not the entire form. 
When web2py serializes a form, it includes two hidden fields -- _formname 
and _formkey, which are needed for processing. Those fields are included as 
part of {{=form.custom.end}}, or you can insert them directly via 
{{=form.hidden_fields()}}. The values of those fields are stored in 
form.formname and form.formkey as well.

Anthony

-- 





Re: [web2py] Web2Py and Ajax

2012-12-20 Thread Bruno Rocha
if not request.ajax:
response.menu = _menu()

On Thu, Dec 20, 2012 at 1:52 PM, Martijn Hermans
wrote:

> When I handle a request in Web2Py it builds a menu in models/menu.py.
> This behaviour is exactly what I want for a normal request, but I want to
> skip this, when I make an ajax-call.
>
> Is this possible?
>
> thx,
>
> Martijn
>
> --
>
>
>
>

-- 





[web2py] Re: Customizing auth login form but unable to set the form class name

2012-12-20 Thread Bhaskar Ramachandran
Great!. Thank you. Web2py is very much customizable!!.

Regards,
Bhaskar


On Thursday, December 20, 2012 10:55:29 PM UTC-6, Anthony wrote:
>
>Your XML(form.custom..) command worked!!.* But simply writing the 
>> form statement in HTML did not .* I am customizing the auth.login() form 
>> here. In my default.py, i have dict(form=auth.login()) statement.
>
> Now if i simply manually write a form in pure HTML in the view file, will 
>> web2py be able to map this form to the auth login form ?. Or do i need any 
>> form name to be specified ? This is the only form in my page.
>>
>
> I was only suggesting doing that first line manually, not the entire form. 
> When web2py serializes a form, it includes two hidden fields -- _formname 
> and _formkey, which are needed for processing. Those fields are included as 
> part of {{=form.custom.end}}, or you can insert them directly via 
> {{=form.hidden_fields()}}. The values of those fields are stored in 
> form.formname and form.formkey as well.
>
> Anthony
>

-- 





[web2py] Re: Web2Py and Ajax

2012-12-20 Thread Massimo Di Pierro
if not request.ajax: 

On Thursday, December 20, 2012 9:35:02 AM UTC-6, Martijn Hermans wrote:
>
> I've just started using web2py and have a question about ajax calls.
>
> In my project a menu is defined (and build) in models/meny.py).
> The menu is added to the response like this : response.menu = _menu()
>
> In this way I can access the menu in my layout and that is exacly what I 
> want, except...
>
> when I am doing a ajax call. 
>
> Is there a way to skip building my menu when I'm using a ajax call?
>
>
>
>

-- 





[web2py] Re: Beware auth.enable_record_versioning

2012-12-20 Thread Massimo Di Pierro
This helped me a lot understand the problem. I believe I have a fix in 
trunk. Can you please check if the problem is indeed solved?

On Thursday, December 20, 2012 1:21:21 PM UTC-6, Cliff Kachinske wrote:
>
> To enable archiving, I added enable_record_versioning(db) = True to my 
> models files.
>
> I encountered the problems described in the two bug reports I submitted 
> today on Google code.
>
> At one point I thought it would help with isolating the problem if I 
> turned off versioning, so I commented out the line enabling it.
>
> When I uncommented the line, I found tables with names like 
> "products_archive_archive."  These are archive tables for the archive 
> tables.
>
> I suppose if I repeated the sequence I would have tables with names like 
> "products_archive_archive_archive."
>
> On Thursday, December 20, 2012 10:05:25 AM UTC-5, Massimo Di Pierro wrote:
>>
>> I do not understand. Can you explain?
>>
>> On Thursday, 20 December 2012 08:11:42 UTC-6, Cliff Kachinske wrote:
>>>
>>> I just discovered that auth.enable_record_versioning will create archive 
>>> tables for the archive tables if turned off and turned back on.
>>>
>>> Not acceptable.
>>>
>>

-- 





[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-20 Thread Massimo Di Pierro
Nice! You should sign up on experts4solutions.com. You'd approve you 
immediately.

Massimo

On Thursday, December 20, 2012 4:40:15 PM UTC-6, Mamisoa Andriantafika 
wrote:
>
> I finally found the solution using COALESCE to merge and order date 
> columns:
>
> exams_mutex = db().select(db.dataset1.date.coalesce(db.dataset2.date), db.
> dataset1.ALL, db.dataset2.ALL, left=[db.dataset1.on(db.mutex.i==0),db.
> dataset2.on(db.mutex.i==1)], orderby=db.dataset1.date.coalesce(db.dataset2
> .date))
>
> Mamisoa
>
> Le jeudi 20 décembre 2012 16:08:34 UTC+1, Massimo Di Pierro a écrit :
>>
>> Sorry I do not have a good solution at the moment. Can you open a ticket 
>> about this so we'll will not forget. For now you may want to consider 
>> creating a database view and selecting from the view. You would need to 
>> create a model (readonly) to access the view.
>>
>> On Wednesday, 19 December 2012 16:19:33 UTC-6, Mamisoa Andriantafika 
>> wrote:
>>>
>>> Best results to UNION I could have was using the mutex table trick:
>>>
>>> http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/
>>> with this syntax:
>>>
>>> exams_mutex = db().select(db.dataset1.ALL, db.dataset2.ALL, 
>>> left=[db.dataset1.on(db.mutex.i==0),db.dataset2.on(db.mutex.i==1)])
>>>
>>> Two problems left:
>>>
>>> 1- how to merge the 2 date columns
>>> 2- how to order then by date
>>>
>>> SQL answer is there:
>>>
>>> http://stackoverflow.com/questions/8245630/mysql-combine-two-date-fields-and-then-order-by
>>>
>>> SELECT
>>> [some info],
>>> GREATEST( ticket_date, ticket_history_date ) as latest_date
>>> FROM
>>> [tables and join]
>>> ORDER BY
>>> latest_date
>>>
>>>
>>> Is is possible using to process it using DAL?
>>>
>>> Le dimanche 16 décembre 2012 17:40:22 UTC+1, Mamisoa Andriantafika a 
>>> écrit :

 Sorry I still get: "Cannot | incompatible Rows objects".

 I'll change the field name "date" you are very right.

 Le dimanche 16 décembre 2012 15:49:57 UTC+1, Massimo Di Pierro a écrit :
>
> My bad. Thry this:
>
> fields1 = [db.dataset1.date, db.dataset1.param1, 
> db.dateset1.patient_id]
> fields2 = [db.dataset2.date, db.dataset2.test1, db.dateset2.patient_id]
> rows = ( db(db.dataset1).select(*fields1) | 
> db(db.dataset2).select(*fields2) ).sort(lambda row: row.date)
>
> Mind that having a column called "date" will result in major headaches 
> in the future.
>
> On Sunday, 16 December 2012 03:15:46 UTC-6, Mamisoa Andriantafika 
> wrote:
>>
>> Hi again,
>>
>> "|" seems not to work because the column numbers is different between 
>> the 2 tables?
>>
>>
>> Le samedi 15 décembre 2012 20:23:44 UTC+1, Massimo Di Pierro a écrit :
>>>
>>> If you have lots of records you may be able to do it with a database 
>>> view but that may be db specific.
>>>
>>> If you don't have too many records you can do:
>>>
>>> rows = ( db(db.dataset1).select() | db(db.dataset2).select() 
>>> ).sort(lambda row: row.date)
>>>
>>>
>>>
>>> On Saturday, 15 December 2012 08:43:35 UTC-6, Mamisoa Andriantafika 
>>> wrote:

 Hi,

 I have this db model:

 db.define_table('patients',
 Field('name', 'string', length=32),
 Field('firstname', 'string', length=32),
 Field('dob', 'date'),
 format='%(name)s')

 db.define_table('dataset1',
 Field('date', 'date', length=32),
 Field('param1', 'string', length=50),
 Field('param2', 'string', length=50),
 Field('patient_id', db.patients, writable=False, 
 readable=False))

 db.define_table('dataset2',
 Field('date', 'date', notnull=True),
 Field('test1', 'text'),
 Field('patient_id', db.patients, writable=False, readable=True))

 I'd like to show in one view, for 1 patient_id, all the 
 corresponding dataset1 and dataset2 ordered by date.

 What query should I use? Do I have to use an intermediate table 
 'history' to record each activity in dataset1/2 to get a result?

 Thanks for help.

>>>

-- 





[web2py] Regarding ldap+kerberos authetication

2012-12-20 Thread r13race

Hello,

I have an application that is using ldap+kerberose for authentication.

models/db.py has the following code to configure the login method:

from gluon.tools import *
mail = Mail()  # mailer
auth = Auth(globals(),db)  # 
authentication/authorization
crud = Crud(globals(),db)  # for CRUD helpers using auth
plugins = PluginManager()

from gluon.contrib.login_methods.pam_auth import pam_auth
auth.settings.actions_disabled=['register','request_reset_password','profile','forgot_username','retrieve_username']
auth.settings.login_methods=[pam_auth()]
auth.settings.allow_basic_login = True  #for CLI access
crud.settings.auth = None  # =auth to enforce 
authorization on crud

I am unable to understand the flow from login to authentication. Need help 
with that.
I want to change the authentication process. I want the application to 
authenticate users from the db instead ldap+kerberos.
Please guide me how to do that?

-- 





[web2py] Regarding running web2py.py on ubuntu

2012-12-20 Thread saransh
Hello,

I have a web2py application running on Ubuntu and when i search for the 
processes running i cannot find python web2py.py running.
Why is this so?

Is there any other way of running web2py on ubuntu other than running 
web2py.py?

 

-- 





[web2py] Re: web3py?

2012-12-20 Thread Massimo Di Pierro
Actually I like your solution. It could be even easier.

class attr(object):
 def __init__(self,key,value):
  self.key=key
  self.value=value

class DIV(object):
def __init__(self,*components,**attributes):
self.components = []
self.attributes = attributes
for x in components:
 if isinstance(x,attr): self.attributes[x.key]=x.value
 else: self.components.append(x)

print DIV('hello','world',attr('data-something','value'),_class='myclass')
helloworld
...

DIV('hello','world',attr('data-something')='value')







On Thursday, December 20, 2012 4:02:45 PM UTC-6, Arnon Marcus wrote:
>
> Pfff...
>
> The creator of web2py says he wishes he could do web3py some other way, 
> but can't...
>
> Am I the only one that finds that funny? :)
>
> web3py will end up however you wish it to end up as...
>
> You can do whatever you want with it, as it's already inherently backwards 
> incompatible (python 3.x), and is not even fully planned yet...
>
> If anyone at any time could change things, it would be you guys and at 
> this time...
>
> How about putting auxiliary attributes "front and center"?
> Data-* attributes are already a part of the standard of HTML5 and 
> most-if-not-all browsers support them.
>
> Single-Page apps are also not even considered a novelty anymore, and we're 
> in a Renaissance of data-binding frameworks...
>
> I mean, I guess I could do this:
>
> def DATA(name, value):
> return {('_data-' + name):str(value)}
> 
>
> Then:
>
> DIV( "{{MyVar}}", **DATA( "ng-controller", "MyController" ) )
> =>
> DIV( "{{MyVar}}", **{ "_data-ng-controller": "MyController" } )
> =>
> {{MyVar}}
>
> and:
>
> DIV( "{{MyVar}}", **DATA( "bind", "text: MyVar" ) )
> =>
> DIV( "{{MyVar}}", **{ "_data-bind": "text: MyVar" } )
> =>
> {{MyVar}}
>
>
> But hell, you can make the TAG classes able to receive DATA 
> class-instances, that other people can sub-class/modify to implenet the 
> interface for different frameworks.
>
> A generic DATA class may look something like this:
>
> class DATA:
>
> namespace = ""
> 
> aggregate = False
> seperator = ": "
> delimiter = ", "
>
> def __init__(self, **attrs):
> self.attrs = dict(**attrs)
> ...
>
> def parse( self ):
> parsed = ""
> 
> if aggregatre:
> parsed += 'data-' + ns + '="'
> for k, v in items(self.attrs):
> parsed += k + seperator + v + delimiter
> parsed = parsed[:-len(delimiter)] + '"'
> else:
> ns  = namespace + '-' if namespace else ''
> for k, v in items(self.attrs):
> parsed += 'data-' + ns + k + '="' + v + '"'
> 
> return parsed  
>
>
> And have your TAG classes do something like:
>
> class :
> def __init__(self, content, *vars, **args):
> ...
> parsed = [ var.parsed() for var in *vars if isinstanceof(var, 
> DATA) ]
> ...
> 
> ...
>
>
> Angular guys may then do something like this:
>
> DATA.namespace = "ng"
> BUTTON( "Delete", DATA( click="destroy()", show="project._id".) )
> =>
>  data-ng-show="project._id">Delete
>
> or:
>
> class ngDATA( DATA ):
> namespace = "ng"
>
> + 
>
>
> Knockout guys could do this:
>
> DATA.namespace = "bind"
> DATA.aggregate = True
> SELECT( "", DATA( options = "$root.availableMeals",
>value = "meal".
>optionsText = "'mealName'" ) )
> =>
> 
>
> or:
>
> class koDATA( DATA ):
> namespace = "bind"
> aggregated = False
>
> + 
>
>
> More advanced usages can then sub-class DATA and just re-implement the 
> parse function...
>
>
> What say you?
>
> On Thursday, December 20, 2012 7:17:48 AM UTC-8, Massimo Di Pierro wrote:
>>
>> Oops. right. I wish there was a simple syntax but I cannot think about 
>> one. 
>>
>> On Thursday, 20 December 2012 09:07:21 UTC-6, Niphlod wrote:
>>>
>>> correction, the _ in front is needed as always  
>>> DIV('content',**{'_data-something':'something value'})
>>>
>>> Il giorno giovedì 20 dicembre 2012 15:58:25 UTC+1, Massimo Di Pierro ha 
>>> scritto:

 They always did although the syntax is cumbersone

 DIV('content',**{'data-something':'something value'})

 On Thursday, 20 December 2012 04:16:54 UTC-6, Arnon Marcus wrote:
>
> Cool (!)
>
> Do the HTML helpers support HTML5's " data-* " attributes?
> Can that be used for javascriupt frameworks like Knockout.js or 
> Angular.js ?
>


-- 





[web2py] Re: web3py?

2012-12-20 Thread Massimo Di Pierro
Ignore the very last line. Cut and paste error.

On Friday, December 21, 2012 12:43:34 AM UTC-6, Massimo Di Pierro wrote:
>
> Actually I like your solution. It could be even easier.
>
> class attr(object):
>  def __init__(self,key,value):
>   self.key=key
>   self.value=value
>
> class DIV(object):
> def __init__(self,*components,**attributes):
> self.components = []
> self.attributes = attributes
> for x in components:
>  if isinstance(x,attr): self.attributes[x.key]=x.value
>  else: self.components.append(x)
>
> print DIV('hello','world',attr('data-something','value'),_class='myclass')
> helloworld
> ...
>
> DIV('hello','world',attr('data-something')='value')
>
> 
>
>
>
>
>
> On Thursday, December 20, 2012 4:02:45 PM UTC-6, Arnon Marcus wrote:
>>
>> Pfff...
>>
>> The creator of web2py says he wishes he could do web3py some other way, 
>> but can't...
>>
>> Am I the only one that finds that funny? :)
>>
>> web3py will end up however you wish it to end up as...
>>
>> You can do whatever you want with it, as it's already inherently 
>> backwards incompatible (python 3.x), and is not even fully planned yet...
>>
>> If anyone at any time could change things, it would be you guys and at 
>> this time...
>>
>> How about putting auxiliary attributes "front and center"?
>> Data-* attributes are already a part of the standard of HTML5 and 
>> most-if-not-all browsers support them.
>>
>> Single-Page apps are also not even considered a novelty anymore, and 
>> we're in a Renaissance of data-binding frameworks...
>>
>> I mean, I guess I could do this:
>>
>> def DATA(name, value):
>> return {('_data-' + name):str(value)}
>> 
>>
>> Then:
>>
>> DIV( "{{MyVar}}", **DATA( "ng-controller", "MyController" ) )
>> =>
>> DIV( "{{MyVar}}", **{ "_data-ng-controller": "MyController" } )
>> =>
>> {{MyVar}}
>>
>> and:
>>
>> DIV( "{{MyVar}}", **DATA( "bind", "text: MyVar" ) )
>> =>
>> DIV( "{{MyVar}}", **{ "_data-bind": "text: MyVar" } )
>> =>
>> {{MyVar}}
>>
>>
>> But hell, you can make the TAG classes able to receive DATA 
>> class-instances, that other people can sub-class/modify to implenet the 
>> interface for different frameworks.
>>
>> A generic DATA class may look something like this:
>>
>> class DATA:
>>
>> namespace = ""
>> 
>> aggregate = False
>> seperator = ": "
>> delimiter = ", "
>>
>> def __init__(self, **attrs):
>> self.attrs = dict(**attrs)
>> ...
>>
>> def parse( self ):
>> parsed = ""
>> 
>> if aggregatre:
>> parsed += 'data-' + ns + '="'
>> for k, v in items(self.attrs):
>> parsed += k + seperator + v + delimiter
>> parsed = parsed[:-len(delimiter)] + '"'
>> else:
>> ns  = namespace + '-' if namespace else ''
>> for k, v in items(self.attrs):
>> parsed += 'data-' + ns + k + '="' + v + '"'
>> 
>> return parsed  
>>
>>
>> And have your TAG classes do something like:
>>
>> class :
>> def __init__(self, content, *vars, **args):
>> ...
>> parsed = [ var.parsed() for var in *vars if isinstanceof(var, 
>> DATA) ]
>> ...
>> 
>> ...
>>
>>
>> Angular guys may then do something like this:
>>
>> DATA.namespace = "ng"
>> BUTTON( "Delete", DATA( click="destroy()", show="project._id".) )
>> =>
>> > data-ng-show="project._id">Delete
>>
>> or:
>>
>> class ngDATA( DATA ):
>> namespace = "ng"
>>
>> + 
>>
>>
>> Knockout guys could do this:
>>
>> DATA.namespace = "bind"
>> DATA.aggregate = True
>> SELECT( "", DATA( options = "$root.availableMeals",
>>value = "meal".
>>optionsText = "'mealName'" ) )
>> =>
>> 
>>
>> or:
>>
>> class koDATA( DATA ):
>> namespace = "bind"
>> aggregated = False
>>
>> + 
>>
>>
>> More advanced usages can then sub-class DATA and just re-implement the 
>> parse function...
>>
>>
>> What say you?
>>
>> On Thursday, December 20, 2012 7:17:48 AM UTC-8, Massimo Di Pierro wrote:
>>>
>>> Oops. right. I wish there was a simple syntax but I cannot think about 
>>> one. 
>>>
>>> On Thursday, 20 December 2012 09:07:21 UTC-6, Niphlod wrote:

 correction, the _ in front is needed as always  
 DIV('content',**{'_data-something':'something value'})

 Il giorno giovedì 20 dicembre 2012 15:58:25 UTC+1, Massimo Di Pierro ha 
 scritto:
>
> They always did although the syntax is cumbersone
>
> DIV('content',**{'data-something':'something value'})
>
> On Thursday, 20 December 2012 04:16:54 UTC-6, Arnon Marcus wrote:
>>
>> Cool (!)
>>
>> Do the HTML helpers support HTML5's " data-* " attributes?
>> Can that be used for javascriupt frameworks like Knockout.js or 
>> Angular.js ?
>>
>

-- 





Re: [web2py] Re: web2py interactive shell in windows does not start the browser

2012-12-20 Thread Massimo Di Pierro
I strongly agree. I wish people outside, specifically in the larger Python 
community, were to understand how large and how nice is this community is.

On Thursday, December 20, 2012 8:04:44 PM UTC-6, Bhaskar Ramachandran wrote:
>
> Thanks very much. This gives me a very good hold to understand web2py 
> internals at my pace, understanding the internal workings step by step. 
> Great!!.
> Can someone explain the workflow in greater details than what is available 
> in the web2py 4th edition (Chapter: THE CORE page 137). ?
>
> One of you who have indepth understanding of the framework - if you could 
> try to explain its internal process, Example of what i am looking for : 
> What happens from the time someone makes a webpage request from the browser 
> -- what objects are created in memory ... how the user inputs in forms are 
> automatically processed by web2py,... how these objects are available to 
> the user for modification through the controller code,... how the final 
> response object is created and rendered as html back to the browser...
>
> ((For example, i was trying to set a break point in the view code 
> layout.html, but this is never reached and i think this is because the view 
> is not directly executed as it is html+python but some other web2py python 
> code is text processing this view code and generating pure python code 
> which then gets executed. This took quite some time and digging iinto 
> the web2py book to figure out... Also , i am new to web development and 
> don't have the correct basic instincts to yet know what to expect and what 
> not :-))
>
> I really want to understand more internal workings I am sure i will 
> make use of the debugger and try to uncover these details one by one... But 
> a documentation from the experts who created web2py would be of immense 
> value to me and reduce my learning time 
>
> I love web2py not just for its simplicity but more importantly for its 
> wonderful support by people like you -- Thank you very much.
>
> Regards,
> Bhaskar
>
>
>
> On Wednesday, December 19, 2012 10:18:44 PM UTC-6, rochacbruno wrote:
>>
>> FYK.
>>
>> I just tested the new WingIDE 4.1 with web2py for debugging and it is 
>> just awesome!
>>
>> **maybe we can try to include this in the documentation
>>
>> Take a look at breakpoints, Stack data, debug probe and documentation on 
>> the right panel!
>>
>> [image: Inline image 1]
>>
>

-- 





[web2py] Re: The book updates and status

2012-12-20 Thread Massimo Di Pierro
Thanks this is great. One thing that can save you time is diff the current 
trunk version of the boot with first github commit. The first commit may 
still have bugs but less likely since it was already the published 4th 
edition.

There is very little that needs to be added (most notably the auth.wiki 
docs) but I need to shuffle come content to balance the size of chapters.

massimo

On Thursday, December 20, 2012 9:23:12 PM UTC-6, Julien Courteau wrote:
>
> I'm in for proof reading of the 5th edition.
>

-- 





[web2py] Re: Regarding ldap+kerberos authetication

2012-12-20 Thread Massimo Di Pierro
Look into gluon/contrib/login_methods/ldap_auth.py

It contains an example of how to use ldap. I am not sure about kerberos. 
There is nothing in web2py for kerberos but I understand kerberos can 
authenticate using both ldap and x509 and for both there is an API.

If we need to add something and you can explain us what we may work on it.

Massimo

On Friday, December 21, 2012 12:26:30 AM UTC-6, saransh wrote:
>
>
> Hello,
>
> I have an application that is using ldap+kerberose for authentication.
>
> models/db.py has the following code to configure the login method:
>
> from gluon.tools import *
> mail = Mail()  # mailer
> auth = Auth(globals(),db)  # 
> authentication/authorization
> crud = Crud(globals(),db)  # for CRUD helpers using 
> auth
> plugins = PluginManager()
>
> from gluon.contrib.login_methods.pam_auth import pam_auth
>
> auth.settings.actions_disabled=['register','request_reset_password','profile','forgot_username','retrieve_username']
> auth.settings.login_methods=[pam_auth()]
> auth.settings.allow_basic_login = True  #for CLI access
> crud.settings.auth = None  # =auth to enforce 
> authorization on crud
>
> I am unable to understand the flow from login to authentication. Need help 
> with that.
> I want to change the authentication process. I want the application to 
> authenticate users from the db instead ldap+kerberos.
> Please guide me how to do that?

-- 





[web2py] Re: Regarding running web2py.py on ubuntu

2012-12-20 Thread Massimo Di Pierro
Did you use setup-web2py-ubuntu.sh? In that case web2py is running under 
apache therefore you will only see the apache processes.

Massimo

On Friday, December 21, 2012 12:37:19 AM UTC-6, saransh wrote:
>
> Hello,
>
> I have a web2py application running on Ubuntu and when i search for the 
> processes running i cannot find python web2py.py running.
> Why is this so?
>
> Is there any other way of running web2py on ubuntu other than running 
> web2py.py?
>
>  
>
>

-- 





Re: [web2py] Re: Regarding running web2py.py on ubuntu

2012-12-20 Thread Saransh Gupta
I am new to the system.
I need to find out how it is running.
How can i verify if setup-web2py-ubuntu.sh has been used?
Would it be mentioned in apache2 config files?


On Fri, Dec 21, 2012 at 12:24 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Did you use setup-web2py-ubuntu.sh? In that case web2py is running under
> apache therefore you will only see the apache processes.
>
> Massimo
>
>
> On Friday, December 21, 2012 12:37:19 AM UTC-6, saransh wrote:
>>
>> Hello,
>>
>> I have a web2py application running on Ubuntu and when i search for the
>> processes running i cannot find python web2py.py running.
>> Why is this so?
>>
>> Is there any other way of running web2py on ubuntu other than running
>> web2py.py?
>>
>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Re: Regarding running web2py.py on ubuntu

2012-12-20 Thread Massimo Di Pierro
when you visit a web page from chrome you can instead the response headers 
and you check which web server is serving pages. Probably you will see 
apache. In this case you should find a reference to web2py in one of the 
apache config file. 

On Friday, 21 December 2012 00:56:37 UTC-6, saransh wrote:
>
> I am new to the system.
> I need to find out how it is running.
> How can i verify if setup-web2py-ubuntu.sh has been used?
> Would it be mentioned in apache2 config files?
>
>
> On Fri, Dec 21, 2012 at 12:24 PM, Massimo Di Pierro 
> 
> > wrote:
>
>> Did you use setup-web2py-ubuntu.sh? In that case web2py is running under 
>> apache therefore you will only see the apache processes.
>>
>> Massimo
>>
>>
>> On Friday, December 21, 2012 12:37:19 AM UTC-6, saransh wrote:
>>>
>>> Hello,
>>>
>>> I have a web2py application running on Ubuntu and when i search for the 
>>> processes running i cannot find python web2py.py running.
>>> Why is this so?
>>>
>>> Is there any other way of running web2py on ubuntu other than running 
>>> web2py.py?
>>>
>>>  
>>>
>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: Div into Markmin

2012-12-20 Thread Massimo Di Pierro
Can you explain the purpose of this?


On Sunday, 16 December 2012 03:57:20 UTC-6, David Alvarez wrote:
>
> I found a module to include in the syntax Markmin div, but I can not do 
> the installation, the module is called Markdiv and attachment to see if 
> anyone can make it work, or explain how to include html code in Markmin, 
> Thanks
>

-- 





[web2py] Re: Upload form, onvalidation and postbacks

2012-12-20 Thread Massimo Di Pierro
Which web2py version? I believe this was fixed in 2.2 or 2.3.

Massimo

On Thursday, 13 December 2012 11:55:34 UTC-6, Andy Salnikov wrote:
>
> Hi, 
>
> I have an issue with the upload form and postbacks. In my application I 
> need to validate file contents before accepting it from user upload form, 
> so naturally I try to use "onvalidation" method to it. The table used in 
> the forma is defined like this:
>
> db.define_table('input_data',
> Field('input_file', 'upload', autodelete=True, 
> requires=IS_NOT_EMPTY(), label=T('Input file')),
> Field('output_type', default="xxx", 
> requires=IS_IN_SET(['xxx', 'yyy']), label=T('Output format')),
> Field('original_name', writable=False, readable=False),
> Field('created', 'datetime', writable=False, 
> readable=False),
> )
>
> My simplified action looks like this:
>
> def _validateFileForm(form):
> try:
> validator.validate(form.vars.input_file.file)
> # on success set hidden fields
> form.vars.original_name = request.vars.input_file.filename
> form.vars.created = datetime.datetime.now()
> except Exception, ex:
> # if validation fails then display an error
> form.errors.input_file = T('file_validation_failed') + ': ' + 
> str(ex)
>
> def index():
>
> form = SQLFORM(db.input_data, submit_button=T("Upload"))
> if form.process(onvalidation=_validateFileForm).accepted:
> # save file id in a session and go to options page
> session.input_data_id = form.vars.id
> redirect(URL(options_odt))
>
> return dict(form=form)
>
> Validation seems to work OK, if file is OK then everything is redirected 
> to next page, if file is bad then message is displayed in red under file 
> upload field. 
>
> What is interesting about it is that when validation fails and form is 
> re-displayed it also looks like that the whole file contents is send back 
> to the client together with the form. For large uploaded file this could be 
> a lot of data. I see long delays and when I check the HTTP response headers 
> I see many-megabytes number there. Is there a way to avoid sending the file 
> contents back with the form during a postback?
>
> Thanks,
> Andy
>

-- 





Re: [web2py] Re: Regarding running web2py.py on ubuntu

2012-12-20 Thread Saransh Gupta
I figured it out.
Thank you.

This application is using pam-auth() for authentication.
I want to used db instead for the authentication process.
I am unable figure out the login workflow.
Please guide me through it or recommend a tutorial if available for the
same.
It will be of great help.


On Fri, Dec 21, 2012 at 12:48 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> when you visit a web page from chrome you can instead the response headers
> and you check which web server is serving pages. Probably you will see
> apache. In this case you should find a reference to web2py in one of the
> apache config file.
>
>
> On Friday, 21 December 2012 00:56:37 UTC-6, saransh wrote:
>
>> I am new to the system.
>> I need to find out how it is running.
>> How can i verify if setup-web2py-ubuntu.sh has been used?
>> Would it be mentioned in apache2 config files?
>>
>>
>> On Fri, Dec 21, 2012 at 12:24 PM, Massimo Di Pierro <
>> massimo@gmail.com> wrote:
>>
>>> Did you use setup-web2py-ubuntu.sh? In that case web2py is running under
>>> apache therefore you will only see the apache processes.
>>>
>>> Massimo
>>>
>>>
>>> On Friday, December 21, 2012 12:37:19 AM UTC-6, saransh wrote:

 Hello,

 I have a web2py application running on Ubuntu and when i search for the
 processes running i cannot find python web2py.py running.
 Why is this so?

 Is there any other way of running web2py on ubuntu other than running
 web2py.py?



  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

--