[web2py] SQLFORM.grid oncreate Issue

2013-10-16 Thread Christian Espinoza
Hi guys, 
I'm using 2.6.4-stable+timestamp.2013.09.22.01.43.37 and I trying to log at 
db every new record
created with SQLFORM.grid:

My controller:

def bodies(): 
grid = SQLFORM.grid(db.bodies, orderby=~db.bodies.id, oncreate=
log_action('System','Created new body'))
return dict(grid=grid)



my function log_action:

def log_action(origin, description):
db.auth_event.insert(time_stamp=request.now, 
client_ip=request.env.remote_addr,
user_id=auth.user.id, 
origin=origin, 
description=description)



It's worked, but not as expected, I get four logs(four new records at 
auth_event) when I add a only new record..
where is the problem?
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/groups/opt_out.


Re: [web2py] pass a arbitrary html attributes with helpers (bootstrap data-toggle with A() for example)

2013-06-14 Thread Christian Espinoza
This was very useful to me too, Thanks.

-- 

--- 
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: MYSQL SQL Query to DAL

2013-05-21 Thread Christian Espinoza
The problem now is how use that dal query into:

IS_IN_DB(query,db.phone_line.id, '%(phone_number)s')

Because a query object doesn't have a select attribute... :-/

-- 

--- 
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: MYSQL SQL Query to DAL

2013-05-21 Thread Christian Espinoza
Well, so far, I think I've get a DAL query that works like the second SQL 
query(LEFT OUTER JOIN based):

db(db.simcard.phone_line==None).select(db.phone_line.ALL, db.simcard.ALL,
left=db.simcard.on((db.simcard.phone_line==db.phone_line.id)))

I wil trying to solve the main problem with the dropdown select.

Cheers!

-- 

--- 
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] MYSQL SQL Query to DAL

2013-05-20 Thread Christian Espinoza
Hi guys, please could somebody help me?

from my tables:

db.define_table('phone_line',
Field('tel_plan',db.tel_plan),
Field('phone_number',length=30),
signature, format='%(phone_number)s'
)

db.define_table('simcard',
Field('serial',length=100, label='Serial', notnull=True, unique=
True),
Field('phone_line', db.phone_line, unique=True),
Field('contract_date', 'date'),
signature, format='%(serial)s'
)


I'm getting the dropdown select, but I need filter phone_line's that was 
assigned to existing simcards, then I have this requires:

db.simcard.phone_line.requires = IS_IN_DB(query,db.phone_line.id, 
'%(phone_number)s')

and the only query that I have working now to show the available 
line_phone's is in two SQL versions, but I have problems to translate it to 
a DAL version:

query1 ="""SELECT *
FROM db_base.phone_line p
WHERE NOT EXISTS(SELECT s.id
 FROM db_base.simcard s
 WHERE s.phone_line = p.id)"""

 
query1 = """SELECT *
FROM db_base.phone_line p
 LEFT OUTER JOIN db_base.simcard s ON s.phone_line = p.id
WHERE s.phone_line IS NULL"""


How can I get it?

Thanks and Greetings.
Christian.

-- 

--- 
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: Dynamic login_next view

2013-05-02 Thread Christian Espinoza
Thanks Anthony, it was ver useful!


2013/5/2 Anthony 

> Since you won't know the user's name until after they log in, you should
> instead do:
>
> auth.settings.login_onaccept = lambda user: user.first_name == 'admin' 
> andredirect
> (URL('admin', 'system'))
>
> Anthony
>
> On Thursday, May 2, 2013 12:54:34 PM UTC-4, Christian Espinoza wrote:
>>
>> Hi guys,
>> I'm trying to do a different 'first view' for a admin user, and for this,
>> I was modified my db.py file on this way:
>>
>> if auth.user.first_name == 'admin':
>> auth.settings.login_next = URL('admin', 'system')
>> else:
>> auth.settings.login_next = URL('mainboard', 'index')
>>
>> But seems that on that point the user doesn't exist yet, how can achieve
>> it?
>>
>> Thanks in advance.
>> Christian.
>>
>> Error:
>> Error ticket for "avl"Ticket ID
>>
>> 127.0.0.1.2013-05-02.12-47-26.**3706ee73-470f-4dd6-bcde-**8a400366785c
>>  'NoneType' object has no attribute
>> 'first_name'Versiónweb2py™Version 2.4.6-stable+timestamp.2013.**
>> 04.21.19.50.11PythonPython 2.7.3: /usr/bin/python (prefix: /usr)Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>>
>> Traceback (most recent call last):
>>   File "/home/www-data/web2py/gluon/**restricted.py", line 212, in restricted
>> exec ccode in environment
>>   File "/home/www-data/web2py/**applications/avl/models/db.py" 
>> <https://127.0.0.1/admin/edit/avl/models/db.py>**, line 72, in 
>> if auth.user.first_name == 'admin':
>> AttributeError: 'NoneType' object has no attribute 'first_name'
>>
>> Error snapshot [image: 
>> help]<https://127.0.0.1/admin/default/ticket/avl/127.0.0.1.2013-05-02.12-47-26.3706ee73-470f-4dd6-bcde-8a400366785c#>
>>
>> ('**NoneType' object has no attribute
>> 'first_name')
>>
>>
>>  --
>
> ---
> 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/eLRKQzv3wd0/unsubscribe?hl=en.
> 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] Dynamic login_next view

2013-05-02 Thread Christian Espinoza
Hi guys, 
I'm trying to do a different 'first view' for a admin user, and for this, I 
was modified my db.py file on this way:

if auth.user.first_name == 'admin':
auth.settings.login_next = URL('admin', 'system')
else:
auth.settings.login_next = URL('mainboard', 'index')

But seems that on that point the user doesn't exist yet, how can achieve it?

Thanks in advance.
Christian.

Error:
Error ticket for "avl"Ticket ID

127.0.0.1.2013-05-02.12-47-26.3706ee73-470f-4dd6-bcde-8a400366785c
 'NoneType' object has no attribute 
'first_name'Versiónweb2py™Version 2.4.6-stable+timestamp.2013.04.21.19.50.11
PythonPython 2.7.3: /usr/bin/python (prefix: /usr)Traceback

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

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
  File "/home/www-data/web2py/applications/avl/models/db.py" 
, line 72, in 
if auth.user.first_name == 'admin':
AttributeError: 'NoneType' object has no attribute 'first_name'

Error snapshot [image: 
help]

('NoneType' object has no attribute 
'first_name')


-- 

--- 
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: Jquery mobile module not working

2013-04-29 Thread Christian Espinoza
I have the same Problem..

El martes, 2 de abril de 2013 17:07:35 UTC-3, Torvald Baade Bringsvor 
escribió:
>
> Hi
>
> I'm trying out the jquery mobile plugin for web2py (2.4.5) and I'm having 
> no success. When I load the page (both on mobile device and desktop) I get 
> a blank page.
>
> When I look at the JavaScript console I get this error:
>
> Uncaught Error: Syntax error, unrecognized expression: [data-role='none'], 
> [data-role='nojs'], [object Object] 
>
> I'm not a JavaScript expert (or Jquery for that matter) so I'm a bit stuck 
> here. The other views (regular desktop version) of the application are 
> working as intended.
>
> I had to change the reference to modernizr in the Jquery mobile plugin 
> layout.html file to point to modernizr.custom.js in stead of the default 
> version 1.6 (which isn't included).
>
> I see that my menu is rendered in the html:
>
>
>
>  data-position="fixed">
> [...]
>
>   
>   
>
> 
> 
>   Main Menu
>
>   Hjem
> [...]
>
> I see one strange thing, the page doesn't seem to have a  starttag, 
> just the end tag. Instead it has this:
>
>
>
>  
> 
> 
> 
> 
>   
>
> Is that a problem too?
>
> -Torvald
>
>
>
>

-- 

--- 
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: getting data from query with SQLFORM.grid

2013-04-25 Thread Christian Espinoza
Hi Massimo, I'm wondering how apply this change, I tried with the last
version, but isn't work yet,
I thought that was implemented in gluon\sqlhtml.py line 2242...

I'm trying to call it on this way:

grid = SQLFORM.grid()

return dict(form=form, grid=grid, license_plate=license_plate,
summary=show_summary(summary), help=help, rows=grid.rows)

but I got this error:

Versión

web2py™Version 2.4.6-stable+timestamp.2013.04.21.19.50.11
PythonPython 2.7.3: /usr/bin/python (prefix: /usr)

Traceback

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
  File "/home/www-data/web2py/applications/avl/controllers/reports.py",
line 426, in 
  File "/home/www-data/web2py/gluon/globals.py", line 194, in 
self._caller = lambda f: f()
  File "/home/www-data/web2py/applications/avl/controllers/reports.py",
line 336, in events
return dict(form=form, grid=grid, license_plate=license_plate,
summary=show_summary(summary), help=help, rows=grid.rows)
AttributeError: 'DIV' object has no attribute 'rows'

Error snapshot

('DIV' object has no attribute 'rows')

Thanks for your time.
Christian.

2013/4/9 Massimo Di Pierro :
> h... looks like the rows are not stored. I can easily change and allow
> you to do:
>
>
> grid = SQLFORM.grid(...)
> grid.rows = 
>
> it would contain the records you see on the page only. Would this be ok?
> Pros/Cons?
>
>
> On Tuesday, 9 April 2013 10:12:57 UTC-5, Christian Espinoza wrote:
>>
>> Hi Massimo, I'm rendering a grid in a view and I'm need add a graph to it,
>> maybe using flot js lib
>> the graph will need the same grid data, and I'm wondering how get the row
>> data without running a query only for the graphs
>> and taking advantage from the raw data used by SQLFORM.grid()...
>>
>> Christian.
>>
>>
>>
>>
>> El martes, 9 de abril de 2013 11:14:50 UTC-3, Massimo Di Pierro escribió:
>>>
>>> I do not understand the question. :-(
>>>
>>> On Tuesday, 9 April 2013 08:38:48 UTC-5, Christian Espinoza wrote:
>>>>
>>>> Hi guys, I'm answering how can I take advantage from SQLFORM.grid in
>>>> order to get aditionally the data from the query
>>>> something like:
>>>>
>>>> SQLFORM.grid():
>>>> .
>>>> .
>>>> return (htmlcode, rawrows)
>>>>
>>>>
>>>>  grid, rows = SQLFORM.grid(query,fields=campos,
>>>>  editable=False,
>>>>  searchable=False,
>>>>  deletable=False,
>>>>  create=False,
>>>>  details=False,
>>>>  user_signature=False,
>>>>  orderby=db_events.events.event_datetime
>>>>  )
>>>>
>>>> There are something working like that?
>>>>
>>>> Thanks in advance.
>>>> Christian.
>
> --
>
> ---
> 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/Q6bEe_rscFw/unsubscribe?hl=en.
> 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: How hide comments column (w2p_fc) from SQLFORM.grid() when edit some record

2013-04-25 Thread Christian Espinoza

Thanks Mark!

-- 

--- 
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: time field format doesn't work when edit

2013-04-23 Thread Christian Espinoza
Thanks Anthony, your answer get me the right direction for my solve my 
issue.

Christian.

-- 

--- 
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] time field format doesn't work when edit

2013-04-22 Thread Christian Espinoza
Hi, I have this table definition:


db.define_table('timetable',
Field('customer', db.customer, label='Cliente'),
Field('name', length=160, label='Nombre'), 
Field('start', 'time', label='Inicio' ),
Field('finish', 'time', label='Final' ),
signature
)
db.timetable.start.represent = lambda value, row: value.strftime("%H:%M")


and the represent function works only when the field is on view mode, but 
when I edit it on the html input
the data have this format: 12:00:00 and I don't want see the seconds..

What is happens? I missed something? 
I'm working with mysql..

Greetings.
Christian.

-- 

--- 
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] How hide comments column (w2p_fc) from SQLFORM.grid() when edit some record

