[web2py] Re: st_dwithin

2015-12-06 Thread Pierre

Great !!

I'd prefer to use Web2py api instead of executesql but I've read the latter 
is faster (speed might be a concern in my case). I'll do the modifications 
you suggest and see if it works. I hope this won't corrupt Web2py magical 
harmony

thanks

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


[web2py] Re: Does web2py set automatic cookies?

2015-12-06 Thread Leonel Câmara
Note that if you're talking about European rules you probably don't need to 
inform your users (In my case whenever I thought I needed I didn't) as 
there are exceptions to the rules. What I found is that the cookie warning 
is idiotically overused in many places where it isn't needed. For instance 
the login/remember me you refer is specifically exempt.  
  
In fact if you're not using the cookie for tracking anything in particular 
you can claim the cookie is a strictly necessary one to detect repeated 
login attempts and csrf prevention which is also exempt.  
  
Seriously, check the exceptions, I wish more website owners did because I 
hate those cookie warnings.

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


[web2py] Re: list:string how to limit the number of strings

2015-12-06 Thread Pierre

custom validator fails : why ?

model:

class IS_LIST_TAGS:
def __init__(self, separator=',', error_message='too many tags max=3 
tags!'):
self.separator = separator
self.e = error_message

def __call__(self,value):
try:
li = value.split(self.separator)
assert(len(li) <= 3)
return (li, None)

db.define_table('listr',
Field('tags','list:string',requires=[IS_NOT_EMPTY(), 
IS_LIST_TAGS()]))

controller:

def test():
form = SQLFORM(db.listr)
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill out the form'
return dict(form=form)

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


[web2py] Re: Problem define model class to model dal table no guide

2015-12-06 Thread Alessio Varalta
This solution for me is not good. Ok in this case work but virtual field 
allows only simple operation on the single filed of a table. I want class 
with function where i can use cicle and where i can use another dal 
object..This is present for all frameworks java-ruiby!!! for 
exmpale

Class Person extend Model
  string name,
  int age ecc..
  function calculateNationOfPerson(id){
Nation nation=new Nation('all')
return nation.find_nation_of_person(id)
  }
}

Don't analyse the exact syntax is only a exmpale
So if there is any possibility to create a class with function where you 
can use also the other tables? Only solution that I have find is to create 
a file module that have the name of the table and where i put all 
function...This is not a good solution but i see only this!
In Java-Ruby the model class are a rapresentation of the object database so 
you can use the model class for the logic for exmpale 
http://guides.rubyonrails.org/active_record_basics.html, implment function 
and use this in the controller. So I see the class in web2py but don't 
class that represent the model so I think is impossibile!Put all logic in 
controller? Create module with many functions??





On Sunday, 6 December 2015 00:03:47 UTC+1, Anthony wrote:

> Also, note that virtual fields (both the old style you have shown below 
> and the new style Field.Virtual) are designed to calculate values based on 
> other fields in the record. This happens at the time the records from the 
> database are parsed into a Rows object, so you cannot use these for 
> updating records by calling them at some later point. Instead, for this 
> purpose, you would have to use Field.Method, or if you want to use the old 
> style virtual fields, you would have to define the methods as "lazy" (as 
> described in the documentation). Field.Method and lazy virtual fields were 
> not really designed with this use in mind, but I suppose they can be used 
> this way. Here's an example:
>
> db.define_table('mytable',
> ...,
> Field.Method('change_name', lambda r, nome: r.mytable.update_record(
> nome=nome)))
>
> db.mytable(1).change_name(nome='Alessio')
>
> Anyway, there are other ways to handle such things without resorting to 
> virtual fields or classes -- for example, just writing simple functions.
>
> Anthony
>
> On Saturday, December 5, 2015 at 5:24:28 PM UTC-5, Anthony wrote:
>>
>> On Saturday, December 5, 2015 at 11:37:01 AM UTC-5, Alessio Varalta wrote:
>>>
>>> Hi, I have a problem..I have controller with too much code..So I want to 
>>> use the logic of Java or Ruby. Have a class that represent the object of my 
>>> database and implement function in this class and use this class in the 
>>> Controller. The problem is that I try the VirtualField a part of web2py 
>>> guide 
>>>
>>> in db file I create
>>> class Layer_scheda(object):
>>> def change_name(self,nome):
>>> self.nome=nome
>>> self.update.update_record() 
>>>
>>
>> It would just be self.update_record(), not self.update.update_record().
>>  
>>
>>> after in my Controller i try 
>>>
>>> order_item.change_name
>>> or order_item.change_name() but I have problem   change_name is not 
>>> defined
>>>
>>
>> What is order_item?
>>
>> Anthony
>>
>

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


[web2py] Re: Problem define model class to model dal table no guide

2015-12-06 Thread Anthony
On Sunday, December 6, 2015 at 9:49:49 AM UTC-5, Alessio Varalta wrote:
>
> This solution for me is not good. Ok in this case work but virtual field 
> allows only simple operation on the single filed of a table.
>

A virtual/method field can be as complex as you want it to be, and it does 
not operate on only a single field of a record. Rather, an entire record is 
passed to it. Furthermore, method fields can take additional arguments and 
of course have access to any global objects as well. Perhaps you are 
confused because the functions of virtual/method fields are often defined 
using lambdas, but you could instead define a separate function using "def" 
and then specify that function in the definition of the virtual field.
 

> I want class with function where i can use cicle and where i can use 
> another dal object..This is present for all frameworks 
> java-ruiby!!! for exmpale
>

I don't see how you would *need* a class for anything you want to do. You 
could simply create functions and pass the records to the functions (the 
DAL method fields are just a convenient way to attach such functions as 
pseudo-methods of the record). If you want a way to organize a set of 
related functions, you could still create a class and just define a set of 
static methods.

If you want an ORM, you might try the weppy ORM or SQLAlchemy or another 
framework altogether, but the web2py DAL is simply not an ORM and is not 
going to be. Nevertheless, it is not clear why you would need an ORM or 
classes to do what you want to do.
 

> Class Person extend Model
>   string name,
>   int age ecc..
>   function calculateNationOfPerson(id){
> Nation nation=new Nation('all')
> return nation.find_nation_of_person(id)
>   }
> }
>

