[web2py] Re: onvalidation in SQLFORM.grid (V2.0.9)

2013-04-25 Thread Martín Miranda
Hiding  errors in SQLFORM.grid?

for example:
form = SQLFORM(db.table):
if form.accepts(request.vars, hideerror=True):
   

In SQLFORM.grid?

El viernes, 14 de septiembre de 2012 08:25:45 UTC-3, Gerd escribió:

 Hi!

 I receive the following error

 Traceback (most recent call last):
   File /home/gniemetz/webapps/web2py/web2py/gluon/restricted.py, line 209, 
 in restricted
 exec ccode in environment
   File 
 /home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py
  https://tauchbuch.niemetz.it/admin/edit/tauchbuch/controllers/default.py, 
 line 92, in module
   File /home/gniemetz/webapps/web2py/web2py/gluon/globals.py, line 186, in 
 lambda
 self._caller = lambda f: f()
   File /home/gniemetz/webapps/web2py/web2py/gluon/tools.py, line 2809, in f
 return action(*a, **b)
   File 
 /home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py
  https://tauchbuch.niemetz.it/admin/edit/tauchbuch/controllers/default.py, 
 line 16, in index
 if grid.errors:
 AttributeError: 'DIV' object has no attribute 'errors'



 This is the controller

 @auth.requires_login()
 def index():
 grid = SQLFORM 
 https://web2py.niemetz.it/examples/global/vars/SQLFORM.grid(db.Logbuch,fields=[db.Logbuch.Datum,db.Logbuch.Kurs,db.Logbuch.Thema,db.Logbuch.Kommentar],maxtextlength=50,orderby=[~db.Logbuch.Datum],onvalidation=check_km)
 if grid.errors:
 response 
 https://web2py.niemetz.it/examples/global/vars/response.flash = 'Bitte 
 Eingaben überprüfen'
 return locals()

 def check_km(form):
 if form.vars.KM_Beginn = form.vars.KM_Ende:
 form.errors.KM_Ende = 'KM-Stand Ende kleiner/gleich KM-Stand Beginn'


 What i'm trying to do is to set response.flash

 What am i doing wrong here?

 Thanks,
 regards
 Gerd




-- 

--- 
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: bootstrap's modal and web2py's LOAD

2013-03-20 Thread Martín Miranda
Here ... 
http://linuxapuntes.blogspot.com.ar/2013/03/plugin-modal-bootstrap-web2py.html



El martes, 19 de marzo de 2013 15:59:06 UTC-3, Vincenzo Ampolo escribió:

 Hi, 

 I'm having a problem in correctly make modal talk with web2py. I want to 
 achieve a simple thing: having a button that loads a SQLFORM and simply 
 creates a bootstrap's modal so that the user can complete the form and 
 type submit. 
 I want to use web2py LOAD such that submit of the form is handled by 
 ajax as well. 

 So far i've this on my view: 

 a href={{=URL(f='add_traceback', args=[request.args(0), 
 bug.tstamp])}} role=button class=btn btn-primary 
 data-toggle=modalAdd bug/a 

 that together with this javascript: 

 script type=text/javascript 
 $(document).ready(function() { 
  
 // Support for AJAX loaded modal window. 
 // Focuses on first input textbox after it loads the window. 
 $('[data-toggle=modal]').click(function(e) { 
 e.preventDefault(); 
 var url = $(this).attr('href'); 
 if (url.indexOf('#') == 0) { 
 $(url).modal('open'); 
 } else { 
 $('body').append('div id=c282718984176loading.../div') 
 $('body').append('script type=text/javascript!-- 
 web2py_component('+url+',c282718984176) 
 //--/'+'script'); 
 // $.get(url, function(data) { 
 // $(data).modal(); 
 // }).success(function() { 
 $('input:text:visible:first').focus(); }); 
 } 
 }); 
  
 }); 
 /script 

 Tries to do what LOAD is supposed to do server side (I want to do the 
 same, but i'm client side here). 

 The problem is mainly that as soon as I inject the script to the dom 
 the page loads the url and replaces the body of my page with the content 
 of the url instead of placing the content on the div #c282718984176 and 
 set all the trigger to do a ajax submit. 

 Any clue in how to solve this problem? 
 -- 
 Vincenzo Ampolo 
 http://goshawknest.wordpress.com/ 
 http://vincenzo-ampolo.net/ 


-- 

--- 
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] Problem with Chromium

2013-03-05 Thread Martín Miranda
I'm not sure where the issue comes but here's the thing.
I did some modifications to some plugins that uses a modal in forms.
Here's the plugin code:


# In models/db.py

db.define_table('Area',
Field('nombre', requires=IS_NOT_EMPTY()),
format=%(nombre)s
)

db.define_table('Docente',
Field('nombre', requires=IS_NOT_EMPTY()),
Field('id_area', db.Area),
format=%(nombre)s
)

# In controller/default.py