2013-04-22 Thread Christian Espinoza
Hi guys, somebody know how hide the comments column at a edit form using 
SQLFORM.grid() ??

I can do it using jquery with:

$("tr td:nth-child(3)").each(function(){this.remove()});

But 'm finding a server side(controllers maybe) way to do it..
 


Id: 1
Cliente: 
Intsercom Ltda

Nombre: 
Velocidad Maxima: 
Marque para eliminar: 




Thanks in advance.
Christian.

-- 

--- 
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: getting data from query with SQLFORM.grid

2013-04-09 Thread Christian Espinoza
I think it will be a nice feature, would save have to querying the database
twice when was required

Christian.


2013/4/9 Massimo Di Pierro 

> h... looks like the rows are not stored. I can easily change and allow
> you to do:
>
>
> grid = SQLFORM.grid(...)
> grid.rows = 
>
> it would contain the records you see on the page only. Would this be ok?
> Pros/Cons?
>
>
> On Tuesday, 9 April 2013 10:12:57 UTC-5, Christian Espinoza wrote:
>>
>> Hi Massimo, I'm rendering a grid in a view and I'm need add a graph to
>> it, maybe using flot js lib
>> the graph will need the same grid data, and I'm wondering how get the row
>> data without running a query only for the graphs
>> and taking advantage from the raw data used by SQLFORM.grid()...
>>
>> Christian.
>>
>>
>>
>>
>> El martes, 9 de abril de 2013 11:14:50 UTC-3, Massimo Di Pierro escribió:
>>>
>>> I do not understand the question. :-(
>>>
>>> On Tuesday, 9 April 2013 08:38:48 UTC-5, Christian Espinoza wrote:
>>>>
>>>> Hi guys, I'm answering how can I take advantage from SQLFORM.grid in
>>>> order to get aditionally the data from the query
>>>> something like:
>>>>
>>>> SQLFORM.grid():
>>>> .
>>>> .
>>>> return (htmlcode, rawrows)
>>>>
>>>>
>>>>  grid, rows = SQLFORM.grid(query,fields=camp**os,
>>>>  editable=False,
>>>>  searchable=False,
>>>>  deletable=False,
>>>>  create=False,
>>>>  details=False,
>>>>  user_signature=False,
>>>>  orderby=db_events.events.even**t_datetime
>>>>  )
>>>>
>>>> There are something working like that?
>>>>
>>>> Thanks in advance.
>>>> Christian.
>>>>
>>>  --
>
> ---
> 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/Q6bEe_rscFw/unsubscribe?hl=en.
> 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: getting data from query with SQLFORM.grid

2013-04-09 Thread Christian Espinoza
Hi Massimo, I'm rendering a grid in a view and I'm need add a graph to it, 
maybe using flot js lib
the graph will need the same grid data, and I'm wondering how get the row 
data without running a query only for the graphs
and taking advantage from the raw data used by SQLFORM.grid()...

Christian.




El martes, 9 de abril de 2013 11:14:50 UTC-3, Massimo Di Pierro escribió:
>
> I do not understand the question. :-(
>
> On Tuesday, 9 April 2013 08:38:48 UTC-5, Christian Espinoza wrote:
>>
>> Hi guys, I'm answering how can I take advantage from SQLFORM.grid in 
>> order to get aditionally the data from the query 
>> something like: 
>>
>> SQLFORM.grid():
>> .
>> .
>> return (htmlcode, rawrows)
>>
>>
>>  grid, rows = SQLFORM.grid(query,fields=campos,
>>  editable=False,
>>  searchable=False,
>>  deletable=False,
>>  create=False,
>>  details=False,
>>  user_signature=False,
>>  orderby=db_events.events.event_datetime
>>  )
>>
>> There are something working like that?
>>
>> Thanks in advance.
>> Christian.
>>
>

-- 

--- 
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] getting data from query with SQLFORM.grid

2013-04-09 Thread Christian Espinoza
Hi guys, I'm answering how can I take advantage from SQLFORM.grid in order 
to get aditionally the data from the query 
something like: 

SQLFORM.grid():
.
.
return (htmlcode, rawrows)


 grid, rows = SQLFORM.grid(query,fields=campos,
 editable=False,
 searchable=False,
 deletable=False,
 create=False,
 details=False,
 user_signature=False,
 orderby=db_events.events.event_datetime
 )

There are something working like that?

Thanks in advance.
Christian.

-- 

--- 
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: Extend SQLFORM.grid Action Button functionality

2013-03-01 Thread Christian Espinoza
Thanks a lot Nihplod, all is working as expected now!!!

-- 

--- 
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: Extend SQLFORM.grid Action Button functionality

2013-03-01 Thread Christian Espinoza
Wow, Thanks Niphlod!,this code worked like a charm!

Additionally how can I append this code: 

jQuery(this).closest('tr').remove();

to the callback?

Thanks again for your time!
Christian.

El viernes, 1 de marzo de 2013 12:31:54 UTC-3, Niphlod escribió:
>
> disclaimer: not tested: in a controller, prepare a function
>
> def check_to_true():
> if not request.args(0):
> return ''
> db_events.alerts(request.args(0)).update_record(checked=1)
>
> and then pass links in the grid as
> links = [
> dict(header='check the rec', 
>body=lambda row : A('check', _class='btn', _href='#', callback=
> URL('check_to_true', args=row.id))
>   )]
>
>
> This should create a clickable button that calls your function and sets 
> the checked to true without leaving the page holding the grid (ajax). 
> If you need to refresh the values also on the grid page, than a full 
> refresh of the page is needed, so remove the callback argument, use that 
> url in the href and put a redirect(URL('function_showing_the_grid')) at the 
> end of the "check_to_true" function.
>
> On Friday, March 1, 2013 4:08:05 PM UTC+1, Christian Espinoza wrote:
>>
>> Hi guys, I want to add a action button(like delete,edit, view, i/e) at 
>> the grid, something to change a value from the record indicated at the line,
>> this is my table:
>>
>> db_events.define_table('alerts',
>> Field('type', length=20, label='Clase' ),
>> Field('rule', label='Regla'),
>> Field('value', length=30, label='Valor'),
>> Field('detail', label='Detalle'),
>> Field('coords', length=20, label='Coordenadas'),
>> Field('checked', 'integer', label='Chequeada', default=0 ),# 
>> 1 to checked
>> Field('created_on', 'datetime', label='Recibida', default=
>> request.now)
>> )
>>
>> The idea is have a button to check the alert, I mean: will be put a 1 at 
>> "checked" field of the record when the button will be clicked
>>
>> Thanks for your time and support!
>> Christian.
>>
>>

-- 

--- 
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] Extend SQLFORM.grid Action Button functionality

2013-03-01 Thread Christian Espinoza
Hi guys, I want to add a action button(like delete,edit, view, i/e) at the 
grid, something to change a value from the record indicated at the line,
this is my table:

db_events.define_table('alerts',
Field('type', length=20, label='Clase' ),
Field('rule', label='Regla'),
Field('value', length=30, label='Valor'),
Field('detail', label='Detalle'),
Field('coords', length=20, label='Coordenadas'),
Field('checked', 'integer', label='Chequeada', default=0 ),# 1 
to checked
Field('created_on', 'datetime', label='Recibida', default=
request.now)
)

The idea is have a button to check the alert, I mean: will be put a 1 at 
"checked" field of the record when the button will be clicked

Thanks for your time and support!
Christian.

-- 

--- 
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: Validate some condition to insert using SQLForm.grid()

2013-02-22 Thread Christian Espinoza
Thanks guys, I'll try with it..

El viernes, 22 de febrero de 2013 10:28:27 UTC-3, Jim S escribió:
>
> You have a couple different options.
>
> 1.  Custom validators (not as scary as they sound) - 
> http://web2py.com/books/default/chapter/29/07#Custom-validators
> 2.  Before and after callbacks - 
> http://web2py.com/books/default/chapter/29/06#before-and-after-callbacks
>
> That should get the job done.
>
> -Jim
>
> On Friday, February 22, 2013 7:22:06 AM UTC-6, Christian Espinoza wrote:
>>
>> Hi guys, there a way to validate some condition before run the insert of 
>> a new record using SQLForm.grid() ?
>>
>> For example if I need insert a record, but a rule ( a value at the db, a 
>> constant) said that the records must be
>> only < 5 and I have already 4 records, then the insert can't be run...
>>
>> Thanks for your time.
>> Cheers
>> Christian.
>>
>

-- 

--- 
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] Validate some condition to insert using SQLForm.grid()

2013-02-22 Thread Christian Espinoza
Hi guys, there a way to validate some condition before run the insert of a 
new record using SQLForm.grid() ?

For example if I need insert a record, but a rule ( a value at the db, a 
constant) said that the records must be
only < 5 and I have already 4 records, then the insert can't be run...

Thanks for your time.
Cheers
Christian.

-- 

--- 
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: Improve this code about ( sql query, dict creation for json service)

2013-02-19 Thread Christian Espinoza
I'm using this query with executesql(), Thanks to all for the support!!

El sábado, 16 de febrero de 2013 15:23:00 UTC-3, Niphlod escribió:
>
> neither let's leave alone event('name') that isn't in the table.
> that query returns the event id for each device_id in the events table, 
> and attaches to it brand and location from the devices table. additionally, 
> it appends the date to it.
>
> the only way to retrieve that set in one query is
>
> select a.id, a.date, b.brand, b.location from events a, devices b
> where 
> a.device_id = b.id
> and a.id in (
> select max(id) from events
> group by device_id
> )
>
>
>
>
>

-- 

--- 
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] @service json and db.executesql

2013-02-19 Thread Christian Espinoza
Hi guys, for this json service I'm using simplejson implicitly because the 
result of db.executesql
isn't serialized automatically by decorator, is this the normal behavior 
for db.executesql or something I'm missed here?
 
@auth.requires_login()
@service.json
def test_trackers():
dthandler = lambda obj: obj.strftime('%d-%m-%Y %H:%M:%S') if isinstance(
obj, datetime.datetime) else None
if auth.user_id == 1:
events = db.executesql(GET_EVENT_ALL, as_dict=True)
else:
if session.customer_id:
rows = db.executesql(GET_EVENT_BY_CUS % 
(session.customer_id),as_dict
=True)
events = simplejson.dumps(rows, default=dthandler)
 
return events

Error without using simplejson: Error 321 
(net::ERR_INVALID_CHUNKED_ENCODING): Unknown Error 

Greetings
Christian.

-- 

--- 
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: Querying values from two databases using Dal

2013-02-18 Thread Christian Espinoza
Yeah, it worked!!!:

query = """SELECT *FROM db_alerts.alerts, db_app.trucks
WHERE db_app.trucks.customer_id = 1
AND db_alerts.alerts.truck_lic = db_app.trucks.lic
ORDER BY db_alerts.alerts.id DESC LIMIT 1"""


db_app.executesql(query)

Thanks Niphlod !!
Christian.

El lunes, 18 de febrero de 2013 13:34:01 UTC-3, Niphlod escribió:
>
> DAL can't do cross database queries, unless you use executesql.
>
> On Monday, February 18, 2013 5:27:38 PM UTC+1, Christian Espinoza wrote:
>>
>> Hi all, I'm need get the last alert(a table record) from db_alerts 
>> database for every customer's truck,
>> but I'm can't get it, I'm using MYSQL.
>>
>> Table trucks at db_base:
>> db_app.define_table('trucks',
>> Field('customer_id', db_app.customers),
>> Field('lic', length=10),
>> Field('cap', 'integer'),
>> Field('vendor' db_app.vendor),
>> format='%(lic)s'
>> )
>>
>> Table alerts at db_alerts:
>> db_alerts.define_table('alerts',
>> Field('truck_lic', length=10),
>> Field('name', length=20),
>> Field('location', length=30),
>> Field('description', length=100),
>> Field('date', datetime)
>> )
>>
>>
>>  WORKING MYSQL QUERY:
>>
>> SELECT *
>> FROM db_alerts.alerts, db_app.trucks
>> WHERE db_app.trucks.customer_id = 1
>> AND db_alerts.alerts.truck_lic = db_app.trucks.lic
>> ORDER BY db_alerts.alerts.id DESC LIMIT 1
>>
>> Using Dal
>>
>> query = (db_app.trucks.customer_id ==1) & (db <http://db.tracker.id/>_app
>> .trucks.lic == db_alerts.alerts.truck_lic)
>>
>>
>>
>> The second query is the problem, how can I run it??
>>
>> Thanks guys for your time and support.
>> Greetings.
>> Christian.
>>
>>