I don't know exactly what the above is attempting to do, as the data model 
of nation is not clear (i.e., is "id" the id of the Person record, and if 
so, how does the Nation object use that to find the person's nation?), so I 
won't attempt any web2py code. But in principle, I don't see why you 
couldn't define a similar function and just pass a web2py Row object to it 
(and optionally, attach it as a method via a method field).

Anthony

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


[web2py] Re: Learning Management System survey

2015-12-06 Thread Richard D
Would love to take this forward too. But I might be able to support you 
before pyodel is developed further.

Richard

On Saturday, February 15, 2014 at 8:09:10 PM UTC+1, Nico de Groot wrote:
>
> Haven't followed thread for a while, I'm still interested. Working at 
> Dutch university as Bb coordinator and have developed Blended learning 
> websites with Web2py.

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


[web2py] Re: submitting the form when updating .load file

2015-12-06 Thread Massimo Di Pierro
Not sure what you are trying to do. could you explain again? Why do you 
have  LOAD inside a form?

On Friday, 4 December 2015 18:00:09 UTC-6, Jason Solack wrote:
>
> Hello all, i have this view:
>
> 
>  for='filter_1'>Test me
> 
> {{=LOAD('chart','test.load',ajax=True, target='test_div', )}}
> 
>
> Test this out
>
> 
> $('#try').click(function(){
> jQuery('#test_div').get(0).reload()
> });
> 
> 
>
>
> and i'm trying to submit that for when reloading my "test.load"...
>
> here's the controller:
>
> def test():
> print request.vars
> 
>
>
> when i print those request.vars i'm just seeing empty storage.  Is there 
> something else i need to do to submit the form when reloading like this?
>
> Thank you
>
> Jason
>

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


[web2py] Re: File Upload Table

2015-12-06 Thread Massimo Di Pierro
What is the question?

On Saturday, 5 December 2015 10:11:04 UTC-6, Eliot Simcoe wrote:
>
> Hello World,
>
> I have a table named File is supposed to be referenced by other tables in 
> an attempt to simulate the "upload' field type. This table is coupled with 
> a Folder table and simulates a file system in the database.
>
> File Fields:
> Field('name', 'string', label=T("Name"), requires=IS_NOT_EMPTY(), required
> =True, notnull=True, length=255),
> Field('caption', 'text', label=T("Caption")),
> Field('content_type', 'string', label=T("Content Type"), requires=
> IS_NOT_EMPTY(), required=True, notnull=True, length=255),
> Field('data_storage', 'upload', label=T("Storage"), uploadfolder=cls.
> __UPLOAD_FOLDER__, uploadseparate=True, autodelete=True, required=True, 
> notnull=True),
> Field('folder_id', cls.__PARENT_CLASS__.Reference(), label=T("Folder"), 
> ondelete='CASCADE'),
> Field('order_hint', 'integer', label=T("Order")),
> Field('absolute_path', compute=lambda row: absolute_path_from_storage(row.
> data_storage, cls.__UPLOAD_FOLDER__))
>
> I have built an ORM around pydal, so the code looks a little funny - but 
> this problem relates directly to web2py.
>
> Now, I have another table that references this file table. This is fine 
> and works well with Smart Grid as long as you are only using file(s) that 
> are already in the database. Smart grid provides the usual popup button on 
> an html page and you can choose which file you want to reference.
>
> Here is an example field set from a table Building that references the 
> File Table:
> Field('address', 'string', label=T("Address"), requires=IS_NOT_EMPTY(), 
> required=True, notnull=True, length=255),
> Field('description', 'text', label=T("Description")),
> Field('picture_id', File.Reference(), label=T("Picture"), ondelete='SET 
> NULL'),
> Field('electric_company', ElectricCompany.Reference(), label=T("Electric 
> Company"), ondelete='SET NULL'),
> Field('school_district', SchoolDistrict.Reference(), label=T("School 
> District"), ondelete='SET NULL'),
> Field('services_ids', Service.ListReference(), label=T("Included Services"
> ), ondelete='SET NULL')
>
> File.Reference() == 'reference plugin_substratum_file' (The pydal table 
> name for the File table is plugin_substratum_file)
>
> Obviously the file reference is now like any other table reference - there 
> is no upload capability. I have written a widget and a validator (that are 
> automatically added to the picture_id field by my ORM)  that create a file 
> input for the field through SQLFORM:
> class FileUploadWidget(FormWidget):
> _class = 'file'
>
> DEFAULT_WIDTH = '150px'
> ID_DELETE_SUFFIX = '__delete'
> GENERIC_DESCRIPTION = 'file ## download'
> DELETE_FILE = 'delete'
>
> @classmethod
> def widget(cls, field, value, **attributes):
> from gluon.contrib.simplejson import JSONEncoder
> 
> """
> generates a INPUT file tag.
>
> Optionally provides an A link to the file, including a checkbox so
> the file can be deleted.
>
> All is wrapped in a DIV.
>
> see also: `FormWidget.widget`
>
> Args:
> field: the field
> value: the field value
> download_url: url for the file download (default = None)
> """
>
> default = dict(_type='file')
> attr = cls._attributes(field, default, **attributes)
>
> attr['_data-show-upload'] = 'false'
> attr['_data-show-close'] = 'false'
> attr['_data-overwrite-initial'] = 'true'
>
> file = File.With_ID(int(value)) if value else None
> if file:
> json = JSONEncoder()
> attr['_data-initial-preview'] = "".format(file
> .url)
> attr['_data-initial-caption'] = file.name
> attr['_data-initial-preview-config'] = json.encode([{
> 'caption' : file.name,
> 'key' : file.id
> }])
> attr['_data-layout-templates'] = json.encode({
> 'actionDelete' : ""
> })
>
> return  INPUT(**attr)
>
> @classmethod
> def represent(cls, field, value):
> """
> How to represent the file:
>
> - with download url and if it is an image:  ...>
> - otherwise with download url: file
> - otherwise: file
>
> Args:
> field: the field
> value: the field value
> download_url: url for the file download (default = None)
> """
>
> inp = current.T(cls.GENERIC_DESCRIPTION)
> file = File.With_ID(int(value)) if value else None
>
> if file:
> url = file.url
> if cls.is_image(file):
> inp = IMG(_src=url, _width
> ...

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues

[web2py] Re: web2py resources

2015-12-06 Thread Massimo Di Pierro
Nice, when did Martin write the original version? I do not remember seeing 
this before.

On Saturday, 5 December 2015 23:07:44 UTC-6, Alfonso Serra wrote:
>
> web2py Best Practices by martin Mulone translated to english by me.
>
> Download "web2py Best Practices.pdf" 
> 
>
>

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


[web2py] Re: submitting the form when updating .load file

2015-12-06 Thread Jason Solack
Sorry i'm not clear!  I'm trying to break up a reporting site and my 
initial idea was to use several LOAD components where in the past i was 
using ajax calls.  I like the component framework as it seems i can return 
HTML templates... it just feels cleaner.

I have this component within the form, but i could keep all the components 
outside the form if that is required to have them passed to their 
corresponding controller.

Another quick question on components.  Is there a way to wait for them to 
be loaded until called upon or must they be all loaded on the initial page 
load?

Thank you for your help

Jason

On Sunday, December 6, 2015 at 3:45:50 PM UTC-5, Massimo Di Pierro wrote:
>
> Not sure what you are trying to do. could you explain again? Why do you 
> have  LOAD inside a form?
>
> On Friday, 4 December 2015 18:00:09 UTC-6, Jason Solack wrote:
>>
>> Hello all, i have this view:
>>
>> 
>> > for='filter_1'>Test me
>> 
>> {{=LOAD('chart','test.load',ajax=True, target='test_div', )}}
>> 
>>
>> Test this out
>>
>> 
>> $('#try').click(function(){
>> jQuery('#test_div').get(0).reload()
>> });
>> 
>> 
>>
>>
>> and i'm trying to submit that for when reloading my "test.load"...
>>
>> here's the controller:
>>
>> def test():
>> print request.vars
>> 
>>
>>
>> when i print those request.vars i'm just seeing empty storage.  Is there 
>> something else i need to do to submit the form when reloading like this?
>>
>> Thank you
>>
>> Jason
>>
>

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


[web2py] Re: CUSTOM a large form

2015-12-06 Thread Jason Solack
I've done this several ways... the actual HTML generation could be via 
web2py's helpers or just writting the HTML. For the tabs i've used 
bootstrap or jquery ui to help out creating tabs... using a library helps 
the process of making tabs pretty trivial...

here's jquery ui's information
http://jqueryui.com/tabs/

bootstrap:
http://getbootstrap.com/components/#nav-tabs

hope that helps

On Friday, December 4, 2015 at 11:51:31 PM UTC-5, Laurent Lc wrote:
>
> Hi,
>
> I'd like to know the best way to present a big form with a lot of fields, 
> using tabs for example and anchors ?
>
> thank you
>

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


Re: [web2py] Re: web2py and python3

2015-12-06 Thread Alex
I'm still missing a clear strategy from the devs... I could understand if 
you don't have enough resources and ask for help (web2py is open source and 
anybody can contribute after all). But saying that python3 is useless and 
nobody wants it is not a good approach.

It seems like most of you only deal with ascii characters. Only if you 
constantly deal with non-ascii characters you really feel the pain of 
python2. e.g. ajax request with user input, use string for mail.send or 
T(..).format(..) -> unicode error. Basically I have to test all user string 
input if it is unicode and convert to str

Alex

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


[web2py] Re: submitting the form when updating .load file

2015-12-06 Thread Anthony
On Sunday, December 6, 2015 at 7:15:04 PM UTC-5, Jason Solack wrote:
>
> Sorry i'm not clear!  I'm trying to break up a reporting site and my 
> initial idea was to use several LOAD components where in the past i was 
> using ajax calls.  I like the component framework as it seems i can return 
> HTML templates... it just feels cleaner.
>
> I have this component within the form, but i could keep all the components 
> outside the form if that is required to have them passed to their 
> corresponding controller.
>
> Another quick question on components.  Is there a way to wait for them to 
> be loaded until called upon or must they be all loaded on the initial page 
> load?
>

Still not quite clear what you are trying to do with the form (as it has no 
action nor submit button). Anyway, you can always manually load and/or 
reload a component as follows:

First, create a div:



Then load a component into the div via:

$.web2py.component('{{=URL('controller', 'function.load')}}', 'mycomponent'
);

Anthony

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


Re: [web2py] Re: web2py and python3

2015-12-06 Thread Jason Solack
i feel this asciii / unicode pain quite often as i deal with data from all 
sorts of sources and much of it is text inputs from various users... i 
would love to see web2py move towards python3

On Sunday, December 6, 2015 at 8:09:41 PM UTC-5, Alex wrote:
>
> I'm still missing a clear strategy from the devs... I could understand if 
> you don't have enough resources and ask for help (web2py is open source and 
> anybody can contribute after all). But saying that python3 is useless and 
> nobody wants it is not a good approach.
>
> It seems like most of you only deal with ascii characters. Only if you 
> constantly deal with non-ascii characters you really feel the pain of 
> python2. e.g. ajax request with user input, use string for mail.send or 
> T(..).format(..) -> unicode error. Basically I have to test all user string 
> input if it is unicode and convert to str
>
> Alex
>

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


[web2py] Re: web2py resources

2015-12-06 Thread Alfonso Serra
No idea, i just know that is pure gold. A set of bests practices to 
structure your application. 
I found this in a post in this user group. Someone was pointing someone 
else to the original pdf in order to answer a question.

On Sunday, 6 December 2015 23:40:51 UTC, Massimo Di Pierro wrote:
>
> Nice, when did Martin write the original version? I do not remember seeing 
> this before.
>
> On Saturday, 5 December 2015 23:07:44 UTC-6, Alfonso Serra wrote:
>>
>> web2py Best Practices by martin Mulone translated to english by me.
>>
>> Download "web2py Best Practices.pdf" 
>> 
>>
>>

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


Re: [web2py] problem while adding a radio button in login form

2015-12-06 Thread Richard Vézina
login form are part of web2py auth.form or something I haven touch that
since a wild... But you have to custom the form and login form is par of
controllers/default/user function... You then need to have a look at the
book to how customize login form...

You may also just try to set readable=True and writable=True on your field
definition it may works... But I am not sure...

Richard

On Fri, Dec 4, 2015 at 5:12 PM, Jonathan R  wrote:

> Hi Richard,
> I've seen people using this way to customize their registration page, they
> could get the radio button to be displayed, I don't really see how the
> login page is different and won't display it, I must miss something.
>
> What "other thing" should I do in your opinion ?
>
> thanks for your time.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: submitting the form when updating .load file

2015-12-06 Thread Jason Solack
So in this case i was just wanting to see if the form was submitted when 
reloading the component via:

jQuery('#test_div').get(0).reload()


and by printing the request.vars to the terminal i saw that it wasn't.  I 
will try your method $.web2py.component and see what results

On Sunday, December 6, 2015 at 8:14:35 PM UTC-5, Anthony wrote:
>
> On Sunday, December 6, 2015 at 7:15:04 PM UTC-5, Jason Solack wrote:
>>
>> Sorry i'm not clear!  I'm trying to break up a reporting site and my 
>> initial idea was to use several LOAD components where in the past i was 
>> using ajax calls.  I like the component framework as it seems i can return 
>> HTML templates... it just feels cleaner.
>>
>> I have this component within the form, but i could keep all the 
>> components outside the form if that is required to have them passed to 
>> their corresponding controller.
>>
>> Another quick question on components.  Is there a way to wait for them to 
>> be loaded until called upon or must they be all loaded on the initial page 
>> load?
>>
>
> Still not quite clear what you are trying to do with the form (as it has 
> no action nor submit button). Anyway, you can always manually load and/or 
> reload a component as follows:
>
> First, create a div:
>
> 
>
> Then load a component into the div via:
>
> $.web2py.component('{{=URL('controller', 'function.load')}}', 
> 'mycomponent');
>
> Anthony
>
>

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


[web2py] custom download function

2015-12-06 Thread Joseph Faulkner


I'm developing a simple webapp in web2py and I want to create a link that 
let's the user download a file. Like this:



However, I want to do this without having to pass the FILE to the user in 
the page handler. I want to retrieve an ID from the server asynchronously 
that will correspond to the file I want to download an then pass it to a 
custom download function like this:

 

This way, I will be able to upload files to the server asynchronously, (I 
already figured out how to do that) and the download link on the page for 
that file will work right away without having to reload the page.

So, on the server side, I would do something like this:

def custom_download(): 
download_row = db(db.computers.FILEID == request.args(0)).select()
download_file = download_row.filefieldreturn download_file

However, I'm not entirely sure what I need to write in order for this to 
work.

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


Re: [web2py] problem while adding a radio button in login form

2015-12-06 Thread Richard Vézina
It

form = auth()

Below example of my login form refactoring :

def user():
"""
exposes:
http:///[app]/default/user/login
http:///[app]/default/user/logout
http:///[app]/default/user/register
http:///[app]/default/user/profile
http:///[app]/default/user/retrieve_password
http:///[app]/default/user/change_password
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control
"""
auth.settings.label_separator = ''
auth.settings.formstyle = 'divs'
form = auth()
if request.args(0) == 'login':
# form.element(_name='email')['_placeholder'] = T('Email')
# form.element(_name='email')['_style'] = 'width: 275px;'
form.element(_name='username')['_placeholder'] = T('Username')
form.element(_name='username')['_style'] = 'width: 275px;'
form.element(_name='password')['_placeholder'] = T('Password')
form.element(_name='password')['_style'] = 'width: 275px;'
form.element(_type='submit').update(_value=T('Log in'), _class='btn
btn-small btn-inverse')
#form[0][1][2].append(A(T('Forgot your password?'),
_href=URL(c='default',
#
f='user', args=('request_reset_password'
response.flash = T('Please login!')
return dict(form=form)
elif request.args(0) == 'profile':
redirect(URL(c='directory', f='user_profile'))
elif request.args(0) == 'request_reset_password':
form.element(_name='email')['_placeholder'] = T('Email')
form.element(_name='email')['_style'] = 'width: 275px;'
form.element(_type='submit').update(_value=T('Send'), _class='btn
btn-small btn-inverse')
return dict(form=form)
elif request.args(0) == 'change_password':
form.element(_name='old_password')['_placeholder'] = T('Old
password')
form.element(_name='old_password')['_style'] = 'width: 275px;'
form.element(_name='new_password')['_placeholder'] = T('New
password')
form.element(_name='new_password')['_style'] = 'width: 275px;'
form.element(_name='new_password2')['_placeholder'] = T('New
password')
form.element(_name='new_password2')['_style'] = 'width: 275px;'
form.element(_type='submit').update(_class='btn btn-small
btn-inverse')
return dict(form=form)
elif request.args(0) == 'not_authorized':
redirect(URL(c='permission', f='not_authorized'))
#if not 'request_reset_password' in
auth.settings.actions_disabled:
#return dict(form=auth()) # Don't understand utility maybe
removed
else:
return dict(form=form)
return dict(form=form)


On Sun, Dec 6, 2015 at 8:48 PM, Richard Vézina 
wrote:

> login form are part of web2py auth.form or something I haven touch that
> since a wild... But you have to custom the form and login form is par of
> controllers/default/user function... You then need to have a look at the
> book to how customize login form...
>
> You may also just try to set readable=True and writable=True on your field
> definition it may works... But I am not sure...
>
> Richard
>
> On Fri, Dec 4, 2015 at 5:12 PM, Jonathan R  wrote:
>
>> Hi Richard,
>> I've seen people using this way to customize their registration page,
>> they could get the radio button to be displayed, I don't really see how the
>> login page is different and won't display it, I must miss something.
>>
>> What "other thing" should I do in your opinion ?
>>
>> thanks for your time.
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


[web2py] Pre-populated Forms

2015-12-06 Thread Anthony Smith
Hi All, 

I have a products table:
 db.define_table('product',
Field('product_name'),
Field('active_ingredient'),
Field('batch_no'),
Field('expiry_date','date'),
Field('product_type', 
requires=IS_IN_SET(PRODUCTTYPES),default= PRODUCTTYPES[0]),
Field('withholding_period','integer'),
Field('ESI_withholding','integer'),
Field('qty','integer'),
Field('date_purchased','date', default = request.now),
Field('purchased_from', 
requires=IS_IN_DB(db,'company.company_name','%(company_name)s')),
(auth.signature),
format='%(product_name)s %(batch_no)s')

I can edit the product with the following controller:
def edit_product():
product_id = request.args(0,cast=int)
product = db.product(product_id) or error()
if not product.created_by==me:
product.created_by.writable = True
else:
product.created_by.writable = False
form = SQLFORM(db.product,product,
   showid=False,
   
deletable=(product.created_by==me)).process(onsuccess=auth.archive)
if form.accepted:
session.flash="Edit Successful"
redirect(URL('products'))
return locals()

At times I need to add new products but only some of the fields change E.G. 
batch_no, expiry_date, and supplier. 
In short if need to add similar item that I already have in the products 
table 


thanks 

Anthony 


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


[web2py] Instruct session.connect to keep using the same table name despite the appname change

2015-12-06 Thread Richard
Hello,

Is there a way to tell session.connect that it should keep using a give 
web2py_session_APPNAME table, because when I am testing before deployment 
app name change... I need to keep the same name...

Thanks

Richard

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


Re: [web2py] Instruct session.connect to keep using the same table name despite the appname change

2015-12-06 Thread Richard Vézina
masterapp='appname'...

On Mon, Dec 7, 2015 at 12:42 AM, Richard 
wrote:

> Hello,
>
> Is there a way to tell session.connect that it should keep using a give
> web2py_session_APPNAME table, because when I am testing before deployment
> app name change... I need to keep the same name...
>
> Thanks
>
> Richard
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: CUSTOM a large form

2015-12-06 Thread Laurent Lc
Ok
Thank you
Le 7 déc. 2015 2:01 AM, "Jason Solack"  a écrit :

> I've done this several ways... the actual HTML generation could be via
> web2py's helpers or just writting the HTML. For the tabs i've used
> bootstrap or jquery ui to help out creating tabs... using a library helps
> the process of making tabs pretty trivial...
>
> here's jquery ui's information
> http://jqueryui.com/tabs/
>
> bootstrap:
> http://getbootstrap.com/components/#nav-tabs
>
> hope that helps
>
> On Friday, December 4, 2015 at 11:51:31 PM UTC-5, Laurent Lc wrote:
>>
>> Hi,
>>
>> I'd like to know the best way to present a big form with a lot of fields,
>> using tabs for example and anchors ?
>>
>> thank you
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/AE8zi_A63vw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: web2py and python3

2015-12-06 Thread Pablo Angulo
I also have to work with unicode all the time. While it's true that
python3 deals better with this issue, there is no way that web2py can
move to python3 and our current code keeps working, precisely because of
this issue. Our code has lots of .encode('utf8'), .decode('utf8'),
unicode(...), etc. We would have to migrate our apps to python3.

So a new framework that is based on the same ideas and part of the
existing code, as Massimo have said explicitely, is the only possible
strategy. But while we do the necessary porting of our code to python3,
we will also get other benefits in the deal. python3 being non-backwards
compatible forces a non-backwards compatible version of web2py.

El 07/12/15 a las 02:09, Alex escribió:
> I'm still missing a clear strategy from the devs... I could understand if you 
> don't have enough resources and ask for help (web2py is open source and 
> anybody can contribute after all). But saying that python3 is useless and 
> nobody wants it is not a good approach. > > It seems like most of you only 
> deal with ascii characters. Only if
you constantly deal with non-ascii characters you really feel the pain
of python2. e.g. ajax request with user input, use string for mail.send
or T(..).format(..) -> unicode error. Basically I have to test all user
string input if it is unicode and convert to str > > Alex > -- >
Resources: > - http://web2py.com > - http://web2py.com/book
(Documentation) > - http://github.com/web2py/web2py (Source code) > -
https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You
received this message because you are subscribed to a topic in the
Google Groups "web2py-users" group. > To unsubscribe from this topic,
visit https://groups.google.com/d/topic/web2py/UKcWKU66qnA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
web2py+unsubscr...@googlegroups.com
. > For more options, visit
https://groups.google.com/d/optout.


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