[web2py] Re: how to calculate size of uploads by user

2016-01-13 Thread Niphlod
manual uploads, dude!

an upload field is a cgi.FieldStorage object.

len(thefieldstorage.value)

or you can seek() and tell() , as IS_LENGTH does already 


-- 
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] import_from_csv_file: how to map columns

2016-01-13 Thread goome
Hi
i created i table definition in db.py by using csvstudio.py, but i cannot 
load the values through db.table.import_from_csv_file becouse the header in 
the csv have spaces and uppercases.
So there a way to tell import_from_csv_file how to map column in csv with 
that in table definition?
By the way, column in csv are in the same order than in table definition.
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] AttributeError: 'Table' object has no attribute '_primarykey'

2016-01-13 Thread Manuele Pesenti
Hi *,
I got this strange error. Where I have to look for the cuase?
The table object of my query is defined by:

# Note: defined as class parameter
table = Table(None, table_name,
Field("uuid", unique=True, default=lambda: web2py_uuid()),
Field("service", required=True),
Field("command", required=True),
Field("args", 'json', default={}),
Field("status", default="QUEUED", requires=IS_IN_SET(task_states)),
Field("command_output", 'json'),
Field("start_time", "datetime"),
Field("end_time", "datetime"),
Field('created_on', 'datetime', default=current.request.now),
Field('updated_on', 'datetime', update=current.request.now),
Field('created_by', 'integer'),
Field('updated_by', 'integer'),
)

and

self.db.define_table(self.table_name, self.table)

and the exception (cited below) is raides calling the method:
validate_and_update_or_insert

---
AttributeErrorTraceback (most recent call last)
/home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/models/utils.py
in ()
> 1 iproot.queue_task("noproot", "test")

/home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/modules/prootdio.py
in queue_task(self, service, command, force_new, **args)
301 command = command,
302 status = "QUEUED",
--> 303 args = args
304 )
305

/home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/modules/prootdio.py
in wrapper(self, *args, **vars)
 94 def wrapper(self, *args, **vars):
 95 self.db[self.table_name].args.requires = []
---> 96 return func(self, *args, **vars)
 97 return wrapper
 98

/home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/modules/prootdio.py
in __validate_and_update_or_insert(self, query, commit, **vars)
254 res =
self.db[self.table_name].validate_and_update_or_insert(
255 query,
--> 256 **vars
257 )
258 if commit: self.db.commit()

/home/manuele/dev/portali/web2py.trunk/gluon/dal/objects.pyc in
validate_and_update_or_insert(self, _key, **fields)
817 response = self.validate_and_update(_key, **fields)
818 primary_keys = {}
--> 819 for key in self._primarykey:
820 primary_keys[key] = getattr(record, key)
821 response.id = primary_keys

/home/manuele/dev/portali/web2py.trunk/gluon/dal/objects.pyc in
__getitem__(self, key)
514 return self._db(self._id == key).select(limitby=(0,
1), orderby_on_limitby=False).first()
515 elif key:
--> 516 return ogetattr(self, str(key))
517
518 def __call__(self, key=DEFAULT, **kwargs):

AttributeError: 'Table' object has no attribute '_primarykey'


Thanks a lot

Manuele

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


[web2py] Re: how to calculate size of uploads by user

2016-01-13 Thread Alex Glaros
am having trouble finding detailed examples.  Can you please help with 
syntax?

Am determining size when uploading a user's photo (thumbnail) to their 
profile:

if form.process().accepted:
   session.flash = 'profile update accepted'
   file_info = cgi.FieldStorage(form.vars.thumbnail)
   form.vars.file_size = len(file_info)

the goal is to populate field file_size with number of bytes the file 
contains

but the above raises errors

thanks

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: what are the ways I can reload or refresh the current page where redirect doesn't work

2016-01-13 Thread Ron Chatterjee
Basically after the file upload, I would like to refresh/reload 
"show_project_summary.html" to show the list of the file that just been 
downloaded. 



On Wednesday, January 13, 2016 at 1:49:42 PM UTC-5, Ron Chatterjee wrote:
>
> *I have this in my view (show_project_summary.html).*
>
>
> 
> {{ if (submission.created_by == auth.user_id):}}
> 
> {{pass}}
> 
>
>
>
>
> *Script in the same view at the bottom:*
>
> 
> jQuery(document).ready(function() {
>   var uploader = new qq.FileUploader({
> // pass the dom node (ex. jQuery(selector)[0] for jQuery users)
> element: document.getElementById('file-uploader'),
> // path to server-side upload script
> action: 
> '{{=URL("upload_callback_submission")}}/{{=request.args(0)}}',
> sizeLimit: 15000,
> minSizeLimit: 0,
> allowedExtensions: ['xls','jpg', 'jpeg', 'pdf', 
> 'txt','doc','docx','ppt', 'pptx', 'htm','html','xml','xmls', 
> 'txt','ppt','png', 'gif'],
> // set to true to output server response to console
> debug: true,
>
> // events
> // you can return false to abort submit
> onSubmit: function(id, fileName){},
> onProgress: function(id, fileName, loaded, total){},
> onComplete: function(id, fileName, responseJSON){},
> onCancel: function(id, fileName){},
>
> messages: {
> // error messages, see qq.FileUploaderBasic for content
> typeError: "{file} {{=T('has invalid extension.')}} 
> {{=T('Only')}} {extensions} {{=T('are allowed.')}}",
> sizeError: "{file} {{=T('is too large, maximum file size 
> is')}} {sizeLimit}.",
> minSizeError: "{file} {{=T('is too small, minimum file size 
> is')}} {minSizeLimit}.",
> emptyError: "{file} {{=T('is empty, please select files again 
> without it.')}}",
> onLeave: "{{=T('The files are being uploaded, if you leave now 
> the upload will be cancelled.')}}"
> },
> showMessage: function(message){ alert(message); }
> });
> });
> 
>
>
>
> *In my default controller:*
>
> def upload_callback():
> Selected_project = []
> #Rendering rule for Post
> Selected_project = db.Project(request.args(0, cast=int))
> db.Project_Files.Project_id.default = Selected_project.id;
> project = db.Project[request.args(0)]
> if Selected_project is None:
> raise HTTP(404)
> if 'qqfile' in request.vars:
> filename = request.vars.qqfile
> newfilename = db.Project_Files.filename.store(request.body, 
> filename)
> db.Project_Files.insert(Project_id=Selected_project.id, 
> filename=newfilename)
> return response.json({'success': 'true'})
>
>
>
>
>
>
> On Wednesday, January 13, 2016 at 1:43:10 PM UTC-5, Anthony wrote:
>>
>> Please show some code.
>>
>> On Wednesday, January 13, 2016 at 1:37:16 PM UTC-5, Ron Chatterjee wrote:
>>>
>>> How do I update a current page in its view after a file submission if 
>>> the redirect doesn't work?
>>>
>>> {{redirect(URL('show_project_summary', args = Selected_project.id), 
>>> client_side = True)}}
>>>
>>> Any response.js that will update or reload/refresh the current page?
>>>
>>>

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


[web2py] Re: Why this HTML email not working? Please tell me the corrected version.

2016-01-13 Thread RAGHIB R
this doesn't even send a mail. It doesn't give any error, but using this 
way doesn't send the mail at all.

On Wednesday, January 13, 2016 at 1:21:11 AM UTC+5:30, Niphlod wrote:
>
> If you read docs about mail.send, you'd know that it takes
>
> mail.send(to, subject, message, attachments, cc, .. etc etc etc).
>
> for html-only mails, it should be
>
> mail.send('reci...@gmail.com , 'subject', 
> 'thebody', etc etc etc)
>
> That being said, what's the error ? 
>
> On Tuesday, January 12, 2016 at 7:21:25 PM UTC+1, RAGHIB R wrote:
>>
>> def result():
>> session.x=mail.send('smm...@gmail.com',
>> 'hello',
>> '> style="background-color:pink;font-size:2em;display:inline">Hi Raghib, you 
>> have a new entry: ','session.name+session.name2+" with 
>> "+str(session.percent)')
>> if session.x==True:
>> response.flash="result"
>> else:
>> response.flash="resultt"
>> return locals()
>>
>

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


[web2py] Re: Why my web2py is running when I haven't downloaded any Mark Hammond's win32 extensions for pywin3?

2016-01-13 Thread Niphlod
probably file locking.

On Wednesday, January 13, 2016 at 8:59:56 PM UTC+1, aston...@gmail.com 
wrote:
>
> Is it that I am loosing something?
>

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


[web2py] How do I select and output multiple checkboxes

2016-01-13 Thread Ron Chatterjee
*Model:*

db.define_table('mytable',
Field('name', type='list:string',requires=IS_IN_SET 
(('True','False')),
  widget=SQLFORM.widgets.checkboxes.widget))


*Controller:*


def index():
variables = []
form = SQLFORM(db.mytable).process()
if form.accepted:
#comments from that particular blog post
variables = form.vars.name
return dict(form = form,variables = variables )


*View:*

{{extend 'layout.html'}}
{{=form}}
{{=variables}}



I can only output true or false. I want to select and output True and False 
both. How?


-- 
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: update 2 session value using module only first session value work

2016-01-13 Thread Anthony
Presumably you are calling this function as follows:

callback_0(session.order, session.sale_order_net)

The problem is you later have:

session_order_net = dict(...)

At that point, you are not modifying the session.sale_order_net object but 
simply assigning a new object to the local variable session_order_net. This 
is equivalent to doing:

session_order_net = current.session.sale_order_net
session_order_net = dict(...)

In the above case, you wouldn't expect the second line to have any effect 
on session.sale_order_net -- the second line simply makes the first line 
irrelevant (i.e., it simply overwrites the value of the session_order_net 
variable that is local to the function).

The earlier line:

session_order[id] = ...

works because in that case, you are not assigning a new object to the 
session_order variable but merely mutating the object to which 
session_order refers (i.e., session.order).

If you want to completely replace the value of session.sale_order_net, then 
pass in the session object and do:

session.sale_order_net = ...

Anthony





On Wednesday, January 13, 2016 at 12:48:11 AM UTC-5, 黄祥 wrote:
>
> is it possible to update 2 sessions values using web2py module? i've 
> tested it only first session value work, the second session value work if 
> explicit define in the module (but the module is used by another 
> controller, so i want to create just 1 module for all controllers).
> e.g.
> *modules/transaction.py*
> def callback_0(session_order, session_order_net):
> if current.request.vars.action == 'adjust_total':
> id = int(current.request.vars.id)
> quantity = int(current.request.vars['quantity_%s' % id])
> price = int(current.request.vars['price_%s' % id])
> *session_order[id] = quantity, price # the first parameter work*
> total_price = quantity * price
> total_quantity = 0
> grand_total = 0
> for calculation_id, (calculation_quantity, calculation_price) in 
> session_order.items():
> calculation_total_price = calculation_quantity * calculation_price
> total_quantity += calculation_quantity
> grand_total += calculation_total_price
> return "jQuery('#total_price_%s').html('%s'); 
> jQuery('#total_quantity').html('%s'); jQuery('#grand_total').html('%s');" % 
> (id, 
>   format(total_price, ",d").replace(",", "."), format(total_quantity, 
> ",d").replace(",", "."), 
>   format(grand_total, ",d").replace(",", ".") )
> if current.request.vars.action == 'adjust_total_net':
> discount = int(current.request.vars['discount'] )
> delivery_fee = int(current.request.vars['delivery_fee'] )
> packing_fee = int(current.request.vars['packing_fee'] )
> stamp_fee = int(current.request.vars['stamp_fee'] )
> paid = int(current.request.vars['paid'] )
>
> * current.session.sale_order_net = dict(discount = discount, delivery_fee 
> = delivery_fee, packing_fee = packing_fee, stamp_fee = stamp_fee, paid = 
> paid) # this work when explicit tell the session name*
>
> * #session_order_net = dict(discount = discount, delivery_fee = 
> delivery_fee, packing_fee = packing_fee, stamp_fee = stamp_fee, paid = 
> paid)** # the second parameter not work, no error traceback occured but 
> the result is not expected (not updated value)*
>
> grand_total = sum(calculation_quantity * calculation_price for 
> calculation_id, (calculation_quantity, calculation_price) in 
> session_order.items() )
> grand_total_net = grand_total-discount+delivery_fee+packing_fee+stamp_fee
> paid_return = paid-grand_total_net
>
> return "jQuery('#grand_total_net').html('%s'); 
> jQuery('#paid_return').html('%s');" % (
>   format(grand_total_net, ",d").replace(",", "."), format(paid_return, 
> ",d").replace(",", ".") )
>
> as in the example code above the bold code is work if i explicit it and if 
> i use the second parameter (*session_order_net*) that been passed by 
> function in controller, it is not work, the funny things is the first 
> parameter work (*session_order*). no error traceback occured but the 
> result is not expected.
>
> any idea how to get it work in web2py way?
>
> thanks and best regards,
> stifan
>

-- 
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] what are the ways I can reload or refresh the current page where redirect doesn't work

2016-01-13 Thread Ron Chatterjee
How do I update a current page in its view after a file submission if the 
redirect doesn't work?