-- 

--- 
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] Querying values from two databases using Dal

2013-02-18 Thread Christian Espinoza
Hi all, I'm need get the last alert(a table record) from db_alerts database 
for every customer's truck,
but I'm can't get it, I'm using MYSQL.

Table trucks at db_base:
db_app.define_table('trucks',
Field('customer_id', db_app.customers),
Field('lic', length=10),
Field('cap', 'integer'),
Field('vendor' db_app.vendor),
format='%(lic)s'
)

Table alerts at db_alerts:
db_alerts.define_table('alerts',
Field('truck_lic', length=10),
Field('name', length=20),
Field('location', length=30),
Field('description', length=100),
Field('date', datetime)
)


 WORKING MYSQL QUERY:

SELECT *
FROM db_alerts.alerts, db_app.trucks
WHERE db_app.trucks.customer_id = 1
AND db_alerts.alerts.truck_lic = db_app.trucks.lic
ORDER BY db_alerts.alerts.id DESC LIMIT 1

Using Dal

query = (db_app.trucks.customer_id ==1) & (db _app.
trucks.lic == db_alerts.alerts.truck_lic)



The second query is the problem, how can I run it??

Thanks guys for your time and support.
Greetings.
Christian.

-- 

--- 
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] Improve this code about ( sql query, dict creation for json service)

2013-02-15 Thread Christian Espinoza
Hi all!, could somebody get me a hand in order to improve this code, please?
I'm getting a array of dicts here, every device have it last event attached 
in the dict...

I'm want delete the iteration over the events table, I don't think it is 
efficient enough
maybe it could be changed doing a better query, joining the event and 
device tables in a sql view...
on this way I can get a row.as_dict directly


db.define_table('devices',
Field('serial'),
Field('brand'),
Field('location'),
format='%(serial)s'
)

db.define_table('events',
Field('device_id'),
Field('date', datetime),
Field('location'),
format='%(device_id)s'
)


@service.json
events_service():
events = {} 
devices = db(db.devices).select()
for dev in devices:
event = db(db.events.device_id == dev.id).select().last()
events[dev.id] = {
 'name':event('name'),
 'date':event('date'),
 'brand':dev.brand,
 'location':dev.location }
return events


Thanks in advance.
Christian.

-- 

--- 
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: .update_or_insert not optimized!!

2013-01-29 Thread Christian Espinoza
Hi all, I'm wondering about if .update_or_insert was enhanced or not yet?

Thanks in advance.
Christian.

El jueves, 3 de mayo de 2012 09:46:46 UTC-4, Anthony escribió:
>
> You're manual version updates only two fields, whereas update_or_insert 
>>> updates six fields -- maybe that's the difference.
>>>
>>> Anthony 
>>>
>>
>> Yes, but I want to insert a new record with six fields, but update only 
>> two if the record exists. How to do that with .update_or_insert?
>>
>
> Looks like you can't. Might be a nice enhancement, though. Maybe it could 
> take "_insert_fields" and "_update_fields" arguments, which could be lists 
> of field names to insert and update, respectively.
>
> Anthony 
>

-- 

--- 
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] Form with fields collected from javascript

2013-01-22 Thread Christian Espinoza
Hi Bruno, now my form at the view is:

{{=form.custom.begin}}
Name: {{=form.custom.widget.name}}



{{=form.custom.submit}}
{{=form.custom.end}}

I'm was testing a lot of times a insert with it, and every first time I'm 
login to app
this form doesn't insert the data and nothing else shows, after that all 
works fine, only the first time fails...
I can insert 30 times after the first time without problems..

I was checking the javascript data and all times the data is collected very 
well
My controller now is :
def fences():
form = SQLFORM(db.fences)
if form:
if form.process().accepted:
response.flash = 'Datos Ingresados'
else:
#response.flash = form.vars
  response.flash = form.errors
return(form=form))
 
I tried to debug, but at the last web2py trunk version the debugger doesn't 
work very well

Thanks in advance.
Christian.

El lunes, 21 de enero de 2013 17:12:38 UTC-3, rochacbruno escribió:
>
> SQLFORM expects a field named "fences_customer" the pattern is 
> tablename_fieldname
>

-- 





Re: [web2py] Form with fields collected from javascript

2013-01-21 Thread Christian Espinoza
Weird, because I'm noted that the first save process doesn't work, but from 
the second all work fine :-/
and I'm have the same code without changes...
I'm have the trunk version.. 

El lunes, 21 de enero de 2013 17:12:38 UTC-3, rochacbruno escribió:
>
> SQLFORM expects a field named "fences_customer" the pattern is 
> tablename_fieldname
>

-- 





Re: [web2py] Form with fields collected from javascript

2013-01-21 Thread Christian Espinoza
Hi Bruno 
I have on this way the code now at the view:

{{=form.custom.begin}}
Name: {{=form.custom.widget.name}}



{{=form.custom.submit}}
{{=form.custom.end}}

and I getting the values for every input ok, but SQLForm doesn't store 
nothing at the db...

Thanks
Christian.



El lunes, 21 de enero de 2013 15:03:55 UTC-3, rochacbruno escribió:
>
> include hidden fields
>
> 
>
> the use Javascript to populate
>
> $('#customer').val("something")
>

-- 





[web2py] Form with fields collected from javascript

2013-01-21 Thread Christian Espinoza
Hello!! I have a Form for this table, but I'm only want to get the 'name' 
field from the user input.
the other fields I need fill them from javascript vars...

Model:
db.define_table('fences',
Field('customer', db.customer, label='Cliente', notnull=True),
Field('name', length=160, label='Nombre', notnull=True), 
Field('type', length=12, label='Tipo', notnull=True),
Field('definition', length=120, notnull=True),
signature
)
Controller:

def fences():
return(form=SQLFORM(db.fences).process())

View:


var get_type;
var definition = [];


{{=form.custom.begin}}
Name: {{=form.custom.widget.name}}
{{=form.custom.submit}}
{{=form.custom.end}}

The customer field I need collect from my function: 
get_customer_id(auth.user.id)

Thanks in advance.
Christian.

-- 





Re: [web2py] Re: Edit or delete not committing in sqlform.grid for custom query

2013-01-11 Thread Christian Espinoza
Thanks Niphlod, I get the trunk with this feature working done now!

Christian.

El viernes, 11 de enero de 2013 10:45:55 UTC-3, Niphlod escribió:
>
> the problem has been fixed in trunk. The issue was *kinda non-existant*for 
> javascript enabled browsers, because there was an onclick attribute on 
> the delete button that called the delete url correctly.
>
> Now there are both the full link to the delete url and the onclick 
> attribute, so behaviour is consistent both in javascript-enabled and 
> javascript-disabled browsers.
>
> Il giorno venerdì 11 gennaio 2013 14:24:46 UTC+1, Christian Espinoza ha 
> scritto:
>>
>> This Problem is currently active in 2.3.2 
>>
>> There is something with the link for delete action at generation of grid 
>> code:
>>
>> With 2.2.1
>>
>> View->http://127.0.0.1:8000/webapp/admin/users/view/auth_user/6?_signature=d408cbb7bcbce4ec22a9089465dcefc7f1f2a5db
>> Edit- 
>> <http://127.0.0.1:8000/webapp/admin/users/view/auth_user/6?_signature=d408cbb7bcbce4ec22a9089465dcefc7f1f2a5dbEdit->>http://127.0.0.1:8000/webapp/admin/users/edit/auth_user/6?_signature=a688c63924538f53fdf0da2630790d780204403d
>> Delete- 
>> <http://127.0.0.1:8000/webapp/admin/users/edit/auth_user/6?_signature=a688c63924538f53fdf0da2630790d780204403dDelete->>http://127.0.0.1:8000/webapp/admin/users?_signature=ca13c286893cff85c6916ff7723d3f0cd8e24c56#null
>>
>> With 2.3.2
>>
>> View->http://127.0.0.1:8000/webapp/admin/users/view/auth_user/6?_signature=d408cbb7bcbce4ec22a9089465dcefc7f1f2a5db
>>
>> Edit->http://127.0.0.1:8000/webapp/admin/users/edit/auth_user/6?_signature=a688c63924538f53fdf0da2630790d780204403d
>>
>> Delete->http://127.0.0.1:8000/avl/admin/users#null
>>
>> As you can see the Delete option link doesn't point to any function at both 
>> versions
>>
>>
>> Christian.
>>
>>
>> El miércoles, 26 de diciembre de 2012 20:48:21 UTC-3, Massimo Di Pierro 
>> escribió:
>>>
>>> Can you please open a ticket about this?
>>>
>>> On Wednesday, 26 December 2012 13:40:15 UTC-6, BJ wrote:
>>>>
>>>> The problem is in sqlhtml.py
>>>>
>>>> In latest version from line 2293-2297 is following content:
>>>>
>>>> if deletable and (not callable(deletable) or deletable(row)):
>>>> row_buttons.append(gridbutton(
>>>> 'buttondelete', 'Delete',
>>>> callback=url(args=['delete', tablename, id
>>>> ]),
>>>> delete='tr'))
>>>>
>>>> but it should be:
>>>>
>>>> if deletable and (not callable(deletable) or deletable(row)):
>>>> row_buttons.append(gridbutton(
>>>> 'buttondelete', 'Delete',
>>>> buttonurl=url(args=['delete', tablename, 
>>>> id]), <--- Missing line to define URL for Delete button
>>>> callback=url(args=['delete', tablename, 
>>>> id]), <--- We need this for warning message (I believe so?)
>>>> delete='tr'))
>>>>
>>>> But we also need to update gridbutton function (line 1806) because we 
>>>> need button URL and warning. I have tried to add "buttonurl" but now the 
>>>> record is deleted even if I select "Cancel".
>>>>
>>>> I don't know how to fix this because I don't how to handle callback.
>>>>
>>>> Boris
>>>>
>>>>
>>>> Dne sreda, 19. december 2012 17:23:18 UTC+1 je oseba Mandar Vaze 
>>>> napisala:
>>>>>
>>>>> I know it is a tough one, but can you guess what "could" be the 
>>>>> problem ? As I mentioned, "explicitly" adding db.commit() helps "resolve" 
>>>>> the problem (Whether in gluon/sqlhtml.py or separately in my custom 
>>>>> ondelete)
>>>>>
>>>>> Does that give you any hints ? I debugged but (obviously) couldn't 
>>>>> find the culprit.
>>>>>
>>>>> Any pointers on how to troubleshoot/debug this ? I think at least one 
>>>>> more person has similar problem (One that started this thread)
>>>>>  
>>>>>
>>>>>> Really not relevant all the modify_grid() part. That doesn't belong 
>>>>>> to web2py, which you are addressing the bug to. 
>>>>>>
>>>>>
>>>>> I know. But it was something different - so I thought it may be 
>>>>> relevant.
>>>>>  
>>>>>
>>>>>> Without the table model, all code is quite useless. We don't need 
>>>>>> your app. Just *an* app showing the problem.
>>>>>>
>>>>>
>>>>> Ahh, I see. Let me try to create that (app) 
>>>>>
>>>>> -Mandar
>>>>>
>>>>

