[web2py] how to include profile photo from Janrain in auth_user?

2011-06-10 Thread Luis Goncalves
I have Janrain working as a login method (thanks to the instructions in the 
web2py manual, and sample code in default app).

I'd like to include the profile photo (that, say, facebook provides via 
janrain) as part of the user profile. 

I had my own function based on the sample code at the Janrain github, but so 
far it doesn't work.

The reason, I believe, is that the token that Janrain provides can only be 
used once. 

In my code, either I let user/login use the token, and then my function 
can't retrieve the photo, or I can use the token (with code in user() that 
detects a request.vars.token),  but then the web2py login procedure can't 
use the token, and the user can't even login.

I imagine that I could hack away at gluon/tools.py to include retrieving the 
profile photo along with the other user data during the login process, but 
I'm sure that's not the easiest or proper way to do things.

Does anyone have, or can anyone provide an example of the proper way to do 
it?

Thanks!!!

Luis.


[web2py] Re: attribute content of meta tag viewport in layout.html (Welcome) should use comma separator

2011-06-10 Thread Nico de Groot
I've put this patch in web2py google code

[web2py] how to write if else in controller in web2py

2011-06-10 Thread anil manikyam
def login():
if db((db.table1.username)== request.vars.visitor_name).select():
redirect(URL('index'))
else:
print 'invalid statement'
return dict()


in this username and visitor_name are compared if correct redirect to
index page it is work very well

but if those are not equal else part is not printed why?

i want code for this


[web2py] anil manikyam wants to chat

2011-06-10 Thread anil manikyam
---

anil manikyam wants to stay in better touch using some of Google's coolest new
products.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-10d5f122fd-0ddf7cb181-wBuQFmlID7kV5jUKC1Oy_058qmo
You'll need to click this link to be able to chat with anil manikyam.

To get Gmail - a free email account from Google with over 2,800 megabytes of
storage - and chat with anil manikyam, visit:
http://mail.google.com/mail/a-10d5f122fd-0ddf7cb181-wBuQFmlID7kV5jUKC1Oy_058qmo

Gmail offers:
- Instant messaging right inside Gmail
- Powerful spam protection
- Built-in search for finding your messages and a helpful way of organizing
  emails into conversations
- No pop-up ads or untargeted banners - just text ads and related information
  that are relevant to the content of your messages

All this, and its yours for free. But wait, there's more! By opening a Gmail
account, you also get access to Google Talk, Google's instant messaging
service:

http://www.google.com/talk/

Google Talk offers:
- Web-based chat that you can use anywhere, without a download
- A contact list that's synchronized with your Gmail account
- Free, high quality PC-to-PC voice calls when you download the Google Talk
  client

We're working hard to add new features and make improvements, so we might also
ask for your comments and suggestions periodically. We appreciate your help in
making our products even better!

Thanks,
The Google Team

To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/about.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste them into
the address bar of your browser).


[web2py] Re: Validator: one of several fields must be non-empty

2011-06-10 Thread David Marko
This(or some modofication) could be part of web2py core, I think its quite 
general purpose validator ...

David


[web2py] IS_IN_SET validator not working as expected

2011-06-10 Thread selecta
i have the model

db.define_table( 'foobar',
Field('open', 'boolean', requires = IS_IN_SET([(True, 'open'),
(False, 'closed')], zero = None), default = True,
widget=SQLFORM.widgets.radio.widget),
)

and the controller

def edit():
  return crud.update(db.foobar, request.args(0), deletable = False)

but it does not work since open is always True because False gets
interpreted as string with content and not as boolean
so i have to fix it like this

def edit():
  def on_accept(form):
open = False if request.vars.open == 'False' else True
if form.vars.id and db.foobar[form.vars.id]:
db.foobar[form.vars.id].update_record(open = open)
  return crud.update(db.foobar, onaccept = on_accept, request.args(0),
deletable = False)

are there alternatives to creating radioboxes for True False
selections? Of course custom validator, but is there something already
built in?


Re: [web2py] how to write if else in controller in web2py

2011-06-10 Thread Bruno Rocha
Are you expecting the print on shell right? there are no message printed to
console?

Are you using mod_wsgi or running on rocket server? (mod_wsgi does not works
well with stdout(print))

If, do you expect the output in to browser, it is better to use a specific
view for handle the message or raise a web2py exception with a custom
message.





On Fri, Jun 10, 2011 at 4:31 AM, anil manikyam anilmanikya...@gmail.comwrote:

 def login():
if db((db.table1.username)== request.vars.visitor_name).select():
redirect(URL('index'))
else:
print 'invalid statement'
return dict()


 in this username and visitor_name are compared if correct redirect to
 index page it is work very well

 but if those are not equal else part is not printed why?

 i want code for this


[web2py] Re: nginx and web2py

2011-06-10 Thread cjrh
On Jun 9, 10:34 pm, peter peterchutchin...@gmail.com wrote:
 I am trying to get web2py going with nginx on a remote server.

 When I try running it via uswgi and nginx, using wsgihandler.py, it

 The VPS uses Centos 5.5, and I am running things on python2.6.1,
 web2py version 1.96.3

I am running a site using exactly the same setup.  The files and
folders must be writable for the same process under which uwsgi is
running.  If you followed the same setup guide that I did, then you
probably created a uwsgi user and group.  The web2py folders must be
writeable for that user.

BTW, for anyone else reading this, setting up nginx was *much* easier
than setting up apache, and with a smaller memory footprint.  I am
pretty sure I will never again use apache.


[web2py] Re: Web2Py RoR performances

2011-06-10 Thread cjrh
pypy changes these kinds of discussions.  In a disruptive sense.

[web2py] Re: Web2Py RoR performances

2011-06-10 Thread cjrh
On Thursday, 9 June 2011 15:40:14 UTC+2, Alexandre Strzelewicz wrote:

 Is Ruby on Rails faster than Web2py ? 


Here are a few *really *important points about speed:


   1. Speed is not the same as *concurrency*.  On the web, generally 
   (depending on your application), it is the latter that matters more.   Ruby 
   and web2py both have solutions for running multiple processes (I am using 
   *thin *for Ruby and *uwsgi *for Python) in most deployments, so that 
   settles the concurrency problems as far as the framework is concerned.  The 
   DB is a whole other matter, unfortunately, and that affects all frameworks 
   in any language.
   2. The most important speed measurement you will ever have to be 
   concerned with in your entire career is *how quickly you can work while 
   maintaining a high level of accuracy*.  This is also the most financially 
   important speed measurement for your work, because every hour lost in 
   productivity is measured in your hourly compensation rate.  Therefore, use 
   the tools with which you are most productive.  If that means Ruby for you, 
   then you should work on that stack.  For me, it's Python.  It doesn't matter 
   what tools you use, just as long as you are most efficient with them.
   3. If you have a hotspot in your interpreted code, whichever language it 
   may be, the tried  tested solution is always** to code just that hotspot in 
   C (assuming the best algorithm is already being used).  The answer is *not 
   *to switch out (and presumably learn) one interpreted language for 
   another.

**pypy may currently be in the process of making this statement a lie.


Re: [web2py] Re: New Features in Book

2011-06-10 Thread cjrh
On Thursday, 9 June 2011 14:00:37 UTC+2, Martin.Mulone wrote:

 I proposed to massimo some ideas and improvements, regarding to this.