{{redirect(URL('show_project_summary', args = Selected_project.id), 
client_side = True)}}

Any response.js that will update or reload/refresh the current page?

-- 
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: what are the ways I can reload or refresh the current page where redirect doesn't work

2016-01-13 Thread Anthony
Where is:

{{redirect(URL('show_project_summary', args = Selected_project.id), 
client_side = True)}}

If that's in a view file for upload_callback, it will never get executed, 
because upload_callback doesn't return a dictionary.

You can call redirect(..., client_side=True) within the upload_callback 
function, though that will skip the returning of the {"success": "true"} 
JSON response (though perhaps you don't need that, as returning a 200 
response may be sufficient to imply success). Alternatively, you can set 
response.js:

response.js = 'window.location = "%s";' % URL(...)

That's really all the client side redirect does.

Anthony

On Wednesday, January 13, 2016 at 1:51:51 PM UTC-5, Ron Chatterjee wrote:
>
> Basically after the file upload, I would like to refresh/reload 
> "show_project_summary.html" to show the list of the file that just been 
> downloaded. 
>
>
>
> On Wednesday, January 13, 2016 at 1:49:42 PM UTC-5, Ron Chatterjee wrote:
>>
>> *I have this in my view (show_project_summary.html).*
>>
>>
>> 
>> {{ if (submission.created_by == auth.user_id):}}
>> 
>> {{pass}}
>> 
>>
>>
>>
>>
>> *Script in the same view at the bottom:*
>>
>> 
>> jQuery(document).ready(function() {
>>   var uploader = new qq.FileUploader({
>> // pass the dom node (ex. jQuery(selector)[0] for jQuery users)
>> element: document.getElementById('file-uploader'),
>> // path to server-side upload script
>> action: 
>> '{{=URL("upload_callback_submission")}}/{{=request.args(0)}}',
>> sizeLimit: 15000,
>> minSizeLimit: 0,
>> allowedExtensions: ['xls','jpg', 'jpeg', 'pdf', 
>> 'txt','doc','docx','ppt', 'pptx', 'htm','html','xml','xmls', 
>> 'txt','ppt','png', 'gif'],
>> // set to true to output server response to console
>> debug: true,
>>
>> // events
>> // you can return false to abort submit
>> onSubmit: function(id, fileName){},
>> onProgress: function(id, fileName, loaded, total){},
>> onComplete: function(id, fileName, responseJSON){},
>> onCancel: function(id, fileName){},
>>
>> messages: {
>> // error messages, see qq.FileUploaderBasic for content
>> typeError: "{file} {{=T('has invalid extension.')}} 
>> {{=T('Only')}} {extensions} {{=T('are allowed.')}}",
>> sizeError: "{file} {{=T('is too large, maximum file size 
>> is')}} {sizeLimit}.",
>> minSizeError: "{file} {{=T('is too small, minimum file size 
>> is')}} {minSizeLimit}.",
>> emptyError: "{file} {{=T('is empty, please select files again 
>> without it.')}}",
>> onLeave: "{{=T('The files are being uploaded, if you leave 
>> now the upload will be cancelled.')}}"
>> },
>> showMessage: function(message){ alert(message); }
>> });
>> });
>> 
>>
>>
>>
>> *In my default controller:*
>>
>> def upload_callback():
>> Selected_project = []
>> #Rendering rule for Post
>> Selected_project = db.Project(request.args(0, cast=int))
>> db.Project_Files.Project_id.default = Selected_project.id;
>> project = db.Project[request.args(0)]
>> if Selected_project is None:
>> raise HTTP(404)
>> if 'qqfile' in request.vars:
>> filename = request.vars.qqfile
>> newfilename = db.Project_Files.filename.store(request.body, 
>> filename)
>> db.Project_Files.insert(Project_id=Selected_project.id, 
>> filename=newfilename)
>> return response.json({'success': 'true'})
>>
>>
>>
>>
>>
>>
>> On Wednesday, January 13, 2016 at 1:43:10 PM UTC-5, Anthony wrote:
>>>
>>> Please show some code.
>>>
>>> On Wednesday, January 13, 2016 at 1:37:16 PM UTC-5, Ron Chatterjee wrote:

 How do I update a current page in its view after a file submission if 
 the redirect doesn't work?

 {{redirect(URL('show_project_summary', args = Selected_project.id), 
 client_side = True)}}

 Any response.js that will update or reload/refresh the current page?



-- 
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: what are the ways I can reload or refresh the current page where redirect doesn't work

2016-01-13 Thread Anthony
Yes, in the controller, and just us the URL function as usual.

Anthony