-- 





Re: [web2py] Re: Edit or delete not committing in sqlform.grid for custom query

2013-01-11 Thread Christian Espinoza


This Problem is currently active in 2.3.2 

There is something with the link for delete action at generation of grid code:

With 2.2.1

View->http://127.0.0.1:8000/webapp/admin/users/view/auth_user/6?_signature=d408cbb7bcbce4ec22a9089465dcefc7f1f2a5db
Edit->http://127.0.0.1:8000/webapp/admin/users/edit/auth_user/6?_signature=a688c63924538f53fdf0da2630790d780204403d
Delete->http://127.0.0.1:8000/webapp/admin/users?_signature=ca13c286893cff85c6916ff7723d3f0cd8e24c56#null

With 2.3.2

View->http://127.0.0.1:8000/webapp/admin/users/view/auth_user/6?_signature=d408cbb7bcbce4ec22a9089465dcefc7f1f2a5db

Edit->http://127.0.0.1:8000/webapp/admin/users/edit/auth_user/6?_signature=a688c63924538f53fdf0da2630790d780204403d

Delete->http://127.0.0.1:8000/avl/admin/users#null

As you can see the Delete option link doesn't point to any function at both 
versions


Christian.


El miércoles, 26 de diciembre de 2012 20:48:21 UTC-3, Massimo Di Pierro 
escribió:
>
> Can you please open a ticket about this?
>
> On Wednesday, 26 December 2012 13:40:15 UTC-6, BJ wrote:
>>
>> The problem is in sqlhtml.py
>>
>> In latest version from line 2293-2297 is following content:
>>
>> if deletable and (not callable(deletable) or deletable(row)):
>> row_buttons.append(gridbutton(
>> 'buttondelete', 'Delete',
>> callback=url(args=['delete', tablename, id]),
>> delete='tr'))
>>
>> but it should be:
>>
>> if deletable and (not callable(deletable) or deletable(row)):
>> row_buttons.append(gridbutton(
>> 'buttondelete', 'Delete',
>> buttonurl=url(args=['delete', tablename, 
>> id]), <--- Missing line to define URL for Delete button
>> callback=url(args=['delete', tablename, id]), 
>> <--- We need this for warning message (I believe so?)
>> delete='tr'))
>>
>> But we also need to update gridbutton function (line 1806) because we 
>> need button URL and warning. I have tried to add "buttonurl" but now the 
>> record is deleted even if I select "Cancel".
>>
>> I don't know how to fix this because I don't how to handle callback.
>>
>> Boris
>>
>>
>> Dne sreda, 19. december 2012 17:23:18 UTC+1 je oseba Mandar Vaze napisala:
>>>
>>> I know it is a tough one, but can you guess what "could" be the problem 
>>> ? As I mentioned, "explicitly" adding db.commit() helps "resolve" the 
>>> problem (Whether in gluon/sqlhtml.py or separately in my custom ondelete)
>>>
>>> Does that give you any hints ? I debugged but (obviously) couldn't find 
>>> the culprit.
>>>
>>> Any pointers on how to troubleshoot/debug this ? I think at least one 
>>> more person has similar problem (One that started this thread)
>>>  
>>>
 Really not relevant all the modify_grid() part. That doesn't belong to 
 web2py, which you are addressing the bug to. 

>>>
>>> I know. But it was something different - so I thought it may be relevant.
>>>  
>>>
 Without the table model, all code is quite useless. We don't need your 
 app. Just *an* app showing the problem.

>>>
>>> Ahh, I see. Let me try to create that (app) 
>>>
>>> -Mandar
>>>
>>

-- 





[web2py] Re: REF: Change order of fields in a form??!

2013-01-04 Thread Christian Espinoza
Is easy use a custom form instead of {{=form}}, then you can control
where put your input fields...

{{=form.custom.begin}}
Image name: {{=form.custom.widget.name}}
Image file: {{=form.custom.widget.file}}
Click here to upload: {{=form.custom.submit}}
{{=form.custom.end}}

Reference: 
http://web2py.com/books/default/chapter/29/07#Custom-forms
Christian.



El viernes, 4 de enero de 2013 04:22:51 UTC-3, software.ted escribió:
>
> How do you change the order of the form after it has been created using:
>
> form = SQLFORM(db.table)
>
> Also how do you change the font of the web2py editor???
>
> -- 
>
> ...
> Teddy Lubasi Nyambe
> Opensource Zambia
> Lusaka, ZAMBIA
>
> Cell: +260 97 7760473
> website: http://www.opensource.org.zm
>
> ~/
> Human Knowledge belongs to the world! - AntiTrust
>
> Man is a tool-using animal. Without tools he is nothing, with tools he is 
> all - Thomas Carlyle 1795-1881
>
> /~ 
>

-- 





[web2py] Re: SQLFORM.grid Error, changes from 2.2.1 to 2.3.1 - 2.3.2

2013-01-04 Thread Christian Espinoza
The issue appears on windows and linux, the db is mysql, I will rewrite my 
code for the new SQLFORM.grid
in order to use the GET vars that are now on the new version ...
Actually I'm doing all work with session vars in order to run the 
pagination of the grid...


El viernes, 4 de enero de 2013 19:57:59 UTC-3, Alan Etkin escribió:
>
> El viernes, 4 de enero de 2013 19:23:35 UTC-3, Christian Espinoza escribió:
>>
>> Hi, In all my webapps I'm working with SQLFORM.grid, and testing with the 
>> new versions I got this error:
>
>
> For debugging, perhaps it would be of help if you could post the relevant 
> part of the app that builds the session variable fecha_inicio and provide 
> more info on the environment (i.e. db engine and operating system)
>
>

-- 





Re: [web2py] Re: error in mysql ?

2013-01-04 Thread Christian Espinoza
Hi, I had a lot of problems like this when I was developing with sqlite, 
now my rule
is develop from beginning with the final database what will run in 
production environment..

Christian. 

El viernes, 4 de enero de 2013 22:45:18 UTC-3, Michele Comitini escribió:
>
> I have no idea where the error happens. If it is not a in form submission 
> "requires" is not considered...
>
>
> 2013/1/5 Derek >
>
>> but wouldn't his 'requires=' catch this before it even gets to the db?
>>
>>
>> On Friday, January 4, 2013 3:51:30 PM UTC-7, Michele Comitini wrote:
>>
>>> Possible solutions:
>>>
>>> 1. Probably Bruno Rocha can help you better, so you can try to post a 
>>> issue on github.
>>> 2. You can find what is the "parent_id" you are trying to insert then 
>>> create an appropriate record with the needed "id".
>>> 3. In case you don't have anything of value in the database just clean 
>>> drop the mysql database and create a new one.
>>>
>>>
>>>
>>>
>>> 2013/1/4 samuel bonilla 
>>>
>>> I can do to fix this problem ?



 El jueves, 3 de enero de 2013 20:30:53 UTC-5, samuel bonilla escribió:

