[web2py] Re: How to add more buttons to form that submits form to different actions ...

2011-10-11 Thread David Marko
I'm trying to find out nice solution for situation where the user makes some 
basic selection on form and then I have to load some aditional data from 
server. For example when user makes selection of manager name using combo 
box on form then I need to send data to server to load some aditional 
information based on his selection . So its just simple roundtrip to server 
but to specific action based on what user just did.(and I can have a few 
such selection-post/refresh actions on the form) 
Is there a way you use for such scenarios?


[web2py] Database constraints or Web2py validators

2011-10-11 Thread Johann Spies
I have several tables where there should only be one possible combination of
two uuid-fields per table (mostly many to many links).

I have created 'unique' constraints for those fields in Postgresql so the
database would not accept any inserts or edits which violates that
constraint.

I use that in combination with 'try:..  except:' to insert data.

Can DAL be used in a way for this?  As far as I understand the IS_NOT_IN_DB
validators that it is working on form-level and not on database level and I
am not sure whether it can be used for a combination of fields (unless I do
it with a computed field - which will use up a lot of extra resources).

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] db events trigger

2011-10-11 Thread Manuele

Hi,
is there a way to trigger some functions on database eventes, for 
example on new record?


thanks a lot

Manuele


[web2py] Re: Making slides with web2py and markmin

2011-10-11 Thread peter
Using windows, and web2py version 1.99.2, if I setup a simple
applicatioin, add slides.py and the test as per your instructions:

Things only half work. The link does not work, it says

you can use

http://www.google.com]]