On Wednesday, January 13, 2016 at 2:17:22 PM UTC-5, Ron Chatterjee wrote:
>
> Yes. That's what I thought too. But what's the correct syntax for 
> response.js Anthony?
>
> Is it:
>
> response.js = 'window.location = "%s";' % URL
> ('default',show_project_summary')
>
> ?
> And I believe I need to invoke that in my controller. Right?
>
>
>
> On Wednesday, January 13, 2016 at 2:06:34 PM UTC-5, Anthony wrote:
>>
>> Where is:
>>
>> {{redirect(URL('show_project_summary', args = Selected_project.id), 
>> client_side = True)}}
>>
>> If that's in a view file for upload_callback, it will never get executed, 
>> because upload_callback doesn't return a dictionary.
>>
>> You can call redirect(..., client_side=True) within the upload_callback 
>> function, though that will skip the returning of the {"success": "true"} 
>> JSON response (though perhaps you don't need that, as returning a 200 
>> response may be sufficient to imply success). Alternatively, you can set 
>> response.js:
>>
>> response.js = 'window.location = "%s";' % URL(...)
>>
>> That's really all the client side redirect does.
>>
>> Anthony
>>
>> On Wednesday, January 13, 2016 at 1:51:51 PM UTC-5, Ron Chatterjee wrote:
>>>
>>> Basically after the file upload, I would like to refresh/reload 
>>> "show_project_summary.html" to show the list of the file that just been 
>>> downloaded. 
>>>
>>>
>>>
>>> On Wednesday, January 13, 2016 at 1:49:42 PM UTC-5, Ron Chatterjee wrote:

 *I have this in my view (show_project_summary.html).*


 
 {{ if (submission.created_by == auth.user_id):}}
 
 {{pass}}
 




 *Script in the same view at the bottom:*

 
 jQuery(document).ready(function() {
   var uploader = new qq.FileUploader({
 // pass the dom node (ex. jQuery(selector)[0] for jQuery users)
 element: document.getElementById('file-uploader'),
 // path to server-side upload script
 action: 
 '{{=URL("upload_callback_submission")}}/{{=request.args(0)}}',
 sizeLimit: 15000,
 minSizeLimit: 0,
 allowedExtensions: ['xls','jpg', 'jpeg', 'pdf', 
 'txt','doc','docx','ppt', 'pptx', 'htm','html','xml','xmls', 
 'txt','ppt','png', 'gif'],
 // set to true to output server response to console
 debug: true,

 // events
 // you can return false to abort submit
 onSubmit: function(id, fileName){},
 onProgress: function(id, fileName, loaded, total){},
 onComplete: function(id, fileName, responseJSON){},
 onCancel: function(id, fileName){},

 messages: {
 // error messages, see qq.FileUploaderBasic for content
 typeError: "{file} {{=T('has invalid extension.')}} 
 {{=T('Only')}} {extensions} {{=T('are allowed.')}}",
 sizeError: "{file} {{=T('is too large, maximum file size 
 is')}} {sizeLimit}.",
 minSizeError: "{file} {{=T('is too small, minimum file size 
 is')}} {minSizeLimit}.",
 emptyError: "{file} {{=T('is empty, please select files 
 again without it.')}}",
 onLeave: "{{=T('The files are being uploaded, if you leave 
 now the upload will be cancelled.')}}"
 },
 showMessage: function(message){ alert(message); }
 });
 });
 



 *In my default controller:*

 def upload_callback():
 Selected_project = []
 #Rendering rule for Post
 Selected_project = db.Project(request.args(0, cast=int))
 db.Project_Files.Project_id.default = Selected_project.id;
 project = db.Project[request.args(0)]
 if Selected_project is None:
 raise HTTP(404)
 if 'qqfile' in request.vars:
 filename = request.vars.qqfile
 newfilename = db.Project_Files.filename.store(request.body, 
 filename)
 db.Project_Files.insert(Project_id=Selected_project.id, 
 filename=newfilename)
 return response.json({'success': 'true'})






 On Wednesday, January 13, 2016 at 1:43:10 PM UTC-5, Anthony wrote:
>
> Please show some code.
>
> On Wednesday, January 13, 2016 at 1:37:16 PM UTC-5, Ron Chatterjee 
> wrote:
>>
>> How do I update a current page in its view after a file submission if 
>> the redirect doesn't work?
>>
>> {{redirect(URL('show_project_summary', args = Selected_project.id), 
>> client_side = True)}}
>>
>> Any response.js that will update or reload/refresh the current page?
>>
>>

-- 
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: what are the ways I can reload or refresh the current page where redirect doesn't work

2016-01-13 Thread Ron Chatterjee
Yes. That's what I thought too. But what's the correct syntax for 
response.js Anthony?

Is it:

response.js = 'window.location = "%s";' % URL
('default',show_project_summary')

?
And I believe I need to invoke that in my controller. Right?



On Wednesday, January 13, 2016 at 2:06:34 PM UTC-5, Anthony wrote:
>
> Where is:
>
> {{redirect(URL('show_project_summary', args = Selected_project.id), 
> client_side = True)}}
>
> If that's in a view file for upload_callback, it will never get executed, 
> because upload_callback doesn't return a dictionary.
>
> You can call redirect(..., client_side=True) within the upload_callback 
> function, though that will skip the returning of the {"success": "true"} 
> JSON response (though perhaps you don't need that, as returning a 200 
> response may be sufficient to imply success). Alternatively, you can set 
> response.js:
>
> response.js = 'window.location = "%s";' % URL(...)
>
> That's really all the client side redirect does.
>
> Anthony
>
> On Wednesday, January 13, 2016 at 1:51:51 PM UTC-5, Ron Chatterjee wrote:
>>
>> Basically after the file upload, I would like to refresh/reload 
>> "show_project_summary.html" to show the list of the file that just been 
>> downloaded. 
>>
>>
>>
>> On Wednesday, January 13, 2016 at 1:49:42 PM UTC-5, Ron Chatterjee wrote:
>>>
>>> *I have this in my view (show_project_summary.html).*
>>>
>>>
>>> 
>>> {{ if (submission.created_by == auth.user_id):}}
>>> 
>>> {{pass}}
>>> 
>>>
>>>
>>>
>>>
>>> *Script in the same view at the bottom:*
>>>
>>> 
>>> jQuery(document).ready(function() {
>>>   var uploader = new qq.FileUploader({
>>> // pass the dom node (ex. jQuery(selector)[0] for jQuery users)
>>> element: document.getElementById('file-uploader'),
>>> // path to server-side upload script
>>> action: 
>>> '{{=URL("upload_callback_submission")}}/{{=request.args(0)}}',
>>> sizeLimit: 15000,
>>> minSizeLimit: 0,
>>> allowedExtensions: ['xls','jpg', 'jpeg', 'pdf', 
>>> 'txt','doc','docx','ppt', 'pptx', 'htm','html','xml','xmls', 
>>> 'txt','ppt','png', 'gif'],
>>> // set to true to output server response to console
>>> debug: true,
>>>
>>> // events
>>> // you can return false to abort submit
>>> onSubmit: function(id, fileName){},
>>> onProgress: function(id, fileName, loaded, total){},
>>> onComplete: function(id, fileName, responseJSON){},
>>> onCancel: function(id, fileName){},
>>>
>>> messages: {
>>> // error messages, see qq.FileUploaderBasic for content
>>> typeError: "{file} {{=T('has invalid extension.')}} 
>>> {{=T('Only')}} {extensions} {{=T('are allowed.')}}",
>>> sizeError: "{file} {{=T('is too large, maximum file size 
>>> is')}} {sizeLimit}.",
>>> minSizeError: "{file} {{=T('is too small, minimum file size 
>>> is')}} {minSizeLimit}.",
>>> emptyError: "{file} {{=T('is empty, please select files 
>>> again without it.')}}",
>>> onLeave: "{{=T('The files are being uploaded, if you leave 
>>> now the upload will be cancelled.')}}"
>>> },
>>> showMessage: function(message){ alert(message); }
>>> });
>>> });
>>> 
>>>
>>>
>>>
>>> *In my default controller:*
>>>
>>> def upload_callback():
>>> Selected_project = []
>>> #Rendering rule for Post
>>> Selected_project = db.Project(request.args(0, cast=int))
>>> db.Project_Files.Project_id.default = Selected_project.id;
>>> project = db.Project[request.args(0)]
>>> if Selected_project is None:
>>> raise HTTP(404)
>>> if 'qqfile' in request.vars:
>>> filename = request.vars.qqfile
>>> newfilename = db.Project_Files.filename.store(request.body, 
>>> filename)
>>> db.Project_Files.insert(Project_id=Selected_project.id, 
>>> filename=newfilename)
>>> return response.json({'success': 'true'})
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wednesday, January 13, 2016 at 1:43:10 PM UTC-5, Anthony wrote:

 Please show some code.

 On Wednesday, January 13, 2016 at 1:37:16 PM UTC-5, Ron Chatterjee 
 wrote:
>
> How do I update a current page in its view after a file submission if 
> the redirect doesn't work?
>
> {{redirect(URL('show_project_summary', args = Selected_project.id), 
> client_side = True)}}
>
> Any response.js that will update or reload/refresh the current page?
>
>

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


[web2py] Re: Why this HTML email not working? Please tell me the corrected version.

2016-01-13 Thread RAGHIB R
just tell me how do I include something as session.name1 inside the html 
body here?

On Wednesday, January 13, 2016 at 1:21:11 AM UTC+5:30, Niphlod wrote:
>
> If you read docs about mail.send, you'd know that it takes
>
> mail.send(to, subject, message, attachments, cc, .. etc etc etc).
>
> for html-only mails, it should be
>
> mail.send('reci...@gmail.com , 'subject', 
> 'thebody', etc etc etc)
>
> That being said, what's the error ? 
>
> On Tuesday, January 12, 2016 at 7:21:25 PM UTC+1, RAGHIB R wrote:
>>
>> def result():
>> session.x=mail.send('smm...@gmail.com',
>> 'hello',
>> '> style="background-color:pink;font-size:2em;display:inline">Hi Raghib, you 
>> have a new entry: ','session.name+session.name2+" with 
>> "+str(session.percent)')
>> if session.x==True:
>> response.flash="result"
>> else:
>> response.flash="resultt"
>> return locals()
>>
>

-- 
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] Why my web2py is running when I haven't downloaded any Mark Hammond's win32 extensions for pywin3?

2016-01-13 Thread aston . ribat
Is it that I am loosing something?

-- 
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: what are the ways I can reload or refresh the current page where redirect doesn't work

2016-01-13 Thread Ron Chatterjee
*I have this in my view (show_project_summary.html).*



{{ if (submission.created_by == auth.user_id):}}

{{pass}}





*Script in the same view at the bottom:*


jQuery(document).ready(function() {
  var uploader = new qq.FileUploader({
// pass the dom node (ex. jQuery(selector)[0] for jQuery users)
element: document.getElementById('file-uploader'),
// path to server-side upload script
action: 
'{{=URL("upload_callback_submission")}}/{{=request.args(0)}}',
sizeLimit: 15000,
minSizeLimit: 0,
allowedExtensions: ['xls','jpg', 'jpeg', 'pdf', 
'txt','doc','docx','ppt', 'pptx', 'htm','html','xml','xmls', 
'txt','ppt','png', 'gif'],
// set to true to output server response to console
debug: true,

// events
// you can return false to abort submit
onSubmit: function(id, fileName){},
onProgress: function(id, fileName, loaded, total){},
onComplete: function(id, fileName, responseJSON){},
onCancel: function(id, fileName){},

messages: {
// error messages, see qq.FileUploaderBasic for content
typeError: "{file} {{=T('has invalid extension.')}} 
{{=T('Only')}} {extensions} {{=T('are allowed.')}}",
sizeError: "{file} {{=T('is too large, maximum file size is')}} 
{sizeLimit}.",
minSizeError: "{file} {{=T('is too small, minimum file size 
is')}} {minSizeLimit}.",
emptyError: "{file} {{=T('is empty, please select files again 
without it.')}}",
onLeave: "{{=T('The files are being uploaded, if you leave now 
the upload will be cancelled.')}}"
},
showMessage: function(message){ alert(message); }
});
});




*In my default controller:*

def upload_callback():
Selected_project = []
#Rendering rule for Post
Selected_project = db.Project(request.args(0, cast=int))
db.Project_Files.Project_id.default = Selected_project.id;
project = db.Project[request.args(0)]
if Selected_project is None:
raise HTTP(404)
if 'qqfile' in request.vars:
filename = request.vars.qqfile
newfilename = db.Project_Files.filename.store(request.body, 
filename)
db.Project_Files.insert(Project_id=Selected_project.id, 
filename=newfilename)
return response.json({'success': 'true'})






On Wednesday, January 13, 2016 at 1:43:10 PM UTC-5, Anthony wrote:
>
> Please show some code.
>
> On Wednesday, January 13, 2016 at 1:37:16 PM UTC-5, Ron Chatterjee wrote:
>>
>> How do I update a current page in its view after a file submission if the 
>> redirect doesn't work?
>>
>> {{redirect(URL('show_project_summary', args = Selected_project.id), 
>> client_side = True)}}
>>
>> Any response.js that will update or reload/refresh the current page?
>>
>>

-- 
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: what are the ways I can reload or refresh the current page where redirect doesn't work

2016-01-13 Thread Ron Chatterjee
It didn't work. didn't reload it. 

On Wednesday, January 13, 2016 at 2:20:14 PM UTC-5, Anthony wrote:
>
> Yes, in the controller, and just us the URL function as usual.
>
> Anthony
>
> On Wednesday, January 13, 2016 at 2:17:22 PM UTC-5, Ron Chatterjee wrote:
>>
>> Yes. That's what I thought too. But what's the correct syntax for 
>> response.js Anthony?
>>
>> Is it:
>>
>> response.js = 'window.location = "%s";' % URL
>> ('default',show_project_summary')
>>
>> ?
>> And I believe I need to invoke that in my controller. Right?
>>
>>
>>
>> On Wednesday, January 13, 2016 at 2:06:34 PM UTC-5, Anthony wrote:
>>>
>>> Where is:
>>>
>>> {{redirect(URL('show_project_summary', args = Selected_project.id), 
>>> client_side = True)}}
>>>
>>> If that's in a view file for upload_callback, it will never get 
>>> executed, because upload_callback doesn't return a dictionary.
>>>
>>> You can call redirect(..., client_side=True) within the upload_callback 
>>> function, though that will skip the returning of the {"success": "true"} 
>>> JSON response (though perhaps you don't need that, as returning a 200 
>>> response may be sufficient to imply success). Alternatively, you can set 
>>> response.js:
>>>
>>> response.js = 'window.location = "%s";' % URL(...)
>>>
>>> That's really all the client side redirect does.
>>>
>>> Anthony
>>>
>>> On Wednesday, January 13, 2016 at 1:51:51 PM UTC-5, Ron Chatterjee wrote:

 Basically after the file upload, I would like to refresh/reload 
 "show_project_summary.html" to show the list of the file that just been 
 downloaded. 



 On Wednesday, January 13, 2016 at 1:49:42 PM UTC-5, Ron Chatterjee 
 wrote:
>
> *I have this in my view (show_project_summary.html).*
>
>
> 
> {{ if (submission.created_by == auth.user_id):}}
> 
> {{pass}}
> 
>
>
>
>
> *Script in the same view at the bottom:*
>
> 
> jQuery(document).ready(function() {
>   var uploader = new qq.FileUploader({
> // pass the dom node (ex. jQuery(selector)[0] for jQuery users)
> element: document.getElementById('file-uploader'),
> // path to server-side upload script
> action: 
> '{{=URL("upload_callback_submission")}}/{{=request.args(0)}}',
> sizeLimit: 15000,
> minSizeLimit: 0,
> allowedExtensions: ['xls','jpg', 'jpeg', 'pdf', 
> 'txt','doc','docx','ppt', 'pptx', 'htm','html','xml','xmls', 
> 'txt','ppt','png', 'gif'],
> // set to true to output server response to console
> debug: true,
>
> // events
> // you can return false to abort submit
> onSubmit: function(id, fileName){},
> onProgress: function(id, fileName, loaded, total){},
> onComplete: function(id, fileName, responseJSON){},
> onCancel: function(id, fileName){},
>
> messages: {
> // error messages, see qq.FileUploaderBasic for content
> typeError: "{file} {{=T('has invalid extension.')}} 
> {{=T('Only')}} {extensions} {{=T('are allowed.')}}",
> sizeError: "{file} {{=T('is too large, maximum file size 
> is')}} {sizeLimit}.",
> minSizeError: "{file} {{=T('is too small, minimum file 
> size is')}} {minSizeLimit}.",
> emptyError: "{file} {{=T('is empty, please select files 
> again without it.')}}",
> onLeave: "{{=T('The files are being uploaded, if you leave 
> now the upload will be cancelled.')}}"
> },
> showMessage: function(message){ alert(message); }
> });
> });
> 
>
>
>
> *In my default controller:*
>
> def upload_callback():
> Selected_project = []
> #Rendering rule for Post
> Selected_project = db.Project(request.args(0, cast=int))
> db.Project_Files.Project_id.default = Selected_project.id;
> project = db.Project[request.args(0)]
> if Selected_project is None:
> raise HTTP(404)
> if 'qqfile' in request.vars:
> filename = request.vars.qqfile
> newfilename = db.Project_Files.filename.store(request.body, 
> filename)
> db.Project_Files.insert(Project_id=Selected_project.id, 
> filename=newfilename)
> return response.json({'success': 'true'})
>
>
>
>
>
>
> On Wednesday, January 13, 2016 at 1:43:10 PM UTC-5, Anthony wrote:
>>
>> Please show some code.
>>
>> On Wednesday, January 13, 2016 at 1:37:16 PM UTC-5, Ron Chatterjee 
>> wrote:
>>>
>>> How do I update a current page in its view after a file submission 
>>> if the redirect doesn't work?
>>>
>>> {{redirect(URL('show_project_summary', args = Selected_project.id), 
>>> client_side = True)}}
>>>
>>> Any 

Re: [web2py] Re: AttributeError: 'Table' object has no attribute '_primarykey'

2016-01-13 Thread Manuele Pesenti
Il 13/01/16 15:56, 'DenesL' via web2py-users ha scritto:
> Which web2py version is that?.
> Not sure when objects.py was fixed but the fix is there in 2.12.03 for
> sure.
Quite an old version... it's a 2.9.12

by the way I've by-passed the problem using theese five lines of code
instead of the single method "validate_and_update_or_insert":

n = self.db(query).count()
if n>0:
res = self.db[self.table_name].validate_and_update(query,
**vars)
else:
res = self.db[self.table_name].validate_and_insert(**vars)

Thank you
Best regards

Manuele
>
> Regards,
> Denes

-- 
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] simple update of an cache.ram python dict

2016-01-13 Thread Richard Vézina
Redis keys are stick for ever...

I figure out most of how to use the Niphold contrib, though it seems that
created cached element stays in Redis for ever... I restart the server and
they still there...

My issue look like it still there... There maybe something wrong in my
logic...

It like if the cached dict can't just be updated as usual :

dict.update(key: value)

Richard

On Wed, Jan 13, 2016 at 1:00 PM, Richard Vézina  wrote:

> Ha!!
>
> Yes nginx/uwsgi...
>
> That what I suspecting, it looks like the dict was kind of unique by
> user...
>
> I think we should leave a note somewhere in the book about this issue...
>
> I was in the process of exploring Redis cache or memcache just to see if
> there were not improvement. I will look into Redis.
>
> Thank you Anthony.
>
> Richard
>
> On Wed, Jan 13, 2016 at 12:19 PM, Anthony  wrote:
>
>> Are you using nginx/uwsgi? If so, I believe cache.ram would not be shared
>> across the different uwsgi worker processes. You might consider switching
>> to the Redis cache.
>>
>> Anthony
>>
>>
>> On Wednesday, January 13, 2016 at 11:26:16 AM UTC-5, Richard wrote:
>>>
>>> Hello,
>>>
>>> Still struggle with this. I don't understand why cache dict is not
>>> updated in real time...
>>>
>>> It get updated but there is a strange delay.
>>>
>>> Thanks
>>>
>>> Richard
>>>
>>> On Mon, Jan 4, 2016 at 4:18 PM, Richard Vézina <
>>> ml.richard.vez...@gmail.com> wrote:
>>>
 UP here!

 Any help would be appreciate...

 Richard

 On Mon, Dec 21, 2015 at 10:22 PM, Richard 
 wrote:

> Hello,
>
> I am still under 2.9.5, I have a simple dict cached in ram which never
> expire that I update when new key value are added to the system... Mainly
> the dict contain id and their representation...
>
> It works flawlessly in dev, but once I pushed in prod, it seems that
> the cached dict takes time to really update... Here how I manage the
> creation an update of this dict :
>
> def set_id_represent(update_id_represent_if_elapsed_time=None, id=None
> ):
> """
> Calling this function will create in globals the "id_represent"
> variable if the call is made without
> id. If id is passed, it will update the id_represent dictionary
> with new
> id and it representation.
> :param id:
> :param update_id_represent_if_elapsed_time:
> """
> if 'id_represent' not in globals():
> global id_represent
> id_represent = \
> cache.ram('id_represent',
>   lambda: {r.id: r.represent_field
>for r in db().select(db.table_name.id,
> db.table_name.
> represent_field,
> orderby=db.
> table_name.represent_field)
>},
>   time_expire=update_id_represent_if_elapsed_time)
> elif isinstance(id, int) or isinstance(id, long):
> id_represent_query = \
> db(db.table_name.id == id
>).select(db.table_name.id,
> db.table_name.represent_field,
> orderby=db.table_name.represent_field)
> id_represent.update({r.id: r.represent_field for r in
> id_represent_query})
> if id:
> return id_represent[id]
>
> set_id_represent(update_id_represent_if_elapsed_time=None)
>
> Then when I want to update the cached dict with new k, v :
>
> set_id_represent(id=my_id)
>
> I have made some test and print after the id_represent.update(...)
> above from the function call and the dict seems to be updated... The
> function that call set_in_represent(id=id) doesn't failed, but when we 
> want
> to access page which user id_represent[some_id], they all failed for a
> couples of minutes... Like if the cached dict not get update 
> immediately...
>
> Thanks for any pointer...
>
> 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)
>> - 

[web2py] Re: what are the ways I can reload or refresh the current page where redirect doesn't work

2016-01-13 Thread Anthony
Please show some code.

On Wednesday, January 13, 2016 at 1:37:16 PM UTC-5, Ron Chatterjee wrote:
>
> How do I update a current page in its view after a file submission if the 
> redirect doesn't work?
>
> {{redirect(URL('show_project_summary', args = Selected_project.id), 
> client_side = True)}}
>
> Any response.js that will update or reload/refresh the current page?
>
>

-- 
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: what are the ways I can reload or refresh the current page where redirect doesn't work

2016-01-13 Thread Anthony
Check the returned response to ensure the JS is in the header, and check 
the browser JS console to see if there are any errors.

Looks like the JS library you are using also has an onComplete callback, so 
you could put the reload code in there.

Anthony

On Wednesday, January 13, 2016 at 2:27:36 PM UTC-5, Ron Chatterjee wrote:
>
> It didn't work. didn't reload it. 
>
> On Wednesday, January 13, 2016 at 2:20:14 PM UTC-5, Anthony wrote:
>>
>> Yes, in the controller, and just us the URL function as usual.
>>
>> Anthony
>>
>> On Wednesday, January 13, 2016 at 2:17:22 PM UTC-5, Ron Chatterjee wrote:
>>>
>>> Yes. That's what I thought too. But what's the correct syntax for 
>>> response.js Anthony?
>>>
>>> Is it:
>>>
>>> response.js = 'window.location = "%s";' % URL
>>> ('default',show_project_summary')
>>>
>>> ?
>>> And I believe I need to invoke that in my controller. Right?
>>>
>>>
>>>
>>> On Wednesday, January 13, 2016 at 2:06:34 PM UTC-5, Anthony wrote:

 Where is:

 {{redirect(URL('show_project_summary', args = Selected_project.id), 
 client_side = True)}}

 If that's in a view file for upload_callback, it will never get 
 executed, because upload_callback doesn't return a dictionary.

 You can call redirect(..., client_side=True) within the upload_callback 
 function, though that will skip the returning of the {"success": "true"} 
 JSON response (though perhaps you don't need that, as returning a 200 
 response may be sufficient to imply success). Alternatively, you can set 
 response.js:

 response.js = 'window.location = "%s";' % URL(...)

 That's really all the client side redirect does.

 Anthony

 On Wednesday, January 13, 2016 at 1:51:51 PM UTC-5, Ron Chatterjee 
 wrote:
>
> Basically after the file upload, I would like to refresh/reload 
> "show_project_summary.html" to show the list of the file that just been 
> downloaded. 
>
>
>
> On Wednesday, January 13, 2016 at 1:49:42 PM UTC-5, Ron Chatterjee 
> wrote:
>>
>> *I have this in my view (show_project_summary.html).*
>>
>>
>> 
>> {{ if (submission.created_by == auth.user_id):}}
>> 
>> {{pass}}
>> 
>>
>>
>>
>>
>> *Script in the same view at the bottom:*
>>
>> 
>> jQuery(document).ready(function() {
>>   var uploader = new qq.FileUploader({
>> // pass the dom node (ex. jQuery(selector)[0] for jQuery 
>> users)
>> element: document.getElementById('file-uploader'),
>> // path to server-side upload script
>> action: 
>> '{{=URL("upload_callback_submission")}}/{{=request.args(0)}}',
>> sizeLimit: 15000,
>> minSizeLimit: 0,
>> allowedExtensions: ['xls','jpg', 'jpeg', 'pdf', 
>> 'txt','doc','docx','ppt', 'pptx', 'htm','html','xml','xmls', 
>> 'txt','ppt','png', 'gif'],
>> // set to true to output server response to console
>> debug: true,
>>
>> // events
>> // you can return false to abort submit
>> onSubmit: function(id, fileName){},
>> onProgress: function(id, fileName, loaded, total){},
>> onComplete: function(id, fileName, responseJSON){},
>> onCancel: function(id, fileName){},
>>
>> messages: {
>> // error messages, see qq.FileUploaderBasic for content
>> typeError: "{file} {{=T('has invalid extension.')}} 
>> {{=T('Only')}} {extensions} {{=T('are allowed.')}}",
>> sizeError: "{file} {{=T('is too large, maximum file size 
>> is')}} {sizeLimit}.",
>> minSizeError: "{file} {{=T('is too small, minimum file 
>> size is')}} {minSizeLimit}.",
>> emptyError: "{file} {{=T('is empty, please select files 
>> again without it.')}}",
>> onLeave: "{{=T('The files are being uploaded, if you 
>> leave now the upload will be cancelled.')}}"
>> },
>> showMessage: function(message){ alert(message); }
>> });
>> });
>> 
>>
>>
>>
>> *In my default controller:*
>>
>> def upload_callback():
>> Selected_project = []
>> #Rendering rule for Post
>> Selected_project = db.Project(request.args(0, cast=int))
>> db.Project_Files.Project_id.default = Selected_project.id;
>> project = db.Project[request.args(0)]
>> if Selected_project is None:
>> raise HTTP(404)
>> if 'qqfile' in request.vars:
>> filename = request.vars.qqfile
>> newfilename = db.Project_Files.filename.store(request.body, 
>> filename)
>> db.Project_Files.insert(Project_id=Selected_project.id, 
>> filename=newfilename)
>> return response.json({'success': 'true'})
>>
>>
>>
>>

[web2py] How can we use variables like session.variable1 inside the html email body?

2016-01-13 Thread RAGHIB R
can you please write a piece of code for it?

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


[web2py] Re: Why this HTML email not working? Please tell me the corrected version.

2016-01-13 Thread Niphlod
replied already in another post. Please, pretty please, read the book 
before posting questions!

On Wednesday, January 13, 2016 at 8:35:25 PM UTC+1, RAGHIB R wrote:
>
> just tell me how do I include something as session.name1 inside the html 
> body here?
>
> On Wednesday, January 13, 2016 at 1:21:11 AM UTC+5:30, Niphlod wrote:
>>
>> If you read docs about mail.send, you'd know that it takes
>>
>> mail.send(to, subject, message, attachments, cc, .. etc etc etc).
>>
>> for html-only mails, it should be
>>
>> mail.send('reci...@gmail.com, 'subject', 'thebody', etc etc 
>> etc)
>>
>> That being said, what's the error ? 
>>
>> On Tuesday, January 12, 2016 at 7:21:25 PM UTC+1, RAGHIB R wrote:
>>>
>>> def result():
>>> session.x=mail.send('smm...@gmail.com',
>>> 'hello',
>>> '>> style="background-color:pink;font-size:2em;display:inline">Hi Raghib, you 
>>> have a new entry: ','session.name+session.name2+" with 
>>> "+str(session.percent)')
>>> if session.x==True:
>>> response.flash="result"
>>> else:
>>> response.flash="resultt"
>>> return locals()
>>>
>>

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


[web2py] Re: how to calculate size of uploads by user

2016-01-13 Thread Niphlod
detailed examples are for hard things AND people not willing to experiment 
:-P

it's pretty simple.

Given a table with

Field('contents', 'upload')

any submitted form will have "contents" as a FieldStorage (standard wsgi 
behaviour). The real deal (or, "the nifty trick") is checking BEFORE 
form.process().accepted (if you're not using your own form, which should 
have been more fun ;-)) what is coming along...
So, you add 

Field('contents_size', 'integer')
Field('contents_filename', length=512)

and you'd like to store the file size and the original filename

Any piece of code happening AFTER form.process().accepted for a SQLFORM 
have done already the insertion at the database level. So you must 
intercept what you need just before it. SQLFORM won't hide contents_size 
and contents_filename by default, so the other piece of the nifty trick is 
remembering that you should set them as hidden by setting writable=False on 
them.
>From there on, it's pretty easy.

form = SQLFORM(db.tablename)
filesize_ = len(request.vars.contents.value)
filename_ = request.vars.contents.filename
form.vars.contents_size = filesize_
form.vars.contents_filename = filename_
if form.process().accepted:
  blablabla



On Wednesday, January 13, 2016 at 7:22:19 PM UTC+1, Alex Glaros wrote:
>
> am having trouble finding detailed examples.  Can you please help with 
> syntax?
>
> Am determining size when uploading a user's photo (thumbnail) to their 
> profile:
>
> if form.process().accepted:
>session.flash = 'profile update accepted'
>file_info = cgi.FieldStorage(form.vars.thumbnail)
>form.vars.file_size = len(file_info)
>
> the goal is to populate field file_size with number of bytes the file 
> contains
>
> but the above raises errors
>
> thanks
>
> 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: How can we use variables like session.variable1 inside the html email body?

2016-01-13 Thread Niphlod
mail.send(to, subject, 'this is the value of variable1 %s' % 
session.variable1).

Don't know why it's difficult to figure out :P

On Wednesday, January 13, 2016 at 8:45:07 PM UTC+1, RAGHIB R wrote:
>
> can you please write a piece of code for it?
>

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

2016-01-13 Thread Massimo DiPierro
It is another experiment.

It is a rewrite of some of the web2py modules and supports 90% of the
current web2py syntax at 2.5x the speed. It works. It it cleaner and should
be easier to port to python 3 than current web2py.

We are debating on web2py developers what to do:
1) backport some of the new modules to web2py (specifically the new Form
class instead of SQLFORM)
2) try to reach a 99.9% compatibility and release it as new major version
with guidelines for porting legacy apps
3) make some drastic changes in backward compatibility and release as a
different framework (but change what? we like web2py as it is)