Would you be willing for forward those to me also, or would you prefer to 
keep those private for now?  One suggestion I made a while ago was to 
appoint (or rather, let's say ask for volunteers) a specific person to be a 
custodian of each particular chapter in the book.   I am willing 
to fulfill such a role, but I just don't have time to cover the whole book.

The other thing is that, honestly, making edits on the book in the current 
format is actually pretty uncomfortable.  I do try, but the process is slow 
and discourages making many small edits.   I would much rather the content 
of the book be hosted in a (mercurial?) repo somewhere, and the online book 
application itself fetches the markmin it needs from that repo on a daily 
basis or something like that.  Then contributors will be able to edit the 
content much easier, and be able to collaborate on sections and see the 
edits of others, etc.


Re: [web2py] Re: New Features in Book

2011-06-10 Thread anil manikyam
how i will send a mail to others using web2py


Re: [web2py] Re: nginx and web2py

2011-06-10 Thread anil manikyam
how i will send mail to others using web2py



-- 
@n!l m@n!ky@m


Re: [web2py] how to include profile photo from Janrain in auth_user?

2011-06-10 Thread anil manikyam
i will i will send mail to other people using web2py


-- 
@n!l m@n!ky@m


[web2py] Re: nginx and web2py

2011-06-10 Thread JorgeH
Cool

Goood to know

BTW, what was the setup guide you say you followed?


Re: [web2py] Re: import error debian package

2011-06-10 Thread José Luis Redrejo Rodríguez
2011/6/9 Stavros stavros32...@gmail.com:
 http://dl.dropbox.com/u/3616407/mathquiz.tar.gz

 Thanks



Thanks for the testing project.  Checking it I've noticed there was a
missing (and important file now) : applications/__init__.py

I've just fixed it and uploaded a new version (1.96.4-2) of the
package to Debian,
but it can take a few hours before it gets visible through the mirrors.

In case you don't want to wait until new packages are visible,
replacing the attached  /usr/bin/web2py file will fix the error.


Regards
José L.


 On Jun 9, 12:30 pm, José Luis Redrejo Rodríguez jredr...@debian.org
 wrote:
 2011/6/9 Jeff Elkner jeff.elk...@gmail.com:

  We copy the math_quiz directory and all its contents from a source install
  of web2py, where it works, to the application directory of a user created 
  by
  the debian package, where it gives the error above.

  Three of us have confirmed this on three separate installations.  We are
  pretty confident it is an error with the way the package works.

 Could you give me a part of the code to test it in the package. I
 guess it's a permission problem.

 Regards.


web2py
Description: Binary data


Re: [web2py] Re: New Features in Book

2011-06-10 Thread Caleb Hattingh
On 10 June 2011 12:47, anil manikyam anilmanikya...@gmail.com wrote:

 how i will send a mail to others using web2py


Just post on the web2py Google Group.


[web2py] Re: IS_IN_SET validator not working as expected

2011-06-10 Thread Ross Peoples
I'm sure you've already considered this, but maybe use a checkbox instead, 
as it's specifically designed to handle true/false. The SELECT widget and 
associated IS_IN_SET is designed to return a string value. So If you really 
want to use a select box for this instead of a checkbox, then you need to do 
 the boolean parsing yourself. Also, depending on the database you are 
using, you may be able to substitute 'True' and 'False' with 1 and 0, which 
the database may automatically parse to a boolean on insert/update.

[web2py] Re: how to write if else in controller in web2py

2011-06-10 Thread Philip
To expand on the first answer, if you want something to appear in the 
browser, you need to return a value to the view.

For example

else:
   msg = 'invalid statement'
   return dict(display_string=msg)

The generic view will show the display_string (you can name the variable 
anything you want, as long as you use the same name in your view), or you 
can set up a view associated with this controller (login.html).



Re: [web2py] Re: how to write if else in controller in web2py

2011-06-10 Thread anil manikyam
def login():
if db((db.table1.username)== request.vars.visitor_name).select():
redirect(URL('index'))
else:
msg='invalid syntax'



return dict(display_msg=msg)

form
  input name=visitor_name /
  input type=submit /
  {{=
/form
{{=display_string}}

i tried it but when this display_string used in form it printed before the
enter the submit button  plz send the code for this


Re: [web2py] Re: nginx and web2py

2011-06-10 Thread anil manikyam
def login():
if db((db.table1.username)== request.vars.visitor_name).select():
redirect(URL('index'))
else:
msg='invalid syntax'



return dict(display_msg=msg)

form
  input name=visitor_name /
  input type=submit /
  {{=
/form
{{=display_string}}

i tried it but when this display_string used in form it printed before the
enter the submit button  plz send the code for this


Re: [web2py] Re: db.define_tables

2011-06-10 Thread anil manikyam
def login():
if db((db.table1.username)== request.vars.visitor_name).select():
redirect(URL('index'))
else:
msg='invalid syntax'



return dict(display_msg=msg)

form
  input name=visitor_name /
  input type=submit /
  {{=
/form
{{=display_string}}

i tried it but when this display_string used in form it printed before the
enter the submit button  plz send the code for this


Re: [web2py] how to write if else in controller in web2py

2011-06-10 Thread anil manikyam
def login():
if db((db.table1.username)== request.vars.visitor_name).select():
redirect(URL('index'))
else:
msg='invalid syntax'



return dict(display_msg=msg)

form
  input name=visitor_name /
  input type=submit /
  {{=
/form
{{=display_string}}

i tried it but when this display_string used in form it printed before the
enter the submit button  plz send the code for this


Re: [web2py] Re: nginx and web2py

2011-06-10 Thread Anthony
See http://web2py.com/book/default/chapter/08#Auth-and-Mail

On Friday, June 10, 2011 6:49:07 AM UTC-4, anil manikyam wrote:



 how i will send mail to others using web2py



 -- 
 @n!l m@n!ky@m



Re: [web2py] Re: how to write if else in controller in web2py

2011-06-10 Thread Anthony
On Friday, June 10, 2011 9:22:11 AM UTC-4, anil manikyam wrote: 

  form
input name=visitor_name /
   input type=submit /
   {{=--- What's this for? Try deleting this line.
 /form
 {{=display_string}}

 
Also, please do not post the same message multiple times. Thank you.


[web2py] Change layout of CRUD forms

2011-06-10 Thread Jim Steil

Hi

I'm looking for a way to modify the presentation of a CRUD form.  
Specifically I want the following:


Name:INPUT_FIELD_FOR_FIRST_NAME   INPUT_FIELD_FOR_LAST_NAME
Address:  INPUT_FIELD_FOR_ADDRESS
City/State/ZIP:  INPUT_FIELD_FOR_CITY, INPUT_FIELD_FOR_STATE, 
INPUT_FIELD_FOR_ZIP


I've been looking around the web but can't seem to find anything that 
specifically addresses this.  Coming from a TurboGears 1.0 background I 
could do this by creating custom widgets and nesting them in forms.  
Obviously no auto-CRUD available there but I'm wondering how I can most 
easily accomplish the same thing using CRUD.  Or, am I asking too much 
from a CRUD interface?


Thanks

-Jim


[web2py] Re: Change layout of CRUD forms

2011-06-10 Thread Anthony
Have you tried the method described here: 
http://web2py.com/book/default/chapter/07#Custom-forms?
 
You can also create custom widgets, but I don't think you'd need to in this 
case. And you can also do some form customization via server-side DOM 
parsing (
http://web2py.com/book/default/chapter/05#Server-side-DOM-and-Parsing; 
http://www.web2pyslices.com/main/slices/take_slice/43).
 
Anthony
 

On Friday, June 10, 2011 10:10:12 AM UTC-4, Jim S wrote:

 Hi

 I'm looking for a way to modify the presentation of a CRUD form.  
 Specifically I want the following:

 Name:INPUT_FIELD_FOR_FIRST_NAME   INPUT_FIELD_FOR_LAST_NAME
 Address:  INPUT_FIELD_FOR_ADDRESS
 City/State/ZIP:  INPUT_FIELD_FOR_CITY, INPUT_FIELD_FOR_STATE, 
 INPUT_FIELD_FOR_ZIP

 I've been looking around the web but can't seem to find anything that 
 specifically addresses this.  Coming from a TurboGears 1.0 background I 
 could do this by creating custom widgets and nesting them in forms.  
 Obviously no auto-CRUD available there but I'm wondering how I can most 
 easily accomplish the same thing using CRUD.  Or, am I asking too much from 
 a CRUD interface?

 Thanks

 -Jim



Re: [web2py] Re: Change layout of CRUD forms

2011-06-10 Thread Jim Steil
Thanks, that's exactly what I missed going through the book.  I'll work 
through this and see what I can come up with.


-Jim

On 6/10/2011 9:21 AM, Anthony wrote:
Have you tried the method described here: 
http://web2py.com/book/default/chapter/07#Custom-forms?
You can also create custom widgets, but I don't think you'd need to in 
this case. And you can also do some form customization via server-side 
DOM parsing 
(http://web2py.com/book/default/chapter/05#Server-side-DOM-and-Parsing; http://www.web2pyslices.com/main/slices/take_slice/43).

Anthony

On Friday, June 10, 2011 10:10:12 AM UTC-4, Jim S wrote:

Hi

I'm looking for a way to modify the presentation of a CRUD form. 
Specifically I want the following:


Name:INPUT_FIELD_FOR_FIRST_NAME   INPUT_FIELD_FOR_LAST_NAME
Address:  INPUT_FIELD_FOR_ADDRESS
City/State/ZIP:  INPUT_FIELD_FOR_CITY, INPUT_FIELD_FOR_STATE,
INPUT_FIELD_FOR_ZIP

I've been looking around the web but can't seem to find anything
that specifically addresses this.  Coming from a TurboGears 1.0
background I could do this by creating custom widgets and nesting
them in forms.  Obviously no auto-CRUD available there but I'm
wondering how I can most easily accomplish the same thing using
CRUD.  Or, am I asking too much from a CRUD interface?

Thanks

-Jim



[web2py] Re: LOAD with ajax=False fails to pass vars

2011-06-10 Thread apple
This does not seem to work for me even with ajax_trap=True.

On May 12, 7:24 pm, pbreit pbreitenb...@gmail.com wrote:
 Still didn't work in trunk. ajax_trap=True makes it work. But that
 shouldn't be necessary, correct?


[web2py] Re: LOAD with ajax=False fails to pass vars

2011-06-10 Thread Anthony
Can you show your code?

On Friday, June 10, 2011 10:53:50 AM UTC-4, apple wrote:

 This does not seem to work for me even with ajax_trap=True. 

 On May 12, 7:24 pm, pbreit pbreit...@gmail.com wrote: 
  Still didn't work in trunk. ajax_trap=True makes it work. But that 
  shouldn't be necessary, correct?



[web2py] limitby not working

2011-06-10 Thread Junaid P V
Hi,

I have a database of lamps, I was trying to show paginated records from
lamps table.
I could not find limitby working.

My code is:

lamps = db().select(db.lamps.ALL, limitby=(offset, limit))


But, I get records only in the rage 0 to limit starting from offset

To clarify, if I have 7 records in lamps table and I give offset = 2 and
limit 4, I get only two records from offset 2

Could somebody help me please??


[web2py] Re: import error debian package

2011-06-10 Thread Stavros
Thank you.  That worked wonderfully.  I'll test out the package when
it's available.

On Jun 10, 8:08 am, José Luis Redrejo Rodríguez jredr...@debian.org
wrote:
 2011/6/9 Stavros stavros32...@gmail.com:

 http://dl.dropbox.com/u/3616407/mathquiz.tar.gz

  Thanks

 Thanks for the testing project.  Checking it I've noticed there was a
 missing (and important file now) : applications/__init__.py

 I've just fixed it and uploaded a new version (1.96.4-2) of the
 package to Debian,
 but it can take a few hours before it gets visible through the mirrors.

 In case you don't want to wait until new packages are visible,
 replacing the attached  /usr/bin/web2py file will fix the error.

 Regards
 José L.







  On Jun 9, 12:30 pm, José Luis Redrejo Rodríguez jredr...@debian.org
  wrote:
  2011/6/9 Jeff Elkner jeff.elk...@gmail.com:

   We copy the math_quiz directory and all its contents from a source 
   install
   of web2py, where it works, to the application directory of a user 
   created by
   the debian package, where it gives the error above.

   Three of us have confirmed this on three separate installations.  We are
   pretty confident it is an error with the way the package works.

  Could you give me a part of the code to test it in the package. I
  guess it's a permission problem.

  Regards.

  web2py
 4KViewDownload


[web2py] Re: limitby not working

2011-06-10 Thread Massimo Di Pierro
limitby=(a,b)

gives you records with a=numberb, NOT a=numbera+b. In other words,
b is not the SQL LIMIT value. You can do

lamps = db().select(db.lamps.ALL, limitby=(offset, offset+limit))


On Jun 10, 10:28 am, Junaid P V junu...@gmail.com wrote:
 Hi,

 I have a database of lamps, I was trying to show paginated records from
 lamps table.
 I could not find limitby working.

 My code is:

 lamps = db().select(db.lamps.ALL, limitby=(offset, limit))

 But, I get records only in the rage 0 to limit starting from offset

 To clarify, if I have 7 records in lamps table and I give offset = 2 and
 limit 4, I get only two records from offset 2

 Could somebody help me please??


[web2py] Re: limitby not working

2011-06-10 Thread Junaid P V
Thank you Massimo :)

I was thinking in SQL


[web2py] Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread Ross Peoples
For the last month or so, I have been working on a plugin that does 
something similar to CRUD, except that it's all AJAX and provides a couple 
of nice features for editing things. Obviously, it doesn't work exactly like 
CRUD, since I've never really looked at the code for it, but I wanted 
something similar that was fast.

Here are some screen shots of how it lists items in a simple, reorderable 
list:

https://lh6.googleusercontent.com/-ZrAVT54bJcg/TfJZni9VRHI/ABQ/UwliZ1DRAjM/Screen%252520shot%2525202011-06-10%252520at%2525201.36.13%252520PM.png
This is the automatically generated editor that shows up with jQuery UI's 
Dialog:

https://lh6.googleusercontent.com/-ZeGy8t8r4Wg/TfJZ1V9CndI/ABY/1ec9UoUvsrI/Screen%252520shot%2525202011-06-10%252520at%2525201.36.39%252520PM.png

Deleting a record is easy too:

https://lh5.googleusercontent.com/-OpZUcBaVYho/TfJZ9iZEgSI/ABg/9s4aXK5W75o/Screen%252520shot%2525202011-06-10%252520at%2525201.37.04%252520PM.png

A more complex list/details view is available as well:

https://lh4.googleusercontent.com/-Gws74Fzm9c0/TfJaHA8JEwI/ABo/Gd9SC_VIPEk/Screen%252520shot%2525202011-06-10%252520at%2525201.43.46%252520PM.png

Finally, the last screen shot was made using only this code in the default 
controller:

https://lh5.googleusercontent.com/-pQqexQOxIiE/TfJaQr6QMlI/ABw/wCy9E7FHg2o/Screen%252520shot%2525202011-06-10%252520at%2525201.50.14%252520PM.png

I originally created this functionality for an application I was using, then 
eventually turned it into a plugin. As such, it assumes that you use jQuery 
UI and the jQuery Layout plugin. It will load the jQuery Layout plugin 
automatically if it is in your app/static/js folder, but again, this assumes 
that you have your own jQuery UI installation. This is probably the only 
draw back so far.

I am not ready to release the code yet, as there is quite a bit of 
documentation that would need to be written for it since it does make a few 
assumptions when creating your own forms versus allowing the plugin to 
create them for you. I am just putting this out there to see if there is any 
community interest in this plugin. If enough people are interested, then I 
will try to set some time aside to clean up the code, document, and release 
the plugin.


[web2py] Re: nginx and web2py

2011-06-10 Thread peter
Thanks. I had already made cache and the files within writeable by
all. I tried making the directories of web2py writeable to all, to no
benefit, so I rather drastically made everything within my application
writeable by all.

This did sort out the problem. I probably ought to go back now and
narrow down what was actually necessary.

I used
http://bda.ath.cx/blog/2009/04/08/installing-python-26-in-centos-5-or-rhel5/

To upgrade to python2.6 (this corrupted the msql configuration file
but was otherwise successful)

One has to be careful here, because web2py does seem to need at least
python 2.5, and my centos system comes with 2.4.

If one is not careful one gets mixed up versions of python and then
things do not work out.


I then got nginx to work with uwsgi by using

http://library.linode.com/web-servers/nginx/python-uwsgi/fedora-13?format=print

but I changed the make of uwsgi to

make -f makefile.py26

This causes it to use python2.6. This is what causes web2py to be run
with python2.6.

So follow the instructions in the above link to get the 'hello world'
application going. This means you have nginx, uwsgi and python working
together.

The change uwsgi configuration file to use

MODULE=wsgihandler
and PYTHONPATH to point to your web2py directory.

from

MODULE=wsgi_configuration_module

and set PYTHONPATH to point to your web2py directory.

Make sure your permissions are okay for your web2py directory and you
should have web2py powered by nginx.

I have managed to also get the same nginx to serve php with fastcgi.
It is really fast.










On Jun 10, 11:49 am, anil manikyam anilmanikya...@gmail.com wrote:
 how i will send mail to others using web2py

 --
 @n!l m@n!ky@m


[web2py] Re: Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread Massimo Di Pierro
I am in love. I look forward to you releasing the source code.

On Jun 10, 1:02 pm, Ross Peoples ross.peop...@gmail.com wrote:
 For the last month or so, I have been working on a plugin that does
 something similar to CRUD, except that it's all AJAX and provides a couple
 of nice features for editing things. Obviously, it doesn't work exactly like
 CRUD, since I've never really looked at the code for it, but I wanted
 something similar that was fast.

 Here are some screen shots of how it lists items in a simple, reorderable
 list:

 https://lh6.googleusercontent.com/-ZrAVT54bJcg/TfJZni9VRHI/AB...
 This is the automatically generated editor that shows up with jQuery UI's
 Dialog:

 https://lh6.googleusercontent.com/-ZeGy8t8r4Wg/TfJZ1V9CndI/AB...

 Deleting a record is easy too:

 https://lh5.googleusercontent.com/-OpZUcBaVYho/TfJZ9iZEgSI/AB...

 A more complex list/details view is available as well:

 https://lh4.googleusercontent.com/-Gws74Fzm9c0/TfJaHA8JEwI/AB...

 Finally, the last screen shot was made using only this code in the default
 controller:

 https://lh5.googleusercontent.com/-pQqexQOxIiE/TfJaQr6QMlI/AB...

 I originally created this functionality for an application I was using, then
 eventually turned it into a plugin. As such, it assumes that you use jQuery
 UI and the jQuery Layout plugin. It will load the jQuery Layout plugin
 automatically if it is in your app/static/js folder, but again, this assumes
 that you have your own jQuery UI installation. This is probably the only
 draw back so far.

 I am not ready to release the code yet, as there is quite a bit of
 documentation that would need to be written for it since it does make a few
 assumptions when creating your own forms versus allowing the plugin to
 create them for you. I am just putting this out there to see if there is any
 community interest in this plugin. If enough people are interested, then I
 will try to set some time aside to clean up the code, document, and release
 the plugin.


Re: [web2py] Re: Auth_user ondelete

2011-06-10 Thread Thiago Carvalho D' Ávila
It worked out, thanks! Thread closed.

2011/6/9 Anthony abasta...@gmail.com

 On Thursday, June 9, 2011 6:59:34 PM UTC-4, Thiago wrote:

 I have this auth_user table, and another table called activities. This
 activities have 2 fields that are foreing keys to user (created by and
 modified by). If I delete any user that created or modified one activity,
 the activity is deleted.

 Do I have to put NO ACTION in all fields that is foreign key to user? I
 don't see how NO ACTION in the ondelete of activity solves my problem...

 Sorry I'm very confused. I just got one system made by some other people
 (with no documentation =( ) and I am trying to understand to maintain it...


 I think you would specify ondelete='NO ACTION' in the reference fields in
 the 'activities' table.




[web2py] Re: LOAD with ajax=False fails to pass vars

2011-06-10 Thread apple
Basically same as previous poster:

View:

{{extend 'layout.html'}}
{{=LOAD(f='test.html', args=[1,2,3], vars=dict(x=1,y=2), ajax=False,
ajax_trap=True)}}

Controller:

def test():
print(test)
print request.args
print request.vars
print(end test)
return

I call it with controller/arg1/arg2?b=123

Result is args=[1,2,3] and vars={b=123}



On Jun 10, 4:15 pm, Anthony abasta...@gmail.com wrote:
 Can you show your code?







 On Friday, June 10, 2011 10:53:50 AM UTC-4, apple wrote:
  This does not seem to work for me even with ajax_trap=True.

  On May 12, 7:24 pm, pbreit pbreit...@gmail.com wrote:
   Still didn't work in trunk. ajax_trap=True makes it work. But that
   shouldn't be necessary, correct?


[web2py] Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread cjrh
Yes. I am willing to help with code cleanup and documentation if you like. Just 
shout if you want help. I'll add any necessary documentation to the book too if 
it goes into trunk.


[web2py] Re: LOAD with ajax=False fails to pass vars

2011-06-10 Thread Massimo Di Pierro
This helps. I think I understand now and should be able to fix it
tonight.

On Jun 10, 1:54 pm, apple simo...@gmail.com wrote:
 Basically same as previous poster:

 View:

 {{extend 'layout.html'}}
 {{=LOAD(f='test.html', args=[1,2,3], vars=dict(x=1,y=2), ajax=False,
 ajax_trap=True)}}

 Controller:

 def test():
     print(test)
     print request.args
     print request.vars
     print(end test)
     return

 I call it with controller/arg1/arg2?b=123

 Result is args=[1,2,3] and vars={b=123}

 On Jun 10, 4:15 pm, Anthony abasta...@gmail.com wrote:







  Can you show your code?

  On Friday, June 10, 2011 10:53:50 AM UTC-4, apple wrote:
   This does not seem to work for me even with ajax_trap=True.

   On May 12, 7:24 pm, pbreit pbreit...@gmail.com wrote:
Still didn't work in trunk. ajax_trap=True makes it work. But that
shouldn't be necessary, correct?


[web2py] preview image from video file

2011-06-10 Thread Sahil Arora
I am making an application in which i want to show the preview image from an 
uploaded video and also stream that video. Can u please guide me how can I 
get a preview image from 
a video file. Also how to stream a video file


[web2py] Re: Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread Ross Peoples
That would be something if it actually went into the trunk :) Thanks for 
offering to help to. I'll send you over what I have. It is a somewhat large 
and complicated plugin, so maybe you will find a better way to do some of 
the things in there and simplify it a bit.

[web2py] Re: Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread cjrh
There is actually a high probability of it getting into trunk if we can get 
it suitably generic.  I am much more familiar with Python than js, but since 
you're using AJAX that should be fine.  Based on your description, it sounds 
great.  Instead of sending me your files set up a project on github, or one 
of the other places, like bitbucket (for hg). Best would be if Massimo makes 
a named branch on the web2py mercurial repo, but I don't know what his 
policy is on that.  Branches work *really* well in git, I am less familiar 
with hg.

[web2py] Re: preview image from video file

2011-06-10 Thread Massimo Di Pierro
http://linuxers.org/tutorial/how-extract-images-video-using-ffmpeg

On Jun 10, 2:00 pm, Sahil Arora sahilarora...@gmail.com wrote:
 I am making an application in which i want to show the preview image from an
 uploaded video and also stream that video. Can u please guide me how can I
 get a preview image from
 a video file. Also how to stream a video file


[web2py] Re: Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread Ross Peoples
I sent everything to you before I got this message, so now I'm looking at 
either using BitBucket or Google Code (because that's what web2py uses). 
That is unless Massimo wants to give me a named branch or something ;)

[web2py] Re: Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread Ross Peoples
Ok, I made a repository on BitBucket, so anyone that wants to help with with 
this, please do.

https://bitbucket.org/PhreeStyle/web2py_crud/src


[web2py] Import from another application in 1.96.x

2011-06-10 Thread Jim Karsten
In a controller of one application I import classes from a module in another 
application using either of these syntaxes. 

from applications.another_app.modules.mymodule import MyClass 
MyClass = local_import('mymodule', app='another_app').MyClass 

Is there a better way to do that with the changes in 1.96.x? 


[web2py] Re: Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread cjrh
Ok, I pulled.   Will have a look over the next few days.  Will probably send 
you diffs, which you can choose to accept/reject.

[web2py] Re: Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread pbreit
Looks cool. I don't use crud (unless admin or appadmin uses it) but would 
check it out. Both Jquery and Jquery UI are in the Google CDN which is 
probably a better place to get them anyhow:
http://code.google.com/apis/libraries/devguide.html#jquery

If you include them like this they work both for http and https:
script 
src=//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js/script


[web2py] Re: Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread Ross Peoples
I chose to go with a locally installed jQuery UI since my original project 
was designed to replace an internal enterprise application which may not 
have internet access once it goes into production. I suppose I could make it 
pull from the CDN by default to lower the barrier to entry. But I want to 
get some more eyes on the code first before I start making changes. Thanks 
for your input, that was very helpful.

[web2py] Re: Anyone interested in an AJAX version of CRUD?

2011-06-10 Thread pbreit
Here's a trick from HTML5 Boilerplate for Jquery. I presume it could be 
modified for UI (or any library).

script 
src=//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js/script
scriptwindow.jQuery || document.write(script 
src='{{=URL('static','js/jquery.js')}}'\x3C/script)/script


Re: [web2py] Re: New Features in Book

2011-06-10 Thread Pierre Thibault
I can talk about the features that I implemented. Just ask.

We could be documentation driven: The developer writes the feature he is
going to implement, we write the tests (tests driven) and then he writes the
implementation. This process will creates the documentation we need for the
book.


-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)http://pierrethibault.posterous.com
YouTube page 
(http://www.youtube.com/user/tubetib)http://www.youtube.com/user/tubetib
Twitter (http://twitter.com/pierreth2) http://twitter.com/pierreth2


[web2py] how to use this ajax upload script with web2py?

2011-06-10 Thread danto
http://valums.com/ajax-upload/

It's supposed to be a ready-to-use asyncronous upload (could be a widget,
later) with load indicator, but I don't know how to integrate with my form.
In fact, I get no errors on console (as the author say after set debug:
true) but still my upload fails. I can tested with rocket and
apache+mod_wsgi, but probably should blame my implementation:

### CONTROLLER:
def post():
response.files.append(URL('static','css/fileuploader.css'))
response.files.append(URL('static','js/fileuploader.js'))
form = SQLFORM.factory(
Field('nombre'),
Field('archivo','upload',uploadfolder='applications/test/uploads')
)

if form.accepts(request.vars,session):
response.flash = 'ok'
elif form.errors:
response.flash = 'no'
return locals()


### VIEW:

{{extend 'layout.html'}}
div id=fileuploader
noscript
pPlease enable JavaScript to use file uploader./p
!-- or put a simple form for upload here --
/noscript
/div

{{=response.toolbar()}}

script
var uploader = new qq.FileUploader({
// pass the dom node (ex. $(selector)[0] for jQuery users)
element: document.getElementById('fileuploader'),
// path to server-side upload scripts
action: 'post',
debug: true,
});
/script

thank you for your time


Re: [web2py] Re: preview image from video file

2011-06-10 Thread Sahil Arora
Thanks for the help. I got the image from the video. Can u help me with the
video streaming part. I could not get a good tutorial for this.

On Sat, Jun 11, 2011 at 12:59 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 http://linuxers.org/tutorial/how-extract-images-video-using-ffmpeg

 On Jun 10, 2:00 pm, Sahil Arora sahilarora...@gmail.com wrote:
  I am making an application in which i want to show the preview image from
 an
  uploaded video and also stream that video. Can u please guide me how can
 I
  get a preview image from
  a video file. Also how to stream a video file




-- 
Sahil Arora
B.Tech 2nd year
Computer Science and Engineering
IIT Delhi
Contact No: +91 9871491046
www.cse.iitd.ac.in/~cs1090213 http://www.cse.iitd.ac.in/%7Ecs1090213


[web2py] Decorated Profiler - New Profiling library for python (thread, greenthread and WSGI friendly)

2011-06-10 Thread Dragonfyre13
I'm currently using this on a few of my projects, and decided to throw
it up on bitbucket for others who might want to use it (and tell me
areas I need to work on). It's pretty solid, again I'm using it
already where I work, and it's got a pretty decent web based reporting
and control interface. Detailed feature list is on the wiki, epydocs
are in the package on bitbucket, and all it takes is decorating a
function/method/generator/class to start profiling. If you want WSGI
data, just add two lines (including the import) to insert the wsgi
middleware. (in fact, I pasted what I'm using at the bottom of the
email, for gunicorn)

Description from the readme:
A thread and greenthread aware profiling module that relies on
decorators to indicate what areas of code to profile. If profiling
WSGI applications, provides a middleware component to allow for
capturing request path of profiling data. Also contains a (somewhat
minimal) UI for presenting the data, and exposes reporting and control
methods via JSON proxy service, used by the UI, or by any subscriber's
data collectors. UI generates a call map, line by line timings,
aggregated resource usage for each decorated callable, and WSGI path
per callable.

it's up here, anyone who logs bugs against it, or tries it out and
likes it, I'd love some feedback (good, bad, or otherwise). Wiki has
some info in there along with screenshots, though I know the docs
aren't amazing.
https://bitbucket.org/dragonfyre13/decorated-profiler

Here's what I'm currently using to point gunicorn to, instead of
wsgibase. Just point it at wsgiwrapper in this file instead:

#!/usr/bin/env python
from gluon.main import wsgibase
from gluon.contrib import decoratedprofiler
wsgiwrapper = decoratedprofiler.ProfilerMiddleware(wsgibase)


[web2py] Script TDD in web2py

2011-06-10 Thread contatogilson...@gmail.com
Hello guys,

I started to create a script to test the scripts that use the library
unittest projects web2py. I usually like this:

- I create the folder *tests* in the project;
- Inside the tests folder create two folders: *models* and *controllers*;

For now, I have done is to test the model layer. But I ask the help and
contribution ofall to improve this script, and so we have a full support to
the use of TDD in both themodel layer as the control. This is good for
people like me, sympathized greatly with doctests.

The link: https://gist.github.com/996576
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*


[web2py] web2py book changelog?

2011-06-10 Thread niknok

Is there like a change log for the web2py book where I can view what's
been added or modified recently?

/r


[web2py] implement public, password protected and private view for user

2011-06-10 Thread 黄祥
hi,

i want to learn and implement public, password protected and private
view for user, is there anyone know how to do that?

thank you so much before

e.g.
=== model ===
db.define_table('files',
Field('title',
  label = T('Title')
  ),
Field('description',
  'text',
  label = T('Description')
  ),
Field('files',
  'upload',
  uploadfield = 'files_data',
  label = T('Files')
  ),
Field('files_data',
  'blob',
  label = T('Files Data')
  ),
Field('visibility',
  'list:string',
  label = T('Visibility')
  ),
Field('password',
  'password',
  label = T('Password')
  ),
auth.signature
)
db.files.visibility.requires = IS_IN_SET(('Public',
  'Private',
  'Protected'))
db.files.password.requires = IS_EMPTY_OR(IS_STRONG(min = 6,
   special = 1,
   upper = 1))


[web2py] ajax is not working in components

2011-06-10 Thread 黄祥
hi,

is ajax can work in components? i mean let say that i separated the
comment into 2 components, 1 for list of view comments and the other
is form to post the comment. i have a problem when i post the comment
using the form, the data that have been posted is not directly change
on list of comments (the other components), i must refresh my browser
many times so that the list comments can show the latest posted
comment. is there any clue or solution to implement ajax that works in
other components?

any hints, suggestion is greatly appreciate.
thank you very much.


[web2py] Re: ajax is not working in components

2011-06-10 Thread Anthony
Maybe try having the post comment action return some JS via response.js that 
calls the web2py_component JS function to update the list component:
 
def post_comment():
# do some stuff
response.js='web2py_component(action=%s,target=%s)' % 
(URL('list_comments.load'), 'comment_list')
return dict(...)
 
def list_comments():
# code to list comments
 
In view:
 
{{=LOAD('post_comment.load', ajax=True)}}
{{=LOAD('list_comments.load', target='comment_list', ajax=True)}} 
 
 
See 
http://web2py.com/book/default/chapter/13#Client-Server-Component-Communications
.
 
Anthony

On Friday, June 10, 2011 8:44:26 PM UTC-4, 黄祥 wrote:

 hi, 

 is ajax can work in components? i mean let say that i separated the 
 comment into 2 components, 1 for list of view comments and the other 
 is form to post the comment. i have a problem when i post the comment 
 using the form, the data that have been posted is not directly change 
 on list of comments (the other components), i must refresh my browser 
 many times so that the list comments can show the latest posted 
 comment. is there any clue or solution to implement ajax that works in 
 other components? 

 any hints, suggestion is greatly appreciate. 
 thank you very much.



[web2py] Howto prepopulate a sqlform's drop-down field

2011-06-10 Thread tomt
Hi,

I've written a controller to add a record using sqlform, and I want to
prepopulate several of the fields.  I've had some success using
form.var.field = x, but I haven't been able to prepopulate the one
field that uses a dropdown list.

In the controller I listed below, I have success on the 'description'
field, but not the 'cpaid' field.

Any suggestions?


Model:
db.define_table('cpa',
Field('cpa','string'),
...

db.define_table('task',
Field('cpaid'),
Field('cpaord'),
Field('cpa','string'),
Field('description','string'),
...

db.task.cpaid.requires = IS_IN_DB(db,'cpa.id','cpa.cpa')


Controller.
def insert_task_cpa():
form = SQLFORM(db.task)
form.vars.description = 'Test Description'
form.vars.cpaid = IS_IN_DB(db,db.cpa.id, '6')
if form.accepts(request.vars,session):
response.flash='Task added'
redirect(URL('task_list_bycpa', args=cpa_id))
return dict(form=form)



[web2py] Re: preview image from video file

2011-06-10 Thread Massimo Di Pierro
are these video in static or uploaded by users?

On Jun 10, 5:00 pm, Sahil Arora sahilarora...@gmail.com wrote:
 Thanks for the help. I got the image from the video. Can u help me with the
 video streaming part. I could not get a good tutorial for this.

 On Sat, Jun 11, 2011 at 12:59 AM, Massimo Di Pierro 

 massimo.dipie...@gmail.com wrote:
 http://linuxers.org/tutorial/how-extract-images-video-using-ffmpeg

  On Jun 10, 2:00 pm, Sahil Arora sahilarora...@gmail.com wrote:
   I am making an application in which i want to show the preview image from
  an
   uploaded video and also stream that video. Can u please guide me how can
  I
   get a preview image from
   a video file. Also how to stream a video file

 --
 Sahil Arora
 B.Tech 2nd year
 Computer Science and Engineering
 IIT Delhi
 Contact No: +91 
 9871491046www.cse.iitd.ac.in/~cs1090213http://www.cse.iitd.ac.in/%7Ecs1090213


Re: Re: Re: [web2py] Re: web2py 1.96.4 is OUT

2011-06-10 Thread Pierre Thibault
2011/6/9 Pierre Thibault pierre.thibau...@gmail.com

 2011/6/9 caleb.hatti...@gmail.com

 On , Anthony abasta...@gmail.com wrote:
  Do you have an app to reproduce the problem? I created an app named
 Castalia (note the capitalization) with a module
 /modules/selfgroup/castalia/config.py, which I think is the same structure
 and naming as Alessandro's app. In a controller action, I then did:
 
  from selfgroup.castalia import config
 
  and it seems to work fine, though I believe Alessandro was getting an
 import error at that point. But maybe I'm missing something.

 I think we should ask him to make a small test app for us that
 demonstrates the problem. Else we're guessing.


 Alessandro, can you send us the code having the unexpected behavior so the
 Windows guys can take a look?

 As I understand, you have to remove the capitalization to make it work
 because otherwise even if the capitalization match, it does not import
 properly. Right?

 --


OK, since we cannot reproduce the bug and we cannot know precisely what the
bug is, we will consider the issue closed. Do you think there is something
to add about this issue?


-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)http://pierrethibault.posterous.com
YouTube page 
(http://www.youtube.com/user/tubetib)http://www.youtube.com/user/tubetib
Twitter (http://twitter.com/pierreth2) http://twitter.com/pierreth2


Re: [web2py] Re: ajax is not working in components

2011-06-10 Thread Stifan Kristi
thank you so much for your hints, anthony, but, pardon me, the results on
the form components is loading..., the page didn't show an error, but keep
loading..., is there something i missed in my code?

e.g.
*=== controller ===*

blog = db.blog
blog_comment = db.blog_comment
blog_comment_blog_id = db.blog_comment.blog_id
blog_comment_active = db.blog_comment.is_active

def blog_comment_add():
return __add_2(blog, blog_index, blog_comment, blog_comment_blog_id)

@auth.requires_login()
def __add_2(table_0, index_link, table_1, field):
page = table_0(request.args(0)) or redirect(URL(index_link))
field.default = page.id
form = crud.create(table_1, message = T('Record Inserted'),
   next = URL(args = page.id))
*response.js = 'web2py_component(action = %s, target = %s)' *
*  % (URL('blog_comment_show.load'), *
*  'comments_%s hidden' % page.id)*
return dict(page = page, form = form)

*=== view ===*

{{=LOAD('default', 'blog_comment_show.load', args = page.id, ajax = True)}}
*{{=LOAD('default', 'blog_comment_add.load', args = page.id, *
*target = 'comments_%s hidden' % page.id, ajax = True)}}*

*=== blog_comment_show.load ===*

{{if len(results):}}
span onclick = jQuery('.comments_{{=page.id}}').slideToggle('slow');
{{=A(T('Comments (%s)' % len(results)), _href = '#')}}
/span

div class = comments_{{=page.id}} hidden
{{for blog_comment in results:}}
{{=SPAN(db.auth_user[blog_comment.created_by].first_name, T(' on
'),
blog_comment.created_on, T(' Said '),
 blog_comment.comment)}}
{{=BR()}}
{{=SPAN(blog_comment.like,
_id = 'blog_comment_like_%s' % blog_comment.id)}}
{{=SPAN(T('People Like This'))}}

span onclick=jQuery('#id').val('{{=blog_comment.id}}');
   ajax('{{=URL('blog_comment_like.load')}}', ['id'],
'blog_comment_like_{{=blog_comment.id}}');
{{=A(T('Like'), _href = '#')}}
/span
{{=BR()}}
{{pass}}
/div
{{else:}}
{{=DIV(B(T('No Comment Posted Yet')))}}
{{pass}}

*=== blog_comment_add.load ===*

{{=DIV(A(T('Post a Comment'), _href = '#'), _class = 'post',
   _onclick = jQuery('.form_%s').slideToggle('slow'); % page.id)}}

{{=DIV(form, _class = 'form_%s hidden' % page.id,
   _onsubmit = ajax('blog_comment_add', [], 'comments_%s hidden'); %
page.id)}}

On Sat, Jun 11, 2011 at 8:28 AM, Anthony abasta...@gmail.com wrote:

 Maybe try having the post comment action return some JS via response.js
 that calls the web2py_component JS function to update the list component:

 def post_comment():
 # do some stuff
 response.js='web2py_component(action=%s,target=%s)' %
 (URL('list_comments.load'), 'comment_list')
 return dict(...)

 def list_comments():
 # code to list comments

 In view:

 {{=LOAD('post_comment.load', ajax=True)}}
 {{=LOAD('list_comments.load', target='comment_list', ajax=True)}}


 See
 http://web2py.com/book/default/chapter/13#Client-Server-Component-Communications
 .

 Anthony

 On Friday, June 10, 2011 8:44:26 PM UTC-4, 黄祥 wrote:

 hi,

 is ajax can work in components? i mean let say that i separated the
 comment into 2 components, 1 for list of view comments and the other
 is form to post the comment. i have a problem when i post the comment
 using the form, the data that have been posted is not directly change
 on list of comments (the other components), i must refresh my browser
 many times so that the list comments can show the latest posted
 comment. is there any clue or solution to implement ajax that works in
 other components?

 any hints, suggestion is greatly appreciate.
 thank you very much.




Re: [web2py] Re: preview image from video file

2011-06-10 Thread Stifan Kristi
how to integrate web2py with ffmpeg? i mean when users uploaded the video,
web2py can automatic reproduce the image and store it in the database. is
there any way to do this?
thank you so much.


[web2py] Re: Howto prepopulate a sqlform's drop-down field

2011-06-10 Thread tomt
Hello again,

I withdraw my question as I managed to get the obvious working:
form.vars.cpaid = 6   # or whatever id is required

I failed to get this working earlier, so I mistakenly assumed that the
solution was more complex.  I must have made some dumb mistake that
disabled proper operation.

Sorry for the wasted post...

On Jun 10, 8:05 pm, tomt tom_tren...@yahoo.com wrote:
 Hi,

 I've written a controller to add a record using sqlform, and I want to
 prepopulate several of the fields.  I've had some success using
 form.var.field = x, but I haven't been able to prepopulate the one
 field that uses a dropdown list.

 In the controller I listed below, I have success on the 'description'
 field, but not the 'cpaid' field.

 Any suggestions?

 Model:
 db.define_table('cpa',
     Field('cpa','string'),
 ...

 db.define_table('task',
     Field('cpaid'),
     Field('cpaord'),
     Field('cpa','string'),
     Field('description','string'),
 ...

 db.task.cpaid.requires = IS_IN_DB(db,'cpa.id','cpa.cpa')

 Controller.
 def insert_task_cpa():
     form = SQLFORM(db.task)
     form.vars.description = 'Test Description'
     form.vars.cpaid = IS_IN_DB(db,db.cpa.id, '6')
     if form.accepts(request.vars,session):
         response.flash='Task added'
         redirect(URL('task_list_bycpa', args=cpa_id))
     return dict(form=form)


[web2py] Re: Social network plug-in

2011-06-10 Thread Luis Goncalves
Ciao Massimo!

Is it now available somewhere for download?   It will be very useful!!!

Thanks,
Luis.


Re: [web2py] Re: ajax is not working in components

2011-06-10 Thread Anthony
Do you have a blog_comment_show() action in your controller?

On Friday, June 10, 2011 10:58:56 PM UTC-4, 黄祥 wrote:

 thank you so much for your hints, anthony, but, pardon me, the results on 
 the form components is loading..., the page didn't show an error, but keep 
 loading..., is there something i missed in my code? 

 e.g.
  *=== controller ===*

 blog = db.blog
 blog_comment = db.blog_comment
 blog_comment_blog_id = db.blog_comment.blog_id
 blog_comment_active = db.blog_comment.is_active

 def blog_comment_add():
 return __add_2(blog, blog_index, blog_comment, blog_comment_blog_id)

 @auth.requires_login()
 def __add_2(table_0, index_link, table_1, field):
 page = table_0(request.args(0)) or redirect(URL(index_link))
 field.default = page.id
 form = crud.create(table_1, message = T('Record Inserted'), 
next = URL(args = page.id))
 *response.js = 'web2py_component(action = %s, target = %s)' *
 *  % (URL('blog_comment_show.load'), *
 *  'comments_%s hidden' % page.id)*
 return dict(page = page, form = form)

 *=== view ===*

 {{=LOAD('default', 'blog_comment_show.load', args = page.id, ajax = 
 True)}}
 *{{=LOAD('default', 'blog_comment_add.load', args = page.id, *
 *target = 'comments_%s hidden' % page.id, ajax = True)}}*
 
 *=== blog_comment_show.load ===*

 {{if len(results):}}
 span onclick = jQuery('.comments_{{=page.id
 }}').slideToggle('slow');
 {{=A(T('Comments (%s)' % len(results)), _href = '#')}}
 /span
 
 div class = comments_{{=page.id}} hidden
 {{for blog_comment in results:}}
 {{=SPAN(db.auth_user[blog_comment.created_by].first_name, T(' on 
 '), 
 blog_comment.created_on, T(' Said '), 
  blog_comment.comment)}}
 {{=BR()}}
 {{=SPAN(blog_comment.like, 
 _id = 'blog_comment_like_%s' % blog_comment.id)}}
 {{=SPAN(T('People Like This'))}}
 
 span onclick=jQuery('#id').val('{{=blog_comment.id}}');
ajax('{{=URL('blog_comment_like.load')}}', ['id'], 
 'blog_comment_like_{{=blog_comment.id}}');
 {{=A(T('Like'), _href = '#')}}
 /span
 {{=BR()}}
 {{pass}}
 /div
 {{else:}}
 {{=DIV(B(T('No Comment Posted Yet')))}}
 {{pass}}

 *=== blog_comment_add.load ===*

 {{=DIV(A(T('Post a Comment'), _href = '#'), _class = 'post', 
_onclick = jQuery('.form_%s').slideToggle('slow'); % page.id)}}

 {{=DIV(form, _class = 'form_%s hidden' % page.id, 
_onsubmit = ajax('blog_comment_add', [], 'comments_%s hidden'); % 
 page.id)}}

 On Sat, Jun 11, 2011 at 8:28 AM, Anthony abas...@gmail.com wrote:

 Maybe try having the post comment action return some JS via response.js 
 that calls the web2py_component JS function to update the list component:
  
 def post_comment():
 # do some stuff
 response.js='web2py_component(action=%s,target=%s)' % 
 (URL('list_comments.load'), 'comment_list')
 return dict(...)
  
 def list_comments():
 # code to list comments
  
 In view:
  
 {{=LOAD('post_comment.load', ajax=True)}}
 {{=LOAD('list_comments.load', target='comment_list', ajax=True)}} 
  
  
 See 
 http://web2py.com/book/default/chapter/13#Client-Server-Component-Communications
 .
  
 Anthony

 On Friday, June 10, 2011 8:44:26 PM UTC-4, 黄祥 wrote:

 hi, 

 is ajax can work in components? i mean let say that i separated the 
 comment into 2 components, 1 for list of view comments and the other 
 is form to post the comment. i have a problem when i post the comment 
 using the form, the data that have been posted is not directly change 
 on list of comments (the other components), i must refresh my browser 
 many times so that the list comments can show the latest posted 
 comment. is there any clue or solution to implement ajax that works in 
 other components? 

 any hints, suggestion is greatly appreciate. 
 thank you very much.




Re: [web2py] Re: ajax is not working in components

2011-06-10 Thread Stifan Kristi
yes, i have.

def blog_comment_show():
return
__show_2(blog, blog_index, blog_comment, blog_comment_blog_id,
blog_comment_active)

@auth.requires_login()
def __show_2(table_0, index_link, table_1, field, active):
page = table_0(request.args(0)) or redirect(URL(index_link))
results = db((field == page.id)  (active == True)).select(orderby = ~
table_1.id,
   cache =
(cache.ram,
10))
return dict(page = page, results = results)

i think the error is on target load, so that my page keep showing loading...

did you have any way out for this probelm?
thank you so much.

On Sat, Jun 11, 2011 at 11:05 AM, Anthony abasta...@gmail.com wrote:

 Do you have a blog_comment_show() action in your controller?

 On Friday, June 10, 2011 10:58:56 PM UTC-4, 黄祥 wrote:

 thank you so much for your hints, anthony, but, pardon me, the results on
 the form components is loading..., the page didn't show an error, but keep
 loading..., is there something i missed in my code?

 e.g.
  *=== controller ===*

 blog = db.blog
 blog_comment = db.blog_comment
 blog_comment_blog_id = db.blog_comment.blog_id
 blog_comment_active = db.blog_comment.is_active

 def blog_comment_add():
 return __add_2(blog, blog_index, blog_comment, blog_comment_blog_id)

 @auth.requires_login()
 def __add_2(table_0, index_link, table_1, field):
 page = table_0(request.args(0)) or redirect(URL(index_link))
 field.default = page.id
 form = crud.create(table_1, message = T('Record Inserted'),
next = URL(args = page.id))
 *response.js = 'web2py_component(action = %s, target = %s)' *
 *  % (URL('blog_comment_show.load'), *
 *  'comments_%s hidden' % page.id)*
 return dict(page = page, form = form)

 *=== view ===*

 {{=LOAD('default', 'blog_comment_show.load', args = page.id, ajax =
 True)}}
 *{{=LOAD('default', 'blog_comment_add.load', args = page.id, *
 *target = 'comments_%s hidden' % page.id, ajax = True)}}*

 *=== blog_comment_show.load ===*

 {{if len(results):}}
 span onclick = jQuery('.comments_{{=page.id
 }}').slideToggle('slow');
 {{=A(T('Comments (%s)' % len(results)), _href = '#')}}
 /span

 div class = comments_{{=page.id}} hidden
 {{for blog_comment in results:}}
 {{=SPAN(db.auth_user[blog_comment.created_by].first_name, T(' on
 '),
 blog_comment.created_on, T(' Said '),
  blog_comment.comment)}}
 {{=BR()}}
 {{=SPAN(blog_comment.like,
 _id = 'blog_comment_like_%s' % blog_comment.id)}}
 {{=SPAN(T('People Like This'))}}

 span onclick=jQuery('#id').val('{{=blog_comment.id}}');
ajax('{{=URL('blog_comment_like.load')}}', ['id'],
 'blog_comment_like_{{=blog_comment.id}}');
 {{=A(T('Like'), _href = '#')}}
 /span
 {{=BR()}}
 {{pass}}
 /div
 {{else:}}
 {{=DIV(B(T('No Comment Posted Yet')))}}
 {{pass}}

 *=== blog_comment_add.load ===*

 {{=DIV(A(T('Post a Comment'), _href = '#'), _class = 'post',
_onclick = jQuery('.form_%s').slideToggle('slow'); % page.id)}}

 {{=DIV(form, _class = 'form_%s hidden' % page.id,
_onsubmit = ajax('blog_comment_add', [], 'comments_%s hidden'); %
 page.id)}}

 On Sat, Jun 11, 2011 at 8:28 AM, Anthony abas...@gmail.com wrote:

 Maybe try having the post comment action return some JS via response.js
 that calls the web2py_component JS function to update the list component:

 def post_comment():
 # do some stuff
 response.js='web2py_component(action=%s,target=%s)' %
 (URL('list_comments.load'), 'comment_list')
 return dict(...)

 def list_comments():
 # code to list comments

 In view:

 {{=LOAD('post_comment.load', ajax=True)}}
 {{=LOAD('list_comments.load', target='comment_list', ajax=True)}}


 See
 http://web2py.com/book/default/chapter/13#Client-Server-Component-Communications
 .

 Anthony

 On Friday, June 10, 2011 8:44:26 PM UTC-4, 黄祥 wrote:

 hi,

 is ajax can work in components? i mean let say that i separated the
 comment into 2 components, 1 for list of view comments and the other
 is form to post the comment. i have a problem when i post the comment
 using the form, the data that have been posted is not directly change
 on list of comments (the other components), i must refresh my browser
 many times so that the list comments can show the latest posted
 comment. is there any clue or solution to implement ajax that works in
 other components?

 any hints, suggestion is greatly appreciate.
 thank you very much.





Re: [web2py] Re: ajax is not working in components

2011-06-10 Thread Anthony
I think you're specifying the target div name in the wrong place. Instead 
of:
 
 {{=LOAD('default', 'blog_comment_show.load', args = page.id, ajax = True)}}
{{=LOAD('default', 'blog_comment_add.load', args = page.id, 
target = 'comments_%s hidden' % page.id, ajax = True)}}
 
I think you want:
 
 {{=LOAD('default', 'blog_comment_show.load', args = page.id,
target = 'comments_%s hidden' % page.id, ajax = True)}}
{{=LOAD('default', 'blog_comment_add.load', args = page.id, ajax = True)}}
 
 
Does that change help?
 
Also, in __add_2(), you might want to return response.js conditionally, only 
when a new comment has actually been added -- otherwise, when the page first 
loads, the blog_comment_show() component will be called/load twice (once 
because of the LOAD, and once because of the response.js from the 
blog_component_add() component).
 
If you're still having problems, I recommend creating a simplified version 
of the setup just to see if you can get the basic inter-component 
communication working -- then add in all the complexity and see where it 
breaks down.
 
Anthony

On Saturday, June 11, 2011 12:46:29 AM UTC-4, 黄祥 wrote:

 yes, i have. 

  def blog_comment_show():
 return 
 __show_2(blog, blog_index, blog_comment, blog_comment_blog_id, 
 blog_comment_active)

 @auth.requires_login()
 def __show_2(table_0, index_link, table_1, field, active):
 page = table_0(request.args(0)) or redirect(URL(index_link))
 results = db((field == page.id)  (active == True)).select(orderby = ~
 table_1.id, 
cache = 
 (cache.ram, 
 
 10))
 return dict(page = page, results = results)

 i think the error is on target load, so that my page keep showing 
 loading...

 did you have any way out for this probelm?
 thank you so much.

 On Sat, Jun 11, 2011 at 11:05 AM, Anthony abas...@gmail.com wrote:

 Do you have a blog_comment_show() action in your controller?
   
 On Friday, June 10, 2011 10:58:56 PM UTC-4, 黄祥 wrote:

   thank you so much for your hints, anthony, but, pardon me, the results 
 on the form components is loading..., the page didn't show an error, but 
 keep loading..., is there something i missed in my code? 

 e.g.
   *=== controller ===*

 blog = db.blog
 blog_comment = db.blog_comment
 blog_comment_blog_id = db.blog_comment.blog_id
 blog_comment_active = db.blog_comment.is_active

 def blog_comment_add():
 return __add_2(blog, blog_index, blog_comment, blog_comment_blog_id)

 @auth.requires_login()
 def __add_2(table_0, index_link, table_1, field):
 page = table_0(request.args(0)) or redirect(URL(index_link))
 field.default = page.id
 form = crud.create(table_1, message = T('Record Inserted'), 
next = URL(args = page.id))
 *response.js = 'web2py_component(action = %s, target = %s)' *
 *  % (URL('blog_comment_show.load'), *
 *  'comments_%s hidden' % page.id)*
 return dict(page = page, form = form)

 *=== view ===*

 {{=LOAD('default', 'blog_comment_show.load', args = page.id, ajax = 
 True)}}
 *{{=LOAD('default', 'blog_comment_add.load', args = page.id, *
 *target = 'comments_%s hidden' % page.id, ajax = True)}}*
 
 *=== blog_comment_show.load ===*

 {{if len(results):}}
 span onclick = jQuery('.comments_{{=page.id
 }}').slideToggle('slow');
 {{=A(T('Comments (%s)' % len(results)), _href = '#')}}
 /span
 
 div class = comments_{{=page.id}} hidden
 {{for blog_comment in results:}}
 {{=SPAN(db.auth_user[blog_comment.created_by].first_name, T(' on 
 '), 
 blog_comment.created_on, T(' Said '), 
  blog_comment.comment)}}
 {{=BR()}}
 {{=SPAN(blog_comment.like, 
 _id = 'blog_comment_like_%s' % blog_comment.id)}}
 {{=SPAN(T('People Like This'))}}
 
 span onclick=jQuery('#id').val('{{=blog_comment.id}}');
ajax('{{=URL('blog_comment_like.load')}}', ['id'], 
 'blog_comment_like_{{=blog_comment.id}}');
 {{=A(T('Like'), _href = '#')}}
 /span
 {{=BR()}}
 {{pass}}
 /div
 {{else:}}
 {{=DIV(B(T('No Comment Posted Yet')))}}
 {{pass}}

 *=== blog_comment_add.load ===*

 {{=DIV(A(T('Post a Comment'), _href = '#'), _class = 'post', 
_onclick = jQuery('.form_%s').slideToggle('slow'); % page.id)}}

 {{=DIV(form, _class = 'form_%s hidden' % page.id, 
_onsubmit = ajax('blog_comment_add', [], 'comments_%s hidden'); 
 % page.id)}}

   On Sat, Jun 11, 2011 at 8:28 AM, Anthony aba...@gmail.com wrote:

 Maybe try having the post comment action return some JS via response.js 
 that calls the web2py_component JS function to update the list component:
  
 def post_comment():
 # do some stuff
 response.js='web2py_component(action=%s,target=%s)' % 
 (URL('list_comments.load'), 'comment_list')
 return