> this is the error
>
>  (1452, 'Cannot add or 
> update a child row: a foreign key constraint fails 
> (`samuel$otra`.`article_
> **catego**ry`, CONSTRAINT `article_category_ibfk_1` FOREIGN KEY 
> (`parent_id`) REFERENCES `article_category` (`id`) ON DELETE CASCADE)') 
>
> help me please
>
  -- 
  
  
  

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

-- 





[web2py] SQLFORM.grid Error, changes from 2.2.1 to 2.3.1 - 2.3.2

2013-01-04 Thread Christian Espinoza
Hi, In all my webapps I'm working with SQLFORM.grid, and testing with the 
new versions I got this error:

 must be string, not listVERSIÓNweb2py™(2, 3, 
2, datetime.datetime(2012, 12, 17, 15, 3, 30), 'stable')PythonPython 2.7.3: 
C:\Python27\python.exeTRACEBACK

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

Traceback (most recent call last):
  File "C:\Users\cespinoza\web2py-2.3.2\gluon\restricted.py", line 212, in 
restricted
exec ccode in environment
  File 
"C:/Users/cespinoza/web2py-2.3.2/applications/avl/controllers/reports.py" 
, line 359, in 

  File "C:\Users\cespinoza\web2py-2.3.2\gluon\globals.py", line 193, in 
self._caller = lambda f: f()
  File 
"C:/Users/cespinoza/web2py-2.3.2/applications/avl/controllers/reports.py" 
, line 214, in 
events
fecha_inicio = datetime.datetime.strptime(session.fecha_inicio,"%d-%m-%Y")
TypeError: must be string, not list

I Noticed that the pagination links now have added some get vars, maybe 
are colliding with my vars, I'm using session vars 
in order to get a right behavior with it, but with the new versions it 
doesn't work...

Thanks
Christian.

-- 





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

2012-12-21 Thread Christian Espinoza
Wow!! Thanks Niphlod, this tip worked like a charm!!

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

-- 





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

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

-- 





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

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

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

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

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

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

Greetings
Christian.

-- 





[web2py] CSS preprocessors & Web2py

2012-11-15 Thread Christian Espinoza
Hi guys, I'm thinking put my hands on some CSS preprocesor to get a 
centralized control over the stylesheets, 
but I'm wondering about how is the impact on the user experience, if it 
have a speed cost on page loading...

Can somebody share some experience about that used with Web2py??

Thanks.
Christian.

-- 





[web2py] Web2py auth_membership table

2012-11-15 Thread Christian Espinoza


Hi, I need only one auth_user form with the option to select the group 
membership in order to get a simple way to add users.

I'm thinking override the auth_membership table use, and add a reference 
from auth_user directly to auth_group to achieve it, also formatting the 
output of the drop down menu with format='%(role)s'

But I need statements like '@auth.requires_membership(group_id=1)' to 
secure my app...

First, what do you think about my approach?
Second, how can I get a feature like @auth.requires_role(role_id=1) that 
get the reference from my auth_user db table?
Third, how can I add the format to the auth_group table if it was created 
by web2py?

PD: In the past I was solve it using manual insert code or another 
approaches like suggested by Bruno here: 
http://rochacbruno.com.br/web2py-manage-users-and-membership-in-the-same-form/ 
but 
now I want achieve it more cleanly...

Posted first in 
http://stackoverflow.com/questions/13387776/web2py-auth-membership-table


-- 





Re: [web2py] Re: Changing a uploaded filename

2012-11-13 Thread Christian Espinoza
No really, I need only that the app admin can change the logo in the
webapp, and for this
only is needed upload the file to applications/myapp/static/**images

Christian


2012/11/13 Derek 

> Wouldn't that also leave the uploaded file in the uploads folder?
>
> On Tuesday, November 13, 2012 10:00:24 AM UTC-7, Christian Espinoza wrote:
>>
>> Well, thanks anyway, its was resolved using the base code from
>> http://stackoverflow.com/**questions/8008213/web2py-**
>> upload-with-original-filename<http://stackoverflow.com/questions/8008213/web2py-upload-with-original-filename>
>>
>> Using for model:
>>
>>  Field("file", "upload", custom_store=store_file, custom_retrieve=
>> retrieve_file)
>>
>> and implementing these functions on this way:
>>
>> import os
>> import shutil
>>
>> def store_file(file, filename=None, path=None):
>> path = "applications/myapp/static/**images"
>> if not os.path.exists(path):
>>  os.makedirs(path)
>> pathfilename = os.path.join(path, filename)
>> dest_file = open(pathfilename, 'wb')
>> try:
>> shutil.copyfileobj(file, dest_file)
>> finally:
>> dest_file.close()
>> return filename
>>
>> def retrieve_file(filename, path=None):
>> path = "applications/myapp/static/**images"
>> return (filename, open(os.path.join(path, filename), 'rb'))
>>
>> With this code was enough to get the uploaded files with the original
>> name and to change the logo online.
>>
>> Thanks to Wikus van de 
>> Merwe<http://stackoverflow.com/users/1054145/wikus-van-de-merwe>
>>
>> Christian.
>>
>> El lunes, 12 de noviembre de 2012 18:50:57 UTC-3, Christian Espinoza
>> escribió:
>>>
>>> Hello, maybe this question was some answers, ie
>>> http://groups.google.com/**group/web2py/browse_thread/**
>>> thread/b04977ace137b317/**f4c3e44b4cd5de6d?lnk=gst&q=**
>>> Change+upload+behaviour#**f4c3e44b4cd5de6d<http://groups.google.com/group/web2py/browse_thread/thread/b04977ace137b317/f4c3e44b4cd5de6d?lnk=gst&q=Change+upload+behaviour#f4c3e44b4cd5de6d>
>>>
>>> But I don't understand if  these args (custom_store  or custom_retrieve)
>>> could be necessary for that I need
>>>
>>> I have this statement on my model
>>>
>>> Field('logo', 'upload', uploadfolder='applications/**myapp/static/images',
>>> label='Logo (227x40px)')
>>>
>>> I need upload a file.png or logo.png called file and store it on
>>> 'applications/myapp/static/**images' with 'logo.png' as filename to
>>> replace
>>> the app logo on my app..
>>>
>>> there are a simple way to do that?
>>>
>>> Thanks in advance.
>>> Christian.
>>>
>>  --
>
>
>
>

-- 





[web2py] Re: Changing a uploaded filename

2012-11-13 Thread Christian Espinoza
Well, thanks anyway, its was resolved using the base code from 
http://stackoverflow.com/questions/8008213/web2py-upload-with-original-filename

Using for model:

 Field("file", "upload", custom_store=store_file, custom_retrieve=
retrieve_file)

and implementing these functions on this way:

import os
import shutil

def store_file(file, filename=None, path=None):
path = "applications/myapp/static/images"
if not os.path.exists(path):
 os.makedirs(path)
pathfilename = os.path.join(path, filename)
dest_file = open(pathfilename, 'wb')
try:
shutil.copyfileobj(file, dest_file)
finally:
dest_file.close()
return filename

def retrieve_file(filename, path=None):
path = "applications/myapp/static/images"
return (filename, open(os.path.join(path, filename), 'rb'))

With this code was enough to get the uploaded files with the original name 
and to change the logo online.

Thanks to Wikus van de 
Merwe<http://stackoverflow.com/users/1054145/wikus-van-de-merwe>

Christian.

El lunes, 12 de noviembre de 2012 18:50:57 UTC-3, Christian Espinoza 
escribió:
>
> Hello, maybe this question was some answers, ie 
> http://groups.google.com/group/web2py/browse_thread/thread/b04977ace137b317/f4c3e44b4cd5de6d?lnk=gst&q=Change+upload+behaviour#f4c3e44b4cd5de6d
>
> But I don't understand if  these args (custom_store  or custom_retrieve) 
> could be necessary for that I need
>
> I have this statement on my model
>
> Field('logo', 'upload', uploadfolder='applications/myapp/static/images', 
> label='Logo (227x40px)')
>
> I need upload a file.png or logo.png called file and store it on 
> 'applications/myapp/static/images' with 'logo.png' as filename to replace 
> the app logo on my app..
>
> there are a simple way to do that?
>
> Thanks in advance.
> Christian.
>

-- 





[web2py] Changing a uploaded filename

2012-11-12 Thread Christian Espinoza
Hello, maybe this question was some answers, 
ie 
http://groups.google.com/group/web2py/browse_thread/thread/b04977ace137b317/f4c3e44b4cd5de6d?lnk=gst&q=Change+upload+behaviour#f4c3e44b4cd5de6d

But I don't understand if  these args (custom_store  or custom_retrieve) 
could be necessary for that I need

I have this statement on my model

Field('logo', 'upload', uploadfolder='applications/myapp/static/images', 
label='Logo (227x40px)')

I need upload a file.png or logo.png called file and store it on 
'applications/myapp/static/images' with 'logo.png' as filename to replace 
the app logo on my app..

there are a simple way to do that?

Thanks in advance.
Christian.

-- 





[web2py] Web2py on Linux Server + DB2 + pyodbc

2012-09-28 Thread Christian Espinoza
Hi, somebody know how connect web2py on linux box to a db2 database server?

I have pyodbc installed, but I dont know how to..

Thanks in advance
Christian.

-- 





Re: [web2py] Re: DB Migration (sqlite->pgsql) Problems with 1.99.7 - 2.0.6 - 2.0.7 Versions

2012-09-06 Thread Christian Espinoza
The last one was with psycopg2, this is the last value of command using  *
pg8000:*

SELECT  auth_group.id, auth_group.role, auth_group.description FROM
auth_group WHERE (auth_group.id > 0) ORDER BY auth_group.id LIMIT 1 OFFSET
0;

The failure appears when I try to init some values in a empty postgresql
database, with a empty sqlite db all works fine...
Im using if db(db.auth_group).isempty():
To check if is empty to insert the firsts values...

Christian.

2012/9/6 Christian Espinoza 

> Massimo,
>
> SELECT  auth_user.id, auth_user.username, auth_user.first_name,
> auth_user.last_name,\
> auth_user.sede_id, auth_user.email, auth_user.estado, auth_user.password,
> auth_user.created_on, auth_user.modified_on, auth_user.registration_key,\
> auth_user.reset_password_key, auth_user.registration_id FROM auth_user
> WHERE (auth_user.id > 0) ORDER BY auth_user.id LIMIT 1 OFFSET 0;
>
> INSERT INTO
> auth_user(username,first_name,last_name,registration_key,reset_password_key,registration_id,modified_on,created_on,sede_id,password,estado,email)\
> VALUES ('-1','admin','admin','','','','2012-09-06
> 10:36:50','2012-09-06 10:36:50',1,'admin','activo','ad...@live.com');
>
> Thanks in advance
> Christian.
>
> 2012/9/6 Massimo Di Pierro 
>
>> Can you add a
>>
>> print command
>>
>> after
>>
>> command = a[0]
>>
>> I want to know what is the invalid command. The ticket only shows part if
>> it.
>>
>> On Wednesday, 5 September 2012 17:27:49 UTC-5, Christian Espinoza wrote:
>>>
>>> Hi Massimo, this is:
>>>
>>> *File /opt/web-apps/web2py/gluon/dal.py in log_execute at line 1653*
>>> Code listing
>>>
>>>
>>> 1648.
>>> 1649.
>>> 1650.
>>> 1651.
>>> 1652.
>>> 1653.
>>>
>>> 1654.
>>> 1655.
>>> 1656.
>>> 1657.
>>>
>>> command = a[0]
>>>
>>>
>>> if self.db._debug:
>>>
>>>
>>> logger.debug('SQL: %s' % command)
>>>
>>>
>>> self.db._lastsql = command
>>>
>>>
>>> t0 = time.time()
>>>
>>> ret = self.cursor.execute(*a, **b)
>>>
>>>
>>> self.db._timings.append((comma**nd,time.time()-t0))
>>>
>>>
>>>     del self.db._timings[:-TIMINGSSIZE**]
>>>
>>>
>>> return ret
>>>
>>> Variables a('SELECT auth_user.id, auth_user.username, auth_u...r.id >
>>> 0) ORDER BY auth_user.id LIMIT 1 OFFSET 0;',) b 
>>> {}selfret
>>> undefined self.cursor
>>> self.cursor.execute>> >
>>>
>>> 2012/9/5 Massimo Di Pierro 
>>>
>>>> Did you install psycopg2? If not it is probably using pg8000. Can you
>>>> please help us debug? Edit dal.py and in the function log_excecute can you
>>>> print the value of the command variable? What does it print when it fails?
>>>>
>>>> On Wednesday, 5 September 2012 11:29:42 UTC-5, Christian Espinoza wrote:
>>>>>
>>>>> Hello, I'm in trouble with a webapp that I'have.
>>>>>
>>>>> I develop it using sqlite only for a best approach of web2py features
>>>>> with it.
>>>>>
>>>>> And I'm trying to migrate it to a Postgresql DB to put it on Testing
>>>>> phase.
>>>>>
>>>>> But It doesn't work with PostgreSQL, only work with sqlite, I'd tried
>>>>> with  1.99.7 - 2.0.6 -  2.0.7 Versions
>>>>>
>>>>> At 2.0.7 and 2.0.6 showme:  invalid
>>>>> literal for int() with base 10: 'SELECT'
>>>>>
>>>>> At
>>>>>
>>>>> Traceback (most recent call last):
>>>>>
>>>>>
>>>>>   File "/opt/web-apps/web2py/gluon/**re**stricted.py", line 209, in 
>>>>> restricted
>>>>>
>>>>>
>>>>> exec ccode in environment
>>>>>
>>>>>
>>>>>   File "/opt/web-apps/web2py-2.0.7/**ap**plications/sadma/models/db.**py" 
>>>>> <https://172.16.1.34/admin/default/edit/sadma/models/db.py>**, line 236, 
>>>>> in 
>>>>>
>>>>>
>>>>> if db(db.auth_user).isempty():
>>>>>
>>>>>
>>>>>   File "/opt/web-apps/web2py/gluon/**da**l.py", line 8722, in isempty
>>>>>
>>>>>
>>>>> return not self.select(limitby=(0,1))
>>>>>
>>>>>
>>>>>   File "/opt/web-apps/web2py/gluon/**da**l.py", line 8743, in select
>>>>>
>>>>>
>>>>> return adapter.select(self.query,fields,attributes)
>>>>>
>>>>>
>>>>>   File "/opt/web-apps/web2py/gluon/**da**l.py", line 1583, in select
>>>>>
>>>>>
>>>>> return self._select_aux(sql,fields,attributes)
>>>>>
>>>>>
>>>>>   File "/opt/web-apps/web2py/gluon/**da**l.py", line 1556, in _select_aux
>>>>>
>>>>>
>>>>> self.execute(sql)
>>>>>
>>>>> My Connection string:
>>>>>
>>>>> *#db = DAL('sqlite://storage.sqlite')
>>>>> db = DAL('postgres://user:pass@localhost/dbapp')**
>>>>> *
>>>>>
>>>>> *Running on Centos 6.0, external Postgresql Server with 9 version, 
>>>>> **Python 2.6.6*
>>>>>
>>>>> *
>>>>> *
>>>>>
>>>>> Thanks in advance
>>>>>
>>>>> Christian.
>>>>>
>>>>>   --
>>>>
>>>>
>>>>
>>>>
>>>
>>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Re: DB Migration (sqlite->pgsql) Problems with 1.99.7 - 2.0.6 - 2.0.7 Versions

2012-09-06 Thread Christian Espinoza
Massimo,

SELECT  auth_user.id, auth_user.username, auth_user.first_name,
auth_user.last_name,\
auth_user.sede_id, auth_user.email, auth_user.estado, auth_user.password,
auth_user.created_on, auth_user.modified_on, auth_user.registration_key,\
auth_user.reset_password_key, auth_user.registration_id FROM auth_user
WHERE (auth_user.id > 0) ORDER BY auth_user.id LIMIT 1 OFFSET 0;

INSERT INTO
auth_user(username,first_name,last_name,registration_key,reset_password_key,registration_id,modified_on,created_on,sede_id,password,estado,email)\
VALUES ('-1','admin','admin','','','','2012-09-06
10:36:50','2012-09-06 10:36:50',1,'admin','activo','ad...@live.com');

Thanks in advance
Christian.

2012/9/6 Massimo Di Pierro 

> Can you add a
>
> print command
>
> after
>
> command = a[0]
>
> I want to know what is the invalid command. The ticket only shows part if
> it.
>
> On Wednesday, 5 September 2012 17:27:49 UTC-5, Christian Espinoza wrote:
>>
>> Hi Massimo, this is:
>>
>> *File /opt/web-apps/web2py/gluon/dal.py in log_execute at line 1653*
>> Code listing
>>
>> 1648.
>> 1649.
>> 1650.
>> 1651.
>> 1652.
>> 1653.
>>
>> 1654.
>> 1655.
>> 1656.
>> 1657.
>>
>> command = a[0]
>>
>> if self.db._debug:
>>
>> logger.debug('SQL: %s' % command)
>>
>> self.db._lastsql = command
>>
>> t0 = time.time()
>> ret = self.cursor.execute(*a, **b)
>>
>> self.db._timings.append((comma**nd,time.time()-t0))
>>
>> del self.db._timings[:-TIMINGSSIZE**]
>>
>> return ret
>>
>> Variables a('SELECT auth_user.id, auth_user.username, auth_u...r.id > 0)
>> ORDER BY auth_user.id LIMIT 1 OFFSET 0;',) b 
>> {}selfret
>> undefined self.cursor> object>self.cursor.execute> method CursorWrapper._fn of > object>>
>>
>> 2012/9/5 Massimo Di Pierro 
>>
>>> Did you install psycopg2? If not it is probably using pg8000. Can you
>>> please help us debug? Edit dal.py and in the function log_excecute can you
>>> print the value of the command variable? What does it print when it fails?
>>>
>>> On Wednesday, 5 September 2012 11:29:42 UTC-5, Christian Espinoza wrote:
>>>>
>>>> Hello, I'm in trouble with a webapp that I'have.
>>>>
>>>> I develop it using sqlite only for a best approach of web2py features
>>>> with it.
>>>>
>>>> And I'm trying to migrate it to a Postgresql DB to put it on Testing
>>>> phase.
>>>>
>>>> But It doesn't work with PostgreSQL, only work with sqlite, I'd tried
>>>> with  1.99.7 - 2.0.6 -  2.0.7 Versions
>>>>
>>>> At 2.0.7 and 2.0.6 showme:  invalid
>>>> literal for int() with base 10: 'SELECT'
>>>>
>>>> At
>>>>
>>>> Traceback (most recent call last):
>>>>
>>>>   File "/opt/web-apps/web2py/gluon/**re**stricted.py", line 209, in 
>>>> restricted
>>>>
>>>> exec ccode in environment
>>>>
>>>>   File "/opt/web-apps/web2py-2.0.7/**ap**plications/sadma/models/db.**py" 
>>>> <https://172.16.1.34/admin/default/edit/sadma/models/db.py>**, line 236, 
>>>> in 
>>>>
>>>> if db(db.auth_user).isempty():
>>>>
>>>>   File "/opt/web-apps/web2py/gluon/**da**l.py", line 8722, in isempty
>>>>
>>>> return not self.select(limitby=(0,1))
>>>>
>>>>   File "/opt/web-apps/web2py/gluon/**da**l.py", line 8743, in select
>>>>
>>>> return adapter.select(self.query,fields,attributes)
>>>>
>>>>   File "/opt/web-apps/web2py/gluon/**da**l.py", line 1583, in select
>>>>
>>>> return self._select_aux(sql,fields,attributes)
>>>>
>>>>   File "/opt/web-apps/web2py/gluon/**da**l.py", line 1556, in _select_aux
>>>>
>>>> self.execute(sql)
>>>>
>>>> My Connection string:
>>>>
>>>> *#db = DAL('sqlite://storage.sqlite')
>>>> db = DAL('postgres://user:pass@localhost/dbapp')**
>>>> *
>>>>
>>>> *Running on Centos 6.0, external Postgresql Server with 9 version, 
>>>> **Python 2.6.6*
>>>>
>>>> *
>>>> *
>>>>
>>>> Thanks in advance
>>>>
>>>> Christian.
>>>>
>>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Re: DB Migration (sqlite->pgsql) Problems with 1.99.7 - 2.0.6 - 2.0.7 Versions

2012-09-05 Thread Christian Espinoza
Hi Massimo, this is:

*File /opt/web-apps/web2py/gluon/dal.py in log_execute at line 1653*
Code listing

1648.
1649.
1650.
1651.
1652.
1653.

1654.
1655.
1656.
1657.

command = a[0]
if self.db._debug:
logger.debug('SQL: %s' % command)
self.db._lastsql = command
t0 = time.time()
ret = self.cursor.execute(*a, **b)

self.db._timings.append((command,time.time()-t0))
del self.db._timings[:-TIMINGSSIZE]
return ret

Variablesa('SELECT auth_user.id, auth_user.username, auth_u...r.id > 0)
ORDER BY auth_user.id LIMIT 1 OFFSET 0;',)b{}selfretundefinedself.cursorself.cursor.execute>

2012/9/5 Massimo Di Pierro 

> Did you install psycopg2? If not it is probably using pg8000. Can you
> please help us debug? Edit dal.py and in the function log_excecute can you
> print the value of the command variable? What does it print when it fails?
>
> On Wednesday, 5 September 2012 11:29:42 UTC-5, Christian Espinoza wrote:
>>
>> Hello, I'm in trouble with a webapp that I'have.
>>
>> I develop it using sqlite only for a best approach of web2py features
>> with it.
>>
>> And I'm trying to migrate it to a Postgresql DB to put it on Testing
>> phase.
>>
>> But It doesn't work with PostgreSQL, only work with sqlite, I'd tried
>> with  1.99.7 - 2.0.6 -  2.0.7 Versions
>>
>> At 2.0.7 and 2.0.6 showme:  invalid
>> literal for int() with base 10: 'SELECT'
>>
>> At
>>
>> Traceback (most recent call last):
>>   File "/opt/web-apps/web2py/gluon/**restricted.py", line 209, in restricted
>> exec ccode in environment
>>   File "/opt/web-apps/web2py-2.0.7/**applications/sadma/models/db.**py" 
>> <https://172.16.1.34/admin/default/edit/sadma/models/db.py>, line 236, in 
>> 
>> if db(db.auth_user).isempty():
>>   File "/opt/web-apps/web2py/gluon/**dal.py", line 8722, in isempty
>> return not self.select(limitby=(0,1))
>>   File "/opt/web-apps/web2py/gluon/**dal.py", line 8743, in select
>> return adapter.select(self.query,fiel**ds,attributes)
>>   File "/opt/web-apps/web2py/gluon/**dal.py", line 1583, in select
>> return self._select_aux(sql,fields,at**tributes)
>>   File "/opt/web-apps/web2py/gluon/**dal.py", line 1556, in _select_aux
>> self.execute(sql)
>>
>> My Connection string:
>>
>> *#db = DAL('sqlite://storage.sqlite')
>> db = DAL('postgres://user:pass@localhost/dbapp')**
>> *
>>
>> *Running on Centos 6.0, external Postgresql Server with 9 version, **Python 
>> 2.6.6*
>>
>> *
>> *
>>
>> Thanks in advance
>>
>> Christian.
>>
>>  --
>
>
>
>

-- 





[web2py] DB Migration (sqlite->pgsql) Problems with 1.99.7 - 2.0.6 - 2.0.7 Versions

2012-09-05 Thread Christian Espinoza
Hello, I'm in trouble with a webapp that I'have.

I develop it using sqlite only for a best approach of web2py features with 
it.

And I'm trying to migrate it to a Postgresql DB to put it on Testing phase.

But It doesn't work with PostgreSQL, only work with sqlite, I'd tried with 
 1.99.7 - 2.0.6 -  2.0.7 Versions

At 2.0.7 and 2.0.6 showme:  invalid literal 
for int() with base 10: 'SELECT'

At 

Traceback (most recent call last):
  File "/opt/web-apps/web2py/gluon/restricted.py", line 209, in restricted
exec ccode in environment
  File "/opt/web-apps/web2py-2.0.7/applications/sadma/models/db.py" 
, line 236, in 

if db(db.auth_user).isempty():
  File "/opt/web-apps/web2py/gluon/dal.py", line 8722, in isempty
return not self.select(limitby=(0,1))
  File "/opt/web-apps/web2py/gluon/dal.py", line 8743, in select
return adapter.select(self.query,fields,attributes)
  File "/opt/web-apps/web2py/gluon/dal.py", line 1583, in select
return self._select_aux(sql,fields,attributes)
  File "/opt/web-apps/web2py/gluon/dal.py", line 1556, in _select_aux
self.execute(sql)

My Connection string:

*#db = DAL('sqlite://storage.sqlite')
db = DAL('postgres://user:pass@localhost/dbapp')**
*

*Running on Centos 6.0, external Postgresql Server with 9 version, **Python 
2.6.6*

*
*

Thanks in advance

Christian.

-- 





[web2py] Re: Centos 5 script for Nginx with Uwsgi and Web2py

2012-09-04 Thread Christian Espinoza
I'm trying step to step now...and only was needed an little changes

El martes, 4 de septiembre de 2012 18:03:16 UTC-3, Christian Espinoza 
escribió:
>
> Hi Alan, I did test this script at a clean Centos 6, and the result is: 502 
> Bad Gateway
> Christian
>
>
> El viernes, 3 de agosto de 2012 20:23:21 UTC-3, Alan Etkin escribió:
>>
>> Updated the script to:
>>
>> - Write port 443 admin password
>> - Create welcome.w2p package (for solving admin create app feature error)
>> - Patch Python2.7.3 code for sqlite3 issue before installing
>>
>> It was tested with a clean CentOS 5.8 vbox and is working. Needs 
>> improvement: it stops a few times for user confirmation
>>
>> El jueves, 2 de agosto de 2012 13:16:18 UTC-3, peter escribió:
>>>
>>> Someone else has provided a script for centos 6. There are plenty of 
>>> webservers out there based on centos 5 I believe because of its stability. 
>>> So it is useful to have a script for Centos 5. Particularly as this seems 
>>> to be the most tricky Linux for web2py because it uses and needs python 2.4
>>> Massimo: it depends how long Alan will take to come up with a tested 
>>> script for python 2.7. A working python2.6 script is better than an almost 
>>> working 2.7 one.
>>>
>>>
>>> Peter
>>>
>>> On Thursday, 2 August 2012 15:22:27 UTC+1, Alan Etkin wrote:
>>>>
>>>> > The script I attached in my previous email is your script but with 
>>>> python set to be 2.6. I tested this and it works.
>>>>
>>>> My concern is that 2.7 is said to be the last supported 2.x version of 
>>>> Python. I agree that testing in a raw install saves time and all kinds of 
>>>> issues. I will deploy in a virtual machine and debug the script so I can 
>>>> come back with a working one.
>>>>
>>>> Shouldn't we provide the working script for the lastest CentOS 
>>>> distribution (which I supposse is not what we are using), instead of 
>>>> basing 
>>>> in a previous one?
>>>>
>>>>

-- 





[web2py] Re: Centos 5 script for Nginx with Uwsgi and Web2py

2012-09-04 Thread Christian Espinoza
Hi Alan, I did test this script at a clean Centos 6, and the result is: 502 
Bad Gateway
Christian


El viernes, 3 de agosto de 2012 20:23:21 UTC-3, Alan Etkin escribió:
>
> Updated the script to:
>
> - Write port 443 admin password
> - Create welcome.w2p package (for solving admin create app feature error)
> - Patch Python2.7.3 code for sqlite3 issue before installing
>
> It was tested with a clean CentOS 5.8 vbox and is working. Needs 
> improvement: it stops a few times for user confirmation
>
> El jueves, 2 de agosto de 2012 13:16:18 UTC-3, peter escribió:
>>
>> Someone else has provided a script for centos 6. There are plenty of 
>> webservers out there based on centos 5 I believe because of its stability. 
>> So it is useful to have a script for Centos 5. Particularly as this seems 
>> to be the most tricky Linux for web2py because it uses and needs python 2.4
>> Massimo: it depends how long Alan will take to come up with a tested 
>> script for python 2.7. A working python2.6 script is better than an almost 
>> working 2.7 one.
>>
>>
>> Peter
>>
>> On Thursday, 2 August 2012 15:22:27 UTC+1, Alan Etkin wrote:
>>>
>>> > The script I attached in my previous email is your script but with 
>>> python set to be 2.6. I tested this and it works.
>>>
>>> My concern is that 2.7 is said to be the last supported 2.x version of 
>>> Python. I agree that testing in a raw install saves time and all kinds of 
>>> issues. I will deploy in a virtual machine and debug the script so I can 
>>> come back with a working one.
>>>
>>> Shouldn't we provide the working script for the lastest CentOS 
>>> distribution (which I supposse is not what we are using), instead of basing 
>>> in a previous one?
>>>
>>>

-- 





[web2py] Web2py MVC pattern using wx for "V"

2012-08-24 Thread Christian Espinoza
Hello guys,
There are somebody with some experience using wx instead of a web view 
layer??

I have some questions about it, and I want to know if exist some 
example over there...


Thanks in advance.
Christian.

-- 





Re: [web2py] Problem trying to get a value from a rows object

2012-08-22 Thread Christian Espinoza
Excellent!

Thanks a lot Anthony and Massimo.

It´s save my day, now all is working using request.get_vars.id instead of
request.vars.id


Christian.

2012/8/22 Anthony 

> Yes. Note, web2py stores GET variables in request.get_vars and POST
> variables in request.post_vars. It stores both GET and POST vars in
> request.vars. If both get_vars and post_vars have variables with the same
> name, it puts their values in a list within request.vars. Just change your
> code to use request.get_vars.id instead of request.vars.id.
>
> Anthony
>
> On Wednesday, August 22, 2012 10:14:12 AM UTC-4, Massimo Di Pierro wrote:
>>
>> You have two id fields. One in request.get_vars.id (from the url) and
>> one in request.post_vars.id (from the form submission).
>>
>>
>>
>> On Wednesday, 22 August 2012 08:51:38 UTC-5, Christian Espinoza wrote:
>>>
>>> When I submit the form, on request.vars.id exist this value: ['2', '2']
>>>
>>> this is the problem, but I dont know why, Im sending the var from the
>>> controller to it self with the 2  value only..
>>>
>>> 'id' is a reserved function??
>>>
>>> Christian.
>>>
>>> 2012/8/21 Anthony 
>>>
>>>> How is request.vars.id being set -- in the query string? What is its
>>>> value when the form is created, and what is the value when submitted?
>>>>
>>>> On Tuesday, August 21, 2012 7:16:18 PM UTC-4, Christian Espinoza wrote:
>>>>>
>>>>> Hi Anthony,  I was try with .select().first(), but I get a error in
>>>>> the same way...
>>>>>
>>>>> The Error appears after I submit the form with the changes over the
>>>>> field, the form for a id user works, the problem is when I submit it.
>>>>>
>>>>> Thanks.
>>>>> Christian
>>>>>
>>>>> 2012/8/21 Anthony 
>>>>>
>>>>>> Also, note the .select().first() returns the first row or None if
>>>>>> there are no results, so you don't have to test whether there are any
>>>>>> records before selecting the first row.
>>>>>>
>>>>>> Anthony
>>>>>>
>>>>>> On Tuesday, August 21, 2012 6:58:47 PM UTC-4, rochacbruno wrote:
>>>>>>>
>>>>>>> You are getting an empty rows object
>>>>>>>
>>>>>>>
>>>>>>> def change_membership():
>>>>>>>
>>>>>>> if request.vars.id:
>>>>>>>
>>>>>>> row = db(db.auth_membership.us**er_id == request.vars.id
>>>>>>> ).sele**ct()
>>>>>>> if not row:
>>>>>>> redirect(.)
>>>>>>> id = row[0].id
>>>>>>> form = SQLFORM(db.auth_membership,
>>>>>>>id,
>>>>>>>fields=['group_id'],
>>>>>>>_action=URL()
>>>>>>>)
>>>>>>> if form.process().accepted:
>>>>>>> ...redirect back to user list
>>>>>>>
>>>>>>> if form.errors:
>>>>>>> response.flash = 'form has errors'
>>>>>>>
>>>>>>> return dict(form=form)
>>>>>>>
>>>>>>> also can be done with
>>>>>>>
>>>>>>>  row = db(db.auth_membership.u**ser_id == request.vars.id).sel**
>>>>>>> ect() or redirect(.)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> *Bruno Cezar Rocha** - @rochacbruno*
>>>>>>> rocha...@gmail.com | Mobile: +55 (11) 99210-8821
>>>>>>> www.CursoDePython.com.br | www.rochacbruno.com.br
>>>>>>> Blog: WEB APPS THAT WORTH A 
>>>>>>> TRY<http://rochacbruno.com.br/web-apps-that-worth-a-try/>
>>>>>>>   Get a signature like this.
>>>>>>> <http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>>>>>  Click
>>>>>>> here.<http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>>>>>
>>>>>>>
>>>>>>>  --
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>  --
>>>>
>>>>
>>>>
>>>>
>>>
>>>  --
>
>
>
>

-- 





Re: [web2py] Problem trying to get a value from a rows object

2012-08-22 Thread Christian Espinoza
Hello Antony,

Before submit the form, id -> 2 , for example.

After submit the form id ->  ['2', '2']

maybe id is a reserved word for Web2py, when I did trace it on the debugger
I saw that it change from a int number to a list,
only in the process of submit a form, without a user interaction.


Christian.

2012/8/22 Anthony 

> It's really hard to say without seeing the code that generates the id.
> Somehow your id is a list instead of a single value.
>
> Anthony
>
> On Wednesday, August 22, 2012 9:51:38 AM UTC-4, Christian Espinoza wrote:
>>
>> When I submit the form, on request.vars.id exist this value: ['2', '2']
>>
>> this is the problem, but I dont know why, Im sending the var from the
>> controller to it self with the 2  value only..
>>
>> 'id' is a reserved function??
>>
>> Christian.
>>
>> 2012/8/21 Anthony 
>>
>>> How is request.vars.id being set -- in the query string? What is its
>>> value when the form is created, and what is the value when submitted?
>>>
>>> On Tuesday, August 21, 2012 7:16:18 PM UTC-4, Christian Espinoza wrote:
>>>>
>>>> Hi Anthony,  I was try with .select().first(), but I get a error in the
>>>> same way...
>>>>
>>>> The Error appears after I submit the form with the changes over the
>>>> field, the form for a id user works, the problem is when I submit it.
>>>>
>>>> Thanks.
>>>> Christian
>>>>
>>>> 2012/8/21 Anthony 
>>>>
>>>>> Also, note the .select().first() returns the first row or None if
>>>>> there are no results, so you don't have to test whether there are any
>>>>> records before selecting the first row.
>>>>>
>>>>> Anthony
>>>>>
>>>>> On Tuesday, August 21, 2012 6:58:47 PM UTC-4, rochacbruno wrote:
>>>>>>
>>>>>> You are getting an empty rows object
>>>>>>
>>>>>>
>>>>>> def change_membership():
>>>>>>
>>>>>> if request.vars.id:
>>>>>>
>>>>>> row = db(db.auth_membership.us**er_id == request.vars.id
>>>>>> ).sele**ct()
>>>>>> if not row:
>>>>>> redirect(.)
>>>>>> id = row[0].id
>>>>>> form = SQLFORM(db.auth_membership,
>>>>>>id,
>>>>>>fields=['group_id'],
>>>>>>_action=URL()
>>>>>>)
>>>>>> if form.process().accepted:
>>>>>> ...redirect back to user list
>>>>>>
>>>>>> if form.errors:
>>>>>> response.flash = 'form has errors'
>>>>>>
>>>>>> return dict(form=form)
>>>>>>
>>>>>> also can be done with
>>>>>>
>>>>>>  row = db(db.auth_membership.u**ser_id == request.vars.id).sel***
>>>>>> ***ect() or redirect(.)
>>>>>>
>>>>>>
>>>>>>
>>>>>> *Bruno Cezar Rocha** - @rochacbruno*
>>>>>> rocha...@gmail.com | Mobile: +55 (11) 99210-8821
>>>>>> www.CursoDePython.com.br | www.rochacbruno.com.br
>>>>>> Blog: WEB APPS THAT WORTH A 
>>>>>> TRY<http://rochacbruno.com.br/web-apps-that-worth-a-try/>
>>>>>>   Get a signature like this.
>>>>>> <http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>>>>  Click
>>>>>> here.<http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>>>>
>>>>>>
>>>>>>  --
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Problem trying to get a value from a rows object

2012-08-22 Thread Christian Espinoza
When I submit the form, on request.vars.id exist this value: ['2', '2']

this is the problem, but I dont know why, Im sending the var from the
controller to it self with the 2  value only..

'id' is a reserved function??

Christian.

2012/8/21 Anthony 

> How is request.vars.id being set -- in the query string? What is its
> value when the form is created, and what is the value when submitted?
>
> On Tuesday, August 21, 2012 7:16:18 PM UTC-4, Christian Espinoza wrote:
>>
>> Hi Anthony,  I was try with .select().first(), but I get a error in the
>> same way...
>>
>> The Error appears after I submit the form with the changes over the
>> field, the form for a id user works, the problem is when I submit it.
>>
>> Thanks.
>> Christian
>>
>> 2012/8/21 Anthony 
>>
>>> Also, note the .select().first() returns the first row or None if there
>>> are no results, so you don't have to test whether there are any records
>>> before selecting the first row.
>>>
>>> Anthony
>>>
>>> On Tuesday, August 21, 2012 6:58:47 PM UTC-4, rochacbruno wrote:
>>>>
>>>> You are getting an empty rows object
>>>>
>>>>
>>>> def change_membership():
>>>>
>>>> if request.vars.id:
>>>>
>>>> row = db(db.auth_membership.user_id == request.vars.id).
>>>> select()
>>>> if not row:
>>>> redirect(.)
>>>> id = row[0].id
>>>> form = SQLFORM(db.auth_membership,
>>>>id,
>>>>fields=['group_id'],
>>>>_action=URL()
>>>>)
>>>> if form.process().accepted:
>>>> ...redirect back to user list
>>>>
>>>> if form.errors:
>>>> response.flash = 'form has errors'
>>>>
>>>> return dict(form=form)
>>>>
>>>> also can be done with
>>>>
>>>>  row = db(db.auth_membership.user_id == request.vars.id).select()
>>>> or redirect(.)
>>>>
>>>>
>>>>
>>>> *Bruno Cezar Rocha** - @rochacbruno*
>>>> rocha...@gmail.com | Mobile: +55 (11) 99210-8821
>>>> www.CursoDePython.com.br | www.rochacbruno.com.br
>>>> Blog: WEB APPS THAT WORTH A 
>>>> TRY<http://rochacbruno.com.br/web-apps-that-worth-a-try/>
>>>>   Get a signature like this.
>>>> <http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>>  Click
>>>> here.<http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>>
>>>>
>>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Problem trying to get a value from a rows object

2012-08-22 Thread Christian Espinoza
I'm sending the id var from a user list view on this way:

edit_user.html:

*Change Membership*

edit_user.py:

def edit_user():

if request.vars.id:

etc

return dict(form=form, id=request.vars.id)

the id var come from another view when I was iterating over a query to get
auth_user.id:

but on every step, I can trace the id value, I traced it with web2py
debugger...

Maybe I'm not clear with web2py Post procedure, because all is right until
I submit the last form, it come with the right id's

If I try with a literal var number it's works without problems

Thanks in advance.
Christian

2012/8/21 Anthony 

> How is request.vars.id being set -- in the query string? What is its
> value when the form is created, and what is the value when submitted?
>
> On Tuesday, August 21, 2012 7:16:18 PM UTC-4, Christian Espinoza wrote:
>>
>> Hi Anthony,  I was try with .select().first(), but I get a error in the
>> same way...
>>
>> The Error appears after I submit the form with the changes over the
>> field, the form for a id user works, the problem is when I submit it.
>>
>> Thanks.
>> Christian
>>
>> 2012/8/21 Anthony 
>>
>>> Also, note the .select().first() returns the first row or None if there
>>> are no results, so you don't have to test whether there are any records
>>> before selecting the first row.
>>>
>>> Anthony
>>>
>>> On Tuesday, August 21, 2012 6:58:47 PM UTC-4, rochacbruno wrote:
>>>>
>>>> You are getting an empty rows object
>>>>
>>>>
>>>> def change_membership():
>>>>
>>>> if request.vars.id:
>>>>
>>>> row = db(db.auth_membership.user_id == request.vars.id).
>>>> select()
>>>> if not row:
>>>> redirect(.)
>>>> id = row[0].id
>>>> form = SQLFORM(db.auth_membership,
>>>>id,
>>>>fields=['group_id'],
>>>>_action=URL()
>>>>)
>>>> if form.process().accepted:
>>>> ...redirect back to user list
>>>>
>>>> if form.errors:
>>>> response.flash = 'form has errors'
>>>>
>>>> return dict(form=form)
>>>>
>>>> also can be done with
>>>>
>>>>  row = db(db.auth_membership.user_id == request.vars.id).select()
>>>> or redirect(.)
>>>>
>>>>
>>>>
>>>> *Bruno Cezar Rocha** - @rochacbruno*
>>>> rocha...@gmail.com | Mobile: +55 (11) 99210-8821
>>>> www.CursoDePython.com.br | www.rochacbruno.com.br
>>>> Blog: WEB APPS THAT WORTH A 
>>>> TRY<http://rochacbruno.com.br/web-apps-that-worth-a-try/>
>>>>   Get a signature like this.
>>>> <http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>>  Click
>>>> here.<http://r1.wisestamp.com/r/landing?promo=18&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18>
>>>>
>>>>
>>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Problem trying to get a value from a rows object

2012-08-21 Thread Christian Espinoza
Hi Anthony,  I was try with .select().first(), but I get a error in the
same way...

The Error appears after I submit the form with the changes over the field,
the form for a id user works, the problem is when I submit it.

Thanks.
Christian

2012/8/21 Anthony 

> Also, note the .select().first() returns the first row or None if there
> are no results, so you don't have to test whether there are any records
> before selecting the first row.
>
> Anthony
>
> On Tuesday, August 21, 2012 6:58:47 PM UTC-4, rochacbruno wrote:
>>
>> You are getting an empty rows object
>>
>>
>> def change_membership():
>>
>> if request.vars.id:
>>
>> row = db(db.auth_membership.us**er_id == request.vars.id).sele**
>> ct()
>> if not row:
>> redirect(.)
>> id = row[0].id
>> form = SQLFORM(db.auth_membership,
>>id,
>>fields=['group_id'],
>>_action=URL()
>>)
>> if form.process().accepted:
>> ...redirect back to user list
>>
>> if form.errors:
>> response.flash = 'form has errors'
>>
>> return dict(form=form)
>>
>> also can be done with
>>
>>  row = db(db.auth_membership.u**ser_id == request.vars.id).sel**ect() or
>> redirect(.)
>>
>>
>>
>> *Bruno Cezar Rocha** - @rochacbruno*
>> rocha...@gmail.com | Mobile: +55 (11) 99210-8821
>> www.CursoDePython.com.br | www.rochacbruno.com.br
>> Blog: WEB APPS THAT WORTH A 
>> TRY
>>   Get a signature like this.
>> 
>>  Click
>> here.
>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Problem trying to get a value from a rows object

2012-08-21 Thread Christian Espinoza
Hi Bruno, this error appear after I submit the changes on the form, 

I can get the form without problems for a user, but the problem appears 
after submit any change.

Christian

El martes, 21 de agosto de 2012 18:58:47 UTC-4, rochacbruno escribió:
>
> You are getting an empty rows object
>
>
> def change_membership():
>
> if request.vars.id:
>
> row = db(db.auth_membership.user_id == request.vars.id).select()
> if not row:
> redirect(.)
> id = row[0].id  
> form = SQLFORM(db.auth_membership,
>id,
>fields=['group_id'],
>_action=URL()
>)
> if form.process().accepted:
> ...redirect back to user list
>
> if form.errors:
> response.flash = 'form has errors'
> 
> return dict(form=form)
>
> also can be done with
>
>  row = db(db.auth_membership.user_id == request.vars.id).select() or 
> redirect(.)
>
>
>
> *Bruno Cezar Rocha** - @rochacbruno*
> rocha...@gmail.com  | Mobile: +55 (11) 99210-8821
> www.CursoDePython.com.br | www.rochacbruno.com.br
> Blog: WEB APPS THAT WORTH A 
> TRY
>   Get a signature like this. 
> 
>  Click 
> here.
>
>
>
>

-- 





[web2py] Problem trying to get a value from a rows object

2012-08-21 Thread Christian Espinoza
Hello, I'm trying to edit the group membership for a user, I have in my 
controller:

def change_membership():

if request.vars.id:

row = db(db.auth_membership.user_id == request.vars.id).select()
id = row[0].id  
form = SQLFORM(db.auth_membership,
   id,
   fields=['group_id'],
   _action=URL()
   )
if form.process().accepted:
...redirect back to user list

if form.errors:
response.flash = 'form has errors'

return dict(form=form)
 

But It doesn't work, I get a :
 list index out of range

I know that only get one row, but I don't understand why its seems empty..

Thanks in advance
Christian

-- 





[web2py] Re: SQLFORM and Nyromodal

2012-08-10 Thread Christian Espinoza
Well, I fix it, pointing (action) to my controller from the form:

form = SQLFORM(db.table, request.vars.id[0], _class='formulario', 
_id='form_std', keepopts=['sede'], _action=URL())

Thanks 
Christian.

El jueves, 9 de agosto de 2012 17:35:23 UTC-4, Christian Espinoza escribió:
>
> Hi, I´m have working a custom SQLFORM in update mode, into a modal popup, 
> when I try to submit changes
> the popup disappear obviously, but it isn't make any changes.
> But if I try the code out from the modal, it's make the changes without 
> problems...
>
> Any Idea?
>
> Thanks in advance.
> Christian.
>

-- 





[web2py] SQLFORM and Nyromodal

2012-08-09 Thread Christian Espinoza
Hi, I´m have working a custom SQLFORM in update mode, into a modal popup, 
when I try to submit changes
the popup disappear obviously, but it isn't make any changes.
But if I try the code out from the modal, it's make the changes without 
problems...

Any Idea?

Thanks in advance.
Christian.

-- 





Re: [web2py] Re: new plugin - web2py Form Wizard - PowerFormWizard

2012-07-13 Thread Christian Espinoza
Hello Bruno, I did download the example app to test it, but i get this 
error:

 'PowerFormWizard' object has no 
attribute 'readonly'

do you know what can be the problem?

Thanks in advance
Christian.

El jueves, 30 de junio de 2011 08:44:42 UTC-4, rochacbruno escribió:
>
> Even without client side validation, the server side will perform at the 
> end of submission.
>
> The client-side validation, for now, just check if a field is required, i 
> did not implemented yet the other kind of client validation.
>
> I guess you can use factory in the normal way, PowerFormWizard.factory, as 
> PowerFormWizard is a subclass of SQLFORM. - But I did not tested yet.
>
> I just found some issues, I will wait for people to raise more issues and 
> I will update.
>
> Thank you all for testing..
>
> On Thu, Jun 30, 2011 at 4:49 AM, niknok  wrote:
>
>> Clarification regarding the bio field with requires. It does let me
>> proceed to the next step, but will not be allowed to submit the data
>> after validation unless i meet the requires statement.
>>
>> A bit confusing since some fields will allow me to move to next step.
>>
>> One more thing, is there going to be an equivalent for
>> SQLFORM.factory?
>>
>>
>>
>> On Jun 30, 2:41 pm, niknok  wrote:
>> > In the validation example,  I entered a single character in the Bio
>> > and was allowed to proceed to the next field despite the
>> > db.person.bio.requires = IS_LENGTH(minsize=5, maxsize=200). You  made
>> > a note about "Client side validation is not supposed to validate
>> > everything!", is this included in that exception?
>> >
>> > A few suggestions:
>> > * How about using "description" or "details" instead of the "legend"
>> > keyword at it seems to be more appropriate for said function.
>> >
>> > • As default behavior, instead of the default "X" errorImage beside
>> > the step title, how about using an exclamation point icon to indicate
>> > that this step needs attention and then in the specific field with an
>> > error use the "X" icon instead.
>> >
>> > The other day you answered my query re modal windows with a reference
>> > to easyframework.com + web2py.
>> >
>> > I pray that you have plans of adding that feature to your
>> > PowerFormWizard Plugin (or perhaps turning this into a "PowerForms"
>> > plugin to truly enable feature-full forms in Web2py?
>> >
>> > Cheers and many thanks for your many contributions to the web2py
>> > community.
>> >
>> > /r
>> > Nik
>> >
>> > On Jun 29, 10:33 pm, Bruno Rocha  wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > Hi,
>> >
>> > > I just created a new plugin for stepped form wizards.
>> >
>> > > I made it last night, so it is not tested very well, I would like 
>> your help
>> > > to test it.
>> >
>> > > web2py PowerFormWizard Plugin - based on Jquery Stepy
>> >
>> > > - Steps
>> > > - Customizable titles
>> > > - Server side validation
>> > > - Client side validation (with jquery validate)
>> > > - Custom css
>> > > - JS Callbaks
>> > > - Error images
>> >
>> > > Take a look:http://labs.blouweb.com/powerformwizard
>> >
>> > > This plugin is the second plugin of blouweb PowerPlugins, I am now 
>> starting
>> > > the third one which I hope to have the first version soon.
>> >
>> > >http://labs.blouweb.com
>> >
>> > > Suggestions, testers, issues, contributions etc on bitbucket:
>> https://bitbucket.org/rochacbruno/powerformwizard
>> >
>> > > Hope it helps someone!
>> >
>> > > Thanks.
>> >
>> > > --
>> > > Bruno Rocha
>> > > [ About me:http://zerp.ly/rochacbruno]
>> > > [ Aprenda Python:http://CursoDePython.com.br]
>> > > [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br
>> ]
>> > > [ Consultoria em desenvolvimento web:http://www.blouweb.com]
>>
>
>
>
> -- 
>
>
>
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
> [ Aprenda a programar: http://CursoDePython.com.br ]
> [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
> [ Consultoria em desenvolvimento web: http://www.blouweb.com ]
>
> 

[web2py] Re: Problems with using downloaded layouts

2012-07-13 Thread Christian Espinoza
I'm newbie too, but I know that all layout's are only a html skeleton, you 
can modify it freely or create your own layout plugin

If you want you can uninstall this layout plugin without problems from the 
admin interface.

Good Luck
Christian. 

El lunes, 18 de junio de 2012 07:24:09 UTC-4, rahulserver escribió:
>
> I am facing two problems in general with downloaded layouts from web2py 
> site:
> 1) whenever a form or table extends beyond the page body area, it goes 
> beyound the middle area's margin.In default layout, the middle area appears 
> to expand to accomodate the form or table.
> 2) In Sqlform.grid or smartgrid, the view edit or delete link appears like 
> vieweditdelete i.e.with no spaces in between. In default layout,they appear 
> spaced apart.
>
> I am currently using corporate office template(
> http://web2py.com/layouts/static/plugin_layouts/plugins/web2py.plugin.layout_CorporateOffice.w2p).
>  
>
> Is there a way to restore the default web2py template?
> Also in my typical case, I am using hindi fonts from google IME. The 
> template does not seems to render these fonts.The default web2py template 
> does render these. So how should I get around these problems?
>