For now I am working on 2 to see how far I can push the backward
compatibility. But there are some functionalities I want remove or move in
an optional module (from legacy_web2py import *).

Feel free to share your opinion on web2py developers.

Massimo


On Wed, Jan 13, 2016 at 11:04 PM, kelson _  wrote:

> I was looking at your recent web3py commits and hoped you could provide
> the web3py vision/intent (or point me towards it if I missed the
> discussion).
>
> Thanks,
> kelson
>

-- 
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: Hide form field

2016-01-13 Thread Massimo Di Pierro
form = SQLFORM.factory(
  Field('year', label='Year'),
  Field('month', label='Month'),
  hidden=dict(fieldname='field value'))


On Wednesday, 13 January 2016 11:21:11 UTC-6, desta wrote:
>
> Thank you Anthony for the help.
>
> I am not sure how to use this though. Reading the documentation I 
> construct my form as follows:
>
> form = SQLFORM.factory(
>   Field('year', label='Year'),
>   Field('month', label='Month'))
>
> How do I apply the hidden part you described?
>
> Thanks again.
>
>
> On Wednesday, January 13, 2016 at 6:55:05 PM UTC+2, Anthony wrote:
>>
>> SQLFORM.factory(..., hidden=dict(fieldname='field value'))
>>
>> Anthony
>>
>> On Wednesday, January 13, 2016 at 11:35:57 AM UTC-5, desta wrote:
>>>
>>> I am generating a form using SQLFORM.factory() and I would like to 
>>> create a hidden field. I tried doing this by setting readable and writable 
>>> to False, but the field dissapears from HTML.
>>>
>>> Is there a way to make it hidden but still accessible in HTML as I want 
>>> to set its value with Javascript.
>>>
>>> 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.


[web2py] Re: multiple instances of a single form on one page

2016-01-13 Thread Massimo Di Pierro
def index():
forms = [SQLFORM(db.table,formname='form%i' % k).process() for k in 
range(10)]
for k,form in enumerate(forms):
   if form.accepted:
   print k, form.vars # or do something else
return dict(forms = DIV(*forms))


On Wednesday, 13 January 2016 10:58:02 UTC-6, aetagot...@gmail.com wrote:
>
> I'm not sure if this is even possible, but if it is..how would something 
> like this work:
>
> You prompt the user for an x amount of days, then with javascript and 
> jquery you have x amount of buttons appear. Each button is an instance of 
> the form. There is a variable within the javascript that holds the amount 
> x. So for each instance of x, the user fills out the same form but with 
> different values for each day. In the db module containing the sqlform, 
> there is a function that takes in each instance and performs what it needs 
> to for each separate instance.
>
> Also, if you are in views, how can you share a variable that is used in a 
> script to python code in the same views, or in the db models file?
>

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


[web2py] Re: SQLFORM.factory() - Display name instead of integer for user_id?