def index():
from plugins import formModal
modal = formModal('boton',
'Agregar Registro Iniciador',
'Agregue un Iniciador',
_crud=crud)
db.Docente.id_area.comment = modal.create(db.Docente.id_area)
form = SQLFORM(db.Docente)
if form.accepts(request.vars, session):
response.flash = Se agregó un nuevo expediente
elif form.errors:
response.flash = Check form
return dict(form=form)

# In views/default/index.html

{{left_sidebar_enabled=True}}
{{extend 'layout.html'}}

{{=form}}


# In modules/plugins.py

There's a file attached 

Now, everything's works fine, or at least in Mozilla Firefox but when I try 
to see it on Chromium it doesn't work as excpected 

Any suggestions?, thanks in advance!

-- 

--- 
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: Problem with Chromium

2013-03-05 Thread Martín Miranda
Attached file.

-- 

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


#-*- encoding:utf-8 -*-
#* formModal
from gluon.html import A, DIV, H3, BUTTON, OPTION, TAG, I
from gluon.compileapp import LOAD
from gluon.http import HTTP
from gluon import current


class formModal(object):

def __init__(self, value, title_btn, title_modal, _crud):
self.value = value
self.title_btn = title_btn
self.title_modal = title_modal
self.key = newkey
self.crud = _crud

def btn_show(self):
#  Button to trigger modal .
btn_show_modal = A(I(_class=icon-plus-sign),
' ', self.value,
**{_role: button,
   #_class: btn btn-link,
   _data-toggle: modal,
   _href: #Modal_%s % self.key,
   _title: self.title_btn})
return btn_show_modal

def div_modal(self, content_modal):
div_modal = DIV(
DIV(
H3(self.title_modal, _id=myModalLabel),
_class=modal-header),
DIV(content_modal, _class=modal-body),
DIV(
BUTTON(Cerrar, **{_class: btn,
_data-dismiss: modal,
_aria-hidden: true}),
_class=modal-footer,
),
**{_id: Modal_%s % self.key,
   _class: modal hide face,
   _tabindex: -1,
   _role: dialog,
   _aria-hidden: true,
   _aria-labelledby: myModalLabel}
)
return div_modal

def create(self, field):
request = current.request
response = current.response
crud = self.crud

if not field.type.startswith('reference'):
raise SyntaxError(S?lo puede usarse con field reference)
if not hasattr(field.requires, 'options'):
raise SyntaxError(No puede determinarse las opciones)