you can use images [[image align=center /


If one tries emboldening words, they do no appear emboldened.

This is a nice little addition to web2py, but it appears there is a
bug.

Thanks again for all you work Massimo.

Peter

On Sep 13, 6:31 am, Andrew awillima...@gmail.com wrote:
 Whilst on the subject of [[ image tags in markmin,  how do I reference
 a local image ?  Can I use the URL function ?

 On Sep 13, 4:11 pm, guruyaya guruy...@gmail.com wrote:







  Well, oddly it works the other way for me. I'll look into it later
  today.

  On Sep 12, 3:20 am, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:

   markmin requires [[...]] not [...]

   On Sep 11, 2:29 pm, guruyaya guruy...@gmail.com wrote:

Ummm, why are you using [[ for links and images instead of just one
[ ? It doesn't work for me, when I user the [[ syntax.

On Sep 11, 1:36 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:

 No. It makes the view. You just return it.

 On Sep 10, 3:53 pm, António Ramos ramstei...@gmail.com wrote:

  Humm, dont i need a view?

  Em 10 de setembro de 2011 21:52, António Ramos 
  ramstei...@gmail.comescreveu:

   Working now :)

   Em 10 de setembro de 2011 21:29, António Ramos 
   ramstei...@gmail.comescreveu:

   Traceback (most recent call last):
   File gluon/restricted.py, line 191, in restricted
   File gluon/restricted.py, line 178, in compile2
   TypeError: compile() expected string without null bytes

   :(

   Just a screenshot please

   2011/9/10 Michele Comitini michele.comit...@gmail.com

   +1

   Terrific!

   mic
   Il giorno 10/set/2011 21:24, Massimo Di Pierro 
   mdipie...@cs.depaul.edu ha scritto:

Based on desk.js now you can do this

Put the attached slide.py under models (any app).

Write a controller like

def test():
content = 
# My slides title
## Slide One
this allows you to create slides using markmin
## Slide Two
- you can use lists
- you can use [[linkshttp://www.google.com]]
- you can use images [[imagehttp://image.example.comcenter]]

return SLIDE(content,title=My slides)

Notice the resulting file is pure html5 with external links 
therefore
   it can be downloaded as an independent document.


Re: [web2py] Re: Tag handling suggestions

2011-10-11 Thread Martín Mulone
In my opinion I'll discard option number 1 if you are not running on GAE.
Because is not a true SQL, is quite awfull indeed, bring it by nosql gae.
 But it's all depends on the amount of records.

2011/10/10 Bruno Rocha rochacbr...@gmail.com

 I like this, and it is really smarter than list:string option, but, imagine
 a blog where users include tags in an INPUT text field, this will be more
 difficult to store tags in other table (you can do using ajax or building a
 checkbox list of tags) but it is easy just to let the user put tags in a
 text field comma separated or space sepated, then split and store in
 list:string field.




-- 
 http://martin.tecnodoc.com.ar


[web2py] Postgresql-problem when deleting fields

2011-10-11 Thread Johann Spies
I have changed the model of a populated table (removing two fields with
uuid-type references to other tables).

Now when I restart web2py the process never becomes ready.  In the
Postgresql-log I see:

2011-10-11 12:24:13 SAST LOG:  could not receive data from client:
Connection reset by peer
2011-10-11 12:24:13 SAST LOG:  unexpected EOF on client connection

and I see nothing in databases/sql.log nor in any other file there that
would suggest that web2py is trying to do something about the situation.

Shall I just change the table structure in Postgresql and then try again?

Regards
Johann


-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Static forms

2011-10-11 Thread Web2Py Freak
Dear All ,

i want to build a form in html and when the form is accepted  send its
content  in a Email , i know how to email it  but i want to know how
can i catch it in the controler and see if its accepted  , how can i
do that ??


[web2py] Re: Tag handling suggestions

2011-10-11 Thread stefaan
How does choosing option 1 -- option 3 affect building a UI ?

It seems to me that option 1 can be used as-is in an SQLFORM.grid
containing other fields,
whereas option 3 might require a separate SQLFORM.grid to manage the
correspondence tags-items?

If this is just me not understanding all possibilities of
SQLFORM.grid, then please elaborate.



[web2py] Re: Static forms

2011-10-11 Thread Anthony
Same as usual -- you have to create a FORM (or SQLFORM) object in the 
controller and use form.accepts (or the newer form.process). You can create 
the form manually in HTML and just make sure you include the _formname 
hidden field 
(see http://web2py.com/book/default/chapter/07#SQLFORM-in-HTML), though that 
won't involve a _formkey and therefore won't provide CSRF protection. A 
better way is probably to use SQLFORM.factory and use the method described 
here (http://web2py.com/book/default/chapter/07#Custom-forms) to customize 
the HTML.

Anthony

On Tuesday, October 11, 2011 7:01:53 AM UTC-4, Web2Py Freak wrote:

 Dear All , 

 i want to build a form in html and when the form is accepted  send its 
 content  in a Email , i know how to email it  but i want to know how 
 can i catch it in the controler and see if its accepted  , how can i 
 do that ??



[web2py] Re: Database constraints or Web2py validators

2011-10-11 Thread Anthony
On Tuesday, October 11, 2011 4:04:41 AM UTC-4, spyker wrote:

 I have several tables where there should only be one possible combination 
 of two uuid-fields per table (mostly many to many links).

 I have created 'unique' constraints for those fields in Postgresql so the 
 database would not accept any inserts or edits which violates that 
 constraint.

 I use that in combination with 'try:..  except:' to insert data.

 Can DAL be used in a way for this?  As far as I understand the IS_NOT_IN_DB 
 validators that it is working on form-level and not on database level and I 
 am not sure whether it can be used for a combination of fields (unless I do 
 it with a computed field - which will use up a lot of extra resources).


If you only need to validate form submissions (and not other means of making 
inserts), then you could do something like:

db.define_table('mytable',
Field('field1'),
Field('field2', 
requires=IS_NOT_IN_DB(db(db.mytable.field1==request.vars.field1), 
'mytable.field2')))

That will make sure field2 is unique among the set of records where field1 
matches the new value of field1 being inserted (so the combination of field1 
and field2 must be unique). It depends on the values being available in 
request.vars, so not relevant for non-form inserts (though in that case, I 
suppose you could create your own request.vars as a hack).

Anthony






[web2py] Re: Static forms

2011-10-11 Thread Web2Py Freak
when using  sqlform-in-html  ,do i have to use a table in the db ,,
and how can i create a radio button from there ?


[web2py] Re: Database constraints or Web2py validators

2011-10-11 Thread Anthony
Again, if just focused on form validation, I suppose another option would be 
to use an onvalidation function (processed after form validation but before 
db insert).

Anthony

On Tuesday, October 11, 2011 7:23:33 AM UTC-4, Anthony wrote:

 On Tuesday, October 11, 2011 4:04:41 AM UTC-4, spyker wrote:

 I have several tables where there should only be one possible combination 
 of two uuid-fields per table (mostly many to many links).

 I have created 'unique' constraints for those fields in Postgresql so the 
 database would not accept any inserts or edits which violates that 
 constraint.

 I use that in combination with 'try:..  except:' to insert data.

 Can DAL be used in a way for this?  As far as I understand the 
 IS_NOT_IN_DB validators that it is working on form-level and not on database 
 level and I am not sure whether it can be used for a combination of fields 
 (unless I do it with a computed field - which will use up a lot of extra 
 resources).


 If you only need to validate form submissions (and not other means of 
 making inserts), then you could do something like:

 db.define_table('mytable',
 Field('field1'),
 Field('field2', 
 requires=IS_NOT_IN_DB(db(db.mytable.field1==request.vars.field1), 
 'mytable.field2')))

 That will make sure field2 is unique among the set of records where field1 
 matches the new value of field1 being inserted (so the combination of field1 
 and field2 must be unique). It depends on the values being available in 
 request.vars, so not relevant for non-form inserts (though in that case, I 
 suppose you could create your own request.vars as a hack).

 Anthony






Re: [web2py] Re: Database constraints or Web2py validators

2011-10-11 Thread Johann Spies
On 11 October 2011 13:25, Anthony abasta...@gmail.com wrote:

 Again, if just focused on form validation, I suppose another option would
 be to use an onvalidation function (processed after form validation but
 before db insert).

 Anthony


 On Tuesday, October 11, 2011 7:23:33 AM UTC-4, Anthony wrote:

 On Tuesday, October 11, 2011 4:04:41 AM UTC-4, spyker wrote:

 I have several tables where there should only be one possible combination
 of two uuid-fields per table (mostly many to many links)...




 db.define_table('mytable',
 Field('field1'),
 Field('field2', requires=IS_NOT_IN_DB(db(db.**
 mytable.field1==request.vars.**field1), 'mytable.field2')))

 That will make sure field2 is unique among the set of records where field1
 matches the new value of field1 being inserted (so the combination of field1
 and field2 must be unique). It depends on the values being available in
 request.vars, so not relevant for non-form inserts (though in that case, I
 suppose you could create your own request.vars as a hack).


Thanks Anthony.  I will probably make use of what you suggested.  I did not
know how to involve the two fields in the form-evaluation.  This will not
replace the database constraint:  tackling this from both the backend and
the user interface.

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


Re: [web2py] Re: Database constraints or Web2py validators

2011-10-11 Thread Bruno Rocha
On Tue, Oct 11, 2011 at 8:43 AM, Johann Spies johann.sp...@gmail.comwrote:

 Thanks Anthony.  I will probably make use of what you suggested.  I did not
 know how to involve the two fields in the form-evaluation.  This will not
 replace the database constraint:  tackling this from both the backend and
 the user interface.


Note that you can use db.table.validate_and_insert and
db.table.validate_and_update to fire validators in pure DAL without forms.

--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]


Re: [web2py] Re: Database constraints or Web2py validators

2011-10-11 Thread Johann Spies
On 11 October 2011 13:48, Bruno Rocha rochacbr...@gmail.com wrote:

 Note that you can use db.table.validate_and_insert and
 db.table.validate_and_update to fire validators in pure DAL without forms.


Thanks!  I did not know about that.

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: Postgresql-problem when deleting fields

2011-10-11 Thread Johann Spies
On 11 October 2011 12:31, Johann Spies johann.sp...@gmail.com wrote:

 I have changed the model of a populated table (removing two fields with
 uuid-type references to other tables).

 Now when I restart web2py the process never becomes ready.  In the
 Postgresql-log I see:

 2011-10-11 12:24:13 SAST LOG:  could not receive data from client:
 Connection reset by peer
 2011-10-11 12:24:13 SAST LOG:  unexpected EOF on client connection

 and I see nothing in databases/sql.log nor in any other file there that
 would suggest that web2py is trying to do something about the situation.

 Shall I just change the table structure in Postgresql and then try again?

 The problem was solved in the end by restarting Postgresql.   I just
stopped reacting to requests.

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: Static forms

2011-10-11 Thread Anthony
You can use SQLFORM.factory if you don't have a db table. For a radio 
button, I suppose you could specify the radio widget for a given field 
(see http://web2py.com/book/default/chapter/07#Widgets), or you could build 
the HTML manually (review the details 
at http://web2py.com/book/default/chapter/07#Custom-forms).

Anthony

On Tuesday, October 11, 2011 7:25:29 AM UTC-4, Web2Py Freak wrote:

 when using  sqlform-in-html  ,do i have to use a table in the db ,, 
 and how can i create a radio button from there ?



[web2py] Re: two SQLFORM.grid in one view?

2011-10-11 Thread stefaan
Maybe useful for readers in the future:

Using multiple grids in one view is not supported, and the problems
won't be fixed.
(workaround: e.g. use iframes, or design a better UI that doesn't need
two grids in one view ;) )



[web2py] Re: two SQLFORM.grid in one view?

2011-10-11 Thread Massimo Di Pierro
Let me explain and clarify.

A grid can display multiple actions (select/edit/view/update etc...)
it discriminates this from the URL. Different grid actions have
different URLs. This is a feature. This allows you to reference a
particular page in a grid using the URL and send for example a link to
a friend.

Fixing would mean removing the ability to link a grid action (for
example results of a search).

If you have two grids in one page you can no longer use the URL to
determine what each of the two views should be displaying unless you
*hide* the URL.
This can be done by putting the grid into an iframe or loading the
grid via ajax with{{=LOAD('')}}

Massimo


On Oct 11, 8:49 am, stefaan stefaan.hi...@gmail.com wrote:
 Maybe useful for readers in the future:

 Using multiple grids in one view is not supported, and the problems
 won't be fixed.
 (workaround: e.g. use iframes, or design a better UI that doesn't need
 two grids in one view ;) )


[web2py] Re: Making slides with web2py and markmin

2011-10-11 Thread Massimo Di Pierro
I do not understand the bug. Can you provide an example?

On Oct 11, 5:28 am, peter peterchutchin...@gmail.com wrote:
 Using windows, and web2py version 1.99.2, if I setup a simple
 applicatioin, add slides.py and the test as per your instructions:

 Things only half work. The link does not work, it says

 you can use

 http://www.google.com]]
 

 you can use images [[image align=center /
 

 If one tries emboldening words, they do no appear emboldened.

 This is a nice little addition to web2py, but it appears there is a
 bug.

 Thanks again for all you work Massimo.

 Peter

 On Sep 13, 6:31 am, Andrew awillima...@gmail.com wrote:







  Whilst on the subject of [[ image tags in markmin,  how do I reference
  a local image ?  Can I use the URL function ?

  On Sep 13, 4:11 pm, guruyaya guruy...@gmail.com wrote:

   Well, oddly it works the other way for me. I'll look into it later
   today.

   On Sep 12, 3:20 am, Massimo Di Pierro massimo.dipie...@gmail.com
   wrote:

markmin requires [[...]] not [...]

On Sep 11, 2:29 pm, guruyaya guruy...@gmail.com wrote:

 Ummm, why are you using [[ for links and images instead of just one
 [ ? It doesn't work for me, when I user the [[ syntax.

 On Sep 11, 1:36 am, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:

  No. It makes the view. You just return it.

  On Sep 10, 3:53 pm, António Ramos ramstei...@gmail.com wrote:

   Humm, dont i need a view?

   Em 10 de setembro de 2011 21:52, António Ramos 
   ramstei...@gmail.comescreveu:

Working now :)

Em 10 de setembro de 2011 21:29, António Ramos 
ramstei...@gmail.comescreveu:

Traceback (most recent call last):
File gluon/restricted.py, line 191, in restricted
File gluon/restricted.py, line 178, in compile2
TypeError: compile() expected string without null bytes

:(

Just a screenshot please

2011/9/10 Michele Comitini michele.comit...@gmail.com

+1

Terrific!

mic
Il giorno 10/set/2011 21:24, Massimo Di Pierro 
mdipie...@cs.depaul.edu ha scritto:

 Based on desk.js now you can do this

 Put the attached slide.py under models (any app).

 Write a controller like

 def test():
 content = 
 # My slides title
 ## Slide One
 this allows you to create slides using markmin
 ## Slide Two
 - you can use lists
 - you can use [[linkshttp://www.google.com]]
 - you can use images [[imagehttp://image.example.comcenter]]
 
 return SLIDE(content,title=My slides)

 Notice the resulting file is pure html5 with external links 
 therefore
it can be downloaded as an independent document.


[web2py] on grid and smartgrid search feature

2011-10-11 Thread Massimo Di Pierro
The new grid/smartgrid have a much better search feature. A new button
query shows a popup panel that allows you to build the query string.
Can you please check on your existing tables and see if you encounter
any problems?

You will need trunk but also the latest applications/welcome/js/
web2py_ajax.js and the css at the bottom of applications/welcome/
static/css/base.css


[web2py] Re: two SQLFORM.grid in one view?

2011-10-11 Thread Anthony
On Tuesday, October 11, 2011 9:49:51 AM UTC-4, stefaan wrote:

 (workaround: e.g. use iframes, or design a better UI that doesn't need 
 two grids in one view ;)


Using ajax components might be better/easier than iframes.


[web2py] Re: Static forms

2011-10-11 Thread Web2Py Freak
am trying to use SQLFORM.factory with a widget but its not working :

def booking():
content=db(db.page.title=='booking').select(db.page.ALL)
form = SQLFORM.factory(
Field('your_name', requires=IS_NOT_EMPTY()),
Field('your_email'),
Field('like',widget=SQLFORM.widgets.radio.widget)
)
if form.accepts(request.vars,session):
response.flash = 'form accepted'

elif form.errors:
response.flash = 'form has errors'
return dict(content=content,form=form)



the error is :

type 'exceptions.SyntaxError'(widget cannot determine options of
no_table.like)


what to do ??!


Re: [web2py] Re: Static forms

2011-10-11 Thread Richard Vézina
Maybe you need a boolean to use this widget?!

Richard

On Tue, Oct 11, 2011 at 10:45 AM, Web2Py Freak
halna...@gardeniatelco.comwrote:

 am trying to use SQLFORM.factory with a widget but its not working :

 def booking():
content=db(db.page.title=='booking').select(db.page.ALL)
form = SQLFORM.factory(
Field('your_name', requires=IS_NOT_EMPTY()),
Field('your_email'),
Field('like',widget=SQLFORM.widgets.radio.widget)
)
if form.accepts(request.vars,session):
response.flash = 'form accepted'

elif form.errors:
response.flash = 'form has errors'
return dict(content=content,form=form)



 the error is :

 type 'exceptions.SyntaxError'(widget cannot determine options of
 no_table.like)


 what to do ??!



[web2py] re populate

2011-10-11 Thread apple
Have just started using populate which is a really useful tool.
However I have a couple of questions:

1) It seems to ignore the length specified for string fields. For
example it fills my postcode field with 100 characters of text despite
it having length of 8. Is there a way of restricting the text to 8
characters?

2) Sometimes it fails with a sqlite error saying column name is not
unique. Does it not recognise unique constraints?

My tabledef is:

db.define_table('customer',
Field('title', requires=IS_IN_SET([Mr, Mrs, Ms],
zero=None)),
Field('name', length=256, requires=[IS_NOT_EMPTY(),
IS_NOT_IN_DB(db,
'customer.name')],  unique=True),
Field('address1', length=256),
Field('address2', length=256),
Field('postcode', length=8, requires=IS_LENGTH(8))


[web2py] Re: Static forms

2011-10-11 Thread Web2Py Freak
oh thnx richard  its working  , and its a radio now but tell me how
can i get its valu when accepted ??


[web2py] table without id

2011-10-11 Thread Cory Coager
I have created some database tables externally to web2py.  Does web2py
require an id field for tables?  The reason why I'm asking is, when I
use the DAL to do an insert, web2py tries to retrieve the currval of
the insert.  Seeing how I don't have an id, this throws an exception.
How should I handle this?


[web2py] Re: re populate

2011-10-11 Thread Anthony
On Tuesday, October 11, 2011 10:49:59 AM UTC-4, apple wrote:

 Have just started using populate which is a really useful tool. 
 However I have a couple of questions: 

 1) It seems to ignore the length specified for string fields. For 
 example it fills my postcode field with 100 characters of text despite 
 it having length of 8. Is there a way of restricting the text to 8 
 characters?


Looking at the code, it appears it should respect the length attribute of a 
string field. Not sure what the problem is. 


 2) Sometimes it fails with a sqlite error saying column name is not 
 unique. Does it not recognise unique constraints? 


It doesn't appear to recognize unique constraints.

Anthony


[web2py] Re: table without id

2011-10-11 Thread Anthony
See http://web2py.com/book/default/chapter/06#Legacy-Databases-and-Keyed-Tables.



[web2py] serving binary data

2011-10-11 Thread Matt Broadstone
Greetings,
   I am trying to serve binary image data from one of my controllers.
The data comes in via xmlrpc, and as such I have access to an xmlrpc
Binary object of the image data. I've written a controller that tries
to emulate what response.download does, but it doesn't seem to work.
Can anyone point me in the right direction here:

def view():
icon_name = request.vars.name if request.vars else None
icon_name = urllib.unquote(icon_name)

if icon_name:
icon_object = bw.objectQuery(icon, icon_name)
response.headers['Content-Type'] = 'image/png'
icon_stream = cStringIO.StringIO(icon_object['icon'])
return response.stream(icon_stream, request=request);

Matt


Re: [web2py] Re: new feature - need help

2011-10-11 Thread Richard Vézina
Nice implementation Paolo!

On Mon, Oct 10, 2011 at 9:56 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Done. Thank you!


 On Oct 10, 6:11 pm, Paolo Caruccio paolo.carucci...@gmail.com wrote:
  The result is splendid with your changes.
  I want only suggest to replace the row # 1344 in /gluon/sqlhtml.py with
 this
 
  jQuery('#w2p_query_fields').val('').change();
 
  so the change event is fired and when you query again the .w2p_query_row
 is
  hidden.
 
  Ciao.
 
  Paolo



[web2py] Re: serving binary data

2011-10-11 Thread Matt Broadstone
Whoops, I just needed to refer to the direct binary data, it was
passing an object in.



On Tue, Oct 11, 2011 at 12:11 PM, Matt Broadstone mbroa...@gmail.com wrote:
 Greetings,
   I am trying to serve binary image data from one of my controllers.
 The data comes in via xmlrpc, and as such I have access to an xmlrpc
 Binary object of the image data. I've written a controller that tries
 to emulate what response.download does, but it doesn't seem to work.
 Can anyone point me in the right direction here:

 def view():
    icon_name = request.vars.name if request.vars else None
    icon_name = urllib.unquote(icon_name)

    if icon_name:
        icon_object = bw.objectQuery(icon, icon_name)
        response.headers['Content-Type'] = 'image/png'
        icon_stream = cStringIO.StringIO(icon_object['icon'])
        return response.stream(icon_stream, request=request);

 Matt



[web2py] OnClick with SELECT

2011-10-11 Thread horridohobbyist
I'm trying to do something fairly simple. I have a dropdown list of
product names from a product database. When the user clicks on the
dropdown list and chooses a different product name, I want a function
to execute onclick that goes to the product database, retrieves the
rest of the record, and displays the fields underneath the dropdown
list. This should be a common pattern.

However, I'm not finding sufficient information in the documentation
to help me. I tried using _onclick with SELECT, but I'm getting
nowhere. Perhaps I'm not doing it right. Can anybody point me in the
right direction? Is there a sample program I can look at?

Thanks,
Richard


[web2py] Re: OnClick with SELECT

2011-10-11 Thread juanduke
Hi Richard:

I think you need fire the onchange event, in the select tag ( whit 
_onchange=yourJSFunction(); if using SELECT helper)
May be you can see this slice (
http://www.web2pyslices.com/slices/take_slice/144) and the working sample 
app:
http://ochiba.fluxflex.com/Ajax_Cascading_Drop_Down/default/index

HTH


Bye


Re: [web2py] Re: new feature - need help

2011-10-11 Thread Paolo Caruccio
Richard, thank you.

Re: [web2py] Re: checkbox input default value

2011-10-11 Thread Wikus van de Merwe
Try to define default values for your fields:
name = Field(name, boolean, default=False)



[web2py] Book source repo

2011-10-11 Thread jheath
Is there a repo where I can check out the current web2py book source?
I'd like to be able to make corrections as I read through the book and
submit a patch file, instead of opening a bunch of bug reports.


[web2py] Re: two SQLFORM.grid in one view?

2011-10-11 Thread apple
Surely there must be a solution to this? It does not seem logical to
have a component that is arbitrarily restricted to one per page?

iframe is not a good solution. And I don't think LOAD with ajax works
with multiple grids and pagination - certainly it does not work in my
application even after the recent fix in trunk. I have got multiple
grids to work with LOAD and no ajax, including the add/view/edit but
not pagination.

Surely there are many possible solutions to this without compromising
the URL benefits you mention. For example you could include a gridid
in request.args or request.vars; maybe also save the grid parameters
in session.

On Oct 11, 3:44 pm, Anthony abasta...@gmail.com wrote:
 On Tuesday, October 11, 2011 9:49:51 AM UTC-4, stefaan wrote:

  (workaround: e.g. use iframes, or design a better UI that doesn't need
  two grids in one view ;)

 Using ajax components might be better/easier than iframes.


[web2py] Re: two SQLFORM.grid in one view?

2011-10-11 Thread apple
also slightly frustrating is that the add/view/edit pass the table
name so you can generate output based on that. However the paginate
buttons do not pass the table name. So if you have a controller that
dynamically creates grid parameters depending on the table then this
does not work with paginate. Would it not be more consistent to pass
the tablename with all the buttons?


On Oct 11, 7:12 pm, apple simo...@gmail.com wrote:
 Surely there must be a solution to this? It does not seem logical to
 have a component that is arbitrarily restricted to one per page?

 iframe is not a good solution. And I don't think LOAD with ajax works
 with multiple grids and pagination - certainly it does not work in my
 application even after the recent fix in trunk. I have got multiple
 grids to work with LOAD and no ajax, including the add/view/edit but
 not pagination.

 Surely there are many possible solutions to this without compromising
 the URL benefits you mention. For example you could include a gridid
 in request.args or request.vars; maybe also save the grid parameters
 in session.

 On Oct 11, 3:44 pm, Anthony abasta...@gmail.com wrote:







  On Tuesday, October 11, 2011 9:49:51 AM UTC-4, stefaan wrote:

   (workaround: e.g. use iframes, or design a better UI that doesn't need
   two grids in one view ;)

  Using ajax components might be better/easier than iframes.


Re: [web2py] Re: two SQLFORM.grid in one view?

2011-10-11 Thread Richard Vézina
I was really disappointed about Datatables not managing correctly more then
one instance of table in the same page... Problem with Datatables, is that
it not supports the export button to work on more then once instance of
datatables init per page if you choose to put your tables into tabs
with jQuery UI tabs... So you have to choose between export feature or put
your differents tables in differents tabs...

I was really happy to see that Web2py was implementing nice grid and thought
that it will support any number of instance per page.

I have to display on the same page more then one table for related data that
not share the same amount of columns... I would prefer to not have more
pages because data are directly related and adding entry in the menu will
bring rapidly the app to be difficult to navigate (there is already a lot of
entry in the menu).

Hope the problems describes here could find a solution soon...

Richard


On Tue, Oct 11, 2011 at 2:20 PM, apple simo...@gmail.com wrote:

 also slightly frustrating is that the add/view/edit pass the table
 name so you can generate output based on that. However the paginate
 buttons do not pass the table name. So if you have a controller that
 dynamically creates grid parameters depending on the table then this
 does not work with paginate. Would it not be more consistent to pass
 the tablename with all the buttons?


 On Oct 11, 7:12 pm, apple simo...@gmail.com wrote:
  Surely there must be a solution to this? It does not seem logical to
  have a component that is arbitrarily restricted to one per page?
 
  iframe is not a good solution. And I don't think LOAD with ajax works
  with multiple grids and pagination - certainly it does not work in my
  application even after the recent fix in trunk. I have got multiple
  grids to work with LOAD and no ajax, including the add/view/edit but
  not pagination.
 
  Surely there are many possible solutions to this without compromising
  the URL benefits you mention. For example you could include a gridid
  in request.args or request.vars; maybe also save the grid parameters
  in session.
 
  On Oct 11, 3:44 pm, Anthony abasta...@gmail.com wrote:
 
 
 
 
 
 
 
   On Tuesday, October 11, 2011 9:49:51 AM UTC-4, stefaan wrote:
 
(workaround: e.g. use iframes, or design a better UI that doesn't
 need
two grids in one view ;)
 
   Using ajax components might be better/easier than iframes.



[web2py] Re: Making slides with web2py and markmin

2011-10-11 Thread jotbe
Thanks for the module, Massimo!

Unfortunately, it is not working in a test app:

## snip ##
$ python web2py.py -P -M -S slides
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.3 (2011-09-26 10:32:57) dev
Database drivers available: SQLite3, pymysql
Python 2.7.2 (default, Jul 27 2011, 15:07:16)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type help, copyright, credits or license for more information.
(InteractiveConsole)
 from applications.slides.modules.slide import SLIDE
 content = 
... # My slides title
... ## Slide One
... this allows you to create slides using markmin
... ## Slide Two
... - you can use lists
... - you can use [[links http://www.google.com]]
... - you can use images [[image http://image.example.com center]]
... 
 SLIDE(content, title='Sample slide')
Traceback (most recent call last):
  File console, line 1, in module
  File applications/slides/modules/slide.py, line 46, in SLIDE
html = str(MARKMIN(body,extra=extra))
NameError: global name 'MARKMIN' is not defined
 print MARKMIN(content)
h1My slides title/h1h2Slide One/h2pthis allows you to create
slides using markmin/ph2Slide Two/h2ulliyou can use lists/
liliyou can use img src=http://image.example.com; alt=links a
href=http://www.google.com;http://www.google.com/a]]/liliyou
can use images [[image align=center //li/ul
## snap ##

What am I doing wrong? :)

Greetings,

Jan

On 10 Sep., 21:24, Massimo Di Pierro mdipie...@cs.depaul.edu wrote:
 Based on desk.js now you can do this

 Put the attached slide.py under models (any app).

 Write a controller like

 def  test():    
     content = 
 # My slides title
 ## Slide One
 this allows you to create slides using markmin
 ## Slide Two
 - you can use lists
 - you can use [[linkshttp://www.google.com]]
 - you can use images [[imagehttp://image.example.comcenter]]
 
    return SLIDE(content,title=My slides)

 Notice the resulting file is pure html5 with external links therefore it can 
 be downloaded as an independent document.

  slide.py
 2KAnzeigenHerunterladen


[web2py] Re: db events trigger

2011-10-11 Thread Massimo Di Pierro
Not yet at the db level but at the form level:


form=SQLFORM(...).process(onsuccess=lambda form:...)


On Oct 11, 3:11 am, Manuele manuele.pese...@gmail.com wrote:
 Hi,
 is there a way to trigger some functions on database eventes, for
 example on new record?

 thanks a lot

      Manuele


[web2py] Re: Book source repo

2011-10-11 Thread Massimo Di Pierro
No. the only book is a wiki but it is temporary locked because I am
doing some work on it.

On Oct 11, 12:57 pm, jheath justin.he...@gmail.com wrote:
 Is there a repo where I can check out the current web2py book source?
 I'd like to be able to make corrections as I read through the book and
 submit a patch file, instead of opening a bunch of bug reports.


[web2py] Re: two SQLFORM.grid in one view?

2011-10-11 Thread Massimo Di Pierro
If an ajax grid does work please open an issue on google code so I can
check it and we can fix it. I cannot reproduce your problem otherwise.


On Oct 11, 1:12 pm, apple simo...@gmail.com wrote:
 Surely there must be a solution to this? It does not seem logical to
 have a component that is arbitrarily restricted to one per page?

 iframe is not a good solution. And I don't think LOAD with ajax works
 with multiple grids and pagination - certainly it does not work in my
 application even after the recent fix in trunk. I have got multiple
 grids to work with LOAD and no ajax, including the add/view/edit but
 not pagination.

 Surely there are many possible solutions to this without compromising
 the URL benefits you mention. For example you could include a gridid
 in request.args or request.vars; maybe also save the grid parameters
 in session.

 On Oct 11, 3:44 pm, Anthony abasta...@gmail.com wrote:







  On Tuesday, October 11, 2011 9:49:51 AM UTC-4, stefaan wrote:

   (workaround: e.g. use iframes, or design a better UI that doesn't need
   two grids in one view ;)

  Using ajax components might be better/easier than iframes.


[web2py] Re: DAL level access to GAE entities by named key

2011-10-11 Thread howesc
i am under the belief that while undocumented it should work and most likely 
can be fixed.

are you getting an error, or just nothing in the result?


Re: [web2py] Re: db events trigger

2011-10-11 Thread Bruno Rocha
Would be nice to have some global events in web2py workflow. I can imagine
some useful hooks:

workflow global events:

onrequest # before the execution of action/model

prerender # after the execution of action/model but before the view
rendering

onrender # after the view render but before the output

onresponse # after all the request process finished.

DAL global events:

preselect - onselect
preinsert - oninsert
preupdate - onupdate
predelete - ondelete

ASPnet has some usefull event system (oninit, onload, pageload etc..)

I dont even know if it is possible to trigger all of them in web2py and how
can it cost. but would be nice to have it.


http://zerp.ly/rochacbruno
Em 11/10/2011 17:23, Massimo Di Pierro massimo.dipie...@gmail.com
escreveu:

 Not yet at the db level but at the form level:


 form=SQLFORM(...).process(onsuccess=lambda form:...)


 On Oct 11, 3:11 am, Manuele manuele.pese...@gmail.com wrote:
  Hi,
  is there a way to trigger some functions on database eventes, for
  example on new record?
 
  thanks a lot
 
   Manuele


Re: [web2py] Re: Making slides with web2py and markmin

2011-10-11 Thread Bruno Rocha
you are putting it in modules while it has to be in models.

if you want it in modules you will need to explicitely import all web2py
helpers and context.

from gluon import *

http://zerp.ly/rochacbruno
Em 11/10/2011 16:28, jotbe jan.beili...@gmail.com escreveu:

 Thanks for the module, Massimo!

 Unfortunately, it is not working in a test app:

 ## snip ##
 $ python web2py.py -P -M -S slides
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2011
 Version 1.99.3 (2011-09-26 10:32:57) dev
 Database drivers available: SQLite3, pymysql
 Python 2.7.2 (default, Jul 27 2011, 15:07:16)
 [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
 Type help, copyright, credits or license for more information.
 (InteractiveConsole)
  from applications.slides.modules.slide import SLIDE
  content = 
 ... # My slides title
 ... ## Slide One
 ... this allows you to create slides using markmin
 ... ## Slide Two
 ... - you can use lists
 ... - you can use [[links http://www.google.com]]
 ... - you can use images [[image http://image.example.com center]]
 ... 
  SLIDE(content, title='Sample slide')
 Traceback (most recent call last):
  File console, line 1, in module
  File applications/slides/modules/slide.py, line 46, in SLIDE
html = str(MARKMIN(body,extra=extra))
 NameError: global name 'MARKMIN' is not defined
  print MARKMIN(content)
 h1My slides title/h1h2Slide One/h2pthis allows you to create
 slides using markmin/ph2Slide Two/h2ulliyou can use lists/
 liliyou can use img src=http://image.example.com; alt=links a
 href=http://www.google.com;http://www.google.com/a]]/liliyou
 can use images [[image align=center //li/ul
 ## snap ##

 What am I doing wrong? :)

 Greetings,

 Jan

 On 10 Sep., 21:24, Massimo Di Pierro mdipie...@cs.depaul.edu wrote:
  Based on desk.js now you can do this
 
  Put the attached slide.py under models (any app).
 
  Write a controller like
 
  def  test():
  content = 
  # My slides title
  ## Slide One
  this allows you to create slides using markmin
  ## Slide Two
  - you can use lists
  - you can use [[linkshttp://www.google.com]]
  - you can use images [[imagehttp://image.example.comcenter]]
  
 return SLIDE(content,title=My slides)
 
  Notice the resulting file is pure html5 with external links therefore it
 can be downloaded as an independent document.
 
   slide.py
  2KAnzeigenHerunterladen


[web2py] Re: manual file upload using SQLFORM.factory

2011-10-11 Thread Alex
the files in the uploads folder should be save since they are all
renamed. But what happens if the user passes e.g. '../models/db.py' as
parameter? (the slashes would have to be encoded though, is this
possible?) Then he would get access to the data model which would not
be good at all. I'm now testing for '..' in the filename, I hope
that's sufficient and there is no way to circumvent this.

On 9 Okt., 03:53, TheSweetlink yanosh...@gmail.com wrote:
 Yes a user can by default can download() but how would the user know
 the renamed filename though?  I cannot say as I do not have much
 detail behind your app.  Depending on where you're saving what will
 dictate what you should do better than any advice I can give.  web2py
 enables a great deal of security enhancements by default so generally
 speaking you should be just fine with store() renaming your file.

 Yes, I too have found web2py to be an invaluable tool as well as this
 community being one of the most helpful and nicest around.

 Best,
 David

 On Oct 8, 6:48 am, Alex mrauc...@gmail.com wrote:



  Upload should be save since its handled by web2py. But with the
  download the user possible could pass any path for the filename and
  download files also from other folders. Should I check for '..' in the
  filename? Would it be sufficient?

  btw, the community is great here. as is web2py :)

  Alex


Re: [web2py] Re: db events trigger

2011-10-11 Thread Michele Comitini
I like the idea!
+1

It is common in many frameworks. IMHO seems more common on compiled
languages frameworks for some reason.

mic

2011/10/11 Bruno Rocha rochacbr...@gmail.com:
 Would be nice to have some global events in web2py workflow. I can imagine
 some useful hooks:

 workflow global events:

 onrequest # before the execution of action/model

 prerender # after the execution of action/model but before the view
 rendering

 onrender # after the view render but before the output

 onresponse # after all the request process finished.

 DAL global events:

 preselect - onselect
 preinsert - oninsert
 preupdate - onupdate
 predelete - ondelete

 ASPnet has some usefull event system (oninit, onload, pageload etc..)

 I dont even know if it is possible to trigger all of them in web2py and how
 can it cost. but would be nice to have it.


 http://zerp.ly/rochacbruno

 Em 11/10/2011 17:23, Massimo Di Pierro massimo.dipie...@gmail.com
 escreveu:

 Not yet at the db level but at the form level:


 form=SQLFORM(...).process(onsuccess=lambda form:...)


 On Oct 11, 3:11 am, Manuele manuele.pese...@gmail.com wrote:
  Hi,
  is there a way to trigger some functions on database eventes, for
  example on new record?
 
  thanks a lot
 
       Manuele


[web2py] Re: on grid and smartgrid search feature

2011-10-11 Thread Stefaan Himpe

Massimo Di Pierro wrote:

The new grid/smartgrid have a much better search feature. A new button
query shows a popup panel that allows you to build the query string.
Can you please check on your existing tables and see if you encounter
any problems?



The capabilities columns seems to be missing in the list that appears 
after pressing query (tried with iceape 2.0.14 and chromium 14.0.835.163 
(Developer Build 101024 Linux) Built on Debian unstable, running on 
Debian wheezy/sid.



*
model
*

db.define_table('servers',
Field('name', 'string', length=63, default='testserver', 
required=True, notnull=True, unique=True, label=Server name),
Field('ip', 'string', requires=IS_IPV4(), required=True, 
notnull=True, unique=True, label=Server ip address),
Field('folder', 'string', length=256, 
default=DEFAULT_TESTIMON_FOLDER, required=True, notnull=True, 
label='installation folder'),
Field('capabilities', 'list:string', requires = 
IS_EMPTY_OR(IS_IN_DB(db, db.capabilities.capability, multiple=True)), 
readable=True, writable=True)

)
from plugin_multiselect_widget import hmultiselect_widget
db.servers.capabilities.widget = hmultiselect_widget


# NOTE: (hmultiselect_widget is a widget from 
http://dev.s-cubism.com/web2py_plugins; but removing it doesn't make a 
difference)


**
controller
**


def server_administration():
  links = [lambda row: A('Check status',_href=URL(c='administration', 
f='check_server_status/%s' % row.id))]

  servers = SQLFORM.grid(
db.servers,
links = links,
deletable=True,
editable=True,
create=True)

  return dict(servers=servers)


view


{{=servers}}




[web2py] Re: migration fails when modifying field with notnull=True

2011-10-11 Thread Alex
I think this has to do with the web2py migration code. Maybe it only
happens if the db is PostgreSQL. Now that I know that a default value
should hopefully solve this its not an issue for me anymore. But I
think it should not be necessary in first place, or if it is, it would
be good if it would be mentioned in the documentation.

Alex


Re: [web2py] Re: Book source repo

2011-10-11 Thread Justin Heath
Okay, thanks.
On Oct 11, 2011 4:24 PM, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:

 No. the only book is a wiki but it is temporary locked because I am
 doing some work on it.

 On Oct 11, 12:57 pm, jheath justin.he...@gmail.com wrote:
  Is there a repo where I can check out the current web2py book source?
  I'd like to be able to make corrections as I read through the book and
  submit a patch file, instead of opening a bunch of bug reports.


[web2py] Re: db events trigger

2011-10-11 Thread Massimo Di Pierro
the problem with this is not the names. ;-)

Consider the case of preupdate and onupdate.

   db(db.person.age18).update(can_drink=True)

What information should be passed to preupdate and update? tablename?
query? {'can_drink':True}? Number of affected records? Should there be
one onselect per table? We do not want to call onupdate for every
table, do we (performance issues)?

What about?

   db(db.person.id=2).update(can_drink=True)

What about

 
db(db.person).select(left=db.dog.on(db.dog.owner==db.person.id),limitby=(0,1))

What should we pass to onselect? query? left? limitby? all arguments?
number of returned records? returned records? In this case we cannot
pass one table because because more than one table may be involved.

Every one of those callbacks would need a different signature. It
would not be obvious and I am not sure people would agree.
I do not oppose to this. I just want to hear more from you.

Massimo



On Oct 11, 4:57 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Would be nice to have some global events in web2py workflow. I can imagine
 some useful hooks:

 workflow global events:

 onrequest # before the execution of action/model

 prerender # after the execution of action/model but before the view
 rendering

 onrender # after the view render but before the output

 onresponse # after all the request process finished.

 DAL global events:

 preselect - onselect
 preinsert - oninsert
 preupdate - onupdate
 predelete - ondelete

 ASPnet has some usefull event system (oninit, onload, pageload etc..)

 I dont even know if it is possible to trigger all of them in web2py and how
 can it cost. but would be nice to have it.

 http://zerp.ly/rochacbruno
 Em 11/10/2011 17:23, Massimo Di Pierro massimo.dipie...@gmail.com
 escreveu:







  Not yet at the db level but at the form level:

  form=SQLFORM(...).process(onsuccess=lambda form:...)

  On Oct 11, 3:11 am, Manuele manuele.pese...@gmail.com wrote:
   Hi,
   is there a way to trigger some functions on database eventes, for
   example on new record?

   thanks a lot

        Manuele


Re: [web2py] Re: db events trigger

2011-10-11 Thread Bruno Rocha
may be a dictionary of tablename_event:function

I see that in DAL level this is very complicated.

but what about the resquest-response workflow events. I had cases where I
needed some global  function to trigger before/after the template rendering
and final response.

http://zerp.ly/rochacbruno
Em 11/10/2011 19:42, Massimo Di Pierro massimo.dipie...@gmail.com
escreveu:

 the problem with this is not the names. ;-)

 Consider the case of preupdate and onupdate.

   db(db.person.age18).update(can_drink=True)

 What information should be passed to preupdate and update? tablename?
 query? {'can_drink':True}? Number of affected records? Should there be
 one onselect per table? We do not want to call onupdate for every
 table, do we (performance issues)?

 What about?

   db(db.person.id=2).update(can_drink=True)

 What about


 db(db.person).select(left=db.dog.on(db.dog.owner==db.person.id
 ),limitby=(0,1))

 What should we pass to onselect? query? left? limitby? all arguments?
 number of returned records? returned records? In this case we cannot
 pass one table because because more than one table may be involved.

 Every one of those callbacks would need a different signature. It
 would not be obvious and I am not sure people would agree.
 I do not oppose to this. I just want to hear more from you.

 Massimo



 On Oct 11, 4:57 pm, Bruno Rocha rochacbr...@gmail.com wrote:
  Would be nice to have some global events in web2py workflow. I can
 imagine
  some useful hooks:
 
  workflow global events:
 
  onrequest # before the execution of action/model
 
  prerender # after the execution of action/model but before the view
  rendering
 
  onrender # after the view render but before the output
 
  onresponse # after all the request process finished.
 
  DAL global events:
 
  preselect - onselect
  preinsert - oninsert
  preupdate - onupdate
  predelete - ondelete
 
  ASPnet has some usefull event system (oninit, onload, pageload etc..)
 
  I dont even know if it is possible to trigger all of them in web2py and
 how
  can it cost. but would be nice to have it.
 
  http://zerp.ly/rochacbruno
  Em 11/10/2011 17:23, Massimo Di Pierro massimo.dipie...@gmail.com
  escreveu:
 
 
 
 
 
 
 
   Not yet at the db level but at the form level:
 
   form=SQLFORM(...).process(onsuccess=lambda form:...)
 
   On Oct 11, 3:11 am, Manuele manuele.pese...@gmail.com wrote:
Hi,
is there a way to trigger some functions on database eventes, for
example on new record?
 
thanks a lot
 
 Manuele


[web2py] Storing date format in dd-mm-yyyy in database

2011-10-11 Thread Rohit
I am developing an online booking application where  
I am storing the date  using the date type of 
web2py which stores the date in -mm-dd format. 
I need to store the data in dd-mm- format in 
the datastore.

For this I tried to use this :
date.requires = IS_DATE(format=T('%d-%m-%Y')

Though it takes the date in dd-mm- format 
it does not store in the dd-mm- format.It still 
stores in -mm-dd format

Please provide suggestion

Thanks



Re: [web2py] Storing date format in dd-mm-yyyy in database

2011-10-11 Thread Ovidio Marinho
  in db

Field('start_time','datetime',requires=IS_DATETIME(str(T('%Y-%m-%d
%H:%M:%S',
Field('stop_time','datetime',requires=IS_DATETIME(str(T('%Y-%m-%d
%H:%M:%S',


   db.task.start_time.represent = lambda v: v.strftime('%d/%m/%Y')
   db.task.stop_time.represent = lambda v: v.strftime('%d/%m/%Y')

is this

in view:


td{{=task.start_time.date().strftime('%d-%m-%Y')}}/td
td{{=task.stop_time.date().strftime('%d-%m-%Y')}}/td

ok?



   Ovidio Marinho Falcao Neto
 ovidio...@gmail.com
   83   8826 9088 - Oi
 83   9334 0266 - Claro
   Paraiba-Brasil



2011/10/11 Rohit rohit.ba...@gmail.com

 I am developing an online booking application where
 I am storing the date  using the date type of
 web2py which stores the date in -mm-dd format.
 I need to store the data in dd-mm- format in
 the datastore.

 For this I tried to use this :
 date.requires = IS_DATE(format=T('%d-%m-%Y')

 Though it takes the date in dd-mm- format
 it does not store in the dd-mm- format.It still
 stores in -mm-dd format

 Please provide suggestion

 Thanks




[web2py] Re: table without id

2011-10-11 Thread tomt
Hi,

I have been able to access legacy databases that don't have an id
field.  In the following example 'pointnumber' is the primary key, and
is unique. I was able to read values from this table with DAL.  I used
the following model:


db2.define_table('statuspoint',
 Field('pointnumber','integer'),
 Field('pointname','string'),
 Field('pointaccessarea','integer'),
 Field('station','integer'),
 Field('statefeatures','integer'),
 Field('indication','integer'),
 primarykey=['pointnumber'],
)


Some parts of web2py(such as SQLFORM.grid) appear to require the 'id'.
To allow this, I created a view in my database(mysql) to rename the
pointnumber field to id.

CREATE VIEW view_statuspoint AS
SELECT pointnumber id,pointname,pointaccessarea,
station,statefeatures,indication
from statuspoint;

The following model uses the view:

db2.define_table('view_statuspoint',
 Field('id','integer'),
 Field('pointname','string'),
 Field('pointaccessarea','integer'),
 Field('station','integer'),
 Field('statefeatures','integer'),
 Field('indication','integer'),
 Field('dog_assignment_fko','integer'),
 migrate=False
)

This allowed me to create a form with SQLFORM.grid and to update
records. That's all I've tested.

- Tom

On Oct 11, 9:04 am, Cory Coager ccoa...@gmail.com wrote:
 I have created some database tables externally to web2py.  Does web2py
 require an id field for tables?  The reason why I'm asking is, when I
 use the DAL to do an insert, web2py tries to retrieve the currval of
 the insert.  Seeing how I don't have an id, this throws an exception.
 How should I handle this?


Re: [web2py] Re: db events trigger

2011-10-11 Thread Vinicius Assef
I suggested it 2 years ago. I'll be happy if it come true someday, in web2py.

I see it as database triggers: before_event  after_event. I.e:
before_insert, after_insert. Event can be: insert, update, delete,
query.

before_insert receives values that will be inserted on database. It
is the last chance to modify, check some value or make run some
routine before register is inserted.
after_insert receives values just stored there.

before_update receives data stored on the database, before the
record is updated. As before_insert, this is a last chance event.
after_update receives data contents after the update took place.

before_delete receives data stored on the database. As
before_update does. Also, it's a last chance event.
after_delete receives same data, but after register was deleted.

before and after query I don't see as important. Web2py already
has virtual and computed fields. But would be nice to log accesses to
some table.

I worked with these triggers on Sybase, many years ago. But I remember
how it was nice to make stored procedures and triggers counting on
these events (except query events. I just saw it on Oracle),
guaranteeing db integrity.

--
Vinicius Assef.



On Tue, Oct 11, 2011 at 7:42 PM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
 the problem with this is not the names. ;-)

 Consider the case of preupdate and onupdate.

   db(db.person.age18).update(can_drink=True)

 What information should be passed to preupdate and update? tablename?
 query? {'can_drink':True}? Number of affected records? Should there be
 one onselect per table? We do not want to call onupdate for every
 table, do we (performance issues)?

 What about?

   db(db.person.id=2).update(can_drink=True)

 What about


 db(db.person).select(left=db.dog.on(db.dog.owner==db.person.id),limitby=(0,1))

 What should we pass to onselect? query? left? limitby? all arguments?
 number of returned records? returned records? In this case we cannot
 pass one table because because more than one table may be involved.

 Every one of those callbacks would need a different signature. It
 would not be obvious and I am not sure people would agree.
 I do not oppose to this. I just want to hear more from you.

 Massimo



 On Oct 11, 4:57 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Would be nice to have some global events in web2py workflow. I can imagine
 some useful hooks:

 workflow global events:

 onrequest # before the execution of action/model

 prerender # after the execution of action/model but before the view
 rendering

 onrender # after the view render but before the output

 onresponse # after all the request process finished.

 DAL global events:

 preselect - onselect
 preinsert - oninsert
 preupdate - onupdate
 predelete - ondelete

 ASPnet has some usefull event system (oninit, onload, pageload etc..)

 I dont even know if it is possible to trigger all of them in web2py and how
 can it cost. but would be nice to have it.

 http://zerp.ly/rochacbruno
 Em 11/10/2011 17:23, Massimo Di Pierro massimo.dipie...@gmail.com
 escreveu:







  Not yet at the db level but at the form level:

  form=SQLFORM(...).process(onsuccess=lambda form:...)

  On Oct 11, 3:11 am, Manuele manuele.pese...@gmail.com wrote:
   Hi,
   is there a way to trigger some functions on database eventes, for
   example on new record?

   thanks a lot

        Manuele


Re: [web2py] Storing date format in dd-mm-yyyy in database

2011-10-11 Thread Vinicius Assef
Clarifying,
date fields are stored in internal format and they are optimized for that.

You can customize representation format, not stored format. It was
what Ovidio showed you.

--
Vinicius Assef.


On Tue, Oct 11, 2011 at 10:16 PM, Ovidio Marinho ovidio...@gmail.com wrote:

       in db
     Field('start_time','datetime',requires=IS_DATETIME(str(T('%Y-%m-%d
 %H:%M:%S',
     Field('stop_time','datetime',requires=IS_DATETIME(str(T('%Y-%m-%d
 %H:%M:%S',

    db.task.start_time.represent = lambda v: v.strftime('%d/%m/%Y')
    db.task.stop_time.represent = lambda v: v.strftime('%d/%m/%Y')
 is this
 in view:

 td{{=task.start_time.date().strftime('%d-%m-%Y')}}/td
 td{{=task.stop_time.date().strftime('%d-%m-%Y')}}/td
 ok?


        Ovidio Marinho Falcao Neto
              ovidio...@gmail.com
                83   8826 9088 - Oi
              83   9334 0266 - Claro
                    Paraiba-Brasil



 2011/10/11 Rohit rohit.ba...@gmail.com

 I am developing an online booking application where
 I am storing the date  using the date type of
 web2py which stores the date in -mm-dd format.
 I need to store the data in dd-mm- format in
 the datastore.

 For this I tried to use this :
 date.requires = IS_DATE(format=T('%d-%m-%Y')

 Though it takes the date in dd-mm- format
 it does not store in the dd-mm- format.It still
 stores in -mm-dd format

 Please provide suggestion

 Thanks





[web2py] Re: db events trigger

2011-10-11 Thread Massimo Di Pierro
As I said, the problem is not the names or when they should be called.
The problem is. What should be input and the output of each of these
functions?

On Oct 11, 9:03 pm, Vinicius Assef vinicius...@gmail.com wrote:
 I suggested it 2 years ago. I'll be happy if it come true someday, in web2py.

 I see it as database triggers: before_event  after_event. I.e:
 before_insert, after_insert. Event can be: insert, update, delete,
 query.

 before_insert receives values that will be inserted on database. It
 is the last chance to modify, check some value or make run some
 routine before register is inserted.
 after_insert receives values just stored there.

 before_update receives data stored on the database, before the
 record is updated. As before_insert, this is a last chance event.
 after_update receives data contents after the update took place.

 before_delete receives data stored on the database. As
 before_update does. Also, it's a last chance event.
 after_delete receives same data, but after register was deleted.

 before and after query I don't see as important. Web2py already
 has virtual and computed fields. But would be nice to log accesses to
 some table.

 I worked with these triggers on Sybase, many years ago. But I remember
 how it was nice to make stored procedures and triggers counting on
 these events (except query events. I just saw it on Oracle),
 guaranteeing db integrity.

 --
 Vinicius Assef.

 On Tue, Oct 11, 2011 at 7:42 PM, Massimo Di Pierro







 massimo.dipie...@gmail.com wrote:
  the problem with this is not the names. ;-)

  Consider the case of preupdate and onupdate.

    db(db.person.age18).update(can_drink=True)

  What information should be passed to preupdate and update? tablename?
  query? {'can_drink':True}? Number of affected records? Should there be
  one onselect per table? We do not want to call onupdate for every
  table, do we (performance issues)?

  What about?

    db(db.person.id=2).update(can_drink=True)

  What about

  db(db.person).select(left=db.dog.on(db.dog.owner==db.person.id),limitby=(0, 
  1))

  What should we pass to onselect? query? left? limitby? all arguments?
  number of returned records? returned records? In this case we cannot
  pass one table because because more than one table may be involved.

  Every one of those callbacks would need a different signature. It
  would not be obvious and I am not sure people would agree.
  I do not oppose to this. I just want to hear more from you.

  Massimo

  On Oct 11, 4:57 pm, Bruno Rocha rochacbr...@gmail.com wrote:
  Would be nice to have some global events in web2py workflow. I can imagine
  some useful hooks:

  workflow global events:

  onrequest # before the execution of action/model

  prerender # after the execution of action/model but before the view
  rendering

  onrender # after the view render but before the output

  onresponse # after all the request process finished.

  DAL global events:

  preselect - onselect
  preinsert - oninsert
  preupdate - onupdate
  predelete - ondelete

  ASPnet has some usefull event system (oninit, onload, pageload etc..)

  I dont even know if it is possible to trigger all of them in web2py and how
  can it cost. but would be nice to have it.

 http://zerp.ly/rochacbruno
  Em 11/10/2011 17:23, Massimo Di Pierro massimo.dipie...@gmail.com
  escreveu:

   Not yet at the db level but at the form level:

   form=SQLFORM(...).process(onsuccess=lambda form:...)

   On Oct 11, 3:11 am, Manuele manuele.pese...@gmail.com wrote:
Hi,
is there a way to trigger some functions on database eventes, for
example on new record?

thanks a lot

     Manuele


[web2py] Python 2.7 on GAE (experimental)

2011-10-11 Thread pbreit
http://code.google.com/appengine/docs/python/python27/newin27.html


[web2py] Re: db events trigger

2011-10-11 Thread guruyaya
Don't forget on table creation and alteration.

On Oct 11, 11:57 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Would be nice to have some global events in web2py workflow. I can imagine
 some useful hooks:

 workflow global events:

 onrequest # before the execution of action/model

 prerender # after the execution of action/model but before the view
 rendering

 onrender # after the view render but before the output

 onresponse # after all the request process finished.

 DAL global events:

 preselect - onselect
 preinsert - oninsert
 preupdate - onupdate
 predelete - ondelete

 ASPnet has some usefull event system (oninit, onload, pageload etc..)

 I dont even know if it is possible to trigger all of them in web2py and how
 can it cost. but would be nice to have it.

 http://zerp.ly/rochacbruno
 Em 11/10/2011 17:23, Massimo Di Pierro massimo.dipie...@gmail.com
 escreveu:







  Not yet at the db level but at the form level:

  form=SQLFORM(...).process(onsuccess=lambda form:...)

  On Oct 11, 3:11 am, Manuele manuele.pese...@gmail.com wrote:
   Hi,
   is there a way to trigger some functions on database eventes, for
   example on new record?

   thanks a lot

        Manuele


[web2py] Re: DAL level access to GAE entities by named key

2011-10-11 Thread Wikus van de Merwe
I'm getting nothing (None). If the intention was to having it work this way 
(by passing key as id) I'll have a look at the DAL code more closely. Maybe 
something affects the key outside of the select_raw function. Have this ever 
worked for you?


[web2py] Re: db events trigger

2011-10-11 Thread guruyaya


On Oct 12, 4:18 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 As I said, the problem is not the names or when they should be called.
 The problem is. What should be input and the output of each of these
 functions?

Whenever I'm in a problem with a full stack web framework, I think to
myself what would cakePHP do?
OK, that's really NOT the way you should think, but they did some job
on the input and output of some of these functions (they don't have
migrates, so the migration events I'd like to see, are not there), and
we should learn from it:

afterDelete( ) - cake API allows you delete only one row at the time,
and it's data is part of the object delete is ran upon (like our
delete_record() method). Retuens a void, but the object stil contain
the deleted record.
afterFind( $results, $primary = false ) -  I'm not sure what primary
means, but the results, contain a list of all results. Returns a list
of modified results.
afterSave( $created ) - The created row. This method runs on create
and on update. When I worked with it, I really wanted 2 seperate
functions. returns void.
beforeDelete( $cascade = true ) - Again, has the data of the deleted
record. The cascade is like  to web2py recursive deletes. Returns a
boolean that suggests wether delete should continue.
beforeFind( $queryData ) = That's a bit more problematic for us.
cakePHP has an array of all the joins and conditions, that can be used
in $queryData. I'm not sure web2py has one we can create. But... what
do I know? returns either boolean or modified query.
beforeSave( $options ) - I have no idea what the options are, and I'm
not sure I'm keen on exploring it. Returns true if save should
continue, false if not.
beforeValidate( $options ) - same as beforeSave

beforeFilter and afterFilter - Well... I'm not sure how relevant it is
for our case. This is where you find user auth logic.
beforeRender() - This function is called, so you can change some vars
before a view is presented. This one applies on a paticular controller
(can be applied to all controllers using inharitance, but that's the
way cake works, not really relevat to web2py).

The cake API is not 100% relevant to web2py, but we can use it to get
some idea how others solved it.