2016-01-13 Thread Tom Campbell


On Wednesday, January 13, 2016 at 3:38:56 PM UTC-8, Tom Campbell wrote:
>
> Creating a custom form that relates first name and last name fields to the 
> db.auth_user's user_id field. In the form below the user ID shows as an 
> integer in the dropdown but I'd like it to show as the user's name. How do 
> I do that?
>
> form = SQLFORM.factory(
> 
> Field('first_name', requires=IS_NOT_EMPTY()),
> Field('last_name', requires=IS_NOT_EMPTY()),
> Field('user_id', 'reference auth_user', requires=IS_IN_DB(db,
> db.auth_user.id)),
> fields=['first_name', 'last_name', 'user_id'],
> )
>
> I also tried this, but it sill displayed as an integer:
Field('user_id', 'reference auth_user', 
widget=SQLFORM.widgets.options.widget, 
requires=IS_IN_DB(db,db.auth_user.id)),
 

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


[web2py] Re: SQLFORM.factory() - Display name instead of integer for user_id?

2016-01-13 Thread 黄祥
i think you can use format or represent to achieve it.
e.g.
*somewhere in models after you define auth tables*
custom_auth_table = db[auth.settings.table_user_name]

custom_auth_table._format = '%(first_name)s %(last_name)s'

*controllers that have SQLFORM.factory that refer to auth_user table*
requires = IS_IN_DB(db, db.auth_user.id, db.auth_user._format)

best regards,
stifan

-- 
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] simple update of an cache.ram python dict

2016-01-13 Thread Niphlod
hem... cache.ram behaves differently than ANY other backend because it 
just stores a reference to the computed value .
That's why you can do a dict.update() without setting explicitely a new 
cached value... but you'd need to do if you see it from a "flow" 
perspective.

What you are tryng to do in pseudo code is really:

 if something_happens:
search_cached_value
if cached_value is not there:
  calculate cached_value for all
  store it in cache
if just_a_piece_isn't_there:
  fetch_cached_value
  update_a_piece_of_it
  store updated_cached_value into cache

and it is what you need to do with anything not being cache.ram (i.e. fetch 
"all", update a piece, store "the new all")

This difference of behaviours, and the lack of proper shortcuts is one of 
the things I hate most from web2py's cache behaviour (which has some pros, 
but lots of cons, like in your case). API for this kind of operations isn't 
really straightforward...


Wrapping things up

if 'foo' not in globals():
fetching = cache.whatever_but_not_ram('thekey', lambda:1, 
time_expire=None) # special case to never refresh the value
if fetching == 1:
# nobody ever stored something here
huge_thing_to_compute = cache.whatever_but_not_ram('thekey', 
lambda: long_cache_func(), time_expire=0) #special case to ALWAYS refresh 
the value
else:
   # something is stored here
   if needs_updating:
fetching[just_a_piece] = 'newpiecevalue'
cache.whatever_but_not_ram('thekey', lambda: fetching, 
time_expire=0)


BTW: I'm the only one thinking that you're overcomplicating the issue ? 
Just store pieces in cache and let them refresh when needed without dealing 
with the whole object and its relative invalidation (plus global escalation 
of local variables, etc etc etc)

BTW2: if you ask to store keys indefinitely, redis is happy to persist 
them. While cache.ram and cache.disk will effectively NEVER delete the 
values, redis has a strict upper value of one day (24*60*60) to avoid stale 
records everywhere.

-- 
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] SQLFORM.factory() - Display name instead of integer for user_id?

2016-01-13 Thread Tom Campbell
Creating a custom form that relates first name and last name fields to the 
db.auth_user's user_id field. In the form below the user ID shows as an 
integer in the dropdown but I'd like it to show as the user's name. How do 
I do that?

form = SQLFORM.factory(

Field('first_name', requires=IS_NOT_EMPTY()),
Field('last_name', requires=IS_NOT_EMPTY()),
Field('user_id', 'reference auth_user', 
requires=IS_IN_DB(db,db.auth_user.id)),
fields=['first_name', 'last_name', 'user_id'],
)

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


Re: [web2py] simple update of an cache.ram python dict

2016-01-13 Thread Anthony
On Wednesday, January 13, 2016 at 3:18:10 PM UTC-5, Richard wrote:
>
> Redis keys are stick for ever...
>
> I figure out most of how to use the Niphold contrib, though it seems that 
> created cached element stays in Redis for ever... I restart the server and 
> they still there... 
>

Are you saying you re-started the web server (e.g., uwsgi) or the entire 
VM? I don't think Redis would be affected by the former.

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] simple update of an cache.ram python dict

2016-01-13 Thread Niphlod
errata corrige on BTW2: on redis, time_expire=None results in key stored at 
most one day. you can always do time_expire=30*24*60*60 for 30days worth.

things_to_know: only cache.disk and cache.ram can effectively cache a value 
indefinitely and enable that strange behaviour of retrieving the previously 
cached element - that you marked to expire after 5 seconds - one day later. 
Web2py's cache API is effectively incompatible with any high-performance 
caching system, unless the user calls upon himself the burden of clearing 
the cache regularly (which is never the case because cache invalidation is 
one of the hardest things to master).
Both memcache and redis take a more strict behaviour, i.e. the value will 
effectively expire at the time it was set on the first time. So, you can 
only fetch a cached value one day later if you originally marked it as 
expiring one day later. Redis allows a leeway of 120 seconds to accomodate 
the 90% of the behavioural usecases of cache.ram and cache.disk.

-- 
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: update 2 session value using module only first session value work

2016-01-13 Thread 黄祥
thank you so much for detail explaination, anthony. i found another way 
around that work fine, don't know is this best practice or not because it 
hard code to reserve the place in session variable. 
like describe in the previous post, i want this module function can be used 
by another functions in another controllers, so to explicit the session is 
fine and then i must copy and rename the module function and rename it's 
session name.
e.g.
*controllers/sale.py*
if 'sale_order' in request.function :
# session sale_order
session.sale_order = session.sale_order or {}
#session.sale_order_net = session.sale_order_net or dict(discount = 0, 
delivery_fee = 0, packing_fee = 0, stamp_fee = 0, paid = 0)
#session.sale_order_net = session.sale_order_net or {'discount':0, 
'delivery_fee':0, 'packing_fee':0, 'stamp_fee':0, 'paid':0}
*session.sale_order_net = session.sale_order_net or {}*
* session.sale_order_net[0] = dict(discount = 0, delivery_fee = 0, 
packing_fee = 0, stamp_fee = 0, paid = 0)*
#sale_order
session_sale_order = session.sale_order
session_sale_order_net = session.sale_order_net

def sale_order_callback():
return transaction.callback_0(session_sale_order, session_sale_order_net)
*modules/transaction.py*
def callback_0(session_order, session_order_net):
if current.request.vars.action == 'adjust_total_net':
discount = int(current.request.vars['discount'] )
delivery_fee = int(current.request.vars['delivery_fee'] )
packing_fee = int(current.request.vars['packing_fee'] )
stamp_fee = int(current.request.vars['stamp_fee'] )
paid = int(current.request.vars['paid'] )

*session_order_net[0] = dict(discount = discount, delivery_fee = 
delivery_fee, packing_fee = packing_fee, stamp_fee = stamp_fee, paid = 
paid)*

thanks and best regards,
stifan

On Thursday, January 14, 2016 at 1:58:07 AM UTC+7, Anthony wrote:
>
> Presumably you are calling this function as follows:
>
> callback_0(session.order, session.sale_order_net)
>
> The problem is you later have:
>
> session_order_net = dict(...)
>
> At that point, you are not modifying the session.sale_order_net object but 
> simply assigning a new object to the local variable session_order_net. This 
> is equivalent to doing:
>
> session_order_net = current.session.sale_order_net
> session_order_net = dict(...)
>
> In the above case, you wouldn't expect the second line to have any effect 
> on session.sale_order_net -- the second line simply makes the first line 
> irrelevant (i.e., it simply overwrites the value of the session_order_net 
> variable that is local to the function).
>
> The earlier line:
>
> session_order[id] = ...
>
> works because in that case, you are not assigning a new object to the 
> session_order variable but merely mutating the object to which 
> session_order refers (i.e., session.order).
>
> If you want to completely replace the value of session.sale_order_net, 
> then pass in the session object and do:
>
> session.sale_order_net = ...
>
> Anthony
>
>
>
>
>
> On Wednesday, January 13, 2016 at 12:48:11 AM UTC-5, 黄祥 wrote:
>>
>> is it possible to update 2 sessions values using web2py module? i've 
>> tested it only first session value work, the second session value work if 
>> explicit define in the module (but the module is used by another 
>> controller, so i want to create just 1 module for all controllers).
>> e.g.
>> *modules/transaction.py*
>> def callback_0(session_order, session_order_net):
>> if current.request.vars.action == 'adjust_total':
>> id = int(current.request.vars.id)
>> quantity = int(current.request.vars['quantity_%s' % id])
>> price = int(current.request.vars['price_%s' % id])
>> *session_order[id] = quantity, price # the first parameter work*
>> total_price = quantity * price
>> total_quantity = 0
>> grand_total = 0
>> for calculation_id, (calculation_quantity, calculation_price) in 
>> session_order.items():
>> calculation_total_price = calculation_quantity * calculation_price
>> total_quantity += calculation_quantity
>> grand_total += calculation_total_price
>> return "jQuery('#total_price_%s').html('%s'); 
>> jQuery('#total_quantity').html('%s'); jQuery('#grand_total').html('%s');" % 
>> (id, 
>>   format(total_price, ",d").replace(",", "."), format(total_quantity, 
>> ",d").replace(",", "."), 
>>   format(grand_total, ",d").replace(",", ".") )
>> if current.request.vars.action == 'adjust_total_net':
>> discount = int(current.request.vars['discount'] )
>> delivery_fee = int(current.request.vars['delivery_fee'] )
>> packing_fee = int(current.request.vars['packing_fee'] )
>> stamp_fee = int(current.request.vars['stamp_fee'] )
>> paid = int(current.request.vars['paid'] )
>>
>> * current.session.sale_order_net = dict(discount = discount, delivery_fee 
>> = delivery_fee, packing_fee = packing_fee, stamp_fee = stamp_fee, paid = 
>> paid) # this work when explicit tell the session name*
>>
>> * #session_order_net = dict(discount = discount, delivery_fee = 
>> delivery_fee, packing_fee = packing_fee, 

[web2py] Field Type Data

2016-01-13 Thread Lorenzo Zonca
Goodmorning  to everyone.

Through a field "date " with calendar of a CRUD , how can I store a date with 
this syntax

eg . Monday, 2 May - 2016 ( day - number of day - month - year )


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.


[web2py] Oracle Blob Read

2016-01-13 Thread Rochdi HASSINE
I'm new on web2py and I need to display some images stored in Oracle 
Database.
It s Oracle BLOB fields.


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


[web2py] Re: How can we use variables like session.variable1 inside the html email body?

2016-01-13 Thread aston . ribat
Thats not html message @Niphlod
here
How to display value of here if here is variable

-- 
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: web2pyslices again

2016-01-13 Thread Anthony

>
> Please use KISS (keep it simple, stupid) technology. We simple need a page 
> with very easy list of plugins: Name, Goal, w2p link, repository link - 
> please NOTHONG more!! Same should see the user who wish use the plugin.
>

Feel free to build an alternative.
 

> What for stupid peace of software.
>

Keep in mind that someone volunteered their time to create this *piece* of 
software, so maybe strive to be a bit more polite with criticisms (and I 
would say your reaction is over the top -- it's not perfect, but it's not 
*that* bad).

Please remove from web2py code and web2py doc all references to 
> web2pyslices. Thank you so much!
>

Quite a presumptuous request. Don't see it happening until there is a 
superior replacement.

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: import_from_csv_file: how to map columns

2016-01-13 Thread Anthony
I think you'll have to manually change the column names in the file, either 
by hand or via Python code.

Anthony

On Wednesday, January 13, 2016 at 7:33:20 AM UTC-5, goome wrote:
>
> Hi
> i created i table definition in db.py by using csvstudio.py, but i cannot 
> load the values through db.table.import_from_csv_file becouse the header in 
> the csv have spaces and uppercases.
> So there a way to tell import_from_csv_file how to map column in csv with 
> that in table definition?
> By the way, column in csv are in the same order than in table definition.
> Thanks
>

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


[web2py] Re: How to perform a query WITHOUT issuing an orderby to the DB

2016-01-13 Thread Paulo Serrão
Thank you Anthony!

Yes I am aware of that issue, that's something I can live with.