self.key = str(field).replace('.', '_')
if request.get_vars._ajax_add == str(field):
def update_select(form):
options = TAG[''](*[OPTION(v,
_value=k,
_selected=str(form.vars.id) == str(k))
for (k, v) in field.requires.options()])
_cmd = jQuery('#%s').html('%s');
_cmd += jQuery('#Modal_%s').modal('hide')
command = _cmd % (self.key,
  options.xml().replace(', \'),
  self.key)
response.headers['web2py-component-command'] = command
table = field._db[field.type[10:]]
raise HTTP(200,
   crud.create(table,
   onaccept=update_select).xml(),
   **response.headers)

return TAG[''](
self.btn_show(),
self.div_modal(LOAD(request.controller,
request.function,
args=request.args,
vars=dict(_ajax_add=field), ajax=True))
)


[web2py] Re: new feature in trunk: generic.map

2012-11-07 Thread Martín Miranda
(2, 0, 9, datetime.datetime(2012, 9, 13, 23, 51, 30), 'stable')  Python Python 
2.7.3: /usr/bin/python  Traceback 

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

Traceback (most recent call last):
  File /home/www-data/web2py/gluon/restricted.py, line 209, in restricted
exec ccode in environment
  File /home/www-data/web2py/applications/comisiones/views/default/map.html, 
line 98, in module
  File /home/www-data/web2py/applications/comisiones/controllers/default.py 
https://localhost/admin/default/edit/comisiones/controllers/default.py, line 
81, in lambda
maker = lambda point: A(row.name,_href='...'),
NameError: global name 'row' is not defined



El jueves, 5 de abril de 2012 20:54:32 UTC-3, Massimo Di Pierro escribió:

 Example:

 # model
 db.define_table('point',
 Field('name'),
 Field('latitude','double'),
 Field('longitude','double'))

 #controller
 def map():
 return dict(
   googlemap_key='...',  # get this from google maps
   center_latitude = 41.878,
   center_longitude = -87.629,
   scale = 7,
   maker = lambda point: A(row.name,_href='...')
   points = db(db.point).select() 
 )

 #in views/defaut/map.html:

 {{extend 'layout.html'}}
 center
h2My Map/h2
 {{include 'generic.map'}}
 /center



-- 





[web2py] Re: web2py 2.0.2 is out

2012-09-03 Thread Martín Miranda
+1 ;) Excelent! 

 I personally want to thank the major contributors to this release (in 
 alphabetic order)
 Alan, Andrew, Anthony, Bruno, Christian, Dave, Dominic, Iceberg, Jonathan, 
 Marc, Mariano, Marin, Martin, Mark, Michael, Michele, Niphlod, Patrick, 
 Vladyslav, 
 They spend many nights testing, coding, debugging at a very fast pace.

 Many many people have contributed.

 If your contribution has not been properly acknowledged please let us know 
 ASAP. It is probably an oversight.


 Massimo


 Detailed changelog
 ===

 ## 2.00.2

 ### DAL Improvements

 - Support for DAL(lazy_tables=True) and db.define_table(on_define=lambda 
 table:), thanks Jonathan
 - db(...).select(cacheable=True) make select 30% faster
 - db(...).select(cache=(cache.ram,3600)) now caches parsed data 100x faster
 - db(...).count(cache=(cache.ram,3600)) now supported
 - MongoDB support in DAL (experimental), thanks Mark Breedveld
 - geodal and spatialite, thanks Denes and Fran (experimental)
 - db.mytable._before_insert, _after_insert, _before_update, _after_update, 
 _before_delete. _after_delete (list of callbacks)
 - db(...).update_naive(...) same as update but ignores 
 table._before_update and table._after_update
 - DAL BIGINT support and DAL(...,bigint_id=True)
 - IS_IN_DB(..., distinct=True)
 - new syntax: db.mytable.insert(myuploadfield=open()), thank you 
 Iceberg
 - db(...).select(db.mytable.myfield.count(distinct=True))
 - db(db.a)._update(name=db(db.b.a==db.a.id).nested_select(db.b.id))
 - db.mytable.myfield.filter_in, filter_out
 - db.mytable._enable_record_versioning(db) adds versioning to this table
 - teradata adapter, thanks Andrew Willimott
 - experimental Sybase Adapter
 - added db.table.field.avg()
 - Support for Google App Engine projections, thanks Christian
 - Field(... 'upload', default=path) now accepts a path to a local file as 
 default value, if user does not upload a file. Relative path looks inside 
 current application folder, thanks Marin
 - executesql(...,fields=,columns=) allows parsing of results in Rows, 
 thanks Anthony

 ### Auth improvements

 - auth.enable_record_versioning(db)  adds full versioning to all tables
 - @auth.requires_login(otherwise=URL(...))
 - auth supports salt and compatible with third party data, thanks Dave 
 Stoll
 - CRYPT now defaults to pbkdf2(1000,20,sha1)
 - Built-in wiki with menu, tags, search, media, permissions. def index: 
 return auth.wiki()
 - auth.settings.everybody_group_id
 - allow storage of uploads on any PyFileSystem (including amazon)

 ### Form improvements

 - FORM.confirm('Are you sure?',{'Back':URL(...)})
 - SQLFORM.smartdictform(dict)
 - form.add_button(value,link)
 - SQLFORM.grid(groupby='...')
 - fixed security issue with SQLFORM.grid and SQLFORM.smartgrid
 - more export options in SQLFORM.grid and SQLFORM.smartgrid (html, xml, 
 csv, ...)

 ### Admin improvements

 - new admin pages: manage_students, bulk_regsiter, and progress reports
 - increased security in admin against CSRF
 - experimental Git integration
 - experimental OpenShift deployment
 - multi-language pluralization engine 
 - ace text web editor in admin
 - Ukrainian translations, thanks Vladyslav Kozlovskyy
 - Romanian translation for welcome, thanks ionel
 - support for mercurial 2.6, thanks Vlad

 ### Scheduler Improvements (thanks to niphlod, ykessler, dhx, toomim)

 - web2py.py -K myapp -X starts the myapp scheduler alongside the webserver
 - tasks are marked EXPIRED (if stop_time passed)
 - functions with no result don't end up in scheduler_run
 - more options: web2py.py -E -b -L
 - scheduler can now handle 10k tasks with 20 concurrent workers and with 
 no issues
 - new params:
 tasks can be found in the environment (no need to define the tasks 
 parameter)
 max_empty_runs kills the workers automatically if no new tasks are 
 found in queue (nice for spikes of processing power)
 discard_results to completely discard the results (if you don't need 
 the output of the task)
 utc_time enables datetime calculations with UTC time
 - scheduler_task changes:
 task_name is no longer required (filled automatically with 
 function_name if found empty)
 uuid makes easy to coordinate scheduler_task maintenance (filled 
 automatically if not provided)
 stop_time has no default (previously was today+1)
 retry_failed to requeue automatically failed tasks
 sync_output refreshes automatically the output (nice to report 
 percentages)
 - workers can be:
 DISABLED (put to sleep and do nothing if not sending the heartbeat 
 every 30 seconds)
 TERMINATE (complete the current task and then die)
 KILL (kill ASAP)

 ### Other Improvements 

 - gluon/contrib/webclient.py makes it easy to create functional tests for 
 app
 - DIV(..).elements(...replace=...), thanks Anthony
 - new layout based on Twitter Bootstrap
 - New generic views: generic.ics (Mac Mail Calendar) and generic.map 
 (Google Maps)
 - request.args(0,default=0,