[web2py] Re: Delete sessions

2019-01-07 Thread Dave S


On Tuesday, December 4, 2018 at 9:34:44 PM UTC-8, Dave S wrote:
>
>
>
> On Tuesday, December 4, 2018 at 12:17:52 AM UTC-8, Gaël Princivalle wrote:
>>
>> Hello.
>>
>> Is there a way to delete automatically the sessions?
>> I mean the folders/files inside this folder:
>> web2py/applications/my_app/sessions
>>
>> For example deleting the sessions oldest than 1 week.
>>
>> Thanks!
>>
>
> I also run the sessions2trash.py script.  On one application, I'm getting 
> a few hits a minute.  I started running it 1x manually.  I'm currently 
> using atq to run it once a week (originally once every two weeks).
>
> (echo 'python web2py.py -S myapp -M -R scripts/sessions2trash.py -A -x -x 
> 3600 -f -v' | at Dec 6 1800)
>
> If I run it more often, I'll probably use the built-in scheduling.
>
>  
Yep, copied the script to modules, added the recommended function to 
models/scheduler.py, and commenced daily cleaning.

If you want to see something in the scheduler_run table, add something like

return "done"


to the function.

/dps

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


[web2py] Re: Delete sessions

2018-12-04 Thread Dave S


On Tuesday, December 4, 2018 at 12:17:52 AM UTC-8, Gaël Princivalle wrote:
>
> Hello.
>
> Is there a way to delete automatically the sessions?
> I mean the folders/files inside this folder:
> web2py/applications/my_app/sessions
>
> For example deleting the sessions oldest than 1 week.
>
> Thanks!
>

I also run the sessions2trash.py script.  On one application, I'm getting a 
few hits a minute.  I started running it 1x manually.  I'm currently using 
atq to run it once a week (originally once every two weeks).

(echo 'python web2py.py -S myapp -M -R scripts/sessions2trash.py -A -x -x 
3600 -f -v' | at Dec 6 1800)

If I run it more often, I'll probably use the built-in scheduling.

/dps

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


[web2py] Re: Delete sessions

2018-12-04 Thread DaneW
I use the sessions2trash.py script very successfully as an hourly task on 
PythonAnywhere.

I copied the code from the web2py scripts folder to a scripts folder under 
my app as I've modified the original code slightly to print totals of 
trashed sessions. I use the "delete after 60 minutes" settings without the 
verbose output which seems to work well for my website. The command for 
my_username and my_app would be:

python /home/my_username/web2py/web2py.py -S my_app -M -R 
/home/my_username/web2py/applications/my_app/scripts/sessions2trash.py -A 
-o -x 3600 -f

If you currently have lots of sessions in your sessions folder it might be 
better to delete most of these first (just deleting the sessions folder 
worked ok for me) before starting to run the scheduled script. 

If you wanted to change the 60 minutes setting I guess you would just alter 
the 3600 value accordingly - or modify the code yourself. 

Dane

-- 
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: Delete sessions

2018-12-04 Thread 黄祥
think there is a web2py script for that session2trash.py
ref:
http://web2py.com/books/default/chapter/29/13/deployment-recipes#Cleaning-up-sessions
another alternative you can use shell or python subprocess then make a 
scheduler for it (cron) or even with configuration management like ansible

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] Re: Delete space from users email in auth form

2018-11-26 Thread Константин Комков
Yes, it's work:
def user():
if request.post_vars.email: 
request.post_vars.email = request.post_vars.email.strip()
return dict(form=auth())


-- 
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: Delete space from users email in auth form

2018-11-26 Thread Val K
1. Oops, instead of request.vars it should be request.post_vars 
2. As 1st validator try CLEANUP('\s')

-- 
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: Delete space from users email in auth form

2018-11-26 Thread Константин Комков
Today I tried both of variant:
first in default.py
def user():  
if request.vars.email: 
request.vars.email = request.vars.email.lower().strip()
return dict(form=auth())
don't work - "incorrect email"
second, I don't sure that all right here in db.py
def emailStrip():
form.vars.email = form.vars.email.strip()
return form.vars.email
auth.settings.table_user.email.requires=[emailStrip,IS_LOWER(),IS_EMAIL(),IS_NOT_IN_DB(db,auth.settings.table_user.email)]
I have found custom validators in book also but don't know how to use it. 
Where I need to write class?

class sample_validator:
def __init__(self, *a, error_message='error'):
self.a = a
self.e = error_message
def __call__(self, value):
if validate(value):
return (parsed(value), None)
return (value, self.e)
def formatter(self, value):
return format(value)







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


[web2py] Re: Delete space from users email in auth form

2018-11-23 Thread Константин Комков
Thank you, I try to change 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: Delete space from users email in auth form

2018-11-23 Thread Val K
`onvalidation` is what happens *after  *form validation is passed.
You can add your validators to auth_user.email.requires (they should be 
first on the validators list )
or  you can insert your formatters in user() controller, I mean:
def user():  
if request.vars.email: 
request.vars.email = request.vars.email.lower().strip()
return dict(form=auth())



On Friday, November 23, 2018 at 9:11:15 AM UTC+3, Константин Комков wrote:
>
> I do like that:
> def email_to_lower(form):
> form.vars.email = form.vars.email.lower()
> form.vars.email = form.vars.email.strip()
> auth.settings.login_onvalidation = email_to_lower
> But I have message that my email is incorrect, if I enter ' 
> myem...@gmail.com ' 
>
>

-- 
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: Delete space from users email in auth form

2018-11-22 Thread Константин Комков
I do like that:
def email_to_lower(form):
form.vars.email = form.vars.email.lower()
form.vars.email = form.vars.email.strip()
auth.settings.login_onvalidation = email_to_lower


-- 
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: Delete space from users email in auth form

2018-11-22 Thread Leonel Câmara
You can use auth.settings.login_onvalidation to strip the email string.

-- 
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: delete record confirmation dialog

2017-04-18 Thread Paolo Valleri
At the moment is not possible to change it directly in grid or smartgrid.
This is because the javascript variable is fixed, assigned 
in 
https://github.com/web2py/web2py/blob/master/applications/welcome/views/web2py_ajax.html
and then used 
in 
https://github.com/web2py/web2py/blob/master/applications/welcome/static/js/web2py.js#L186

Depending on your use case you can either translate the sentence defined in 
web2py_ajax.html or add your custom logic in order to change the content of 
the w2p_ajax_confirm_message javascript variable.

Paolo

On Tuesday, April 18, 2017 at 6:00:21 PM UTC+2, Andrea Fae' wrote:
>
> How to change customized message in the confirmation dialog about delete a 
> record using grid or smartgrid? (depending on the situation)
> Any examples?
>
>
>

-- 
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: Delete confirmation popup

2017-03-28 Thread Marlysson Silva
No. 
This 
http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#The-ajax-function

More especifically this example 
: 
http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#Ajax-form-submission

I suggest you put a attribute "data-id" in your delete button and when you 
click them get the "data-id" attribute pass to ajax_function that run some 
function in controller.

Em terça-feira, 28 de março de 2017 15:39:19 UTC-3, Winter Kryz escreveu:
>
> You mean the onclick: function() ?
>
> El martes, 28 de marzo de 2017, 10:09:04 (UTC-3), Marlysson Silva escribió:
>>
>> Have you tried the ajax function() from web2py ?
>>
>> It use the callback function on controller and the data( id by example ) 
>> , and the callback receive this data and process them ( make search and 
>> delete it ) .
>>
>> Em segunda-feira, 27 de março de 2017 20:49:59 UTC-3, Winter Kryz 
>> escreveu:
>>>
>>> Hello Everybody,
>>>
>>> I hope someone can help me, I have a table full of records from a data 
>>> base, each row has a delete button so what I want to do is to show a 
>>> "Yes/No" Javascript popup to confirm the delete action.
>>>
>>> So far what I did is:
>>>
>>>  *** controller ***
>>> def Person():
>>> person = db(db.Person.id>0).select()
>>> class Virtual(object):
>>> def button(self):
>>>   XML(A(SPAN(_class='glyphicon 
>>> glyphicon-remove'),_id="delete",_onclick='myFunction()',_class='btn 
>>> btn-default fechar Jview btn-xs')),_class='btn-group btn-group-justified 
>>> JpositionA')
>>> return bts
>>> person.setvirtualfields(campos_virtual = Virtual())
>>> return dict(formListar=person)
>>>
>>> *** View ***
>>> 
>>> function myFunction() {
>>> $('#myModal').modal('show');
>>> return false;
>>> };
>>>
>>>  function myFunctiondelete() {
>>>  };
>>> 
>>>
>>> 
>>> 
>>> 
>>> Name
>>> Surname
>>> 
>>> 
>>> 
>>> {{for person in formListar:}}
>>> 
>>> {{=person.Person.name}}
>>> {{=person.Person.surname}}
>>> >> class="options">{{=person.campos_virtual.buttons}}
>>> 
>>> 
>>>{{pass}}
>>> 
>>> 
>>> 
>>>   
>>> 
>>>   
>>>Confirmation 
>>>   
>>>   
>>>
>>>   Are you sure you want to delete?
>>>   
>>>   
>>>   
>>>   
>>> No
>>> Yes 
>>>  
>>>
>>> Basically, everytime I click on the button I defined on the controller 
>>> it calls a function "myFunction()" which shows a Javascript modal with the 
>>> Yes/No options. When I click on "Yes" it doesn't do anything because I 
>>> don't know how to pass the id of that particular record.
>>>
>>> Anyone knows an easier method or how can I pass the id of that 
>>> particular record?
>>>
>>> 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: Delete confirmation popup

2017-03-28 Thread Winter Kryz
You mean the onclick: function() ?

El martes, 28 de marzo de 2017, 10:09:04 (UTC-3), Marlysson Silva escribió:
>
> Have you tried the ajax function() from web2py ?
>
> It use the callback function on controller and the data( id by example ) , 
> and the callback receive this data and process them ( make search and 
> delete it ) .
>
> Em segunda-feira, 27 de março de 2017 20:49:59 UTC-3, Winter Kryz escreveu:
>>
>> Hello Everybody,
>>
>> I hope someone can help me, I have a table full of records from a data 
>> base, each row has a delete button so what I want to do is to show a 
>> "Yes/No" Javascript popup to confirm the delete action.
>>
>> So far what I did is:
>>
>>  *** controller ***
>> def Person():
>> person = db(db.Person.id>0).select()
>> class Virtual(object):
>> def button(self):
>>   XML(A(SPAN(_class='glyphicon 
>> glyphicon-remove'),_id="delete",_onclick='myFunction()',_class='btn 
>> btn-default fechar Jview btn-xs')),_class='btn-group btn-group-justified 
>> JpositionA')
>> return bts
>> person.setvirtualfields(campos_virtual = Virtual())
>> return dict(formListar=person)
>>
>> *** View ***
>> 
>> function myFunction() {
>> $('#myModal').modal('show');
>> return false;
>> };
>>
>>  function myFunctiondelete() {
>>  };
>> 
>>
>> 
>> 
>> 
>> Name
>> Surname
>> 
>> 
>> 
>> {{for person in formListar:}}
>> 
>> {{=person.Person.name}}
>> {{=person.Person.surname}}
>> > class="options">{{=person.campos_virtual.buttons}}
>> 
>> 
>>{{pass}}
>> 
>> 
>> 
>>   
>> 
>>   
>>Confirmation 
>>   
>>   
>>
>>   Are you sure you want to delete?
>>   
>>   
>>   
>>   
>> No
>> Yes 
>>  
>>
>> Basically, everytime I click on the button I defined on the controller it 
>> calls a function "myFunction()" which shows a Javascript modal with the 
>> Yes/No options. When I click on "Yes" it doesn't do anything because I 
>> don't know how to pass the id of that particular record.
>>
>> Anyone knows an easier method or how can I pass the id of that particular 
>> record?
>>
>> Thanks
>>
>

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


Re: [web2py] Re: Delete a row from one table when two tables are joined

2017-02-23 Thread Mat Miles
Actually that solution was not quite correct. The one below is.

if form.process(formname='form').accepted:
rows = db(db.auth_user.location_id ==
auth.user.location_id).select(db.auth_user.id)

db(db.shift_availability.created_by.belongs(rows)).delete()


On Thu, Feb 23, 2017 at 12:57 PM, Mat Miles  wrote:

> Thanks that worked. I have a shift_availability table and the auth_user
> table. The auth_user table contains a location. I want to clear all the
> rows in the shift_availability table but by location. Below is the solution:
>
> if form.process(formname='form').accepted:
> rows = db((db.shift_availability.created_by == db.auth_user.id)
>   & (db.auth_user.location_id == 
> auth.user.location_id)).select(db.shift_availability.id)
>
> db(db.shift_availability.id.belongs(rows)).delete()
>
>
> On Wed, Feb 22, 2017 at 5:14 PM, Dave S  wrote:
>
>> On Wednesday, February 22, 2017 at 4:03:00 PM UTC-8, Mat Miles wrote:
>>>
>>> I need to create a join to limit the rows to be deleted. Is it possible
>>> to delete a row from one table when a query joins two tables?
>>>
>>
>> Not sure about the full answer, but a partial answer would be to use the
>> join in a SELECT ( db(...).select(), frex) and obtain the row ids, then do
>> a seperate DELETE using those row ids.
>>
>> /dps
>>
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/web2py/6V2skxjxNG0/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: [web2py] Re: Delete a row from one table when two tables are joined

2017-02-23 Thread Mat Miles
Thanks that worked. I have a shift_availability table and the auth_user
table. The auth_user table contains a location. I want to clear all the
rows in the shift_availability table but by location. Below is the solution:

if form.process(formname='form').accepted:
rows = db((db.shift_availability.created_by == db.auth_user.id)
  & (db.auth_user.location_id ==
auth.user.location_id)).select(db.shift_availability.id)

db(db.shift_availability.id.belongs(rows)).delete()


On Wed, Feb 22, 2017 at 5:14 PM, Dave S  wrote:

> On Wednesday, February 22, 2017 at 4:03:00 PM UTC-8, Mat Miles wrote:
>>
>> I need to create a join to limit the rows to be deleted. Is it possible
>> to delete a row from one table when a query joins two tables?
>>
>
> Not sure about the full answer, but a partial answer would be to use the
> join in a SELECT ( db(...).select(), frex) and obtain the row ids, then do
> a seperate DELETE using those row ids.
>
> /dps
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/6V2skxjxNG0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: Delete a row from one table when two tables are joined

2017-02-22 Thread Dave S
On Wednesday, February 22, 2017 at 4:03:00 PM UTC-8, Mat Miles wrote:
>
> I need to create a join to limit the rows to be deleted. Is it possible to 
> delete a row from one table when a query joins two tables?
>

Not sure about the full answer, but a partial answer would be to use the 
join in a SELECT ( db(...).select(), frex) and obtain the row ids, then do 
a seperate DELETE using those row ids.

/dps
 

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


[web2py] Re: delete on confirmation

2016-04-11 Thread Ron Chatterjee
use text.string. 



On Monday, April 11, 2016 at 8:52:56 AM UTC-4, rajjm...@gmail.com wrote:
>
> If I use the helper function it works. Ran into one issue though.
>
> {{=SPAN(A( IMG(_src=URL('static','images/delete.png')), _href = 
> URL('delete',args=id), _title = 'Delete',  _onclick = "javascript:return 
> confirm('Are you sure you want to process?')", _class = 'Delete') ) }}
>
>
> Now, if I want to style the image it doesn't work. For example. 
>
> 
> .Delete {
>width:40px;
>cursor: pointer;
> }
> 
>
> How do I style my logo to specific size?
>
>
>
>
> On Sunday, April 10, 2016 at 11:19:48 PM UTC-4, 黄祥 wrote:
>>
>> please try
>> {{=SPAN(A(T('Delete'), _href = URL('delete', args = [id] ), _title = 
>> 'Delete', 
>>  _onclick = "javascript:return confirm('Are you sure you want to 
>> process?')", 
>>  _class = 'to-delete') ) }}
>>
>> 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] Re: delete on confirmation

2016-04-11 Thread rajjmatthur
If I use the helper function it works. Ran into one issue though.

{{=SPAN(A( IMG(_src=URL('static','images/delete.png')), _href = 
URL('delete',args=id), _title = 'Delete',  _onclick = "javascript:return 
confirm('Are you sure you want to process?')", _class = 'Delete') ) }}


Now, if I want to style the image it doesn't work. For example. 


.Delete {
   width:40px;
   cursor: pointer;
}


How do I style my logo to specific size?




On Sunday, April 10, 2016 at 11:19:48 PM UTC-4, 黄祥 wrote:
>
> please try
> {{=SPAN(A(T('Delete'), _href = URL('delete', args = [id] ), _title = 
> 'Delete', 
>  _onclick = "javascript:return confirm('Are you sure you want to 
> process?')", 
>  _class = 'to-delete') ) }}
>
> 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] Re: delete on confirmation

2016-04-10 Thread 黄祥
please try
{{=SPAN(A(T('Delete'), _href = URL('delete', args = [id] ), _title = 
'Delete', 
 _onclick = "javascript:return confirm('Are you sure you want to 
process?')", 
 _class = 'to-delete') ) }}

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] Re: delete and logout user

2015-11-24 Thread Alex Glaros
thanks guys, good insight as always

-- 
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: delete and logout user

2015-11-24 Thread Anthony
Presumably the logout and delete are happening in the same request, so just 
put the id in a variable. Hard to say exactly how you should handle it 
without seeing your code.

On Tuesday, November 24, 2015 at 2:05:35 PM UTC-5, Alex Glaros wrote:
>
> Anthony,
>
> am using custom deletion workflow.  
>
> Where is best place to store the user_id so logout doesn't erase it? 
>  session?  temp table?
>
> 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: delete and logout user

2015-11-24 Thread Leonel Câmara
Anthony shouldn't Auth.profile do that by default?

-- 
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: delete and logout user

2015-11-24 Thread Anthony
On Tuesday, November 24, 2015 at 12:28:13 PM UTC-5, Leonel Câmara wrote:
>
> Anthony shouldn't Auth.profile do that by default?
>

Yes. I assume he was using some custom user account deletion workflow.

Alex, if you set auth.settings.allow_delete_accounts=True, you can let 
users delete their accounts via the auth.profile() action, and all of this 
is handled automatically.

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: delete and logout user

2015-11-24 Thread Anthony
Sure, grab the ID first, then logout, then delete.

On Tuesday, November 24, 2015 at 11:44:24 AM UTC-5, Alex Glaros wrote:
>
> If a user deletes their account, my controller deletes their db.auth_user 
> record but their login session is still active.  If I try to auth.logout() 
> then, I get integrity restraint error.  If I log them out first, I don't 
> automatically have their user_id to delete the records with.
>
> Is there a simple way to handle this?
>
> thanks,
>
> Alex Glaros
>

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


[web2py] Re: delete and logout user

2015-11-24 Thread Alex Glaros
Anthony,

am using custom deletion workflow.  

Where is best place to store the user_id so logout doesn't erase it? 
 session?  temp table?

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: Delete a row at a given index from a Rows object

2014-09-13 Thread Anthony
You can try:

session.exrows = session.exrows.find(lambda r: r.id == session.exrows[
session.counter].id)

Keep in mind that will not delete the record from the database -- only from 
the Rows object itself.

Anthony

On Saturday, September 13, 2014 12:12:39 PM UTC-4, Gliese 581 g wrote:

 I have fetched large number of rows from a database. I am fetching the 
 rows from database and storing it in a session. Now when I delete a record 
 for some reasons I do not want to get the entire data back but just delete 
 the corresponding row from the Rows object. I have the index of deleted 
 record. I am trying to do it using following code:

  *del session.exrows[session.counter]*

 But it says TypeError: 'Rows' object does not support item deletion

 How do I delete it from Rows object?



-- 
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: Delete a row at a given index from a Rows object

2014-09-13 Thread Gliese 581 g
It returns Rows object with only one record in it. I want to delete only 
one record from the Rows object.

On Saturday, 13 September 2014 22:24:08 UTC+5:30, Anthony wrote:

 You can try:

 session.exrows = session.exrows.find(lambda r: r.id == session.exrows[
 session.counter].id)

 Keep in mind that will not delete the record from the database -- only 
 from the Rows object itself.

 Anthony

 On Saturday, September 13, 2014 12:12:39 PM UTC-4, Gliese 581 g wrote:

 I have fetched large number of rows from a database. I am fetching the 
 rows from database and storing it in a session. Now when I delete a record 
 for some reasons I do not want to get the entire data back but just delete 
 the corresponding row from the Rows object. I have the index of deleted 
 record. I am trying to do it using following code:

  *del session.exrows[session.counter]*

 But it says TypeError: 'Rows' object does not support item deletion

 How do I delete it from Rows object?



-- 
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: Delete a row at a given index from a Rows object

2014-09-13 Thread Anthony
Oops, good catch.

-- 
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: Delete Query Not Working

2014-07-09 Thread Leonel Câmara
It should be:
d = request.args(0)

-- 
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: Delete in SQLFORM.grid does not update number of records

2014-04-05 Thread Massimo Di Pierro
Yes. Please open a ticket so we'll remember to fix it.

On Saturday, 5 April 2014 18:21:35 UTC-5, horridohobbyist wrote:

 If I delete records in SQLFORM.grid, the number of records does not 
 change. Only if I explicitly refresh the browser page does the number of 
 records change.

 Have I found a bug?

 (I'm using web2py 2.9.4.)


-- 
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: delete stored image

2013-07-23 Thread Niphlod
use Field('image', 'upload', autodelete=True)

On Tuesday, July 23, 2013 10:18:24 PM UTC+2, nicor...@gmail.com wrote:

 i am making a product app in web2py everything is working really well 
 exept one thing.

 i upload the images like this:

 the_image = db.product_images.image.store(request.vars.image.file, 
 request.vars.image.filename)
 img_id = db.product_images.insert(product_id=p_id , 
 image=the_image , main_image=True)

 that work awesome, it stores the image in the uploads folder.
 now the problem is when i try to delete a image it only deletes the 
 database record, and not the image itself stored in the uploads folder

 this is how i delete my current image:

 db(db.product_images.id == img_id).delete()

 i want to know how can i delete the image and not only the record so i 
 dont store that amazing ammount of unused images in the server.

 Txn for your help!!!


-- 

--- 
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/groups/opt_out.




Re: [web2py] Re: delete stored image

2013-07-23 Thread Nicolas Rodriguez
Thanks :P awesome thats really simple hahaha :D


On Tue, Jul 23, 2013 at 5:06 PM, Niphlod niph...@gmail.com wrote:

 use Field('image', 'upload', autodelete=True)


 On Tuesday, July 23, 2013 10:18:24 PM UTC+2, nicor...@gmail.com wrote:

 i am making a product app in web2py everything is working really well
 exept one thing.

 i upload the images like this:

 the_image = db.product_images.image.store(**request.vars.image.file,
 request.vars.image.filename)
 img_id = db.product_images.insert(**product_id=p_id ,
 image=the_image , main_image=True)

 that work awesome, it stores the image in the uploads folder.
 now the problem is when i try to delete a image it only deletes the
 database record, and not the image itself stored in the uploads folder

 this is how i delete my current image:

 db(db.product_images.id == img_id).delete()

 i want to know how can i delete the image and not only the record so i
 dont store that amazing ammount of unused images in the server.

 Txn for your help!!!

  --

 ---
 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/ULmgbt5L-1c/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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/groups/opt_out.




[web2py] Re: delete session strange behaviour

2013-02-16 Thread Anthony
Difficult to help without knowing what the error is. Do you have a 
traceback?

When you return a dict from a controller function, web2py looks for the 
associated view and then executes the view. If the view is expecting some 
variable to be in the returned dict but that variable happens not to be in 
locals() at the point you call return, then the view will generate an error.

Anthony

On Saturday, February 16, 2013 2:03:01 AM UTC-5, 黄祥 wrote:

 hi anthony,

 sorry, i'm not sure what do you mean 'the view is expecting a particular 
 variable to be returned but that variable is not in locals()'

 here is the code that return an error:

 for k, v in session.order.items():
 if v==0:
 del session.order[k]
 *redirect(URL('order')) # if use return locals() an error 
 will occur*

 the logic is : it just checked if somebody made an order value is 0 
 (zero), they won't get into the bill page. when i use redirect to the order 
 page, it's work fine, what i've expected, but when i try to learn to use 
 return locals() an error rise. 


-- 

--- 
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/groups/opt_out.




[web2py] Re: delete session strange behaviour

2013-02-16 Thread 黄祥
hi anthony,

here is the trace back :
TRACEBACK

1.
2.
3.
4.
5.
6.

Traceback (most recent call last):
  File /host/Downloads/web2py/gluon/restricted.py, line 212, in restricted
exec ccode in environment
  File /host/Downloads/web2py/applications/retail/views/default/bill.html, 
line 83, in module
NameError: name 'form' is not defined

*an error occured when using return locals()*
for k, v in session.order.items():
if v==0:
del session.order[k]
*return locals() # the diference part*

*work fine*
for k, v in session.order.items():
if v==0:
del session.order[k]
*redirect(URL('order'))** # the diference part*

here is the full function that is work right now:
def bill():
if not session.order:
session.flash=T(Order Now!!!)
redirect(URL('product'))
for k, v in session.order.items():
if v==0:
del session.order[k]
redirect(URL('order'))
import datetime
import uuid
invoice_no=str(datetime.date.today())+'-'+str(uuid.uuid4())
grand_total=sum(db.product(id).unit_price*qty for id, qty in 
session.order.items())
*form=SQLFORM.factory(Field('note', 'text')) # form is define after the 
logical condition*
if form.accepts(request,session):
for key, value in session.order.items():
db.sale.insert(invoice_no=invoice_no,
   product_id=key,
   quantity=value,
   unit_price=db.product(key).unit_price,
   total_price=db.product(key).unit_price*value,
   grand_total=grand_total,
   note=form.vars.note)
db(db.product.id==key).update(quantity=db.product.quantity - 
value)
session.order.clear()  
session.flash=T(Thank you for your Order)
redirect(URL('invoice', args=invoice_no))
return dict(order=session.order, form=form, grand_total=grand_total)

i'm just curious where is the diference workflow when deal with del 
session. is it better using return locals() or just use redirect when deal 
with del session?

many thanks before

-- 

--- 
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/groups/opt_out.




[web2py] Re: delete session strange behaviour

2013-02-15 Thread Anthony
In the second and third cases, you delete session.order[id] but then try to 
return it, which will generate an error (so the response to the Ajax call 
will be a 500 error). This doesn't happen in the first case because the 
redirect happens before the return.

Anthony

On Thursday, February 14, 2013 10:36:24 PM UTC-5, 黄祥 wrote:

 hi,

 i'm trying to delete session using del session, and found strange 
 behaviour 

 for example
 *#**views/default/order.html*
 table width=100%
 {{for id, qty in order.items():}}
 {{p=db.product(id)}}
 tr
 td{{=p.product_name}}/td
 tdRp. {{=p.unit_price}}/td
 tdspan id={{='item%s'%p.id}}{{=qty}}/span
 {{=SPAN(A('+', callback=URL('order_callback', vars=dict(id=p.id, 
 action='add')), target='item%s'%p.id, _title='Add Product', _class='btn 
 btn-navbar'))}} {{=SPAN(A('-', callback=URL('order_callback', vars=dict(id=
 p.id, action='subtract')), target='item%s'%p.id, _title='Substract 
 Product', _class='btn btn-navbar'))}} *{{=SPAN(A('X', 
 callback=URL('order_callback', vars=dict(id=p.id, action='remove')), 
 delete='tr', _title='Remove Product', _class='btn btn-navbar'))}}*/td
 /tr
 {{pass}}
 /table
 *
 work*
 *#controllers/default.py*
 def order_callback():
 id=int(request.vars.id)
 if request.vars.action=='add':
 session.order[id]=session.order.get(id, 0)+1
 if request.vars.action=='subtract':
 session.order[id]=max(0,session.order.get(id, 0)-1)
 *if request.vars.action=='remove':*
 *del session.order[id]*
 *redirect(URL('product'))*
 return str(session.order[id])
 *
 not work*
 *#controllers/default.py*
 def order_callback():
 id=int(request.vars.id)
 if request.vars.action=='add':
 session.order[id]=session.order.get(id, 0)+1
 if request.vars.action=='subtract':
 session.order[id]=max(0,session.order.get(id, 0)-1)
 *if request.vars.action=='remove':*
 *del session.order[id]*
 *session.flash=T(Order Deleted!!!)*
 return str(session.order[id])
 *
 not work*
 *#controllers/default.py*
 def order_callback():
 id=int(request.vars.id)
 if request.vars.action=='add':
 session.order[id]=session.order.get(id, 0)+1
 if request.vars.action=='subtract':
 session.order[id]=max(0,session.order.get(id, 0)-1)
 *if request.vars.action=='remove':*
 *del session.order[id]*
 return str(session.order[id])

 my question is it normal, or there is something error or lack in my code?

 thank you so much before


-- 

--- 
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/groups/opt_out.




[web2py] Re: delete session strange behaviour

2013-02-15 Thread 黄祥
thank you so much for your detail explaination about the differnce logic, 
anthony.
according to your explaination about return so that i've modified into :

*#controllers/default.py*
def order_callback():
id=int(request.vars.id)
if request.vars.action=='add':
session.order[id]=session.order.get(id, 0)+1
if request.vars.action=='subtract':
session.order[id]=max(0,session.order.get(id, 0)-1)
*if request.vars.action=='remove':*
*del session.order[id]*
*return locals()*
return str(session.order[id])

is the logic above is correct? i mean there is two return types in 1 
definition, is it allowed? i've already tested it, it can work same like 
using redirect, if it not correct or not allowed, should i create into the 
different definition like :

*#controllers/default.py*
def order_callback():
id=int(request.vars.id)
if request.vars.action=='add':
session.order[id]=session.order.get(id, 0)+1
if request.vars.action=='subtract':
session.order[id]=max(0,session.order.get(id, 0)-1)
*if request.vars.action=='remove':*
*del session.order[id]*
*redirect(URL('product'))*
return str(session.order[id])

def order_remove():
id=int(request.vars.id)
del session.order[id]
return locals()

*#**views/default/order.html*
table width=100%
{{for id, qty in order.items():}}
{{p=db.product(id)}}
tr
td{{=p.product_name}}/td
tdRp. {{=p.unit_price}}/td
tdspan id={{='item%s'%p.id}}{{=qty}}/span
{{=SPAN(A('+', callback=URL('order_callback', vars=dict(id=p.id, 
action='add')), target='item%s'%p.id, _title='Add Product', _class='btn 
btn-navbar'))}} {{=SPAN(A('-', callback=URL('order_callback', vars=dict(id=
p.id, action='subtract')), target='item%s'%p.id, _title='Substract 
Product', _class='btn btn-navbar'))}} *{{=SPAN(A('X', 
callback=URL('order_remove', vars=dict(id=p.id)), delete='tr', 
_title='Remove Product', _class='btn btn-navbar'))}}*/td
/tr
{{pass}}
/table

both are work, i've already test it.

thank you

-- 

--- 
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/groups/opt_out.




[web2py] Re: delete session strange behaviour

2013-02-15 Thread Anthony
Yes, you can have multiple return statements in different logic branches of 
a function.

Anthony

On Friday, February 15, 2013 11:44:02 AM UTC-5, 黄祥 wrote:

 thank you so much for your detail explaination about the differnce logic, 
 anthony.
 according to your explaination about return so that i've modified into :

 *#controllers/default.py*
 def order_callback():
 id=int(request.vars.id)
 if request.vars.action=='add':
 session.order[id]=session.order.get(id, 0)+1
 if request.vars.action=='subtract':
 session.order[id]=max(0,session.order.get(id, 0)-1)
 *if request.vars.action=='remove':*
 *del session.order[id]*
 *return locals()*
 return str(session.order[id])

 is the logic above is correct? i mean there is two return types in 1 
 definition, is it allowed? i've already tested it, it can work same like 
 using redirect, if it not correct or not allowed, should i create into the 
 different definition like :

 *#controllers/default.py*
 def order_callback():
 id=int(request.vars.id)
 if request.vars.action=='add':
 session.order[id]=session.order.get(id, 0)+1
 if request.vars.action=='subtract':
 session.order[id]=max(0,session.order.get(id, 0)-1)
 *if request.vars.action=='remove':*
 *del session.order[id]*
 *redirect(URL('product'))*
 return str(session.order[id])

 def order_remove():
 id=int(request.vars.id)
 del session.order[id]
 return locals()

 *#**views/default/order.html*
 table width=100%
 {{for id, qty in order.items():}}
 {{p=db.product(id)}}
 tr
 td{{=p.product_name}}/td
 tdRp. {{=p.unit_price}}/td
 tdspan id={{='item%s'%p.id}}{{=qty}}/span
 {{=SPAN(A('+', callback=URL('order_callback', vars=dict(id=p.id, 
 action='add')), target='item%s'%p.id, _title='Add Product', _class='btn 
 btn-navbar'))}} {{=SPAN(A('-', callback=URL('order_callback', vars=dict(id=
 p.id, action='subtract')), target='item%s'%p.id, _title='Substract 
 Product', _class='btn btn-navbar'))}} *{{=SPAN(A('X', 
 callback=URL('order_remove', vars=dict(id=p.id)), delete='tr', 
 _title='Remove Product', _class='btn btn-navbar'))}}*/td
 /tr
 {{pass}}
 /table

 both are work, i've already test it.

 thank you


-- 

--- 
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/groups/opt_out.




[web2py] Re: delete session strange behaviour

2013-02-15 Thread 黄祥
thank you so much for your explaination, antony, i thought it was an 
illegal operation in web2py work flow or programming logic. but some times 
it's wise to decide it whether use redirect or return locals(), or is there 
any other options to do this except using redirect or return locals()?

here is the example that can not use return locals(), because when the 
condition is true, it will return an error:

def bill():
if not session.order:
session.flash=T(Order Now!!!)
redirect(URL('product'))
for k, v in session.order.items():
if v==0:
del session.order[k]
*redirect(URL('order')) # if use return locals() an error will 
occur*
import datetime
import uuid
invoice_no=str(datetime.date.today())+'-'+str(uuid.uuid4())
grand_total=sum(db.product(id).unit_price*qty for id, qty in 
session.order.items())
form=SQLFORM.factory(Field('note', 'text'))
if form.accepts(request,session):
for key, value in session.order.items():
db.sale.insert(invoice_no=invoice_no,
   product_id=key,
   quantity=value,
   unit_price=db.product(key).unit_price,
   total_price=db.product(key).unit_price*value,
   grand_total=grand_total,
   note=form.vars.note)
db(db.product.id==key).update(quantity=db.product.quantity - 
value)
session.order.clear()  
session.flash=T(Thank you for your Order)
redirect(URL('invoice', args=invoice_no))
return dict(order=session.order, form=form, grand_total=grand_total)

-- 

--- 
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/groups/opt_out.




[web2py] Re: delete session strange behaviour

2013-02-15 Thread Anthony
What error occurs if you return locals()? If the view is expecting a 
particular variable to be returned but that variable is not in locals(), 
that would cause an error -- is that the issue?

Anthony

On Friday, February 15, 2013 7:39:17 PM UTC-5, 黄祥 wrote:

 thank you so much for your explaination, antony, i thought it was an 
 illegal operation in web2py work flow or programming logic. but some times 
 it's wise to decide it whether use redirect or return locals(), or is there 
 any other options to do this except using redirect or return locals()?

 here is the example that can not use return locals(), because when the 
 condition is true, it will return an error:

 def bill():
 if not session.order:
 session.flash=T(Order Now!!!)
 redirect(URL('product'))
 for k, v in session.order.items():
 if v==0:
 del session.order[k]
 *redirect(URL('order')) # if use return locals() an error 
 will occur*
 import datetime
 import uuid
 invoice_no=str(datetime.date.today())+'-'+str(uuid.uuid4())
 grand_total=sum(db.product(id).unit_price*qty for id, qty in 
 session.order.items())
 form=SQLFORM.factory(Field('note', 'text'))
 if form.accepts(request,session):
 for key, value in session.order.items():
 db.sale.insert(invoice_no=invoice_no,
product_id=key,
quantity=value,
unit_price=db.product(key).unit_price,
total_price=db.product(key).unit_price*value,
grand_total=grand_total,
note=form.vars.note)
 db(db.product.id==key).update(quantity=db.product.quantity - 
 value)
 session.order.clear()  
 session.flash=T(Thank you for your Order)
 redirect(URL('invoice', args=invoice_no))
 return dict(order=session.order, form=form, grand_total=grand_total)


-- 

--- 
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/groups/opt_out.




[web2py] Re: delete session strange behaviour

2013-02-15 Thread 黄祥
hi anthony,

sorry, i'm not sure what do you mean 'the view is expecting a particular 
variable to be returned but that variable is not in locals()'

here is the code that return an error:

for k, v in session.order.items():
if v==0:
del session.order[k]
*redirect(URL('order')) # if use return locals() an error will 
occur*

the logic is : it just checked if somebody made an order value is 0 (zero), 
they won't get into the bill page. when i use redirect to the order page, 
it's work fine, what i've expected, but when i try to learn to use return 
locals() an error rise. 

-- 

--- 
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/groups/opt_out.




[web2py] Re: .delete()

2013-02-08 Thread Annet
Hi Anthony,

Thanks for your reply. 

It should just return 0 (indicating that 0 records were deleted).


In that case I don't have to check db(db.eventList.nodeID==id) on emptyness
before calling .delete()

Best regards,

Annet

-- 

--- 
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/groups/opt_out.




[web2py] Re: .delete()

2013-02-07 Thread Anthony
It should just return 0 (indicating that 0 records were deleted).

Anthony

On Thursday, February 7, 2013 1:38:34 PM UTC-5, Annet wrote:

 If db(db.eventList.nodeID==id) is empty will 
 db(db.eventList.nodeID==id).delete()
 result in an error?

 Best regards,

 Annet


-- 

--- 
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/groups/opt_out.




[web2py] Re: delete query translation

2013-01-14 Thread Ron McOuat

Change the == on the field tests to single =

db((tableA.field1='x')  (tableA.field3==TableB.field2)  
(TableB.field3=y)).delete()

Ron

if you do db((tableA.field1=='x')  (tableA.field3==TableB.field2)  
 (TableB.field3==y)).delete() it doesn't work -- too many tables selected.
 I also tried db(query).delete(join =...), but in this case join is not 
 supported. Should it be the way to go?


-- 





[web2py] Re: delete query translation

2013-01-14 Thread Massimo Di Pierro
It should. Please open a ticket and we will add it.

On Monday, 14 January 2013 07:34:51 UTC-6, dederocks wrote:

 Hello,

 How do you translate the following in dal?

 delete tableA from tableA where TableA.field1='x'
 join TableB on TableB.field2=TableA.field3
 WHERE (TableB.field3 = y) ?

 if you do db((tableA.field1=='x')  (tableA.field3==TableB.field2)  
 (TableB.field3==y)).delete() it doesn't work -- too many tables selected.
 I also tried db(query).delete(join =...), but in this case join is not 
 supported. Should it be the way to go?


-- 





Re: [web2py] Re: delete uploads with SQLFORM.factory

2012-12-28 Thread paolo.vall...@gmail.com
Hi, I had a look at sqlform.py, the error comes from the fact that if a
default value is set for the field upload, web2py tries to read it and
store it as the new value for the upload field. As a result it is not
possible to me to edit forms and remove uploads by setting the default
value, this trick doesn't work.
Moreover, I tried to fix the initial error about the missing file, by
setting db.test_img['picture'].default  equal to real path of the file.
This worked well but than, if I understood correctly how web2py works, it
tried to store again the default value as the new value, starting a kind of
loop! That was wrong, and actually this has never worked, it stopped due to
the 'error filename' to long.

The good thing is that by changing this two line (line 1394 of sqlhtml.py)
f = self.table[fieldname].default or ''
fields[fieldname] = f
to:
fields[fieldname] = self.table[fieldname].default
It seems that this solved the issue, but of course, I need something better.


2012/12/27 Paolo paolo.vall...@gmail.com

 Hi Massimo, thank for the answer, I updated the code but the problem is
 still there, I made several tests, no one figured out what is wrong. So
 that I tried to simplify the code as follows:
 db.define_table('test_img',

 Field(picture, upload,

   uploadfolder=os.path.join(request.folder,'uploads','pictures'),
   uploadseparate=True),
 Field('created_on', 'datetime', default=request.now, writable=False)
 )

 def sqlform_add():
 form = SQLFORM.factory(db.test_img, _class='well',

upload=URL('default', 'download'),

uploadfolder=os.path.join(request.folder,
 'uploads','pictures'),
uploadseparate=True, table_name='test')
 if form.process(dbio=False).accepted:
 id = db.test_img.insert(**dict(form.vars))
 return response.render('generic.html', dict(form=form))

 def sqlform_edit():
 img = db(db.test_img.id0).select().first()
 db.test_img['picture'].default = img['picture']
 form = SQLFORM.factory(db.test_img, _class='well',

upload=URL('default', 'download'),

uploadfolder=os.path.join(request.folder,
 'uploads','pictures'),
uploadseparate=True, table_name='test')
 if form.process(dbio=False).accepted:
 print 'form accepted'
 return response.render('generic.html', dict(form=form))

 what I got:
 - adding an img with sqlform_add and then removing it with appadmin  --
 worked
 - adding an img with appadmin and then removing it with sqlform_edit --
 failed
 - using both sqlform_add and sqlform_edit -- failed
 Now I am thinking about the way I set the default value, maybe for a field
 as an upload I have to set something more?

 Paolo


 On Thursday, December 27, 2012 9:28:54 PM UTC+1, Massimo Di Pierro wrote:

 perhaps not the cause of the problem but

 request.folder+'uploads/**pictures'

 should be

 os.path.join(request.folder,'**uploads','pictures')

 On Thursday, 27 December 2012 00:30:00 UTC-6, Paolo wrote:

 Hi Massimo,
 I've just tried to post and then edit with both SQLFORM.factory having
 uploadseparate but nothing has changed. The problem is still there,
 actually I am making explicitly inserts and  edits.
 The whole SQLFORM.factory to edit a field is this:
 for field in ['title','description', 'user_contact',
 'picture' ]:
 db.club[field].default = club[field]
 for field in ['name']:
 db.cities[field].default = city[field]
 form = SQLFORM.factory(db.club, db.cities, _class='well',
formstyle='bootstrap', showid= False,
upload=URL('default', 
 'download'),uploadfolder
 =request.folder+'**uploads/pictures',
uploadseparate=True, 
 autodelete=True,table_name
 ='club')


 Paolo



 On Thursday, December 27, 2012 12:47:19 AM UTC+1, Massimo Di Pierro
 wrote:

 Did you upload the file first and then add uploadseparate/uploadfolder?


 On Wednesday, 26 December 2012 12:49:01 UTC-6, Paolo wrote:

 Hi all,
 it seems to me that SQLFORM.factory doesn't honor the uploadseparate
 option because I'am not able to delete the uploaded file with
 SQLFORM.factory

 form = SQLFORM.factory(db.club, db.cities, _class='well',
formstyle='bootstrap', showid= False,
upload=URL('default', 'download'), uploadfolder
 =request.folder+'**uploads/pictures',
uploadseparate=True, autodelete=True,table_name
 ='club'  )



 The error:
 Enter code here...2012-12-26 19:38:07,728 - web2py - ERROR - Traceback
 (most recent call last):
   File /home/paolo/Dropbox/git/**web2py/gluon/restricted.py, line
 212, in restricted
 exec ccode in environment
   File /home/paolo/Dropbox/git/**web2py/applications/bikend/**
 controllers/club.py, line 123, in module
 

[web2py] Re: delete uploads with SQLFORM.factory

2012-12-27 Thread Paolo
Hi, I thought about the option requires, right now I have:

requires=[IS_IMAGE(), IS_UPLOAD_FILENAME(extension='jpg|jpeg|png'), IS_IMAGE
(extensions=('jpeg', 'png'))
I thought that as defined, the field could not be empty, so, I tried to 
remove any constrain

requires=None
but then the delete button is no longer shown, why ?!
I've also tried:

requires=[]
but in this case I got the same error as in the other cases.

Paolo





On Thursday, December 27, 2012 7:30:00 AM UTC+1, Paolo wrote:

 Hi Massimo, 
 I've just tried to post and then edit with both SQLFORM.factory having  
 uploadseparate but nothing has changed. The problem is still there, 
 actually I am making explicitly inserts and  edits. 
 The whole SQLFORM.factory to edit a field is this:
 for field in ['title','description', 'user_contact','picture' 
 ]:
 db.club[field].default = club[field]
 for field in ['name']:
 db.cities[field].default = city[field]
 form = SQLFORM.factory(db.club, db.cities, _class='well', 
formstyle='bootstrap', showid= False,
upload=URL('default', 
 'download'),uploadfolder
 =request.folder+'uploads/pictures',  
uploadseparate=True, 
 autodelete=True,table_name
 ='club')


 Paolo



 On Thursday, December 27, 2012 12:47:19 AM UTC+1, Massimo Di Pierro wrote:

 Did you upload the file first and then add uploadseparate/uploadfolder?  

 On Wednesday, 26 December 2012 12:49:01 UTC-6, Paolo wrote:

 Hi all, 
 it seems to me that SQLFORM.factory doesn't honor the uploadseparate 
 option because I'am not able to delete the uploaded file with 
 SQLFORM.factory

 form = SQLFORM.factory(db.club, db.cities, _class='well', 
formstyle='bootstrap', showid= False,
upload=URL('default', 'download'), uploadfolder=
 request.folder+'uploads/pictures',  
uploadseparate=True, autodelete=True, table_name=
 'club'  )

  

 The error:
 Enter code here...2012-12-26 19:38:07,728 - web2py - ERROR - Traceback 
 (most 
 recent call last):
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 212, 
 in restricted
 exec ccode in environment
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py
 , line 123, in module
   File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 193, in 
 lambda
 self._caller = lambda f: f()
   File /home/paolo/Dropbox/git/web2py/gluon/tools.py, line 2935, in f
 return action(*a, **b)
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py
 , line 35, in modal
 d = {'form':club_form(c_id=club_id)}
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py
 , line 103, in club_form
 if form.process(dbio=False).accepted:
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2179, inprocess
 self.validate(**kwargs)
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2118, invalidate
 if self.accepts(**kwargs):
   File /home/paolo/Dropbox/git/web2py/gluon/sqlhtml.py, line 1408, 
 inaccepts
 source_file = open(f, 'rb')
 IOError: [Errno 2] No such file or directory: 
 '/home/paolo/Dropbox/git/web2py/applications/bikend/club.picture.a4bd97789f289bcc.6c6f676f322e706e67.png'

 It tries to remove the file in the wrong directory. The right one would 
 be:
 cod...
 Show 
 originalhttps://groups.google.com/group/web2py/msg/ff7178943040387c?dmode=sourceoutput=gplainnoredirect



-- 





[web2py] Re: delete uploads with SQLFORM.factory

2012-12-27 Thread Massimo Di Pierro
perhaps not the cause of the problem but

request.folder+'uploads/pictures'

should be

os.path.join(request.folder,'uploads','pictures')

On Thursday, 27 December 2012 00:30:00 UTC-6, Paolo wrote:

 Hi Massimo, 
 I've just tried to post and then edit with both SQLFORM.factory having  
 uploadseparate but nothing has changed. The problem is still there, 
 actually I am making explicitly inserts and  edits. 
 The whole SQLFORM.factory to edit a field is this:
 for field in ['title','description', 'user_contact','picture' 
 ]:
 db.club[field].default = club[field]
 for field in ['name']:
 db.cities[field].default = city[field]
 form = SQLFORM.factory(db.club, db.cities, _class='well', 
formstyle='bootstrap', showid= False,
upload=URL('default', 
 'download'),uploadfolder
 =request.folder+'uploads/pictures',  
uploadseparate=True, 
 autodelete=True,table_name
 ='club')


 Paolo



 On Thursday, December 27, 2012 12:47:19 AM UTC+1, Massimo Di Pierro wrote:

 Did you upload the file first and then add uploadseparate/uploadfolder?  

 On Wednesday, 26 December 2012 12:49:01 UTC-6, Paolo wrote:

 Hi all, 
 it seems to me that SQLFORM.factory doesn't honor the uploadseparate 
 option because I'am not able to delete the uploaded file with 
 SQLFORM.factory

 form = SQLFORM.factory(db.club, db.cities, _class='well', 
formstyle='bootstrap', showid= False,
upload=URL('default', 'download'), uploadfolder=
 request.folder+'uploads/pictures',  
uploadseparate=True, autodelete=True, table_name=
 'club'  )

  

 The error:
 Enter code here...2012-12-26 19:38:07,728 - web2py - ERROR - Traceback 
 (most 
 recent call last):
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 212, 
 in restricted
 exec ccode in environment
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py
 , line 123, in module
   File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 193, in 
 lambda
 self._caller = lambda f: f()
   File /home/paolo/Dropbox/git/web2py/gluon/tools.py, line 2935, in f
 return action(*a, **b)
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py
 , line 35, in modal
 d = {'form':club_form(c_id=club_id)}
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py
 , line 103, in club_form
 if form.process(dbio=False).accepted:
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2179, inprocess
 self.validate(**kwargs)
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2118, invalidate
 if self.accepts(**kwargs):
   File /home/paolo/Dropbox/git/web2py/gluon/sqlhtml.py, line 1408, 
 inaccepts
 source_file = open(f, 'rb')
 IOError: [Errno 2] No such file or directory: 
 '/home/paolo/Dropbox/git/web2py/applications/bikend/club.picture.a4bd97789f289bcc.6c6f676f322e706e67.png'

 It tries to remove the file in the wrong directory. The right one would 
 be:
 cod...
 Show 
 originalhttps://groups.google.com/group/web2py/msg/ff7178943040387c?dmode=sourceoutput=gplainnoredirect



-- 





[web2py] Re: delete uploads with SQLFORM.factory

2012-12-27 Thread Paolo
Hi Massimo, thank for the answer, I updated the code but the problem is 
still there, I made several tests, no one figured out what is wrong. So 
that I tried to simplify the code as follows:
db.define_table('test_img',
Field(picture, upload, 
  uploadfolder=os.path.join(request.folder,'uploads','pictures'), 
  uploadseparate=True),
Field('created_on', 'datetime', default=request.now, writable=False)
)

def sqlform_add():
form = SQLFORM.factory(db.test_img, _class='well',
   upload=URL('default', 'download'),
   uploadfolder=os.path.join(request.folder,
'uploads','pictures'),  
   uploadseparate=True, table_name='test')
if form.process(dbio=False).accepted:
id = db.test_img.insert(**dict(form.vars))
return response.render('generic.html', dict(form=form))

def sqlform_edit():
img = db(db.test_img.id0).select().first()
db.test_img['picture'].default = img['picture']
form = SQLFORM.factory(db.test_img, _class='well',
   upload=URL('default', 'download'),
   uploadfolder=os.path.join(request.folder,
'uploads','pictures'),  
   uploadseparate=True, table_name='test')
if form.process(dbio=False).accepted:
print 'form accepted'
return response.render('generic.html', dict(form=form))

what I got:
- adding an img with sqlform_add and then removing it with appadmin  -- 
worked
- adding an img with appadmin and then removing it with sqlform_edit -- 
failed 
- using both sqlform_add and sqlform_edit -- failed
Now I am thinking about the way I set the default value, maybe for a field 
as an upload I have to set something more?

Paolo

On Thursday, December 27, 2012 9:28:54 PM UTC+1, Massimo Di Pierro wrote:

 perhaps not the cause of the problem but

 request.folder+'uploads/pictures'

 should be

 os.path.join(request.folder,'uploads','pictures')

 On Thursday, 27 December 2012 00:30:00 UTC-6, Paolo wrote:

 Hi Massimo, 
 I've just tried to post and then edit with both SQLFORM.factory having  
 uploadseparate but nothing has changed. The problem is still there, 
 actually I am making explicitly inserts and  edits. 
 The whole SQLFORM.factory to edit a field is this:
 for field in ['title','description', 'user_contact','picture' 
 ]:
 db.club[field].default = club[field]
 for field in ['name']:
 db.cities[field].default = city[field]
 form = SQLFORM.factory(db.club, db.cities, _class='well', 
formstyle='bootstrap', showid= False,
upload=URL('default', 
 'download'),uploadfolder
 =request.folder+'uploads/pictures',  
uploadseparate=True, 
 autodelete=True,table_name
 ='club')


 Paolo



 On Thursday, December 27, 2012 12:47:19 AM UTC+1, Massimo Di Pierro wrote:

 Did you upload the file first and then add uploadseparate/uploadfolder?  

 On Wednesday, 26 December 2012 12:49:01 UTC-6, Paolo wrote:

 Hi all, 
 it seems to me that SQLFORM.factory doesn't honor the uploadseparate 
 option because I'am not able to delete the uploaded file with 
 SQLFORM.factory

 form = SQLFORM.factory(db.club, db.cities, _class='well', 
formstyle='bootstrap', showid= False,
upload=URL('default', 'download'), uploadfolder=
 request.folder+'uploads/pictures',  
uploadseparate=True, autodelete=True, table_name
 ='club'  )

  

 The error:
 Enter code here...2012-12-26 19:38:07,728 - web2py - ERROR - Traceback 
 (most recent call last):
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 212, 
 in restricted
 exec ccode in environment
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py
 , line 123, in module
   File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 193, in 
 lambda
 self._caller = lambda f: f()
   File /home/paolo/Dropbox/git/web2py/gluon/tools.py, line 2935, in f
 return action(*a, **b)
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py
 , line 35, in modal
 d = {'form':club_form(c_id=club_id)}
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py
 , line 103, in club_form
 if form.process(dbio=False).accepted:
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2179, inprocess
 self.validate(**kwargs)
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2118, 
 invalidate
 if self.accepts(**kwargs):
   File /home/paolo/Dropbox/git/web2py/gluon/sqlhtml.py, line 1408, 
 inaccepts
 source_file = open(f, 'rb')
 IOError: [Errno 2] No such file or directory: 
 '/home/paolo/Dropbox/git/web2py/applications/bikend/club.picture.a4bd97789f289bcc.6c6f676f322e706e67.png'

 It tries to remove the file in the wrong directory. The right 

[web2py] Re: delete uploads with SQLFORM.factory

2012-12-26 Thread Massimo Di Pierro
Did you upload the file first and then add uploadseparate/uploadfolder?  

On Wednesday, 26 December 2012 12:49:01 UTC-6, Paolo wrote:

 Hi all, 
 it seems to me that SQLFORM.factory doesn't honor the uploadseparate 
 option because I'am not able to delete the uploaded file with 
 SQLFORM.factory

 form = SQLFORM.factory(db.club, db.cities, _class='well', 
formstyle='bootstrap', showid= False,
upload=URL('default', 'download'), uploadfolder=
 request.folder+'uploads/pictures',  
uploadseparate=True, autodelete=True, table_name=
 'club'  )

  

 The error:
 Enter code here...2012-12-26 19:38:07,728 - web2py - ERROR - Traceback (most 
 recent call last):
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 212, 
 inrestricted
 exec ccode in environment
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py,line 
 123, in module
   File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 193, in 
 lambda
 self._caller = lambda f: f()
   File /home/paolo/Dropbox/git/web2py/gluon/tools.py, line 2935, in f
 return action(*a, **b)
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py,line 
 35, in modal
 d = {'form':club_form(c_id=club_id)}
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py,line 
 103, in club_form
 if form.process(dbio=False).accepted:
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2179, inprocess
 self.validate(**kwargs)
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2118, invalidate
 if self.accepts(**kwargs):
   File /home/paolo/Dropbox/git/web2py/gluon/sqlhtml.py, line 1408, inaccepts
 source_file = open(f, 'rb')
 IOError: [Errno 2] No such file or directory: 
 '/home/paolo/Dropbox/git/web2py/applications/bikend/club.picture.a4bd97789f289bcc.6c6f676f322e706e67.png'

 It tries to remove the file in the wrong directory. The right one would be:
 /home/paolo/Dropbox/git/span style=color: #000; class=styled-b...
 Show 
 originalhttps://groups.google.com/group/web2py/msg/77f8e5478e8b77b8?dmode=sourceoutput=gplainnoredirect


-- 





[web2py] Re: delete uploads with SQLFORM.factory

2012-12-26 Thread Paolo
Hi Massimo, 
I've just tried to post and then edit with both SQLFORM.factory having  
uploadseparate but nothing has changed. The problem is still there, 
actually I am making explicitly inserts and  edits. 
The whole SQLFORM.factory to edit a field is this:
for field in ['title','description', 'user_contact','picture' ]:
db.club[field].default = club[field]
for field in ['name']:
db.cities[field].default = city[field]
form = SQLFORM.factory(db.club, db.cities, _class='well', 
   formstyle='bootstrap', showid= False,
   upload=URL('default', 
'download'),uploadfolder
=request.folder+'uploads/pictures',  
   uploadseparate=True, 
autodelete=True,table_name
='club')


Paolo



On Thursday, December 27, 2012 12:47:19 AM UTC+1, Massimo Di Pierro wrote:

 Did you upload the file first and then add uploadseparate/uploadfolder?  

 On Wednesday, 26 December 2012 12:49:01 UTC-6, Paolo wrote:

 Hi all, 
 it seems to me that SQLFORM.factory doesn't honor the uploadseparate 
 option because I'am not able to delete the uploaded file with 
 SQLFORM.factory

 form = SQLFORM.factory(db.club, db.cities, _class='well', 
formstyle='bootstrap', showid= False,
upload=URL('default', 'download'), uploadfolder=
 request.folder+'uploads/pictures',  
uploadseparate=True, autodelete=True, table_name=
 'club'  )

  

 The error:
 Enter code here...2012-12-26 19:38:07,728 - web2py - ERROR - Traceback (most 
 recent call last):
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 212, 
 inrestricted
 exec ccode in environment
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py,line
  
 123, in module
   File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 193, in 
 lambda
 self._caller = lambda f: f()
   File /home/paolo/Dropbox/git/web2py/gluon/tools.py, line 2935, in f
 return action(*a, **b)
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py,line
  
 35, in modal
 d = {'form':club_form(c_id=club_id)}
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py,line
  
 103, in club_form
 if form.process(dbio=False).accepted:
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2179, inprocess
 self.validate(**kwargs)
   File /home/paolo/Dropbox/git/web2py/gluon/html.py, line 2118, invalidate
 if self.accepts(**kwargs):
   File /home/paolo/Dropbox/git/web2py/gluon/sqlhtml.py, line 1408, 
 inaccepts
 source_file = open(f, 'rb')
 IOError: [Errno 2] No such file or directory: 
 '/home/paolo/Dropbox/git/web2py/applications/bikend/club.picture.a4bd97789f289bcc.6c6f676f322e706e67.png'

 It tries to remove the file in the wrong directory. The right one would 
 be:
 /home/paolo/Dropbox/git/span style=color: #000; class=styled-b...
 Show 
 originalhttps://groups.google.com/group/web2py/msg/77f8e5478e8b77b8?dmode=sourceoutput=gplainnoredirect



-- 





Re: [web2py] Re: delete on GAE

2012-11-01 Thread howesc
so it turns out that GAE itself fails when i pass an iterator over a large 
list to gae.delete().  so i've tweaked the implementation to not call 
count, but to still count the number of entries deleted and it seems to be 
working.

suggested patch included 
in http://code.google.com/p/web2py/issues/detail?id=1134

thanks!

cfh

On Saturday, October 20, 2012 6:18:23 PM UTC-7, howesc wrote:

 sure.  i'll make a patch soon... 

 thanks for the input! 

 cfh 

 On 10/20/12 13:29 , Massimo Di Pierro wrote: 
  I meant to skip count. 
  
  On Saturday, 20 October 2012 15:28:56 UTC-5, Massimo Di Pierro wrote: 
  
  How about adding a gae only parameter to the gae adapter_args that 
 tells 
  it to skip fetch? 
  
  On Saturday, 20 October 2012 11:25:51 UTC-5, howesc wrote: 
  
  It appears that the most efficient way to delete on app engine is to: 
- build a query object, like we are doing now 
- call run with keys_only=True ( 
  
 https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
  

  which returns an iterator. 
- pass that iterator to the datastore delete method ( 
  
 https://developers.google.com/appengine/docs/python/datastore/functions#delete
  
  ) 
  
  this avoids the cost of loading the rows into memory, decreases the 
  likelihood of timeout, and has the cost of 1 datastore small operation 
 per 
  row.  but it does prevent us from getting a count of rows deleted. 
  
  the way we do it now: 
- run count() on the query.  this has a cost (time and money) of 
  iterating over all the rows that match the query on GAE (1 datastore 
 small 
  operation per row) 
- run fetch(limit=1000) and call delete() successively until no more 
  rows.  this has the cost of running a full query (at least 1 datastore 
 read 
  operation per row) and loading the result set into memory and then 
 deleting 
  the results. 
  
  in my case i'm timing out on the count() call so i don't even start 
 the 
  delete.  from an efficiency standpoint i'd rather have more rows 
 deleted 
  for less cost then get a countbut this may not be acceptable for 
 all. 
at a minimum i think we should switch to use keys_only=True for the 
 fetch, 
  and skip the leading count() call and just sum the number of times we 
 call 
  fetch.  we may also consider catching the datastore timeout error and 
  trying to handle a partial delete more gracefully (or continue to let 
 the 
  user catch the error). 
  
  what is the right approach for web2py?  if the approach with count 
 is 
  correct, could i propose a gae bulk_delete method that does not return 
  count but uses my first method? 
  
  thanks for the input! 
  
  cfh 
  
  On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro 
 wrote: 
  
  Delete should return the number of deleted records. What is your 
  proposal? 
  
  On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote: 
  
  Hi all, 
  
  I'm trying to clean up old expired sessions.but i waited a long 
  time to get to this and now my GAE delete is just timing out. 
  Reading the 
  GAE docs, there appears to be some improvements that we can make to 
 the 
  query delete method on GAE that will make it faster and cheaper. 
  what we 
  lose then is the count of the number of rows deleted. 
  
  my question is, does having a db(db.table.something==True).delete() 
  that does not return a count break the web2py API contract, or break 
  anyone's applications? 
  
  thanks, 
  
  christian 
  
  
  


-- 





[web2py] Re: delete on GAE

2012-10-20 Thread Massimo Di Pierro
Delete should return the number of deleted records. What is your proposal?

On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:

 Hi all,

 I'm trying to clean up old expired sessions.but i waited a long time 
 to get to this and now my GAE delete is just timing out.  Reading the GAE 
 docs, there appears to be some improvements that we can make to the query 
 delete method on GAE that will make it faster and cheaper.  what we lose 
 then is the count of the number of rows deleted.

 my question is, does having a db(db.table.something==True).delete() that 
 does not return a count break the web2py API contract, or break anyone's 
 applications?

 thanks,

 christian


-- 





[web2py] Re: delete on GAE

2012-10-20 Thread howesc
It appears that the most efficient way to delete on app engine is to:
 - build a query object, like we are doing now
 - call run with keys_only=True 
(https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
 
which returns an iterator.
 - pass that iterator to the datastore delete method 
(https://developers.google.com/appengine/docs/python/datastore/functions#delete)

this avoids the cost of loading the rows into memory, decreases the 
likelihood of timeout, and has the cost of 1 datastore small operation per 
row.  but it does prevent us from getting a count of rows deleted.

the way we do it now:
 - run count() on the query.  this has a cost (time and money) of iterating 
over all the rows that match the query on GAE (1 datastore small operation 
per row)
 - run fetch(limit=1000) and call delete() successively until no more rows. 
 this has the cost of running a full query (at least 1 datastore read 
operation per row) and loading the result set into memory and then deleting 
the results.

in my case i'm timing out on the count() call so i don't even start the 
delete.  from an efficiency standpoint i'd rather have more rows deleted 
for less cost then get a countbut this may not be acceptable for all. 
 at a minimum i think we should switch to use keys_only=True for the fetch, 
and skip the leading count() call and just sum the number of times we call 
fetch.  we may also consider catching the datastore timeout error and 
trying to handle a partial delete more gracefully (or continue to let the 
user catch the error).

what is the right approach for web2py?  if the approach with count is 
correct, could i propose a gae bulk_delete method that does not return 
count but uses my first method?

thanks for the input!

cfh

On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro wrote:

 Delete should return the number of deleted records. What is your proposal?

 On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:

 Hi all,

 I'm trying to clean up old expired sessions.but i waited a long time 
 to get to this and now my GAE delete is just timing out.  Reading the GAE 
 docs, there appears to be some improvements that we can make to the query 
 delete method on GAE that will make it faster and cheaper.  what we lose 
 then is the count of the number of rows deleted.

 my question is, does having a db(db.table.something==True).delete() that 
 does not return a count break the web2py API contract, or break anyone's 
 applications?

 thanks,

 christian



-- 





[web2py] Re: delete on GAE

2012-10-20 Thread Massimo Di Pierro
How about adding a gae only parameter to the gae adapter_args that tells it 
to skip fetch?

On Saturday, 20 October 2012 11:25:51 UTC-5, howesc wrote:

 It appears that the most efficient way to delete on app engine is to:
  - build a query object, like we are doing now
  - call run with keys_only=True (
 https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
  
 which returns an iterator.
  - pass that iterator to the datastore delete method (
 https://developers.google.com/appengine/docs/python/datastore/functions#delete
 )

 this avoids the cost of loading the rows into memory, decreases the 
 likelihood of timeout, and has the cost of 1 datastore small operation per 
 row.  but it does prevent us from getting a count of rows deleted.

 the way we do it now:
  - run count() on the query.  this has a cost (time and money) of 
 iterating over all the rows that match the query on GAE (1 datastore small 
 operation per row)
  - run fetch(limit=1000) and call delete() successively until no more 
 rows.  this has the cost of running a full query (at least 1 datastore read 
 operation per row) and loading the result set into memory and then deleting 
 the results.

 in my case i'm timing out on the count() call so i don't even start the 
 delete.  from an efficiency standpoint i'd rather have more rows deleted 
 for less cost then get a countbut this may not be acceptable for all. 
  at a minimum i think we should switch to use keys_only=True for the fetch, 
 and skip the leading count() call and just sum the number of times we call 
 fetch.  we may also consider catching the datastore timeout error and 
 trying to handle a partial delete more gracefully (or continue to let the 
 user catch the error).

 what is the right approach for web2py?  if the approach with count is 
 correct, could i propose a gae bulk_delete method that does not return 
 count but uses my first method?

 thanks for the input!

 cfh

 On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro wrote:

 Delete should return the number of deleted records. What is your proposal?

 On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:

 Hi all,

 I'm trying to clean up old expired sessions.but i waited a long time 
 to get to this and now my GAE delete is just timing out.  Reading the GAE 
 docs, there appears to be some improvements that we can make to the query 
 delete method on GAE that will make it faster and cheaper.  what we lose 
 then is the count of the number of rows deleted.

 my question is, does having a db(db.table.something==True).delete() that 
 does not return a count break the web2py API contract, or break anyone's 
 applications?

 thanks,

 christian



-- 





[web2py] Re: delete on GAE

2012-10-20 Thread Massimo Di Pierro
I meant to skip count.

On Saturday, 20 October 2012 15:28:56 UTC-5, Massimo Di Pierro wrote:

 How about adding a gae only parameter to the gae adapter_args that tells 
 it to skip fetch?

 On Saturday, 20 October 2012 11:25:51 UTC-5, howesc wrote:

 It appears that the most efficient way to delete on app engine is to:
  - build a query object, like we are doing now
  - call run with keys_only=True (
 https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
  
 which returns an iterator.
  - pass that iterator to the datastore delete method (
 https://developers.google.com/appengine/docs/python/datastore/functions#delete
 )

 this avoids the cost of loading the rows into memory, decreases the 
 likelihood of timeout, and has the cost of 1 datastore small operation per 
 row.  but it does prevent us from getting a count of rows deleted.

 the way we do it now:
  - run count() on the query.  this has a cost (time and money) of 
 iterating over all the rows that match the query on GAE (1 datastore small 
 operation per row)
  - run fetch(limit=1000) and call delete() successively until no more 
 rows.  this has the cost of running a full query (at least 1 datastore read 
 operation per row) and loading the result set into memory and then deleting 
 the results.

 in my case i'm timing out on the count() call so i don't even start the 
 delete.  from an efficiency standpoint i'd rather have more rows deleted 
 for less cost then get a countbut this may not be acceptable for all. 
  at a minimum i think we should switch to use keys_only=True for the fetch, 
 and skip the leading count() call and just sum the number of times we call 
 fetch.  we may also consider catching the datastore timeout error and 
 trying to handle a partial delete more gracefully (or continue to let the 
 user catch the error).

 what is the right approach for web2py?  if the approach with count is 
 correct, could i propose a gae bulk_delete method that does not return 
 count but uses my first method?

 thanks for the input!

 cfh

 On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro wrote:

 Delete should return the number of deleted records. What is your 
 proposal?

 On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:

 Hi all,

 I'm trying to clean up old expired sessions.but i waited a long 
 time to get to this and now my GAE delete is just timing out.  Reading the 
 GAE docs, there appears to be some improvements that we can make to the 
 query delete method on GAE that will make it faster and cheaper.  what we 
 lose then is the count of the number of rows deleted.

 my question is, does having a db(db.table.something==True).delete() 
 that does not return a count break the web2py API contract, or break 
 anyone's applications?

 thanks,

 christian



-- 





Re: [web2py] Re: delete on GAE

2012-10-20 Thread Christian Foster Howes

sure.  i'll make a patch soon...

thanks for the input!

cfh

On 10/20/12 13:29 , Massimo Di Pierro wrote:

I meant to skip count.

On Saturday, 20 October 2012 15:28:56 UTC-5, Massimo Di Pierro wrote:


How about adding a gae only parameter to the gae adapter_args that tells
it to skip fetch?

On Saturday, 20 October 2012 11:25:51 UTC-5, howesc wrote:


It appears that the most efficient way to delete on app engine is to:
  - build a query object, like we are doing now
  - call run with keys_only=True (
https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_run)
which returns an iterator.
  - pass that iterator to the datastore delete method (
https://developers.google.com/appengine/docs/python/datastore/functions#delete
)

this avoids the cost of loading the rows into memory, decreases the
likelihood of timeout, and has the cost of 1 datastore small operation per
row.  but it does prevent us from getting a count of rows deleted.

the way we do it now:
  - run count() on the query.  this has a cost (time and money) of
iterating over all the rows that match the query on GAE (1 datastore small
operation per row)
  - run fetch(limit=1000) and call delete() successively until no more
rows.  this has the cost of running a full query (at least 1 datastore read
operation per row) and loading the result set into memory and then deleting
the results.

in my case i'm timing out on the count() call so i don't even start the
delete.  from an efficiency standpoint i'd rather have more rows deleted
for less cost then get a countbut this may not be acceptable for all.
  at a minimum i think we should switch to use keys_only=True for the fetch,
and skip the leading count() call and just sum the number of times we call
fetch.  we may also consider catching the datastore timeout error and
trying to handle a partial delete more gracefully (or continue to let the
user catch the error).

what is the right approach for web2py?  if the approach with count is
correct, could i propose a gae bulk_delete method that does not return
count but uses my first method?

thanks for the input!

cfh

On Saturday, October 20, 2012 7:58:56 AM UTC-7, Massimo Di Pierro wrote:


Delete should return the number of deleted records. What is your
proposal?

On Wednesday, 17 October 2012 17:30:22 UTC-5, howesc wrote:


Hi all,

I'm trying to clean up old expired sessions.but i waited a long
time to get to this and now my GAE delete is just timing out.  Reading the
GAE docs, there appears to be some improvements that we can make to the
query delete method on GAE that will make it faster and cheaper.  what we
lose then is the count of the number of rows deleted.

my question is, does having a db(db.table.something==True).delete()
that does not return a count break the web2py API contract, or break
anyone's applications?

thanks,

christian







--





[web2py] Re: delete posts

2012-10-11 Thread curiouslearn
This is perhaps a problem with google groups. Only reasons I am saying this 
is because this happened to me on d3.js google groups.
I had to repost in the chain and then it worked.


On Wednesday, October 10, 2012 10:04:50 PM UTC-4, Massimo Di Pierro wrote:

 I have seen some delete posts. We do not delete posts ever! We just block 
 spam (nude girls and java job advertisements usually).
 I do not know why some posts have disappeared and listed as deleted. If 
 you know something please share here.


-- 





[web2py] Re: delete posts

2012-10-11 Thread Paolo Caruccio
Sometimes the message was deleted, if I forgot to wrap the code through 
apposite tool (button with braces symbol) . Maybe for security reasons. 


Il giorno giovedì 11 ottobre 2012 13:45:31 UTC+2, curiouslearn ha scritto:

 This is perhaps a problem with google groups. Only reasons I am saying 
 this is because this happened to me on d3.js google groups.
 I had to repost in the chain and then it worked.


 On Wednesday, October 10, 2012 10:04:50 PM UTC-4, Massimo Di Pierro wrote:

 I have seen some delete posts. We do not delete posts ever! We just block 
 spam (nude girls and java job advertisements usually).
 I do not know why some posts have disappeared and listed as deleted. If 
 you know something please share here.



-- 





[web2py] Re: delete row question

2012-05-25 Thread Anthony
Not in current stable, but in trunk, you can do:

db.mytable._after_delete.append(myfunction)

The _after_delete attribute of the table is a list of functions that take 
the table as an argument and are run after any delete is performed. There's 
also _before_delete as well as similar lists for before and after insert 
and update.

If the deletion is happening via a form submission, you could also simply 
add some logic to the form processing code to run the function.

Anthony

On Friday, May 25, 2012 12:19:37 PM UTC-4, Roberto Perdomo wrote:

 Hi, 

 I have a single question, 

 There is a way to run a feature automatically when you delete a record 
 from a particular table? 



Re: [web2py] Re: delete row question

2012-05-25 Thread Roberto Perdomo
_after_delete.append is a great improvement.

I really like to run a function after the user press the default
delete button from a smartgrid, I can hide this button and add a
custom delete button, but whit _after_delete.append(function) is a
best solution.

Thanks.

2012/5/25 Anthony abasta...@gmail.com:
 Not in current stable, but in trunk, you can do:

 db.mytable._after_delete.append(myfunction)

 The _after_delete attribute of the table is a list of functions that take
 the table as an argument and are run after any delete is performed. There's
 also _before_delete as well as similar lists for before and after insert and
 update.

 If the deletion is happening via a form submission, you could also simply
 add some logic to the form processing code to run the function.

 Anthony

 On Friday, May 25, 2012 12:19:37 PM UTC-4, Roberto Perdomo wrote:

 Hi,

 I have a single question,

 There is a way to run a feature automatically when you delete a record
 from a particular table?


[web2py] Re: Delete plugin will also delete default theme

2011-10-07 Thread Omi Chiba
Thank you, I found the problem.

views/layout.html is REPLACED when the layout plugin installed and
stay as is even you uninstall the plugin, which means the original one
is not restored.

I tried the following but others cause the same problem.

http://web2py.com/layouts/static/plugin_layouts/plugins/web2py.plugin.layout_RedCity.w2p

We can manually restore the original from other apps but it's nice to
have feature to restore the original and backup when it's uninstalled.


On Oct 6, 6:12 pm, Anthony abasta...@gmail.com wrote:
 Which layout plugin did you install?

 On Thursday, October 6, 2011 6:27:27 PM UTC-4, Omi Chiba wrote:

  Have you confirmed the default theme files have actually been deleted?
  Not sure where it's located...

 It would be /views/layout.html and /static/css/base.css.









   When using the layout plugin, had you modified your layout.html to extend
  the
   plugin layout.html

  No. It's a brand new app. I think you can also re-produce it very
  easily.  By the way, web2py version is the latest (Version 1.99.2)
  one.

  On Oct 6, 3:51 pm, Anthony abas...@gmail.com wrote:
   Have you confirmed the default theme files have actually been deleted?
  When
   using the layout plugin, had you modified your layout.html to extend the
   plugin layout.html, and if so, did you change it back after deleting the
   plugin?

   Anthony

   On Thursday, October 6, 2011 4:34:17 PM UTC-4, Omi Chiba wrote:

See attached screen shot.

1. Download layout plugin
2. Upload to your app
3. Click delete plugin
4. Now I'm naked like attached screen.


[web2py] Re: Delete plugin will also delete default theme

2011-10-07 Thread Christopher Steel
that is is precisely...

The current recommended way of creating layout plugins works fine when 
installing plugins but does leave you naked if you decide to uninstall all 
layout plugins or uninstall the last  layout plugin installed.

To get a better understanding of why this is true you can see the web2py 
manual or examine the contents of a layout plugin (basically a tar archive) 
:

http://www.web2py.com/book/default/chapter/13?search=layout+plugin#Layout-plugins

In a nutshell, many layout plugins (all of them?) overwrite 
views/layout.html or recommend that views/layout.html be replaced with the 
following content:

{{extend 'plugin_layout_name/layout.html'}}
{{include}}


So restoring your original views/layout.html will give you your original 
layout again.

Alternatively you could create a layout plugin that installs your original 
views/layout.html (or even the entire default theme) for the version of 
Web2py you used to create the application or your own custom version.


Chris


[web2py] Re: Delete plugin will also delete default theme

2011-10-06 Thread Anthony
Have you confirmed the default theme files have actually been deleted? When 
using the layout plugin, had you modified your layout.html to extend the 
plugin layout.html, and if so, did you change it back after deleting the 
plugin?

Anthony

On Thursday, October 6, 2011 4:34:17 PM UTC-4, Omi Chiba wrote:

 See attached screen shot.

 1. Download layout plugin
 2. Upload to your app
 3. Click delete plugin
 4. Now I'm naked like attached screen.



[web2py] Re: Delete plugin will also delete default theme

2011-10-06 Thread Omi Chiba
Have you confirmed the default theme files have actually been deleted?
Not sure where it's located...

 When using the layout plugin, had you modified your layout.html to extend the
 plugin layout.html

No. It's a brand new app. I think you can also re-produce it very
easily.  By the way, web2py version is the latest (Version 1.99.2)
one.


On Oct 6, 3:51 pm, Anthony abasta...@gmail.com wrote:
 Have you confirmed the default theme files have actually been deleted? When
 using the layout plugin, had you modified your layout.html to extend the
 plugin layout.html, and if so, did you change it back after deleting the
 plugin?

 Anthony







 On Thursday, October 6, 2011 4:34:17 PM UTC-4, Omi Chiba wrote:

  See attached screen shot.

  1. Download layout plugin
  2. Upload to your app
  3. Click delete plugin
  4. Now I'm naked like attached screen.


[web2py] Re: Delete plugin will also delete default theme

2011-10-06 Thread Anthony
Which layout plugin did you install?

On Thursday, October 6, 2011 6:27:27 PM UTC-4, Omi Chiba wrote:

 Have you confirmed the default theme files have actually been deleted? 
 Not sure where it's located... 


It would be /views/layout.html and /static/css/base.css.
 


  When using the layout plugin, had you modified your layout.html to extend 
 the 
  plugin layout.html 

 No. It's a brand new app. I think you can also re-produce it very 
 easily.  By the way, web2py version is the latest (Version 1.99.2) 
 one. 


 On Oct 6, 3:51 pm, Anthony abas...@gmail.com wrote: 
  Have you confirmed the default theme files have actually been deleted? 
 When 
  using the layout plugin, had you modified your layout.html to extend the 
  plugin layout.html, and if so, did you change it back after deleting the 
  plugin? 
  
  Anthony 
  
  
  
  
  
  
  
  On Thursday, October 6, 2011 4:34:17 PM UTC-4, Omi Chiba wrote: 
  
   See attached screen shot. 
  
   1. Download layout plugin 
   2. Upload to your app 
   3. Click delete plugin 
   4. Now I'm naked like attached screen.



Re: [web2py] Re: delete a SQLTABLE column

2011-08-04 Thread Richard Vézina
I can't, I have to work with the html table because I do this before
creating the SQLTQBLE :

db[request.args(0)].sample_id.represent=\
lambda sample_id, record: A(%(sample)s
%db.v_sample_num_all[sample_id],\
_href=URL(r=request,f='read',args=request.args(0)+'/'+str(
record.id)))

So, because the .represent = lambda sample_id, record: SQLTABLE seems to
need the id column to build the HTML table in the first place... The
sample_id is not the id of the table get by request.args(0)...

That why I wrote the function...

Richard

On Wed, Aug 3, 2011 at 6:50 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 I do not think this qualifies for addition but it is useful.

 I would have done:

 rows = db().select(db.table.ALL)
 db.table.fieldtodelete.writable=False
 table = SQLTABLE(rows)

 or

 rows = db().select(*[field for field in db.table if not
 field.name=='fieldtodelete'])
 table = SQLTABLE(rows)


 On Aug 3, 3:17 pm, Richard Vézina ml.richard.vez...@gmail.com wrote:
  Don't know if my delete column function could be part of web2py core
  functions but here it is :
 
  def __del_sqltable_column(sqltable, column_name):
  
  For deleting a given column in an instance of web2py SQLTABLE class.
  Pass the SQLTABLE object and the column name to delete.
  Ex.: table1 = SQLTABLE(rows) contains id column and we want to delete
  it.
  So we call __del_sqltable_column(tabel1, 'table.id') or
  __del_sqltable_column(request.args(0), db[request.args(0)].id)
  When the column name is changed with represent the representation
 should
  be
  passed as column name.
  
  import re
  regex_colum_name = re.compile(str(TH(column_name)))
  for i in range(0, len(sqltable[0][0])):
  if regex_colum_name.match(str(sqltable[0][0][i])):
  for r in range(0, len(sqltable[1])):
  del(sqltable[1][r][i])
  del(sqltable[0][0][i])
  return sqltable
  return sqltable
 
  It could be my first contribution to web2py ;-)
 
  Richard
 
  On Wed, Aug 3, 2011 at 4:08 PM, Richard Vézina
  ml.richard.vez...@gmail.comwrote:
 
 
 
 
 
 
 
   Yes... I use pgAdmin for the other things, I didn't fix my choice on a
   commercial database manager...
 
   ;-)
 
   Richard
 
   On Wed, Aug 3, 2011 at 4:04 PM, Anthony abasta...@gmail.com wrote:
 
   I think he wants to delete columns from a SQLTABLE, not a db table.
 
   On Wednesday, August 3, 2011 4:01:09 PM UTC-4, pbreit wrote:
 
   That's how I delete columns.



[web2py] Re: delete a SQLTABLE column

2011-08-03 Thread Massimo Di Pierro
I do not think this qualifies for addition but it is useful.

I would have done:

rows = db().select(db.table.ALL)
db.table.fieldtodelete.writable=False
table = SQLTABLE(rows)

or

rows = db().select(*[field for field in db.table if not
field.name=='fieldtodelete'])
table = SQLTABLE(rows)


On Aug 3, 3:17 pm, Richard Vézina ml.richard.vez...@gmail.com wrote:
 Don't know if my delete column function could be part of web2py core
 functions but here it is :

 def __del_sqltable_column(sqltable, column_name):
     
     For deleting a given column in an instance of web2py SQLTABLE class.
     Pass the SQLTABLE object and the column name to delete.
     Ex.: table1 = SQLTABLE(rows) contains id column and we want to delete
 it.
     So we call __del_sqltable_column(tabel1, 'table.id') or
     __del_sqltable_column(request.args(0), db[request.args(0)].id)
     When the column name is changed with represent the representation should
 be
     passed as column name.
     
     import re
     regex_colum_name = re.compile(str(TH(column_name)))
     for i in range(0, len(sqltable[0][0])):
         if regex_colum_name.match(str(sqltable[0][0][i])):
             for r in range(0, len(sqltable[1])):
                 del(sqltable[1][r][i])
             del(sqltable[0][0][i])
             return sqltable
     return sqltable

 It could be my first contribution to web2py ;-)

 Richard

 On Wed, Aug 3, 2011 at 4:08 PM, Richard Vézina
 ml.richard.vez...@gmail.comwrote:







  Yes... I use pgAdmin for the other things, I didn't fix my choice on a
  commercial database manager...

  ;-)

  Richard

  On Wed, Aug 3, 2011 at 4:04 PM, Anthony abasta...@gmail.com wrote:

  I think he wants to delete columns from a SQLTABLE, not a db table.

  On Wednesday, August 3, 2011 4:01:09 PM UTC-4, pbreit wrote:

  That's how I delete columns.


[web2py] Re: Delete buttons not working

2011-07-31 Thread Massimo Di Pierro
I am a bit lost about the context. Is this about a previous thread?

massimo

On Jul 31, 4:12 pm, peter peterchutchin...@gmail.com wrote:
 Bruno

 Thanks a lot for this, it is a very useful tool just as I needed it.

 I am using the latest version of web2py, and python 2.5, so I had the
 same problems as Tomt had. I commented out the
 'with open(path' etc.

 I am now finding that the delete buttons do not work on the examples
 on which they appear. I discovered that the 'data' functions were not
 being called, so the confirmationmodal does not seem to be working.
 Using refreshmodal to force the link to the 'data' functions got it
 further but then I get a page not found, which is strange as the
 details and edit buttons do work fine.

 I hope this is useful feedback.

 Peter


[web2py] Re: delete buttons not working

2011-07-31 Thread Massimo Di Pierro
do you refer to web2py.com/demo_admin and web2py.com/demo_app ? Yes,
they are in readonly mode.

On Jul 31, 4:23 pm, peter peterchutchin...@gmail.com wrote:
 I now see that the delete buttons do not work in your live demos, and
 that this is maybe deliberate as you do not want people emptying the
 demo databases. So maybe this is not a bug, but the lack of
 documentation leaves me unclear.

 Thanks
 Peter


[web2py] Re: delete online user

2011-03-24 Thread Massimo Di Pierro
You have to id the user session and delete it

On Mar 24, 6:30 am, Neveen Adel nevo.a...@gmail.com wrote:
 Hello,

 Is there a way to when a user delete another online user , the deleted
 user logged out ?

 Thanks in Advance


[web2py] Re: Delete error in SQLFORM with marked up labels

2010-07-04 Thread mdipierro
I added your suggested solution to trunk because the fact that
form.elements(...) does not work in this case should be considered a
bug. I wish there was a better solution but I could not think of one.

On 4 Lug, 11:06, Bob_in_Comox rwstj...@gmail.com wrote:
 Using web2py version 1.79.2

 In building a form using SQLFORM I use:
 form = SQLFORM(db.table, record, fields=myfields, labels=mylabels,
 col3=mycol3, deletable=True)

 where mylabels and mycol3 use XML() to wrap some HTML markup

 PROBLEM:
 Works fine, except when I try to delete a record I get:

   File /home/bob/cdmc_site/web2py/applications/init/controllers/
 trip.py, line 221, in edit
     if form.accepts(request.vars, session):
   File /home/bob/cdmc_site/web2py/gluon/sqlhtml.py, line 930, in
 accepts
     for component in self.elements('input, select, textarea'):
   File /home/bob/cdmc_site/web2py/gluon/html.py, line 634, in
 elements
     subset = [self.elements(a,**kargs) for a in args]
   File /home/bob/cdmc_site/web2py/gluon/html.py, line 695, in
 elements
     child_matches = c.elements( *args,  **kargs )
   File /home/bob/cdmc_site/web2py/gluon/html.py, line 695, in
 elements
     child_matches = c.elements( *args,  **kargs )
   File /home/bob/cdmc_site/web2py/gluon/html.py, line 695, in
 elements
     child_matches = c.elements( *args,  **kargs )
   File /home/bob/cdmc_site/web2py/gluon/html.py, line 695, in
 elements
     child_matches = c.elements( *args,  **kargs )
 AttributeError: 'XML' object has no attribute 'elements'

 SOLUTION:
 add a dummy 'elements' method to gluon.html.XML(XmlComponent):

     def elements(self, *args, **kargs):
         return []

 CAVEAT:
 While this works for me, perhaps it is a bit simplistic.


[web2py] Re: delete row issue with postgre many to many relation table and Web2py

2010-07-01 Thread mdipierro


On 1 Lug, 15:34, Lennon lpru...@hotmail.com wrote:
 In my application I have a form that removes the relationship between
 two data types without deleting each piece of data.

 To do this I run a delete on the many to many relation lookup table
 that stores the relationships.

 For each of the relationships removed I run this line in web2py:

 db(db.relation_table.data_type_A_id==data_type_A_id) 
 db.relation_table.data_type_B_id==data_type_B_id)).delete()

This is odd because web2py just transpates this in the SQL below and
sends it to the server.
Something else is causing the problem.



 This seems to work in that the relationships are destroyed, but
 sometimes it doesn't delete the entire row in the relation_table, it
 sometimes only sets the entry for data_type_A_ID to Null.

 I want the entire row deleted.

 When I experimented with removing 2 or 3 rows at a time, the second
 and third row to be deleted would always be removed, but that first
 row would always set data_type_A_id to Null.

 I added some code to log all of my postgresql to see what was going on
 there and it looks right:

 DELETE FROM relation_table WHERE (table_A.data_type_A_id='X' AND
 table_B.data_type_B_id='Y');

 And when I copy and paste that directly into postgreSQL with existing
 values populated, it works fine and removes the entire row including
 the first one if I do multiples.

 But web2py always sets the first row's data_type_A_id to Null

 Any ideas?

 ~Lennon


[web2py] Re: Delete record without triggering validators?

2010-05-27 Thread Iceberg
 On May 11, 1:08 pm,Icebergiceb...@21cn.com wrote:

  Hi Massimo,

  Right now validators are triggered even when a record is successfully
  being deleted. This can be annoying in case I am deleting old records
  as below:

  db.define_table('my_table',
      Field('today', 'date',
          requires=IS_DATE_IN_RANGE(minimum=request.now.date()),
          default = request.now.date(),
          )
      )

  What if we drop all the form.errors content before line 923 in gluon/
  sqlhtml.py?
      if requested_delete:
          ..
          self.form.errors = {} # to override unnecessary error message
          return True

  Or a better way is to dodeletebefore validators are called. Can you
  do that?

  Regards,
 Iceberg


On May12, 2:18am, mdipierro mdipie...@cs.depaul.edu wrote:
 Good point! Will do.

 Massimo



Any news?


[web2py] Re: Delete record without triggering validators?

2010-05-27 Thread mdipierro
Posting a possible solution in trunk now.
in gluon/sqlhtml.py replace

if requested_delete:

return True

with

if requested_delete:

self.errors.clear()
return True

let me know if it works for you.

On May 27, 6:07 am, Iceberg iceb...@21cn.com wrote:
  On May 11, 1:08 pm,Icebergiceb...@21cn.com wrote:

   Hi Massimo,

   Right now validators are triggered even when a record is successfully
   being deleted. This can be annoying in case I am deleting old records
   as below:

   db.define_table('my_table',
       Field('today', 'date',
           requires=IS_DATE_IN_RANGE(minimum=request.now.date()),
           default = request.now.date(),
           )
       )

   What if we drop all the form.errors content before line 923 in gluon/
   sqlhtml.py?
       if requested_delete:
           ..
           self.form.errors = {} # to override unnecessary error message
           return True

   Or a better way is to dodeletebefore validators are called. Can you
   do that?

   Regards,
  Iceberg

 On May12, 2:18am, mdipierro mdipie...@cs.depaul.edu wrote:

  Good point! Will do.

  Massimo

 Any news?


[web2py] Re: Delete record without triggering validators?

2010-05-27 Thread Iceberg
   On May 11, 1:08 pm,Icebergiceb...@21cn.com wrote:

Hi Massimo,

Right now validators are triggered even when a record is successfully
being deleted. This can be annoying in case I am deleting old records
as below:

db.define_table('my_table',
    Field('today', 'date',
        requires=IS_DATE_IN_RANGE(minimum=request.now.date()),
        default = request.now.date(),
        )
    )

What if we drop all the form.errors content before line 923 in gluon/
sqlhtml.py?
    if requested_delete:
        ..
        self.form.errors = {} # to override unnecessary error message
        return True

Or a better way is to do delete before validators are called. Can you
do that?

Regards,
   Iceberg


On May27, 9:13pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Posting a possible solution in trunk now.
 in gluon/sqlhtml.py replace

         if requested_delete:
             
             return True

 with

         if requested_delete:
             
             self.errors.clear()
             return True

 let me know if it works for you.



It works as expected. Good.

On the other hand, like I said in the first post of this thread
(quoted above), a better way is to do delete before validators are
called. Right now all the real delete job are performed at line 911,
after a potential early exit at line 905, this makes me a little
nervous, will the delete operation be unintentionally bypassed in
some certain circumstance?  But after all, so far so good. So you
make the decision whether a refactor is needed here.


[web2py] Re: Delete record without triggering validators?

2010-05-27 Thread mdipierro
You are right. We can do this better but the only improvement would be
speed.

On May 27, 2:06 pm, Iceberg iceb...@21cn.com wrote:
On May 11, 1:08 pm,Icebergiceb...@21cn.com wrote:

 Hi Massimo,

 Right now validators are triggered even when a record is successfully
 being deleted. This can be annoying in case I am deleting old records
 as below:

 db.define_table('my_table',
     Field('today', 'date',
         requires=IS_DATE_IN_RANGE(minimum=request.now.date()),
         default = request.now.date(),
         )
     )

 What if we drop all the form.errors content before line 923 in gluon/
 sqlhtml.py?
     if requested_delete:
         ..
         self.form.errors = {} # to override unnecessary error message
         return True

 Or a better way is to do delete before validators are called. Can you
 do that?

 Regards,
Iceberg

 On May27, 9:13pm, mdipierro mdipie...@cs.depaul.edu wrote:



  Posting a possible solution in trunk now.
  in gluon/sqlhtml.py replace

          if requested_delete:
              
              return True

  with

          if requested_delete:
              
              self.errors.clear()
              return True

  let me know if it works for you.

 It works as expected. Good.

 On the other hand, like I said in the first post of this thread
 (quoted above), a better way is to do delete before validators are
 called. Right now all the real delete job are performed at line 911,
 after a potential early exit at line 905, this makes me a little
 nervous, will the delete operation be unintentionally bypassed in
 some certain circumstance?  But after all, so far so good. So you
 make the decision whether a refactor is needed here.


[web2py] Re: Delete record without triggering validators?

2010-05-11 Thread mdipierro
Good point! Will do.

Massimo

On May 11, 1:08 pm, Iceberg iceb...@21cn.com wrote:
 Hi Massimo,

 Right now validators are triggered even when a record is successfully
 being deleted. This can be annoying in case I am deleting old records
 as below:

 db.define_table('my_table',
     Field('today', 'date',
         requires=IS_DATE_IN_RANGE(minimum=request.now.date()),
         default = request.now.date(),
         )
     )

 What if we drop all the form.errors content before line 923 in gluon/
 sqlhtml.py?
     if requested_delete:
         ..
         self.form.errors = {} # to override unnecessary error message
         return True

 Or a better way is to do delete before validators are called. Can you
 do that?

 Regards,
 Iceberg


[web2py] Re: delete database entry by form

2010-04-19 Thread mdipierro
This would delete all posts by current user for example:

db(db.posts.author==auth.user_id).delete()

On Apr 19, 7:12 pm, claudio grossep...@googlemail.com wrote:
 I have a newbie question: How can I create a form to delete selected
 entries from a database? Can I use SQLFORM for this?

 I have tables roughly like this in db.py

 db.define_table('person',
 Field('name'))

 db.define_table('posts',
 Field('title'),
 Field('author',db.person))

 and in default.py a function that should create the form and then
 delete the picked entry
 def delEntry:

 form=SQLFORM((db.posts.author==session.authorized).select(),fields=['posts'])

 --
 Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: delete database entry by form

2010-04-19 Thread Mengu
SQLFORM has an argument called deletable if you set it to True when
you initialize it, you will have an option like delete this record.
and when you submit the form with that option checked then the record
will be deleted.

On 20 Nisan, 03:12, claudio grossep...@googlemail.com wrote:
 I have a newbie question: How can I create a form to delete selected
 entries from a database? Can I use SQLFORM for this?

 I have tables roughly like this in db.py

 db.define_table('person',
 Field('name'))

 db.define_table('posts',
 Field('title'),
 Field('author',db.person))

 and in default.py a function that should create the form and then
 delete the picked entry
 def delEntry:

 form=SQLFORM((db.posts.author==session.authorized).select(),fields=['posts' ])

 --
 Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py:/] Re: Delete

2009-06-14 Thread pk

a projectfile should reference a project, but a project can have many
projectfiles


On 14 Jun., 23:37, mdipierro mdipie...@cs.depaul.edu wrote:
 shouldn't there be a file in projectfile that references a project? Or
 can a projectfile belong to multiple projects?

 On Jun 14, 4:13 pm, pk peter.kirch...@youngdesigners.de wrote:

  yeah,
  sorry i think i pressed my self not good enough, when youser delete a
  project from the table project
  then i need a command to delete the accordant file record from the
  table file

  thanks

  On 14 Jun., 23:02, mdipierro mdipie...@cs.depaul.edu wrote:

   this has been default behavior for some time. Have you checked it?
   Does it not work?

   Massimo

   On Jun 14, 11:50 am, pk peter.kirch...@youngdesigners.de wrote:

Hi together,

i have a question. i have a talbe project and there i can delete
without any problems.
i have another table calls projectfile. here is my model:

#
## Tabelle File
#
db.define_table('projectfile',
                SQLField('userid', default=auth.user.id if auth.user
else 0, writable=False, readable=False),
                SQLField('procreator', default=auth.user.last_name if
auth.user else 0, writable=False, readable=False),
                SQLField('projectname'),
                SQLField('filename'),
                SQLField('format'),
                SQLField('cdate', 'date', default=now),
                SQLField('datei','upload'),
                SQLField('description','text'))

if auth.is_logged_in():
    db.projectfile.projectname.requires=IS_IN_DB(db
(db.project.userid==auth.user.id),'project.pname','%(pname)s')
db.projectfile.procreator.requires=IS_IN_DB(db,'auth_user.last_name')
db.projectfile.userid.requires=IS_IN_DB(db,'auth_user.id')
db.projectfile.filename.requires=[IS_NOT_EMPTY()]
db.projectfile.format.requires=[IS_NOT_EMPTY()]
db.projectfile.cdate.requires=[IS_NOT_EMPTY(), IS_DATE()]
db.projectfile.datei.requires=IS_NOT_EMPTY()

how can i now delete automaticly the file which belong to the project.

here my def:

def deletepro():
    if auth.is_logged_in():
        db(db.project.id==request.args[0]).delete()
        redirect(URL(r=request, f='project'))
    redirect(URL(r=request,c='default/user',f='login'))

thanks for your help


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---