On Wednesday, 13 January 2016 15:17:05 UTC, Anthony wrote:
>
> db().select(db.table.ALL, limitby=(0,1000), orderby_on_limitby=False)
>
> But note that the order of records is not guaranteed to be the same on 
> repeat calls to the database, so you may get a different 1000 records each 
> time you run that query (that's why the DAL defaults to 
> orderby_on_limitby=True). If you order by a column with unique values (such 
> as the primary key), you are guarenteed to get the same ordering (and 
> therefore the same set of records, assuming there have been no 
> insertions/deletions) on each run.
>
> See http://web2py.com/books/ 
> 
> default/chapter/29/06/the- 
> 
> database-abstraction-layer? 
> 
> search=orderby_on_limitby# 
> 
> orderby--groupby--limitby-- 
> 
> distinct--having-orderby_on_ 
> 
> limitby-left-cache 
> 
>
> Anthony
>
> On Wednesday, January 13, 2016 at 10:08:13 AM UTC-5, Paulo Serrão wrote:
>>
>>
>> Hello everyone!
>>
>> I'm querying a legacy database and for performance issues I can't do an 
>> orderby and the end of the SQL (HUGE table).
>>
>> If I do:
>>
>> db().select(db.table.ALL, orderby=db.table.some_key, limitby=(0,1000))
>>
>> It will issue as supposed: SELECT * FROM table ORDER BY *some_key* LIMIT 
>> 1000 OFFSET 0;
>>
>> But if I remove the "orderby":
>>
>> db().select(db.table.ALL, limitby=(0,1000))
>>
>> It will automatically issue: SELECT * FROM table ORDER BY *primary_key* 
>> LIMIT 1000 OFFSET 0;
>>
>> Since I HAVE to define a primary key on the legacy table, Is there any 
>> way to avoid issuing an order by without having to do db.executesql 
>> manually?
>>
>

-- 
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: Function fails when called from scheduler, but ok when called from a controller/function

2016-01-13 Thread Lisandro
Thanks for the answer. 
I've found that one of my models does a conditional check on request 
object. 
However, when the function is called from the scheduler, there is no HTTP 
request, so there is no request object.

Is there a way to check if request object exists from inside the model?

I've tried this:
if 'request' in globals():
#do stuff here

and this
try:
request = request
except:
   request = None
if request:
#do stuff here (I know, this is really bad thing to do)

Thanks in advance





El martes, 12 de enero de 2016, 16:59:26 (UTC-3), Niphlod escribió:
>
> it seems an error in the model definition, as line 166 in gluon.shell is 
> where an exception is raised when executing model files BEFORE calling the 
> controller.
> As I repeatedly said, scheduler is just calling shell at regular intervals 
> on steroids. If it works on the shell, it'll work on the scheduler too.
>
> so, 1st step. What if you execute the function in the shell directly ?
>
> web2py.py -M -S appname/controller_name/function_name
>
> The only thing that can sometimes get you in the corner is conditional 
> models ... If  you're using them, be sure when you are queuing the task, 
> that you do from the same controller which triggers the same conditional 
> models where the function is defined.
> Remember that the scheduler executes the same environment where the 
> queuing happened if you don't pass an explicit application_name parameter 
> (by default is current.request.application/current.request.controller) 
> which executes models/* and models/controller_name but not 
> models/other_controller_name
>
> On Tuesday, January 12, 2016 at 5:50:52 PM UTC+1, Lisandro wrote:
>>
>> I'm seeing this traceback error when I try to run a function defined in a 
>> model:
>>
>> Traceback (most recent call last): File 
>> "/var/www/medios/gluon/scheduler.py", line 295, in executor _env = env(a=
>> a, c=c, import_models=True) File "/var/www/medios/gluon/shell.py", line 
>> 166, in env sys.exit(1) SystemExit: 1
>>
>> However, if I call the function from within a controller/function, the 
>> function executes ok.
>> As I don't see an error pointing to my app's code, I thought I could ask 
>> here. What am I missing?
>>
>

-- 
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: AttributeError: 'Table' object has no attribute '_primarykey'

2016-01-13 Thread 'DenesL' via web2py-users
Which web2py version is that?.
Not sure when objects.py was fixed but the fix is there in 2.12.03 for sure.

Regards,
Denes

On Wednesday, January 13, 2016 at 8:49:34 AM UTC-5, Manuele wrote:
>
> Hi *, 
> I got this strange error. Where I have to look for the cuase? 
> The table object of my query is defined by: 
>
> # Note: defined as class parameter 
> table = Table(None, table_name, 
> Field("uuid", unique=True, default=lambda: web2py_uuid()), 
> Field("service", required=True), 
> Field("command", required=True), 
> Field("args", 'json', default={}), 
> Field("status", default="QUEUED", 
> requires=IS_IN_SET(task_states)), 
> Field("command_output", 'json'), 
> Field("start_time", "datetime"), 
> Field("end_time", "datetime"), 
> Field('created_on', 'datetime', default=current.request.now), 
> Field('updated_on', 'datetime', update=current.request.now), 
> Field('created_by', 'integer'), 
> Field('updated_by', 'integer'), 
> ) 
>
> and 
>
> self.db.define_table(self.table_name, self.table) 
>
> and the exception (cited below) is raides calling the method: 
> validate_and_update_or_insert 
>
> --- 
>
> AttributeErrorTraceback (most recent call 
> last) 
> /home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/models/utils.py
>  
>
> in () 
> > 1 iproot.queue_task("noproot", "test") 
>
> /home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/modules/prootdio.py
>  
>
> in queue_task(self, service, command, force_new, **args) 
> 301 command = command, 
> 302 status = "QUEUED", 
> --> 303 args = args 
> 304 ) 
> 305 
>
> /home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/modules/prootdio.py
>  
>
> in wrapper(self, *args, **vars) 
>  94 def wrapper(self, *args, **vars): 
>  95 self.db[self.table_name].args.requires = [] 
> ---> 96 return func(self, *args, **vars) 
>  97 return wrapper 
>  98 
>
> /home/manuele/dev/portali/web2py.trunk/applications/teleservice_node/modules/prootdio.py
>  
>
> in __validate_and_update_or_insert(self, query, commit, **vars) 
> 254 res = 
> self.db[self.table_name].validate_and_update_or_insert( 
> 255 query, 
> --> 256 **vars 
> 257 ) 
> 258 if commit: self.db.commit() 
>
> /home/manuele/dev/portali/web2py.trunk/gluon/dal/objects.pyc in 
> validate_and_update_or_insert(self, _key, **fields) 
> 817 response = self.validate_and_update(_key, **fields) 
> 818 primary_keys = {} 
> --> 819 for key in self._primarykey: 
> 820 primary_keys[key] = getattr(record, key) 
> 821 response.id = primary_keys 
>
> /home/manuele/dev/portali/web2py.trunk/gluon/dal/objects.pyc in 
> __getitem__(self, key) 
> 514 return self._db(self._id == key).select(limitby=(0, 
> 1), orderby_on_limitby=False).first() 
> 515 elif key: 
> --> 516 return ogetattr(self, str(key)) 
> 517 
> 518 def __call__(self, key=DEFAULT, **kwargs): 
>
> AttributeError: 'Table' object has no attribute '_primarykey' 
>
>
> Thanks a lot 
>
> Manuele 
>

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


Re: [web2py] Re: Can we use a web2py app on Android mobile?

2016-01-13 Thread Mathieu Clabaut
A bit out of topic, but also note that with the help of the nice termux
android app, you can develop and run the web2py server on your android…
Quite nice when you're far from a real computer…

-Mathieu

2016-01-12 16:39 GMT+01:00 eric cuver :

> there are several solution all depends on your application. facebook use 2
> adress  url www.facebook.com for the web and when you go through the
> mobile it is this address that is used https://m.facebook.com/
>
> If you want to create video games for example I think it's better to do it
> in native. Now for notifications exist for example in  HTML there are
>  things like this https://pusher.com/tutorials/realtime-notifications I
> think that there are more. To access the camera you have api in html like
> this http://bridgeit.mobi/html5-camera-access.html.
>  look this website you are all api html for mobile http://mobilehtml5.org/
>   as I say it depends on what you want to do
>
> Le mardi 12 janvier 2016 15:53:44 UTC+1, Andrew Buchan a écrit :
>>
>> @eric That's interesting... So essentially you'd get an "app" on your
>> mobile, but it just opens to a webpage on a server.
>> That is probably the best solution offered so far although you need to be
>> connected to and also don't get access to phone's features like contacts,
>> notifications etc...
>>
>>
>> On Tue, Jan 12, 2016 at 9:04 AM, eric cuver  wrote:
>>
>>> you can also do this with web2py you just need to create a webview with
>>> Cordova or Kivy with the URL of your mobile website view. Me this is what I
>>> do and it works without problems
>>>
>>>
>>> Le lundi 11 janvier 2016 22:31:58 UTC+1, Alessio Varalta a écrit :

 Sorry, , you are right. Now i have developed only in Android now in
 these day for a project i start to study cordova and is true that you can
 upload on Google market this my first time with Hybrid app

 Il giorno lunedì 11 gennaio 2016 13:17:14 UTC+1, Andrew Buchan ha
 scritto:
>
> Just to butt-in on what Richard said:
>
> "But this kind of app are often not that interresting from user stand
> point... I mean you don't have a good mobile app user experience with them
> most of the time because they to simple that you can just access the real
> web app and it could be even better..."
>
> That's not really true anymore...
>
> What you are referring to are hybrid apps, which is essentially a
> mini-website (HTML, JS, CSS) wrapped in a package and rendered in a native
> webview, as opposed to a native app which is built in objective-C or Java.
> Hybrid apps can access the phone's features such as camera, battery,
> geolocation, accelerometer etc... So you can do much more than you would 
> by
> accessing a web app in the browser!
> Hybrid performance is also more than adequate for most applications,
> and many of today's top apps are hybrid (in fact I challenge you to find
> out which apps on your phone are hybrid and which are native...)
>
> What's more, with tools like cordova you can target both Android and
> iOS (with caveats) with the same code.
> You also get to use the latest Javascript frameworks, such as
> AngularJS or ReactJS.
>
> My advice would be to learn js and angular then go down the ionic (
> http://ionicframework.com/) path. I really don't see a case for
> bringing web2py into android.
>
> Edit:
>
> What Alessio said isn't true either. You can publish hybrid apps to
> Google play and Apple's app store.
>
> Here's a useful page:
>
>
> http://www.joshmorony.com/the-step-by-step-guide-to-publishing-a-html5-mobile-application-on-app-stores/
>
>
>
> On Monday, January 4, 2016 at 9:20:53 PM UTC, RAGHIB R wrote:
>>
>> --
>>> 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/1ZxFEB5j4XA/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

Re: [web2py] Re: How to perform a query WITHOUT issuing an orderby to the DB

2016-01-13 Thread Richard Vézina
Hello Paulo,

If you concern about performance and you don't need all the fields of that
table, try to specify them individually you will save some cycle...

db.table.ALL is equal to SELECT *

Richard

On Wed, Jan 13, 2016 at 10:48 AM, Paulo Serrão 
wrote:

> Thank you Anthony!
>
> Yes I am aware of that issue, that's something I can live with.
>
> On Wednesday, 13 January 2016 15:17:05 UTC, Anthony wrote:
>>
>> db().select(db.table.ALL, limitby=(0,1000), orderby_on_limitby=False)
>>
>> But note that the order of records is not guaranteed to be the same on
>> repeat calls to the database, so you may get a different 1000 records each
>> time you run that query (that's why the DAL defaults to
>> orderby_on_limitby=True). If you order by a column with unique values (such
>> as the primary key), you are guarenteed to get the same ordering (and
>> therefore the same set of records, assuming there have been no
>> insertions/deletions) on each run.
>>
>> See http://web2py.com/books/
>> 
>> default/chapter/29/06/the-
>> 
>> database-abstraction-layer?
>> 
>> search=orderby_on_limitby#
>> 
>> orderby--groupby--limitby--
>> 
>> distinct--having-orderby_on_
>> 
>> limitby-left-cache
>> 
>>
>> Anthony
>>
>> On Wednesday, January 13, 2016 at 10:08:13 AM UTC-5, Paulo Serrão wrote:
>>>
>>>
>>> Hello everyone!
>>>
>>> I'm querying a legacy database and for performance issues I can't do an
>>> orderby and the end of the SQL (HUGE table).
>>>
>>> If I do:
>>>
>>> db().select(db.table.ALL, orderby=db.table.some_key, limitby=(0,1000))
>>>
>>> It will issue as supposed: SELECT * FROM table ORDER BY *some_key*
>>> LIMIT 1000 OFFSET 0;
>>>
>>> But if I remove the "orderby":
>>>
>>> db().select(db.table.ALL, limitby=(0,1000))
>>>
>>> It will automatically issue: SELECT * FROM table ORDER BY *primary_key*
>>> LIMIT 1000 OFFSET 0;
>>>
>>> Since I HAVE to define a primary key on the legacy table, Is there any
>>> way to avoid issuing an order by without having to do db.executesql
>>> manually?
>>>
>> --
> 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: Function fails when called from scheduler, but ok when called from a controller/function

2016-01-13 Thread Anthony
There is a request object, but it doesn't have all the same attributes 
during a scheduler run as it does during an HTTP request. Anyway, you can 
determine whether the current execution is happening via the scheduler by 
checking request.is_scheduler. Similarly, you can determine if in a shell 
with request.is_shell. Note, these two attributes have only been working 
properly since the latest release. In earlier versions, you would have to 
check request.env.cmd_options.scheduler and request.env.cmd_options.shell.

Anthony

On Wednesday, January 13, 2016 at 9:44:13 AM UTC-5, Lisandro wrote:
>
> Thanks for the answer. 
> I've found that one of my models does a conditional check on request 
> object. 
> However, when the function is called from the scheduler, there is no HTTP 
> request, so there is no request object.
>
> Is there a way to check if request object exists from inside the model?
>
> I've tried this:
> if 'request' in globals():
> #do stuff here
>
> and this
> try:
> request = request
> except:
>request = None
> if request:
> #do stuff here (I know, this is really bad thing to do)
>
> Thanks in advance
>
>
>
>
>
> El martes, 12 de enero de 2016, 16:59:26 (UTC-3), Niphlod escribió:
>>
>> it seems an error in the model definition, as line 166 in gluon.shell is 
>> where an exception is raised when executing model files BEFORE calling the 
>> controller.
>> As I repeatedly said, scheduler is just calling shell at regular 
>> intervals on steroids. If it works on the shell, it'll work on the 
>> scheduler too.
>>
>> so, 1st step. What if you execute the function in the shell directly ?
>>
>> web2py.py -M -S appname/controller_name/function_name
>>
>> The only thing that can sometimes get you in the corner is conditional 
>> models ... If  you're using them, be sure when you are queuing the task, 
>> that you do from the same controller which triggers the same conditional 
>> models where the function is defined.
>> Remember that the scheduler executes the same environment where the 
>> queuing happened if you don't pass an explicit application_name parameter 
>> (by default is current.request.application/current.request.controller) 
>> which executes models/* and models/controller_name but not 
>> models/other_controller_name
>>
>> On Tuesday, January 12, 2016 at 5:50:52 PM UTC+1, Lisandro wrote:
>>>
>>> I'm seeing this traceback error when I try to run a function defined in 
>>> a model:
>>>
>>> Traceback (most recent call last): File 
>>> "/var/www/medios/gluon/scheduler.py", line 295, in executor _env = env(a
>>> =a, c=c, import_models=True) File "/var/www/medios/gluon/shell.py", 
>>> line 166, in env sys.exit(1) SystemExit: 1
>>>
>>> However, if I call the function from within a controller/function, the 
>>> function executes ok.
>>> As I don't see an error pointing to my app's code, I thought I could ask 
>>> here. What am I missing?
>>>
>>

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


[web2py] How to perform a query WITHOUT issuing an orderby to the DB

2016-01-13 Thread Paulo Serrão

Hello everyone!

I'm querying a legacy database and for performance issues I can't do an 
orderby and the end of the SQL (HUGE table).

If I do:

db().select(db.table.ALL, orderby=db.table.some_key, limitby=(0,1000))

It will issue as supposed: SELECT * FROM table ORDER BY *some_key* LIMIT 
1000 OFFSET 0;

But if I remove the "orderby":

db().select(db.table.ALL, limitby=(0,1000))

It will automatically issue: SELECT * FROM table ORDER BY *primary_key* 
LIMIT 1000 OFFSET 0;

Since I HAVE to define a primary key on the legacy table, Is there any way 
to avoid issuing an order by without having to do db.executesql manually?

-- 
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: Can we use a web2py app on Android mobile?

2016-01-13 Thread eric cuver
half of the applications being used are not native. Facebook, 
uber,instagram etc ... all his  companies were not going to rewrite their 
applications for each platform in java for android, iphone in objective c, 
blackbery etc ... there is an article on the topic http : 
//kennethormandy.com/journal/your-favourite-app-isnt-native

Le mardi 12 janvier 2016 15:53:44 UTC+1, Andrew Buchan a écrit :
>
> @eric That's interesting... So essentially you'd get an "app" on your 
> mobile, but it just opens to a webpage on a server.
> That is probably the best solution offered so far although you need to be 
> connected to and also don't get access to phone's features like contacts, 
> notifications etc...
>
>
> On Tue, Jan 12, 2016 at 9:04 AM, eric cuver  > wrote:
>
>> you can also do this with web2py you just need to create a webview with 
>> Cordova or Kivy with the URL of your mobile website view. Me this is what I 
>> do and it works without problems
>>
>>
>> Le lundi 11 janvier 2016 22:31:58 UTC+1, Alessio Varalta a écrit :
>>>
>>> Sorry, , you are right. Now i have developed only in Android now in 
>>> these day for a project i start to study cordova and is true that you can 
>>> upload on Google market this my first time with Hybrid app
>>>
>>> Il giorno lunedì 11 gennaio 2016 13:17:14 UTC+1, Andrew Buchan ha 
>>> scritto:

 Just to butt-in on what Richard said:

 "But this kind of app are often not that interresting from user stand 
 point... I mean you don't have a good mobile app user experience with them 
 most of the time because they to simple that you can just access the real 
 web app and it could be even better..."

 That's not really true anymore...

 What you are referring to are hybrid apps, which is essentially a 
 mini-website (HTML, JS, CSS) wrapped in a package and rendered in a native 
 webview, as opposed to a native app which is built in objective-C or Java.
 Hybrid apps can access the phone's features such as camera, battery, 
 geolocation, accelerometer etc... So you can do much more than you would 
 by 
 accessing a web app in the browser!
 Hybrid performance is also more than adequate for most applications, 
 and many of today's top apps are hybrid (in fact I challenge you to find 
 out which apps on your phone are hybrid and which are native...)

 What's more, with tools like cordova you can target both Android and 
 iOS (with caveats) with the same code.
 You also get to use the latest Javascript frameworks, such as AngularJS 
 or ReactJS.

 My advice would be to learn js and angular then go down the ionic (
 http://ionicframework.com/) path. I really don't see a case for 
 bringing web2py into android.

 Edit:

 What Alessio said isn't true either. You can publish hybrid apps to 
 Google play and Apple's app store.

 Here's a useful page:


 http://www.joshmorony.com/the-step-by-step-guide-to-publishing-a-html5-mobile-application-on-app-stores/



 On Monday, January 4, 2016 at 9:20:53 PM UTC, RAGHIB R wrote:
>
> -- 
>> 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/1ZxFEB5j4XA/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: [web2py] Re: Can we use a web2py app on Android mobile?

2016-01-13 Thread eric cuver
there are several solution all depends on your application. facebook use 2 
adress  url www.facebook.com for the web and when you go through the mobile 
it is this address that is used https://m.facebook.com/

If you want to create video games for example I think it's better to do it 
in native. Now for notifications exist for example in  HTML there are 
 things like this https://pusher.com/tutorials/realtime-notifications I 
think that there are more. To access the camera you have api in html like 
this http://bridgeit.mobi/html5-camera-access.html.   
 look this website you are all api html for mobile http://mobilehtml5.org/ 
  as I say it depends on what you want to do

Le mardi 12 janvier 2016 15:53:44 UTC+1, Andrew Buchan a écrit :
>
> @eric That's interesting... So essentially you'd get an "app" on your 
> mobile, but it just opens to a webpage on a server.
> That is probably the best solution offered so far although you need to be 
> connected to and also don't get access to phone's features like contacts, 
> notifications etc...
>
>
> On Tue, Jan 12, 2016 at 9:04 AM, eric cuver  > wrote:
>
>> you can also do this with web2py you just need to create a webview with 
>> Cordova or Kivy with the URL of your mobile website view. Me this is what I 
>> do and it works without problems
>>
>>
>> Le lundi 11 janvier 2016 22:31:58 UTC+1, Alessio Varalta a écrit :
>>>
>>> Sorry, , you are right. Now i have developed only in Android now in 
>>> these day for a project i start to study cordova and is true that you can 
>>> upload on Google market this my first time with Hybrid app
>>>
>>> Il giorno lunedì 11 gennaio 2016 13:17:14 UTC+1, Andrew Buchan ha 
>>> scritto:

 Just to butt-in on what Richard said:

 "But this kind of app are often not that interresting from user stand 
 point... I mean you don't have a good mobile app user experience with them 
 most of the time because they to simple that you can just access the real 
 web app and it could be even better..."

 That's not really true anymore...

 What you are referring to are hybrid apps, which is essentially a 
 mini-website (HTML, JS, CSS) wrapped in a package and rendered in a native 
 webview, as opposed to a native app which is built in objective-C or Java.
 Hybrid apps can access the phone's features such as camera, battery, 
 geolocation, accelerometer etc... So you can do much more than you would 
 by 
 accessing a web app in the browser!
 Hybrid performance is also more than adequate for most applications, 
 and many of today's top apps are hybrid (in fact I challenge you to find 
 out which apps on your phone are hybrid and which are native...)

 What's more, with tools like cordova you can target both Android and 
 iOS (with caveats) with the same code.
 You also get to use the latest Javascript frameworks, such as AngularJS 
 or ReactJS.

 My advice would be to learn js and angular then go down the ionic (
 http://ionicframework.com/) path. I really don't see a case for 
 bringing web2py into android.

 Edit:

 What Alessio said isn't true either. You can publish hybrid apps to 
 Google play and Apple's app store.

 Here's a useful page:


 http://www.joshmorony.com/the-step-by-step-guide-to-publishing-a-html5-mobile-application-on-app-stores/



 On Monday, January 4, 2016 at 9:20:53 PM UTC, RAGHIB R wrote:
>
> -- 
>> 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/1ZxFEB5j4XA/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


[web2py] Re: How to perform a query WITHOUT issuing an orderby to the DB

2016-01-13 Thread Anthony
db().select(db.table.ALL, limitby=(0,1000), orderby_on_limitby=False)

But note that the order of records is not guaranteed to be the same on 
repeat calls to the database, so you may get a different 1000 records each 
time you run that query (that's why the DAL defaults to 
orderby_on_limitby=True). If you order by a column with unique values (such 
as the primary key), you are guarenteed to get the same ordering (and 
therefore the same set of records, assuming there have been no 
insertions/deletions) on each run.

Anthony

On Wednesday, January 13, 2016 at 10:08:13 AM UTC-5, Paulo Serrão wrote:
>
>
> Hello everyone!
>
> I'm querying a legacy database and for performance issues I can't do an 
> orderby and the end of the SQL (HUGE table).
>
> If I do:
>
> db().select(db.table.ALL, orderby=db.table.some_key, limitby=(0,1000))
>
> It will issue as supposed: SELECT * FROM table ORDER BY *some_key* LIMIT 
> 1000 OFFSET 0;
>
> But if I remove the "orderby":
>
> db().select(db.table.ALL, limitby=(0,1000))
>
> It will automatically issue: SELECT * FROM table ORDER BY *primary_key* 
> LIMIT 1000 OFFSET 0;
>
> Since I HAVE to define a primary key on the legacy table, Is there any way 
> to avoid issuing an order by without having to do db.executesql manually?
>

-- 
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: Hide form field

2016-01-13 Thread Anthony
SQLFORM.factory(..., hidden=dict(fieldname='field value'))

Anthony

On Wednesday, January 13, 2016 at 11:35:57 AM UTC-5, desta wrote:
>
> I am generating a form using SQLFORM.factory() and I would like to create 
> a hidden field. I tried doing this by setting readable and writable to 
> False, but the field dissapears from HTML.
>
> Is there a way to make it hidden but still accessible in HTML as I want to 
> set its value with Javascript.
>
> 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: Can we use a web2py app on Android mobile?

2016-01-13 Thread eric cuver
a parenthesis between French Mathieu you're French?

Le mercredi 13 janvier 2016 16:50:12 UTC+1, Mathieu Clabaut a écrit :
>
> A bit out of topic, but also note that with the help of the nice termux 
> android app, you can develop and run the web2py server on your android…
> Quite nice when you're far from a real computer…
>
> -Mathieu
>
> 2016-01-12 16:39 GMT+01:00 eric cuver 
> :
>
>> there are several solution all depends on your application. facebook use 
>> 2 adress  url www.facebook.com for the web and when you go through the 
>> mobile it is this address that is used https://m.facebook.com/
>>
>> If you want to create video games for example I think it's better to do 
>> it in native. Now for notifications exist for example in  HTML there are 
>>  things like this https://pusher.com/tutorials/realtime-notifications I 
>> think that there are more. To access the camera you have api in html like 
>> this http://bridgeit.mobi/html5-camera-access.html.   
>>  look this website you are all api html for mobile 
>> http://mobilehtml5.org/   as I say it depends on what you want to do
>>
>> Le mardi 12 janvier 2016 15:53:44 UTC+1, Andrew Buchan a écrit :
>>>
>>> @eric That's interesting... So essentially you'd get an "app" on your 
>>> mobile, but it just opens to a webpage on a server.
>>> That is probably the best solution offered so far although you need to 
>>> be connected to and also don't get access to phone's features like 
>>> contacts, notifications etc...
>>>
>>>
>>> On Tue, Jan 12, 2016 at 9:04 AM, eric cuver  
>>> wrote:
>>>
 you can also do this with web2py you just need to create a webview with 
 Cordova or Kivy with the URL of your mobile website view. Me this is what 
 I 
 do and it works without problems


 Le lundi 11 janvier 2016 22:31:58 UTC+1, Alessio Varalta a écrit :
>
> Sorry, , you are right. Now i have developed only in Android now in 
> these day for a project i start to study cordova and is true that you can 
> upload on Google market this my first time with Hybrid app
>
> Il giorno lunedì 11 gennaio 2016 13:17:14 UTC+1, Andrew Buchan ha 
> scritto:
>>
>> Just to butt-in on what Richard said:
>>
>> "But this kind of app are often not that interresting from user stand 
>> point... I mean you don't have a good mobile app user experience with 
>> them 
>> most of the time because they to simple that you can just access the 
>> real 
>> web app and it could be even better..."
>>
>> That's not really true anymore...
>>
>> What you are referring to are hybrid apps, which is essentially a 
>> mini-website (HTML, JS, CSS) wrapped in a package and rendered in a 
>> native 
>> webview, as opposed to a native app which is built in objective-C or 
>> Java.
>> Hybrid apps can access the phone's features such as camera, battery, 
>> geolocation, accelerometer etc... So you can do much more than you would 
>> by 
>> accessing a web app in the browser!
>> Hybrid performance is also more than adequate for most applications, 
>> and many of today's top apps are hybrid (in fact I challenge you to find 
>> out which apps on your phone are hybrid and which are native...)
>>
>> What's more, with tools like cordova you can target both Android and 
>> iOS (with caveats) with the same code.
>> You also get to use the latest Javascript frameworks, such as 
>> AngularJS or ReactJS.
>>
>> My advice would be to learn js and angular then go down the ionic (
>> http://ionicframework.com/) path. I really don't see a case for 
>> bringing web2py into android.
>>
>> Edit:
>>
>> What Alessio said isn't true either. You can publish hybrid apps to 
>> Google play and Apple's app store.
>>
>> Here's a useful page:
>>
>>
>> http://www.joshmorony.com/the-step-by-step-guide-to-publishing-a-html5-mobile-application-on-app-stores/
>>
>>
>>
>> On Monday, January 4, 2016 at 9:20:53 PM UTC, RAGHIB R wrote:
>>>
>>> -- 
 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/1ZxFEB5j4XA/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

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

Re: [web2py] simple update of an cache.ram python dict

2016-01-13 Thread Anthony
Are you using nginx/uwsgi? If so, I believe cache.ram would not be shared 
across the different uwsgi worker processes. You might consider switching 
to the Redis cache.

Anthony

On Wednesday, January 13, 2016 at 11:26:16 AM UTC-5, Richard wrote:
>
> Hello,
>
> Still struggle with this. I don't understand why cache dict is not updated 
> in real time...
>
> It get updated but there is a strange delay.
>
> Thanks
>
> Richard
>
> On Mon, Jan 4, 2016 at 4:18 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> UP here!
>>
>> Any help would be appreciate...
>>
>> Richard
>>
>> On Mon, Dec 21, 2015 at 10:22 PM, Richard  
>> wrote:
>>
>>> Hello,
>>>
>>> I am still under 2.9.5, I have a simple dict cached in ram which never 
>>> expire that I update when new key value are added to the system... Mainly 
>>> the dict contain id and their representation...
>>>
>>> It works flawlessly in dev, but once I pushed in prod, it seems that the 
>>> cached dict takes time to really update... Here how I manage the creation 
>>> an update of this dict :
>>>
>>> def set_id_represent(update_id_represent_if_elapsed_time=None, id=None):
>>> """
>>> Calling this function will create in globals the "id_represent" 
>>> variable if the call is made without
>>> id. If id is passed, it will update the id_represent dictionary with 
>>> new
>>> id and it representation.
>>> :param id:
>>> :param update_id_represent_if_elapsed_time:
>>> """
>>> if 'id_represent' not in globals():
>>> global id_represent
>>> id_represent = \
>>> cache.ram('id_represent',
>>>   lambda: {r.id: r.represent_field
>>>for r in db().select(db.table_name.id,
>>> db.table_name.
>>> represent_field,
>>> orderby=db.
>>> table_name.represent_field)
>>>},
>>>   time_expire=update_id_represent_if_elapsed_time)
>>> elif isinstance(id, int) or isinstance(id, long):
>>> id_represent_query = \
>>> db(db.table_name.id == id
>>>).select(db.table_name.id,
>>> db.table_name.represent_field,
>>> orderby=db.table_name.represent_field)
>>> id_represent.update({r.id: r.represent_field for r in 
>>> id_represent_query})
>>> if id:
>>> return id_represent[id]
>>>
>>> set_id_represent(update_id_represent_if_elapsed_time=None)
>>>
>>> Then when I want to update the cached dict with new k, v :
>>>
>>> set_id_represent(id=my_id)
>>>
>>> I have made some test and print after the id_represent.update(...) above 
>>> from the function call and the dict seems to be updated... The function 
>>> that call set_in_represent(id=id) doesn't failed, but when we want to 
>>> access page which user id_represent[some_id], they all failed for a couples 
>>> of minutes... Like if the cached dict not get update immediately...
>>>
>>> Thanks for any pointer...
>>>
>>> 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] simple update of an cache.ram python dict

2016-01-13 Thread Richard Vézina
Hello,

Still struggle with this. I don't understand why cache dict is not updated
in real time...

It get updated but there is a strange delay.

Thanks

Richard

On Mon, Jan 4, 2016 at 4:18 PM, Richard Vézina 
wrote:

> UP here!
>
> Any help would be appreciate...
>
> Richard
>
> On Mon, Dec 21, 2015 at 10:22 PM, Richard 
> wrote:
>
>> Hello,
>>
>> I am still under 2.9.5, I have a simple dict cached in ram which never
>> expire that I update when new key value are added to the system... Mainly
>> the dict contain id and their representation...
>>
>> It works flawlessly in dev, but once I pushed in prod, it seems that the
>> cached dict takes time to really update... Here how I manage the creation
>> an update of this dict :
>>
>> def set_id_represent(update_id_represent_if_elapsed_time=None, id=None):
>> """
>> Calling this function will create in globals the "id_represent"
>> variable if the call is made without
>> id. If id is passed, it will update the id_represent dictionary with
>> new
>> id and it representation.
>> :param id:
>> :param update_id_represent_if_elapsed_time:
>> """
>> if 'id_represent' not in globals():
>> global id_represent
>> id_represent = \
>> cache.ram('id_represent',
>>   lambda: {r.id: r.represent_field
>>for r in db().select(db.table_name.id,
>> db.table_name.
>> represent_field,
>> orderby=db.table_name
>> .represent_field)
>>},
>>   time_expire=update_id_represent_if_elapsed_time)
>> elif isinstance(id, int) or isinstance(id, long):
>> id_represent_query = \
>> db(db.table_name.id == id
>>).select(db.table_name.id,
>> db.table_name.represent_field,
>> orderby=db.table_name.represent_field)
>> id_represent.update({r.id: r.represent_field for r in
>> id_represent_query})
>> if id:
>> return id_represent[id]
>>
>> set_id_represent(update_id_represent_if_elapsed_time=None)
>>
>> Then when I want to update the cached dict with new k, v :
>>
>> set_id_represent(id=my_id)
>>
>> I have made some test and print after the id_represent.update(...) above
>> from the function call and the dict seems to be updated... The function
>> that call set_in_represent(id=id) doesn't failed, but when we want to
>> access page which user id_represent[some_id], they all failed for a couples
>> of minutes... Like if the cached dict not get update immediately...
>>
>> Thanks for any pointer...
>>
>> 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.


[web2py] multiple instances of a single form on one page

2016-01-13 Thread aetagothno
I'm not sure if this is even possible, but if it is..how would something 
like this work:

You prompt the user for an x amount of days, then with javascript and 
jquery you have x amount of buttons appear. Each button is an instance of 
the form. There is a variable within the javascript that holds the amount 
x. So for each instance of x, the user fills out the same form but with 
different values for each day. In the db module containing the sqlform, 
there is a function that takes in each instance and performs what it needs 
to for each separate instance.

Also, if you are in views, how can you share a variable that is used in a 
script to python code in the same views, or in the db models file?

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


[web2py] Hide form field

2016-01-13 Thread desta
I am generating a form using SQLFORM.factory() and I would like to create a 
hidden field. I tried doing this by setting readable and writable to False, 
but the field dissapears from HTML.

Is there a way to make it hidden but still accessible in HTML as I want to 
set its value with Javascript.

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.


[web2py] Re: Hide form field

2016-01-13 Thread desta
Thank you Anthony for the help.

I am not sure how to use this though. Reading the documentation I construct 
my form as follows:

form = SQLFORM.factory(¬
Field('year', label='Year', readable=False, writable=True),¬
  57 Field('month', label='Month', readable=False, writable=True
))¬


On Wednesday, January 13, 2016 at 6:55:05 PM UTC+2, Anthony wrote:
>
> SQLFORM.factory(..., hidden=dict(fieldname='field value'))
>
> Anthony
>
> On Wednesday, January 13, 2016 at 11:35:57 AM UTC-5, desta wrote:
>>
>> I am generating a form using SQLFORM.factory() and I would like to create 
>> a hidden field. I tried doing this by setting readable and writable to 
>> False, but the field dissapears from HTML.
>>
>> Is there a way to make it hidden but still accessible in HTML as I want 
>> to set its value with Javascript.
>>
>> 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.


[web2py] Re: import_from_csv_file: how to map columns

2016-01-13 Thread goome

Thanks for your help!

Il giorno mercoledì 13 gennaio 2016 16:38:12 UTC+1, Anthony ha scritto:
>
> I think you'll have to manually change the column names in the file, 
> either by hand or via Python code.
>
> Anthony
>
> On Wednesday, January 13, 2016 at 7:33:20 AM UTC-5, goome wrote:
>>
>> Hi
>> i created i table definition in db.py by using csvstudio.py, but i cannot 
>> load the values through db.table.import_from_csv_file becouse the header in 
>> the csv have spaces and uppercases.
>> So there a way to tell import_from_csv_file how to map column in csv with 
>> that in table definition?
>> By the way, column in csv are in the same order than in table definition.
>> Thanks
>>
>

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


Re: [web2py] simple update of an cache.ram python dict

2016-01-13 Thread Richard Vézina
Ha!!

Yes nginx/uwsgi...

That what I suspecting, it looks like the dict was kind of unique by user...

I think we should leave a note somewhere in the book about this issue...

I was in the process of exploring Redis cache or memcache just to see if
there were not improvement. I will look into Redis.

Thank you Anthony.

Richard

On Wed, Jan 13, 2016 at 12:19 PM, Anthony  wrote:

> Are you using nginx/uwsgi? If so, I believe cache.ram would not be shared
> across the different uwsgi worker processes. You might consider switching
> to the Redis cache.
>
> Anthony
>
>
> On Wednesday, January 13, 2016 at 11:26:16 AM UTC-5, Richard wrote:
>>
>> Hello,
>>
>> Still struggle with this. I don't understand why cache dict is not
>> updated in real time...
>>
>> It get updated but there is a strange delay.
>>
>> Thanks
>>
>> Richard
>>
>> On Mon, Jan 4, 2016 at 4:18 PM, Richard Vézina <
>> ml.richard.vez...@gmail.com> wrote:
>>
>>> UP here!
>>>
>>> Any help would be appreciate...
>>>
>>> Richard
>>>
>>> On Mon, Dec 21, 2015 at 10:22 PM, Richard 
>>> wrote:
>>>
 Hello,

 I am still under 2.9.5, I have a simple dict cached in ram which never
 expire that I update when new key value are added to the system... Mainly
 the dict contain id and their representation...

 It works flawlessly in dev, but once I pushed in prod, it seems that
 the cached dict takes time to really update... Here how I manage the
 creation an update of this dict :

 def set_id_represent(update_id_represent_if_elapsed_time=None, id=None
 ):
 """
 Calling this function will create in globals the "id_represent"
 variable if the call is made without
 id. If id is passed, it will update the id_represent dictionary
 with new
 id and it representation.
 :param id:
 :param update_id_represent_if_elapsed_time:
 """
 if 'id_represent' not in globals():
 global id_represent
 id_represent = \
 cache.ram('id_represent',
   lambda: {r.id: r.represent_field
for r in db().select(db.table_name.id,
 db.table_name.
 represent_field,
 orderby=db.
 table_name.represent_field)
},
   time_expire=update_id_represent_if_elapsed_time)
 elif isinstance(id, int) or isinstance(id, long):
 id_represent_query = \
 db(db.table_name.id == id
).select(db.table_name.id,
 db.table_name.represent_field,
 orderby=db.table_name.represent_field)
 id_represent.update({r.id: r.represent_field for r in
 id_represent_query})
 if id:
 return id_represent[id]

 set_id_represent(update_id_represent_if_elapsed_time=None)

 Then when I want to update the cached dict with new k, v :

 set_id_represent(id=my_id)

 I have made some test and print after the id_represent.update(...)
 above from the function call and the dict seems to be updated... The
 function that call set_in_represent(id=id) doesn't failed, but when we want
 to access page which user id_represent[some_id], they all failed for a
 couples of minutes... Like if the cached dict not get update immediately...

 Thanks for any pointer...

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

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