[web2py] Re: question about loading a component during a callback [closed]

2011-09-12 Thread weheh
Never mind. I think I figured out what I'm doing wrong. The path from
controller to view to controller to view gets me dizzy when I haven't
done it in awhile.


On Sep 12, 12:08 am, weheh  wrote:
> I have a component. The controller is standard:
>
> # controller
> def index():
>     blah
>     blah
>     form=crud(db.mytable,record_id)
>     return dict(form=form)
>
> # view index.html
> ...
> LOAD("index","index.load",ajax=True)
>
> # view index.load
> {{=show_form(form)}}
>
> # model
> def show_form(form):
>     return DIV(form)
>
> Later on, in an onclick triggers for a link causes a server-side
> callback to select a new record for mytable. I want to get the same
> form to load up again but with this new record selected.
>
> The question is, how can I get the callback to force the new form to
> get loaded? I tried having the callback return a
> URL(r=request,c='mycontroller',f='index',args=[new_record_id]) but
> this didn't seem to work.
>
> I figure I could get this to work if I push the form creation onto the
> view side, but this somehow seems wrong.
>
> Suggestions are much appreciated.


Re: [web2py] Re: physics examples in web2py + processing.js

2011-09-12 Thread Michele Comitini
I love switching the gravity on and off! :D

2011/9/12 Ivica Kralj :
> Cool 
>
> The power of web2py and MDP  :)
>
> On 12 September 2011 06:12, Noel Villamor  wrote:
>>
>> Massimo, I feel like a toddler in a playpen right now. Too many toys I
>> can't decide which one to play!
>>
>> Nice and fun projects you have there.
>>
>> On Sep 12, 2:56 pm, Massimo Di Pierro 
>> wrote:
>> > Not really server side intensive, mostly client side but fun project.
>> >
>> > http://tests.web2py.com/physics2d
>


Re: [web2py] Re: Issues with TAG() encoding and XML().flatten()

2011-09-12 Thread jot.be
Hi Massimo,

thanks for your answer!

On Mon, Sep 12, 2011 at 2:19 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Are you sure your input is UTF8? The web2py markmin_serializer is in
> gluon/html.py and it is relatively straightforward. Nothing can really
> go bad there. I suspect your input has not been parsed at all into the
> web2py object representation.
>
>
Not sure - I am quite new to Python and am not so skilled in dealing with
Unicode issues.

I just appended my last approaches:
https://gist.github.com/caec7bd5b41624d50b01#gistcomment-50227

For my understanding it is not the input that TAG(input) expects. When using
classic html entities ("ä") it works.

Any hint what I could try next? :)


> the parsing is done by TAG(input) (not by XML(input)) and it is based
> on the python built-in XML parser which chokes on non-utf8 chars. It
> may not be parsting the XML at all and returning the XML as a single
> string.
>

OK, this is clear.

Jan


>
> Massimo
>
> On Sep 11, 2:01 pm, jotbe  wrote:
> > Hi List,
> >
> > I just started my first Web2Py sample project (the Wiki from the book)
> > and got it even managed to integrate the HTML5 editor Aloha:
> http://aloha-editor.org/
> >
> > My pages should use Markmin instead of HTML and therefore I am
> > converting the HTML to Markmin using TAG().flatten() and
> > markmin_serializer. In general it is working and the content is stored
> > as Markmin code, but when using eg. German umlauts like 'öä', TAG()
> > seems to get confused and doesn't handle the encoding properly.
> >
> > On the other hand, when trying to use
> > XML().flatten(render=markmin_serializer) instead of
> > TAG().flatten(render=markmin_serializer), nothing changes at all.
> > XML().flatten(render=markmin_serializer) will return the input HTML
> > string as is, instead of converting it to Markmin.
> >
> > I am trying to solve this issue for two days now and read lots of
> > posts regarding handling of UTF-8 in Python, tried lots of third party
> > modules to workaround this issue, but had no luck so far. I really
> > appreciate your help/tips. :)
> >
> > Various sample code using the Web2Py Shell:
> https://gist.github.com/caec7bd5b41624d50b01
> >
> > Thanks in advance!
>


Re: [web2py] How to flash a message after a callback

2011-09-12 Thread jot.be
Hi,

On Mon, Sep 12, 2011 at 4:57 AM, Noel Villamor  wrote:

> I have a button which does the following callback:
>
> ajax('{{=URL('callback')}}',['btn1'],':eval');"
>
> Then I have the following callback function in my controller:
>
> def callback():
>db(db.tbl.id==100).update(data='sampledata')
>jquery = ???
>return jquery
>
> I can use jquery = "alert('Lame table update message');" but it
> doesn't appear as good as the response.flash message.
>
> 1) How do I emulate response.flash?
>

In a controller:

msg = T('Page updated')
return 'jQuery(".flash").html("' + msg + '")\
   .slideDown().delay(1000).slideUp();'


> 2) How to determine if the db update is successful or not so I can
> flash the appropriate message.
>

I am using a slightly modified version of the function ajax() in
web2py_ajax.js which provides an error handler:

https://gist.github.com/1210855

Maybe you can adapt it to your needs or someone has another tip how to
achieve this with web2py :)

Jan


> Thanks!


[web2py] Re: How to flash a message after a callback

2011-09-12 Thread Noel Villamor

Thanks Jan.

On Sep 12, 8:47 pm, "jot.be"  wrote:
> Hi,
>
>
>
>
>
>
>
>
>
> On Mon, Sep 12, 2011 at 4:57 AM, Noel Villamor  wrote:
> > I have a button which does the following callback:
>
> > ajax('{{=URL('callback')}}',['btn1'],':eval');"
>
> > Then I have the following callback function in my controller:
>
> > def callback():
> >    db(db.tbl.id==100).update(data='sampledata')
> >    jquery = ???
> >    return jquery
>
> > I can use jquery = "alert('Lame table update message');" but it
> > doesn't appear as good as the response.flash message.
>
> > 1) How do I emulate response.flash?
>
> In a controller:
>
> msg = T('Page updated')
> return 'jQuery(".flash").html("' + msg + '")\
>            .slideDown().delay(1000).slideUp();'
>
> > 2) How to determine if the db update is successful or not so I can
> > flash the appropriate message.
>
> I am using a slightly modified version of the function ajax() in
> web2py_ajax.js which provides an error handler:
>
> https://gist.github.com/1210855
>
> Maybe you can adapt it to your needs or someone has another tip how to
> achieve this with web2py :)
>
> Jan
>
>
>
>
>
>
>
> > Thanks!


Re: [web2py] Re: billing app

2011-09-12 Thread Kenneth Lundström

Now you can have a look at it at http://web2py.nudata.fi/em

Login with kenneth and kenneth

This is an application for a very small firm, three part-time 
IT-supporters.


FRONTPAGE:
summary of all kind of data.
a) how many unpaid receipts
b) how much money every person has earned
c) ticket situation
d) log work done

RECEIPT:
this is the place where we declare what we have bought, either by credit 
card or on bill. If a bill then you put due-date and things like that 
too and out accountant receives an mail about it. Here you upload an PDF 
or JPG of the receipt too. Every receipt has to be broken down to which 
customer should be billed for it.


BILLS:
here you create bills that should be sent to customer. A bill is created 
from items from Receipts, Reported work. If you have customer that buys 
something from you and you bill every year you can create Periodical bills.


CUSTOMERS:
customerdatabase

PRODUCTS:
product database

TICKETS:
a very simple ticketing system, work in progress. If you visit 
web2py.nudata.fi/em/ticket without being logged in you´ll get a create 
ticket page ment for customers.
The idea is that when a ticket is ready the work used to solve the 
problem will be billed directly. But I´m working on that part.


All comments are welcomed.


Kenneth



That would be awesome! Looking forward to it.

On Sep 8, 3:05 pm, Kenneth Lundström
wrote:

Hello Nikolai,

I have created a simple billing application that contains customers,
products, hour tracker (simple) and receipt handling.

If interested I could during the weekend put up a english version of it
(Well swedish too it thats better) so you can check it out.

Kenneth








is there any billing component among the web2py appliances that can be
used as a base or a billing appliance?
Just wondering if there's any such code out there before starting from
scratch.
Thanks.




[web2py] Re: instruct web2py only to alter table.

2011-09-12 Thread vortex
I don't understand. I was working with sqlite and it worked OK. Now I
am using mysql and it doesn't alter the columns in the table.


On Sep 9, 2:34 pm, Massimo Di Pierro 
wrote:
> If web2py tries to create it then it does not know it exist. If you do
> know and web2py does not know it means something is wrong with the
> database metadata and needs rebuilding. You can do
>
> db.define_tables(...,migrate=True,fake_migrate=True)
>
> to rebuild metadata. Once done, remove the fake_migrate option.
>
> On Sep 9, 4:19 am,vortex wrote:
>
>
>
>
>
>
>
> > What should be the definition so that web2py only alters the mysql
> > table to correspond to the new definition but if it exists not to
> > create it.
>
> >             db_server.define_table('db_version',
> >                 Field('major', 'integer', default = 0),
> >                 Field('minor', 'integer', default = 0),
> >                migrate= True,
> >             )
>
> > Or at least never to create the table but alter it if needed.


[web2py] Re: instruct web2py only to alter table.

2011-09-12 Thread vortex
Can it be a problem with permissions? Does web2py need to create a
database for migration or something?
Because it can create the table just never alters it.



On Sep 12, 11:12 am, vortex  wrote:
> I don't understand. I was working with sqlite and it worked OK. Now I
> am using mysql and it doesn't alter the columns in the table.
>
> On Sep 9, 2:34 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > If web2py tries to create it then it does not know it exist. If you do
> > know and web2py does not know it means something is wrong with the
> > database metadata and needs rebuilding. You can do
>
> > db.define_tables(...,migrate=True,fake_migrate=True)
>
> > to rebuild metadata. Once done, remove the fake_migrate option.
>
> > On Sep 9, 4:19 am,vortex wrote:
>
> > > What should be the definition so that web2py only alters the mysql
> > > table to correspond to the new definition but if it exists not to
> > > create it.
>
> > >             db_server.define_table('db_version',
> > >                 Field('major', 'integer', default = 0),
> > >                 Field('minor', 'integer', default = 0),
> > >                migrate= True,
> > >             )
>
> > > Or at least never to create the table but alter it if needed.


[web2py] Re: billing app

2011-09-12 Thread Gour-Gadadhara Dasa
On Mon, 12 Sep 2011 13:03:03 +0300
Kenneth Lundström
 wrote:

> Now you can have a look at it at http://web2py.nudata.fi/em


It's very nice, and based on brief overlook, it looks as capable as PHP's
MyClientBase. :-)


Sincerely,
Gour

-- 
“In the material world, conceptions of good and bad are
all mental speculations…” (Sri Caitanya Mahaprabhu)

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810




signature.asc
Description: PGP signature


Re: [web2py] support-ticket plugin

2011-09-12 Thread Martin Weissenboeck
Hi Kenneth,

I have found your webpage (in an other thread): http://web2py.nudata.fi/em
The ticket looks nice - is it possible to get the source?

Martin

2011/9/9 Martin Weissenboeck 

> Hi Kenneth, thank you!
>
>
> 2011/9/9 Kenneth Lundström 
>
>> Hi Martin,
>>
>> in my billing/customer/product application I have a simple ticket system.
>> It would be easy to use only the ticket part if needed. I´m going to put up
>> an english version of the application during the weekend. Then you can look
>> at it.
>>
>>
>> Kenneth
>>
>>
>>  Hi,
>>>
>>> does somebody knows a plugin for a support ticket system?
>>> Desired function: something like
>>> 1.  the user fills a form or sends an email,
>>> 2.  web2py creates and sends a ticket to the admin of the webpage
>>> 3.  the admin answers
>>> 4.  the user can answer again or the ticket will be closed after some
>>> days
>>>
>>> Regards, Martin
>>>
>>
>>
>
>
> --
>


Re: [web2py] support-ticket plugin

2011-09-12 Thread Kenneth Lundström

Sorry, forgot to send an email in this threads.

Do you need source for the ticket part or the whole application? Just so 
I know what to send to you.



Kenneth


Hi Kenneth,

I have found your webpage (in an other thread): http://web2py.nudata.fi/em
The ticket looks nice - is it possible to get the source?

Martin

2011/9/9 Martin Weissenboeck >


Hi Kenneth, thank you!


2011/9/9 Kenneth Lundström mailto:kenneth.t.lundst...@gmail.com>>

Hi Martin,

in my billing/customer/product application I have a simple
ticket system. It would be easy to use only the ticket part if
needed. I´m going to put up an english version of the
application during the weekend. Then you can look at it.


Kenneth


Hi,

does somebody knows a plugin for a support ticket system?
Desired function: something like
1.  the user fills a form or sends an email,
2.  web2py creates and sends a ticket to the admin of the
webpage
3.  the admin answers
4.  the user can answer again or the ticket will be closed
after some days

Regards, Martin





-- 





[web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-12 Thread encompass
Yup... he just might be.  That or he works on the train.  SMARTS!  I
tried programming on my bike, but it's not very functional. :)
Congrats to Massimo, he has made a framework that works like a dream.

On Sep 11, 9:30 am, GoldenTiger  wrote:
> In this community there's a rumor that he is a cyborg.
> Take a look at posts stats:
>
> 17918   mdipierro
>  2324   Massimo Di Pierro
>  2116   Yarko
>  1814   thade...@thadeusb.com
>  1776   Jonathan Lundell
>  1461   DenesL
>  1454   rochacbruno
>  1401   Anthony
>  1311   pbreit
>  1104   nat...@freezable.com
>
> On 10 sep, 22:46, António Ramos  wrote:
>
>
>
>
>
>
>
> >  hey,
> > we are here all fascinated about web2py and i was thinking ,
>
> > who is Massimo as a man in the society, among friends, does he drive a
> > Ferrary or a fiat 500?
>
> > Does he eat meat or is a vegetarian. Is he good at other stuff or was just
> > born to bring us web2py ?
> > What are his projects in the future. How does he sees Web2py in 5 years?
>
> > Let me be curious about a guy that created such a powerfull and funny tool.
>
> > I envy you :)
>
> > Let me suggest to you all
>
> > Stop programming and give Massimo an Applause  for making the clock ticking
>
> > +
>
> > 2011/9/9 mikech > Congratulations!  Hey DePaul you just 
> > got some PR from one of your esteemed
> > > faculty!


[web2py] error in trunk

2011-09-12 Thread Marin Pranjić
Traceback (most recent call last):
  File "web2py.py", line 16, in 
import gluon.widget
  File "/srv/test/web2py/gluon/__init__.py", line 15, in 
from globals import current
ImportError: No module named globals


run with python web2py.py, current trunk


Re: [web2py] error in trunk

2011-09-12 Thread Marin Pranjic
few more errors:
ImportError: cannot import name redirect
ImportError: No module named validators

This is weird. Is it just me?



On Mon, Sep 12, 2011 at 1:15 PM, Marin Pranjić wrote:

> Traceback (most recent call last):
>  File "web2py.py", line 16, in 
>import gluon.widget
>  File "/srv/test/web2py/gluon/__init__.py", line 15, in 
>from globals import current
> ImportError: No module named globals
>
>
> run with python web2py.py, current trunk


Re: [web2py] error in trunk

2011-09-12 Thread Martín Mulone
You are right, current trunk is broken

2011/9/12 Marin Pranjic 

> few more errors:
> ImportError: cannot import name redirect
> ImportError: No module named validators
>
> This is weird. Is it just me?
>
>
>
> On Mon, Sep 12, 2011 at 1:15 PM, Marin Pranjić wrote:
>
>> Traceback (most recent call last):
>>  File "web2py.py", line 16, in 
>>import gluon.widget
>>  File "/srv/test/web2py/gluon/__init__.py", line 15, in 
>>from globals import current
>> ImportError: No module named globals
>>
>>
>> run with python web2py.py, current trunk
>
>
>


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


[web2py] From Drupal to web2py: taxonomy/tagging and comments?

2011-09-12 Thread User
I have some sites that I implemented using Drupal. However as cool as
Drupal is I've never been satisfied with coding in it mostly because
it's in PHP and I've wanted to work with python. I've flirted with
Django but I just recently discovered web2py and it's definitely
caught my eye. Seems like it may be a sweet spot between Drupal and
Django. Although django-cms is also on my radar.

So now I'm wondering how to re-implement my sites with web2py. I've
started going through the web2py book but I'm trying to wrap my head
around some conceptual stuff.

Specifically suppose I have a site about DVD players. So in Drupal I'd
have a CCK (Content Creation Kit) type DVD player, with various
attributes. I guess this would correspond to a web2py model. How would
I implement something like Drupal's taxonomy which is like a tagging
system in web2py? Is there a module/plugin/appliance for that? Or am I
manually creating the model schema to handle tagging?

Secondly, how would you handle something like comments and/or reviews
on posts? Again, is there a pre-built plugin for this or do I have
roll my own?

Finally should I be looking at plugin wiki to handle some of this?


Re: [web2py] Trunk - rev 894137606632 breaks web2py!

2011-09-12 Thread Martín Mulone
Yes I confirm this

*__builtins__**.**__import__ = __builtin__.__import__** ### WHY?*

I think you also think this is gonna break some things :D

2011/9/12 Brian M 

> Massimo,
>
> The change made to gluon/compileapp.py in rev 
> 894137606632appears
>  to breakboth web2py under worth Windows 7 and Ubuntu 11.04.  The failure is 
> such
> that a ticket is immediately created and when you try to view the ticket you
> actually get an error too.  After undoing the change, the ticket can be
> viewed and says:
>
> Traceback (most recent call last):
>   File "C:\Users\Brian\Documents\development\web2py\google hg 
> repo\trunk\gluon\main.py", line 489, in wsgibase
> serve_controller(request, response, session)
>   File "C:\Users\Brian\Documents\development\web2py\google hg 
> repo\trunk\gluon\main.py", line 188, in serve_controller
> environment = build_environment(request, response, session)
>   File "C:\Users\Brian\Documents\development\web2py\google hg 
> repo\trunk\gluon\compileapp.py", line 269, in build_environment
> __builtins__['__import__'] = __builtin__.__import__ ### WHY?
> AttributeError: 'dict' object has no attribute '__import__'
>
>
>
>
> The new scheduler (the latest trunk rev 
> 16e51fec2980).
> The same traceback happens under both Windows 7 and Ubuntu 11.04
>
> C:\Users\Brian\Documents\development\web2py\google hg repo\trunk>python
> web2py.p
> y -K scheduler
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2011
> Version 1.98.2 (2011-09-11 20:21:15)
> Database drivers available: SQLite3, pymysql, MSSQL/DB2, mongoDB
> starting scheduler for "scheduler"...
> Currently running 1 scheduler processes
> Processes started
> Process Process-1:
> Traceback (most recent call last):
>   File "C:\Python26\lib\multiprocessing\process.py", line 232, in
> _bootstrap
> self.run()
>   File "C:\Python26\lib\multiprocessing\process.py", line 88, in run
> self._target(*self._args, **self._kwargs)
>   File "C:\Users\Brian\Documents\development\web2py\google hg
> repo\trunk\gluon\s
> hell.py", line 189, in run
> _env = env(a, c=c, import_models=import_models)
>   File "C:\Users\Brian\Documents\development\web2py\google hg
> repo\trunk\gluon\s
> hell.py", line 127, in env
> environment = build_environment(request, response, session)
>   File "C:\Users\Brian\Documents\development\web2py\google hg
> repo\trunk\gluon\c
> ompileapp.py", line 269, in build_environment
> __builtins__.__import__ = __builtin__.__import__ ### WHY?
> AttributeError: 'dict' object has no attribute '__import__'
>
>
>
> What issue was the change from __builtins__.__import__ to
> __builtins['__import__'] supposed to fix?  I've been using web2py with
> Windows 7 without a problem.
>
> ~Brian
>



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


Re: [web2py] support-ticket plugin

2011-09-12 Thread Martin Weissenboeck
I am very interested in the ticket part.

2011/9/12 Kenneth Lundström 

>  Sorry, forgot to send an email in this threads.
>
> Do you need source for the ticket part or the whole application? Just so I
> know what to send to you.
>
>
> Kenneth
>
>
> Hi Kenneth,
>
> I have found your webpage (in an other thread): http://web2py.nudata.fi/em
> The ticket looks nice - is it possible to get the source?
>
> Martin
>
>  2011/9/9 Martin Weissenboeck 
>
>> Hi Kenneth, thank you!
>>
>>
>> 2011/9/9 Kenneth Lundström 
>>
>>> Hi Martin,
>>>
>>> in my billing/customer/product application I have a simple ticket system.
>>> It would be easy to use only the ticket part if needed. I´m going to put up
>>> an english version of the application during the weekend. Then you can look
>>> at it.
>>>
>>>
>>> Kenneth
>>>
>>>
>>>  Hi,

 does somebody knows a plugin for a support ticket system?
 Desired function: something like
 1.  the user fills a form or sends an email,
 2.  web2py creates and sends a ticket to the admin of the webpage
 3.  the admin answers
 4.  the user can answer again or the ticket will be closed after some
 days

 Regards, Martin

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


[web2py] Re: error in trunk

2011-09-12 Thread Massimo Di Pierro
can you try again please? What os?

On Sep 12, 6:15 am, Marin Pranjić  wrote:
> Traceback (most recent call last):
>   File "web2py.py", line 16, in 
>     import gluon.widget
>   File "/srv/test/web2py/gluon/__init__.py", line 15, in 
>     from globals import current
> ImportError: No module named globals
>
> run with python web2py.py, current trunk


[web2py] Re: Trunk - rev 894137606632 breaks web2py!

2011-09-12 Thread Massimo Di Pierro
That was an experiment. I reverted it. Thanks for checking.

On Sep 12, 6:43 am, Martín Mulone  wrote:
> Yes I confirm this
>
> *__builtins__**.**__import__ = __builtin__.__import__** ### WHY?*
>
> I think you also think this is gonna break some things :D
>
> 2011/9/12 Brian M 
>
>
>
>
>
>
>
>
>
> > Massimo,
>
> > The change made to gluon/compileapp.py in rev 
> > 894137606632appears
> >  to breakboth web2py under worth Windows 7 and Ubuntu 11.04.  The failure 
> > is such
> > that a ticket is immediately created and when you try to view the ticket you
> > actually get an error too.  After undoing the change, the ticket can be
> > viewed and says:
>
> > Traceback (most recent call last):
> >   File "C:\Users\Brian\Documents\development\web2py\google hg 
> > repo\trunk\gluon\main.py", line 489, in wsgibase
> >     serve_controller(request, response, session)
> >   File "C:\Users\Brian\Documents\development\web2py\google hg 
> > repo\trunk\gluon\main.py", line 188, in serve_controller
> >     environment = build_environment(request, response, session)
> >   File "C:\Users\Brian\Documents\development\web2py\google hg 
> > repo\trunk\gluon\compileapp.py", line 269, in build_environment
> >     __builtins__['__import__'] = __builtin__.__import__ ### WHY?
> > AttributeError: 'dict' object has no attribute '__import__'
>
> > The new scheduler (the latest trunk rev 
> > 16e51fec2980).
> > The same traceback happens under both Windows 7 and Ubuntu 11.04
>
> > C:\Users\Brian\Documents\development\web2py\google hg repo\trunk>python
> > web2py.p
> > y -K scheduler
> > web2py Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2011
> > Version 1.98.2 (2011-09-11 20:21:15)
> > Database drivers available: SQLite3, pymysql, MSSQL/DB2, mongoDB
> > starting scheduler for "scheduler"...
> > Currently running 1 scheduler processes
> > Processes started
> > Process Process-1:
> > Traceback (most recent call last):
> >   File "C:\Python26\lib\multiprocessing\process.py", line 232, in
> > _bootstrap
> >     self.run()
> >   File "C:\Python26\lib\multiprocessing\process.py", line 88, in run
> >     self._target(*self._args, **self._kwargs)
> >   File "C:\Users\Brian\Documents\development\web2py\google hg
> > repo\trunk\gluon\s
> > hell.py", line 189, in run
> >     _env = env(a, c=c, import_models=import_models)
> >   File "C:\Users\Brian\Documents\development\web2py\google hg
> > repo\trunk\gluon\s
> > hell.py", line 127, in env
> >     environment = build_environment(request, response, session)
> >   File "C:\Users\Brian\Documents\development\web2py\google hg
> > repo\trunk\gluon\c
> > ompileapp.py", line 269, in build_environment
> >     __builtins__.__import__ = __builtin__.__import__ ### WHY?
> > AttributeError: 'dict' object has no attribute '__import__'
>
> > What issue was the change from __builtins__.__import__ to
> > __builtins['__import__'] supposed to fix?  I've been using web2py with
> > Windows 7 without a problem.
>
> > ~Brian
>
> --
>  http://martin.tecnodoc.com.ar


Re: [web2py] Re: error in trunk

2011-09-12 Thread Marin Pranjic
Hi Massimo,
you can ignore this. I unintentionally ran python3 instead python2.
My mistake, sorry about that.


Marin

On Mon, Sep 12, 2011 at 2:28 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> can you try again please? What os?
>
> On Sep 12, 6:15 am, Marin Pranjić  wrote:
> > Traceback (most recent call last):
> >   File "web2py.py", line 16, in 
> > import gluon.widget
> >   File "/srv/test/web2py/gluon/__init__.py", line 15, in 
> > from globals import current
> > ImportError: No module named globals
> >
> > run with python web2py.py, current trunk
>


[web2py] simjsonrpc Client and Keyword Arguments

2011-09-12 Thread Ross Peoples
I know that the XMLRPC spec doesn't support keyword arguments, but JSONRPC 
does. I have been playing with the new simplejsonrpc client and it doesn't 
seem to support keyword arguments.

Here is an example controller:

@service.jsonrpc
def concat(str1, str2, str3=''):
"""
Concatenates two strings. Supply a third string if needed.
"""
return str1 + str2 + str3


And for the client code (from console):

from gluon.contrib.simplejsonrpc import JSONRPCClient
c = JSONRPCClient('http://127.0.0.1:8000/rpc_test/default/call/jsonrpc')
c.concat('hello ', 'world', str3='!!!')

Traceback (most recent call last):
  File "", line 1, in 
TypeError: () got an unexpected keyword argument 'str3'

Is it possible that the new simplejsonrpc client could support this?

Thanks


Re: [web2py]Web2py MVC and Qooxdoo

2011-09-12 Thread Alexei Vinidiktov
I'm afraid it really does have a minimum of 600 KB.

It's compiled with build.

Too bad the server the app is hosted on is so unreliable.

On Sun, Sep 11, 2011 at 11:16 PM, Phyo Arkar wrote:

> that never runs , giving me error in json response , too bad.
>
> And the javascript alone really have 600KB ? is that compiled with
> source-all ?
>
> On 9/11/11, Alexei Vinidiktov  wrote:
> > You are right about the CAPTCHA. The reason I'm not using it is that at
> the
> > moment the site is only a playground where I'm getting familiar with
> web2py
> > and qooxdoo and testing things out.
> >
> > Please try again. Registration should work this time.
> >
> > On Sun, Sep 11, 2011 at 7:20 PM, Phyo Arkar  >wrote:
> >
> >> That page should have a CAPCHA .  spambots will like to spam
> >> registration it till your mailserver down with registrations.
> >>
> >> One thing i am liking about qooxdoo is that really eliminate HTML CSS
> >> and Graphics skills
> >> needed to develop a desktop like web-app easily. Normally desiging
> >> web2py app needs all those skills.
> >>
> >> I am good at linux , system engineering and python + js not at those
> >> art skills so i believes good intergration of qooxdoo with web2py will
> >> be perfect.
> >>
> >> On 9/11/11, Alexei Vinidiktov  wrote:
> >> > Oops, sorry. I'll see if I can fix it. It's been a long time since I
> >> touched
> >> > the app last.
> >> >
> >> > On Sun, Sep 11, 2011 at 7:05 PM, Phyo Arkar  >> >wrote:
> >> >
> >> >> AH sorry i write this post before read the previous post.
> >> >>
> >> >> Yeah as it seems all view code needs to go into Qooxdoo , and web2py
> >> >> as Json RPC only. hmm.. so half of web2py potential will only be
> used,
> >> >>
> >> >>
> >> >> pyjamas todo tutorial i cannot register at all , ur mail sender seems
> >> >> to be down. it saids unable to send email.
> >> >>
> >> >>
> >> >>
> >> >> On 9/11/11, Phyo Arkar  wrote:
> >> >> > Anyone have experience with qooxdoo?
> >> >> >
> >> >> > It seems that only way web2py applicable with QooXDoo is as a
> >> >> > JSON-RPC
> >> >> > Server. Whole view logic will be  only in Qooxdoo , cannot use any
> >> >> > Template langauge of web2py i guess.
> >> >> >
> >> >> > If anyone have any expeirence , enlighten me.
> >> >> >
> >> >> > On 9/11/11, Phyo Arkar  wrote:
> >> >> >> Anyone have a working tutorial for web2py MVC and Qooxdoo ?
> >> >> >>
> >> >> >> I am wondering how to use Web2py's response.view template code
> >> >> >> inside
> >> >> >> JS files coz Qooxdoo's class definations are in JS file . Somthing
> i
> >> >> >> haven't tried.
> >> >> >>
> >> >> >
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Alexei Vinidiktov
> >> >
> >>
> >
> >
> >
> > --
> > Alexei Vinidiktov
> >
>



-- 
Alexei Vinidiktov


[web2py] Re: How to disable account creation?

2011-09-12 Thread Massimo Di Pierro
auth.settings.actions_disabled.append('register')

On Sep 12, 2011, at 6:29 AM, Henri Heinonen wrote:

> Hi!
> 
> How to disable account creation? 
> https://fsi.it.jyu.fi/aarrearkku/default/user/register
> 
> Thanks!
> 
> Henri.



Re: [web2py] From Drupal to web2py: taxonomy/tagging and comments?

2011-09-12 Thread Jim Steil

Yes, I would be looking at plugin-wiki for this.

-Jim

On 9/11/2011 11:07 PM, User wrote:

I have some sites that I implemented using Drupal. However as cool as
Drupal is I've never been satisfied with coding in it mostly because
it's in PHP and I've wanted to work with python. I've flirted with
Django but I just recently discovered web2py and it's definitely
caught my eye. Seems like it may be a sweet spot between Drupal and
Django. Although django-cms is also on my radar.

So now I'm wondering how to re-implement my sites with web2py. I've
started going through the web2py book but I'm trying to wrap my head
around some conceptual stuff.

Specifically suppose I have a site about DVD players. So in Drupal I'd
have a CCK (Content Creation Kit) type DVD player, with various
attributes. I guess this would correspond to a web2py model. How would
I implement something like Drupal's taxonomy which is like a tagging
system in web2py? Is there a module/plugin/appliance for that? Or am I
manually creating the model schema to handle tagging?

Secondly, how would you handle something like comments and/or reviews
on posts? Again, is there a pre-built plugin for this or do I have
roll my own?

Finally should I be looking at plugin wiki to handle some of this?


[web2py] Re: billing app

2011-09-12 Thread niknok
Thanks for sharing Kenneth. This looks good. Are you going to open
source it?

Would like to learn from the code, especially the invoicing part.

On Sep 12, 6:03 pm, Kenneth Lundström 
wrote:
> Now you can have a look at it athttp://web2py.nudata.fi/em
>
> Login with kenneth and kenneth
>
> This is an application for a very small firm, three part-time
> IT-supporters.
>
> FRONTPAGE:
> summary of all kind of data.
>          a) how many unpaid receipts
>          b) how much money every person has earned
>          c) ticket situation
>          d) log work done
>
> RECEIPT:
> this is the place where we declare what we have bought, either by credit
> card or on bill. If a bill then you put due-date and things like that
> too and out accountant receives an mail about it. Here you upload an PDF
> or JPG of the receipt too. Every receipt has to be broken down to which
> customer should be billed for it.
>
> BILLS:
> here you create bills that should be sent to customer. A bill is created
> from items from Receipts, Reported work. If you have customer that buys
> something from you and you bill every year you can create Periodical bills.
>
> CUSTOMERS:
> customerdatabase
>
> PRODUCTS:
> product database
>
> TICKETS:
> a very simple ticketing system, work in progress. If you visit
> web2py.nudata.fi/em/ticket without being logged in you ll get a create
> ticket page ment for customers.
> The idea is that when a ticket is ready the work used to solve the
> problem will be billed directly. But I m working on that part.
>
> All comments are welcomed.
>
> Kenneth
>
>
>
>
>
>
>
> > That would be awesome! Looking forward to it.
>
> > On Sep 8, 3:05 pm, Kenneth Lundstr m
> > wrote:
> >> Hello Nikolai,
>
> >> I have created a simple billing application that contains customers,
> >> products, hour tracker (simple) and receipt handling.
>
> >> If interested I could during the weekend put up a english version of it
> >> (Well swedish too it thats better) so you can check it out.
>
> >> Kenneth
>
> >>> is there any billing component among the web2py appliances that can be
> >>> used as a base or a billing appliance?
> >>> Just wondering if there's any such code out there before starting from
> >>> scratch.
> >>> Thanks.


[web2py] Custom auth_user with different fileds name

2011-09-12 Thread white fox
hi, I have a website which is written by PHP, so i decided to move to
python and use web2py for new version of my site.
anyway, in my Mysql Database i have lots of tables, one of them is
"Users" table. the table is like this


db.define_table ("qbp_user",
 Field ("userid", "integer"),
 Field ("email_address", "string", length = 50, required=True),
 Field ("username", "string", length = 25, required=True),
 Field ("PASSWORD", type='password', readable=False, length = 255,
required=True),
 Field ("user_level", "string", length = 11, default=2),
 Field ("signup_date", "datetime", default=now),
 Field ("last_login", "datetime"),
 Field ("country", "string", length = 50),
 Field ("ip", "string", length = 50),
 Field ("homepage", "string", length = 50),
 Field ("activated", "integer", default=0),
 Field ("session", "string", length = 255),
 Field ("avatar", "string", length = 100),
 Field ("signature", "text"),
 Field ("messenger2", "string", length = 55),
 Field ("title", "string", length = 20, default='Registered'),
 Field ("Tell", "string", length = 20),
 Field ("Address", "string", length = 500),
 Field ("score", "integer"),
 Field ("FullName", "string", length = 70),
 Field ("ZipCode", "string", length = 50),
 Field ("mode_state", "integer"),
 Field ("status", "integer"),
 Field ("active_mail", "string", length = 50, default=-1),
 Field ("tanksto", "integer"),
 Field ("tanksfrom", "integer"),
 Field ("type", "integer"),
 Field ("blog_url", "string", length = 100),
 Field ("settings", "integer", default=1),
 Field ('registration_key', length=512, writable=False,
readable=False, default=''),
 Field ('reset_password_key', length=512, writable=False,
readable=False, default=''),
 migrate = False)


As you can see i have `userid` instead of `id` and have `FullName`
instead of `fist_name` and `last_name`,  and at last i have
`email_address` as `email`,
this is  a very big website and have different parts, so i can't
change fields name, because i'm sure my code broken in other parts.

i know i can change the auth_user table name(i read about this in
http://web2py.com/book/default/chapter/08#Customizing-Auth), but is it
possible to change auth_users'fields names too? is it possible that i
migrate web2py authentication with my database? or i should my own
athentication?


p.s: sorry for my bad english :)


[web2py] Re: Crud.update Multiple

2011-09-12 Thread Serbitar
Works like a charm.

On 12 Sep., 04:51, Massimo Di Pierro 
wrote:
> rows = db(yourquery).select(mytable.id, mytable.myfield)
> form = SQLFORM.factory(*[Field('name_%s'%r.id, default=r.myfield) for
> r in rows])
> if form.process().accepted:
>     for key,value in form.vars.items():
>         db(mytable.id==key[5:]).update(myfield = value)
>
> form.process().accepted is the same as form.accepted(request,session)
> but shorter.
>
> On Sep 10, 2:55 pm, Serbitar  wrote:
>
>
>
> > is there any way to update multiple records with crud.update, or even
> > records with a given query?- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -


[web2py] Re: How to flash a message after a callback

2011-09-12 Thread Anthony
On Monday, September 12, 2011 1:00:41 AM UTC-4, Noel Villamor wrote:
>
> If the db update failed in the regular controller I would assume that 
> a ticket page would appear. But what if the db update is in a callback 
> function?
>

In that case, an error ticket will still be logged, and web2py will return 
the usual 500 error with the link to the ticket. However, nothing will 
happen on the client side unless you include some JS to handle such errors. 
For example, you might register a jQuery .ajaxError handler 
(http://api.jquery.com/ajaxError/). You should be careful about the message 
you flash, though -- it's possible that the record could update but another 
error occurs -- in that case, you don't want to flash a message saying the 
record did not update.  

>
> @Anthony, it seems that a db update failure would cause the rest of 
> the callback code to be not executed and so the flash='failure' 
> message won't appear at all.
>

Yes, it depends on the reason for the failure. If, for example, you try to 
update with a record id that doesn't exist, you won't get an error -- it 
will just return 0 as the number of rows updated. If you want to catch 
particular database errors on the server side, I suppose you could do 
something like this:

try:
db(db.tbl.id==100).update(data='sampledata')
flash='success'
except IntegrityError, OperationalError:
flash='failure'
# possibly log this somehow
# All other exceptions result in 500 error to be handled client side.

Anthony


[web2py] Re: web2ruby possible?

2011-09-12 Thread dspiteself
I would enjoy some web2go as well. 

[web2py] Re: deploying web2py on IIS

2011-09-12 Thread sherdim
Onmi, it is not clear - whether you have separate domain for the site under 
IIS. if no - then you can use default pathes.

To be honest, I cannot really understand routes even I read the book. 
>
routes.py is not related to deployment on IIS. You can skip routes 
configuration upto you need/want it.

for beginners I would suppose such if your app called "ochibaapp", not 
"welcome":

routers = dict( 
  BASE  = dict(default_application='ochibaapp',
domains={ 'ochiba.com' : 'ochibaapp'},
root_static = ['favicon.ico', 'robots.txt', 'sitemap.xml'],
  ), 
)
==

Here's my directories: 
> --- 
> web2py: 
> C:\Python25\web2py 
>
I am not sure - will python include gluon from this dir automatically?
More advantageous place - \Python25\Lib\site-packages\gluon

So my proposal - copy gluon dir to C:\Python25\Lib\site-packages\
 

> web2py appllications: 
> C:\Python25\web2py\applications 
>
so C:\w2p\ in the slice become C:\Python25\web2py in your current placement 
 

> Created by 2.3. Configure WSGI handler: 
> C:\w2p\applications (Empty) 
> is link to... 
> C:\Python25\Lib\site-packages\applications (Empty) 
>
> reverse order!!! link (junction) the second one to 
C:\Python25\web2py\applications 
 

> I start web2py like this: 
> c:\Python25\web2py>python web2py.py 
>
this can be used for development and debugging 
 

> Virtual Directory on IIS 
> "ochibaapp" (renamed from "appname") under "Default Web Site" 
>
this app must point to C:\Python25\Lib\site-packages\_ochibaapp.dll
or whatever name you used  (through wildcard mapping in the app config)
(According to name agreement - DLL must be named _filename.dll for 
filename.py ) 
So in the file C:\Python25\Lib\site-packages\ochibaapp.py  you can call 
gluon.main.wsgibase

Goodluck!


Re: [web2py] Re: web2ruby possible?

2011-09-12 Thread Vasile Ermicioi
skulpt with node.js makes it possible a web2py nodejs


[web2py] MySQL lost connection to server

2011-09-12 Thread G
Hi,
After leaving my app running for a while, when I come back to access
it, I get an error in Framework that is from pymysql reporting that
the connection to the server has been lost (because it timed out from
inactivity presumably). If I refresh the page a couple of times, the
error goes away. I assume this is because DAL opens a new connection
after finding that all the available connections have closed. This
provides a poor impression for users.
I have encountered this in non-web based code and so I wrap all of my
database accesses with a function that first trys to ping the
connection by doing a db.commit, and if it fails, reconnects to the
server. Can something like this be added to dal.py? Is there a better
way to handle this?

The exact source of the error is here

File "/home/dl/trunkw2p/web2py/gluon/main.py", line 506, in wsgibase
BaseAdapter.close_all_instances('commit')

and sometimes here:

File "/home/dl/trunkw2p/web2py/gluon/main.py", line 570, in wsgibase
BaseAdapter.close_all_instances('rollback')


Thanks,
G


[web2py] XML-RPC Service Introspection / Discovery

2011-09-12 Thread Ross Peoples
One of the nice things about SOAP is the WDSL that gives you information 
about the methods the service supports. I recently discovered that you can 
do the same thing with XML-RPC. The trick is to document your methods 
properly, like you should be doing anyways. Lets say I have the following 
controller:

@service.xmlrpc
@service.jsonrpc
def add(num1, num2):
"""
Adds two numbers together.

add(num1, num2) -> number

Arguments:
num1First number
num2Second number

Returns:
The sum of the two numbers.

Examples:
add(2, 2) -> 4
add(2.5, 2.5) -> 5.0
"""
return num1 + num2

@service.xmlrpc
@service.jsonrpc
def concat(str1, str2, str3=''):
"""
Concatenates two or three strings.

concat(str1, str2, str3='') -> string

Arguments:
str1First string
str2Second string
str3(Optional) Third string

Returns:
The concatenated string.

Examples:
concat('hello', ' world') -> 'hello world'
concat('hello', ' world', ' !!!') -> 'hello world !!!
"""
return str1 + str2 + str3

@service.xmlrpc
@service.jsonrpc
def date():
"""
Returns the server's current date and time.
"""
return datetime.datetime.now()


Now let's connect using xmlrpclib:

>>> import xmlrpclib
>>> x = 
xmlrpclib.ServerProxy('http://127.0.0.1:8000/rpc_test/default/call/xmlrpc')


Now, we could start calling the methods as usual, or we could do a little 
introspection to see what methods are available, and even get the docstrings 
of those methods:

>>> print x.system.listMethods()
['add', 'concat', 'date', 'system.listMethods', 'system.methodHelp', 
'system.methodSignature']

>>> print x.system.methodHelp('concat')
Concatenates two or three strings.

concat(str1, str2, str3='') -> string

Arguments:
str1First string
str2Second string
str3(Optional) Third string

Returns:
The concatenated string.

Examples:
concat('hello', ' world') -> 'hello world'
concat('hello', ' world', ' !!!') -> 'hello world !!!'


>>> x.concat('hello', 'web2py')
'helloweb2py'


Very cool! However, you will notice that there is another method in there: 
system.methodSignature(). This would show the signature of the method (i.e. 
concat(str1, str2, str3=''), however, it seems that web2py's XMLRPC server 
implementation (or SimpleXMLRPCServer.py) doesn't support this, as it 
returns 'signatures not supported' whenever you try to call this method.

I hope that someone finds this useful!


[web2py] Re: How to flash a message after a callback

2011-09-12 Thread Cliff
>> If the db update failed in the regular controller I would assume that
>> a ticket page would appear. But what if the db update is in a callback
>> function?


>In that case, an error ticket will still be logged, and web2py will return
>the usual 500 error with the link to the ticket.

Anthony, I don't think that always happens.

Some failures in an ajax callback will log a ticket but not flash 500
error with the link to the ticket.

When I'm playing with ajax I always keep the error page open on
another tab, sometimes even in a different browser window if I'm
feeling paranoid about browser conflicts.  If I'm getting unexpected
results I refresh the error page and often find hidden tickets there.

Cliff Kachinske

On Sep 12, 10:20 am, Anthony  wrote:
> On Monday, September 12, 2011 1:00:41 AM UTC-4, Noel Villamor wrote:
>
> > If the db update failed in the regular controller I would assume that
> > a ticket page would appear. But what if the db update is in a callback
> > function?
>
> In that case, an error ticket will still be logged, and web2py will return
> the usual 500 error with the link to the ticket. However, nothing will
> happen on the client side unless you include some JS to handle such errors.
> For example, you might register a jQuery .ajaxError handler
> (http://api.jquery.com/ajaxError/). You should be careful about the message
> you flash, though -- it's possible that the record could update but another
> error occurs -- in that case, you don't want to flash a message saying the
> record did not update.  
>
>
>
> > @Anthony, it seems that a db update failure would cause the rest of
> > the callback code to be not executed and so the flash='failure'
> > message won't appear at all.
>
> Yes, it depends on the reason for the failure. If, for example, you try to
> update with a record id that doesn't exist, you won't get an error -- it
> will just return 0 as the number of rows updated. If you want to catch
> particular database errors on the server side, I suppose you could do
> something like this:
>
> try:
>     db(db.tbl.id==100).update(data='sampledata')
>     flash='success'
> except IntegrityError, OperationalError:
>     flash='failure'
>     # possibly log this somehow
> # All other exceptions result in 500 error to be handled client side.
>
> Anthony


Re: [web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-12 Thread Bruno de Oliva Bemfica
Bravíssimo, Massimo! Congratulazioni per te e per tutti i programmatori che
hanno colaborato con il web2py.

2011/9/12 encompass 

> Yup... he just might be.  That or he works on the train.  SMARTS!  I
> tried programming on my bike, but it's not very functional. :)
> Congrats to Massimo, he has made a framework that works like a dream.
>
> On Sep 11, 9:30 am, GoldenTiger  wrote:
> > In this community there's a rumor that he is a cyborg.
> > Take a look at posts stats:
> >
> > 17918   mdipierro
> >  2324   Massimo Di Pierro
> >  2116   Yarko
> >  1814   thade...@thadeusb.com
> >  1776   Jonathan Lundell
> >  1461   DenesL
> >  1454   rochacbruno
> >  1401   Anthony
> >  1311   pbreit
> >  1104   nat...@freezable.com
> >
> > On 10 sep, 22:46, António Ramos  wrote:
> >
> >
> >
> >
> >
> >
> >
> > >  hey,
> > > we are here all fascinated about web2py and i was thinking ,
> >
> > > who is Massimo as a man in the society, among friends, does he drive a
> > > Ferrary or a fiat 500?
> >
> > > Does he eat meat or is a vegetarian. Is he good at other stuff or was
> just
> > > born to bring us web2py ?
> > > What are his projects in the future. How does he sees Web2py in 5
> years?
> >
> > > Let me be curious about a guy that created such a powerfull and funny
> tool.
> >
> > > I envy you :)
> >
> > > Let me suggest to you all
> >
> > > Stop programming and give Massimo an Applause  for making the clock
> ticking
> >
> > > +
> >
> > > 2011/9/9 mikech > Congratulations!  Hey DePaul you
> just got some PR from one of your esteemed
> > > > faculty!
>



-- 
Bruno de Oliva Bemfica
*Engenheiro de Software*
MSN: brunocode...@live.com 
Mobile: +55 11 8457-0978
http://www.devfranca.com.br
http://www.brunobemfica.net
http://www.codigofree.net


[web2py] Re: How to flash a message after a callback

2011-09-12 Thread Anthony
On Monday, September 12, 2011 1:23:47 PM UTC-4, Cliff wrote:
>
> >> If the db update failed in the regular controller I would assume that 
> >> a ticket page would appear. But what if the db update is in a callback 
> >> function? 
>
>
> >In that case, an error ticket will still be logged, and web2py will return 
>
> >the usual 500 error with the link to the ticket. 
>
> Anthony, I don't think that always happens. 
>
> Some failures in an ajax callback will log a ticket but not flash 500 
> error with the link to the ticket.
>

Sorry if I wasn't clear. I wasn't saying that the browser will display the 
500 error with link to the ticket, just that web2py will send the 500 
response back to the browser -- if it was an Ajax request, the browser might 
simply ignore the response, unless there is some JS to handle it. If it's a 
web2py Ajax component, then the error will be displayed in the component 
div, but if it's some other Ajax call, the browser may not display anything. 
I don't think web2py will generate an error ticket without sending out a 500 
response, though.

Anthony


[web2py] Re: Custom auth_user with different fileds name

2011-09-12 Thread pbreit
Customizing auth might work:
http://web2py.com/book/default/chapter/08#Customizing-Auth

I'm not sure exactly what the implications might be of changing the field 
names. My experience is that the core code is genericised pretty well to 
handle name changes. The one issue I see, though, is that web2py does seem 
to expect table primary keys to be "id". I'm not sure what to suggest there.


[web2py] New UI package

2011-09-12 Thread mikech
Telerik - a Windows UI vendor has made a move into the Javascript/web market 
with it's Kendo UI http://www.kendoui.com/.   The package works with jQuery. 
 
Maybe we'll see other vendors embracing this strategy.


[web2py] Re: Custom auth_user with different fileds name

2011-09-12 Thread Anthony
On Monday, September 12, 2011 2:10:02 PM UTC-4, pbreit wrote:
>
> The one issue I see, though, is that web2py does seem to expect table 
> primary keys to be "id". I'm not sure what to suggest there.
>

It is possible to name your id field something other than 'id' (recommended 
only for accessing legacy DBs): 
http://web2py.com/book/default/chapter/06?search=named+id+field. Just do:

db.define_table('qbp_user',
Field('userid','id'),...)

Specifying the field type as 'id' tells web2py to treat the 'userid' field 
as the record id, so it won't create its own 'id' field.

Anthony
 


[web2py] Re: New UI package

2011-09-12 Thread Ross Peoples
This looks like a good alternative to jQuery UI

Re: [web2py] Re: How to disable account creation?

2011-09-12 Thread Ovidio Marinho
this is important, but I was commenting on the command line



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



2011/9/12 Massimo Di Pierro 

> auth.settings.actions_disabled.append('register')
>
> On Sep 12, 2011, at 6:29 AM, Henri Heinonen wrote:
>
> Hi!
>
> How to disable account creation?
> https://fsi.it.jyu.fi/aarrearkku/default/user/register
>
> Thanks!
>
> Henri.
>
>
>


Re: [web2py] encoding

2011-09-12 Thread Richard Vézina
Are you talking about the URL?

If yes read this :
http://groups.google.com/group/fameisfame/browse_thread/thread/081461db3d72c14b

Richard

On Sat, Sep 10, 2011 at 2:14 PM, Emy  wrote:
> hey all
> my website is dealing with arabic characters and I have a problem with
> encoding I can read from DB wothout problem when I try to insert any
> data using ajax function  I got the string written like that in
> python :
> "%D8%A8%D8%A8%D9%8A%D9%8A%D9%8A%D8%B3%D8%B3%'"
>
> when I try to write :
> txt=unicode(txt)
> I get the same result
>
> can anyone help me


[web2py] Selecting a linked field

2011-09-12 Thread Chris Rowson
I have two tables:
-
db.define_table('providers',
   Field('name'),
   Field('email'),
   Field('tel')

db.define_table('data',
   Field('dataowner', db.auth_user, default=auth.user_id,
writable=False, readable=False), #this points at the auth user
   Field('provider', db.providers),
   Field('speed', 'integer')

db.data.provider.requires=IS_IN_DB(db, 'providers.id','providers.name')
-

My controller has this code

def map():
response.view="map.html"
# selects the data postcode fields from the database
# returns an interable object
rows=db().select(db.data.lon, db.data.lat, db.data.provider)
return dict(rows=rows)

---

And my view this code

 {{for i,row in enumerate(rows):}}{{if not i==0:}},{{pass}}
  { lat: {{=row.lat}}, lng: {{=row.lon}}, name: "{{=row.provider.name}}" }
  {{pass}}


As you can see, the provider field in the data table stores the provider id.

I'm confused!

Although this does work I don't know why!, is it the correct way to
reference the name field from the providers table?

Thanks!

Chris


Re: [web2py] Selecting a linked field

2011-09-12 Thread Richard Vézina
It seems to me correct except for the view, if you want a table not use :

Controller :
table = crud.select(db.data)
return dict(table=table)



View :
{{=table}}


You can also make your select constraint in the controller :

query = (db.data.FIELD == SOMETHING)

table = crud.select(db.data, query=query)


http://www.web2py.com/book/default/chapter/07?search=crud.select#CRUD

Richard

On Mon, Sep 12, 2011 at 4:27 PM, Chris Rowson
 wrote:
> I have two tables:
> -
> db.define_table('providers',
>               Field('name'),
>               Field('email'),
>               Field('tel')
>
> db.define_table('data',
>               Field('dataowner', db.auth_user, default=auth.user_id,
> writable=False, readable=False), #this points at the auth user
>               Field('provider', db.providers),
>               Field('speed', 'integer')
>
> db.data.provider.requires=IS_IN_DB(db, 'providers.id','providers.name')
> -
>
> My controller has this code
>
> def map():
>    response.view="map.html"
>    # selects the data postcode fields from the database
>    # returns an interable object
>    rows=db().select(db.data.lon, db.data.lat, db.data.provider)
>    return dict(rows=rows)
>
> ---
>
> And my view this code
>
>  {{for i,row in enumerate(rows):}}{{if not i==0:}},{{pass}}
>      { lat: {{=row.lat}}, lng: {{=row.lon}}, name: "{{=row.provider.name}}" }
>      {{pass}}
>
> 
> As you can see, the provider field in the data table stores the provider id.
>
> I'm confused!
>
> Although this does work I don't know why!, is it the correct way to
> reference the name field from the providers table?
>
> Thanks!
>
> Chris
>


Re: [web2py] Selecting a linked field

2011-09-12 Thread Richard Vézina
Mistake in my first paragraph

table why not use

On Mon, Sep 12, 2011 at 4:35 PM, Richard Vézina
 wrote:
> It seems to me correct except for the view, if you want a table not use :
>
> Controller :
> table = crud.select(db.data)
> return dict(table=table)
>
>
>
> View :
> {{=table}}
>
>
> You can also make your select constraint in the controller :
>
> query = (db.data.FIELD == SOMETHING)
>
> table = crud.select(db.data, query=query)
>
>
> http://www.web2py.com/book/default/chapter/07?search=crud.select#CRUD
>
> Richard
>
> On Mon, Sep 12, 2011 at 4:27 PM, Chris Rowson
>  wrote:
>> I have two tables:
>> -
>> db.define_table('providers',
>>               Field('name'),
>>               Field('email'),
>>               Field('tel')
>>
>> db.define_table('data',
>>               Field('dataowner', db.auth_user, default=auth.user_id,
>> writable=False, readable=False), #this points at the auth user
>>               Field('provider', db.providers),
>>               Field('speed', 'integer')
>>
>> db.data.provider.requires=IS_IN_DB(db, 'providers.id','providers.name')
>> -
>>
>> My controller has this code
>>
>> def map():
>>    response.view="map.html"
>>    # selects the data postcode fields from the database
>>    # returns an interable object
>>    rows=db().select(db.data.lon, db.data.lat, db.data.provider)
>>    return dict(rows=rows)
>>
>> ---
>>
>> And my view this code
>>
>>  {{for i,row in enumerate(rows):}}{{if not i==0:}},{{pass}}
>>      { lat: {{=row.lat}}, lng: {{=row.lon}}, name: "{{=row.provider.name}}" }
>>      {{pass}}
>>
>> 
>> As you can see, the provider field in the data table stores the provider id.
>>
>> I'm confused!
>>
>> Although this does work I don't know why!, is it the correct way to
>> reference the name field from the providers table?
>>
>> Thanks!
>>
>> Chris
>>
>


[web2py] Re: Selecting a linked field

2011-09-12 Thread Anthony
On Monday, September 12, 2011 4:27:08 PM UTC-4, leftcase wrote:
>
>  {{for i,row in enumerate(rows):}}{{if not i==0:}},{{pass}}
>   { lat: {{=row.lat}}, lng: {{=row.lon}}, name: "{{=row.provider.name}}" 
> }
>   {{pass}}
>
> 
> As you can see, the provider field in the data table stores the provider 
> id.
>
> I'm confused!
>
> Although this does work I don't know why!, is it the correct way to
> reference the name field from the providers table?
>
Yes, that's a recursive 
select: http://web2py.com/book/default/chapter/06#Recursive-selects. Note, 
though, that it will do a new select for every row, so it is not efficient 
when processing many records. Instead, you should do a 
join: http://web2py.com/book/default/chapter/06#Inner-Joins.

Anthony
 


[web2py] Re: Selecting a linked field

2011-09-12 Thread Anthony
Also, if you need JSON, check 
out http://web2py.com/book/default/chapter/09#Rendering-Rows.

Anthony


Re: [web2py] Re: Selecting a linked field

2011-09-12 Thread Chris Rowson
Thank you both. I shall revisit, replace with a join and put the logic
into the controller rather than the view :-)

Chris


Re: [web2py] Re: billing app

2011-09-12 Thread Kenneth Lundström

Hi Nikolai,

if you want a copy of the code I can send it, or if somebody else wants 
a copy let me know. The code is a mess in places and for the moment I 
don't have time to clean it up. I could opensource it when it's cleaned. 
There no point in waiting for it to be ready, it's a work in progress. :=)



Kenneth


Thanks for sharing Kenneth. This looks good. Are you going to open
source it?

Would like to learn from the code, especially the invoicing part.

On Sep 12, 6:03 pm, Kenneth Lundström
wrote:

Now you can have a look at it athttp://web2py.nudata.fi/em

Login with kenneth and kenneth

This is an application for a very small firm, three part-time
IT-supporters.

FRONTPAGE:
summary of all kind of data.
  a) how many unpaid receipts
  b) how much money every person has earned
  c) ticket situation
  d) log work done

RECEIPT:
this is the place where we declare what we have bought, either by credit
card or on bill. If a bill then you put due-date and things like that
too and out accountant receives an mail about it. Here you upload an PDF
or JPG of the receipt too. Every receipt has to be broken down to which
customer should be billed for it.

BILLS:
here you create bills that should be sent to customer. A bill is created
from items from Receipts, Reported work. If you have customer that buys
something from you and you bill every year you can create Periodical bills.

CUSTOMERS:
customerdatabase

PRODUCTS:
product database

TICKETS:
a very simple ticketing system, work in progress. If you visit
web2py.nudata.fi/em/ticket without being logged in you ll get a create
ticket page ment for customers.
The idea is that when a ticket is ready the work used to solve the
problem will be billed directly. But I m working on that part.

All comments are welcomed.

Kenneth








That would be awesome! Looking forward to it.
On Sep 8, 3:05 pm, Kenneth Lundstr m
wrote:

Hello Nikolai,
I have created a simple billing application that contains customers,
products, hour tracker (simple) and receipt handling.
If interested I could during the weekend put up a english version of it
(Well swedish too it thats better) so you can check it out.
Kenneth

is there any billing component among the web2py appliances that can be
used as a base or a billing appliance?
Just wondering if there's any such code out there before starting from
scratch.
Thanks.




Re: [web2py] Re: web2ruby possible?

2011-09-12 Thread Michele Comitini
Already posted but still effective:

http://bellard.org/jslinux/

mic

2011/9/12 Vasile Ermicioi :
> skulpt with node.js makes it possible a web2py nodejs


[web2py] auth.key in private?

2011-09-12 Thread pbreit
I'm seeing a new file in private "auth.key". Is that some new way to store 
the hmac_key? 

Re: [web2py] Re: billing app

2011-09-12 Thread pbreit
I'd like to take a look. thx! pbreitenbach at gmail

[web2py] Re: auth.key in private?

2011-09-12 Thread Anthony
On Monday, September 12, 2011 5:38:04 PM UTC-4, pbreit wrote:
>
> I'm seeing a new file in private "auth.key". Is that some new way to store 
> the hmac_key?


Yes, instead of the admin app automatically inserting a new hmac_key when an 
app is created, now an auth.key file is created in /private by 
Auth.get_or_create_key(). See 
http://code.google.com/p/web2py/source/detail?r=4fc35e8b3b3e79c498dac5ba6f1937cdaea5190a.

Anthony


Re: [web2py] Re: billing app

2011-09-12 Thread Christopher Steel
I would love to take a look as well.  Thanks for offering.

chris DOT steel @ gmail.com






[web2py] Re: MySQL lost connection to server

2011-09-12 Thread Massimo Di Pierro
this issue should be solved in trunk (and nightly build)

On Sep 12, 10:30 am, G  wrote:
> Hi,
> After leaving my app running for a while, when I come back to access
> it, I get an error in Framework that is from pymysql reporting that
> the connection to the server has been lost (because it timed out from
> inactivity presumably). If I refresh the page a couple of times, the
> error goes away. I assume this is because DAL opens a new connection
> after finding that all the available connections have closed. This
> provides a poor impression for users.
> I have encountered this in non-web based code and so I wrap all of my
> database accesses with a function that first trys to ping the
> connection by doing a db.commit, and if it fails, reconnects to the
> server. Can something like this be added to dal.py? Is there a better
> way to handle this?
>
> The exact source of the error is here
>
> File "/home/dl/trunkw2p/web2py/gluon/main.py", line 506, in wsgibase
>     BaseAdapter.close_all_instances('commit')
>
> and sometimes here:
>
> File "/home/dl/trunkw2p/web2py/gluon/main.py", line 570, in wsgibase
>     BaseAdapter.close_all_instances('rollback')
>
> Thanks,
> G


[web2py] Re: XML-RPC Service Introspection / Discovery

2011-09-12 Thread Massimo Di Pierro
Cool! This should go in the manual.

On Sep 12, 10:47 am, Ross Peoples  wrote:
> One of the nice things about SOAP is the WDSL that gives you information
> about the methods the service supports. I recently discovered that you can
> do the same thing with XML-RPC. The trick is to document your methods
> properly, like you should be doing anyways. Lets say I have the following
> controller:
>
> @service.xmlrpc
> @service.jsonrpc
> def add(num1, num2):
>     """
>     Adds two numbers together.
>
>     add(num1, num2) -> number
>
>     Arguments:
>     num1        First number
>     num2        Second number
>
>     Returns:
>     The sum of the two numbers.
>
>     Examples:
>     add(2, 2) -> 4
>     add(2.5, 2.5) -> 5.0
>     """
>     return num1 + num2
>
> @service.xmlrpc
> @service.jsonrpc
> def concat(str1, str2, str3=''):
>     """
>     Concatenates two or three strings.
>
>     concat(str1, str2, str3='') -> string
>
>     Arguments:
>     str1        First string
>     str2        Second string
>     str3        (Optional) Third string
>
>     Returns:
>     The concatenated string.
>
>     Examples:
>     concat('hello', ' world') -> 'hello world'
>     concat('hello', ' world', ' !!!') -> 'hello world !!!
>     """
>     return str1 + str2 + str3
>
> @service.xmlrpc
> @service.jsonrpc
> def date():
>     """
>     Returns the server's current date and time.
>     """
>     return datetime.datetime.now()
>
> Now let's connect using xmlrpclib:
>
> >>> import xmlrpclib
> >>> x =
>
> xmlrpclib.ServerProxy('http://127.0.0.1:8000/rpc_test/default/call/xmlrpc')
>
> Now, we could start calling the methods as usual, or we could do a little
> introspection to see what methods are available, and even get the docstrings
> of those methods:
>
> >>> print x.system.listMethods()
>
> ['add', 'concat', 'date', 'system.listMethods', 'system.methodHelp',
> 'system.methodSignature']
>
> >>> print x.system.methodHelp('concat')
>
> Concatenates two or three strings.
>
> concat(str1, str2, str3='') -> string
>
> Arguments:
> str1        First string
> str2        Second string
> str3        (Optional) Third string
>
> Returns:
> The concatenated string.
>
> Examples:
> concat('hello', ' world') -> 'hello world'
> concat('hello', ' world', ' !!!') -> 'hello world !!!'
>
> >>> x.concat('hello', 'web2py')
>
> 'helloweb2py'
>
> Very cool! However, you will notice that there is another method in there:
> system.methodSignature(). This would show the signature of the method (i.e.
> concat(str1, str2, str3=''), however, it seems that web2py's XMLRPC server
> implementation (or SimpleXMLRPCServer.py) doesn't support this, as it
> returns 'signatures not supported' whenever you try to call this method.
>
> I hope that someone finds this useful!


[web2py] Re: web2ruby possible?

2011-09-12 Thread Massimo Di Pierro
The main problem is the last of database drivers and operator
overloading. the dal would be very limited

On Sep 12, 10:21 am, Vasile Ermicioi  wrote:
> skulpt with node.js makes it possible a web2py nodejs


[web2py] Re: Custom auth_user with different fileds name

2011-09-12 Thread white fox
Thanks for your helping me, but it doesn't solve my problem. because
when the auth tables trying to define i receive  this error:

Can't create table 'myDB.auth_membership' (errno: 150)

and i think this errors raised because of the
`auth_membership.user_id` is depend on the ID column of my users table
which is not `id` as i said it's `userid`.
and i don't think we can solve the problem, because i looked at
Tools.py and i see the `id` column is a static string and not
optional.

i just should hack the core code and i don't think it's a good idea!!


[web2py] Returning a dict from a controller

2011-09-12 Thread HughBarker
Hi all,
So I've got a controller that builds a dict of strings and returns
them - although I'm building the dict dynamically, essentially what
I'm doing is this:

def getsensors():
  d = {'airTemp' : 'Air Temperature', 'PAR' : 'PAR',
'IMOSPortRadiometer' : 'IMOS Port Radiometer'}
  return d

When I call the URL, ie ../default/getsensors, I get 'invalid view
(default/getsensors.html)'.

My understanding was that if a dict is returned from a controller and
you call the appropriate URL, the dict will get processed and
displayed on screen (ultimately what I'm trying to do is call
getsensors.json and process the returned JSON, kind of like Example 3
at http://web2py.com/examples/default/examples).

I've played around with this a fair bit now, and I can't understand
why it isn't working. I'm sure it's some elementary mistake on my
part, but any help would be appreciated.

-Hugh


Re: [web2py] Returning a dict from a controller

2011-09-12 Thread Bruno Rocha
do you have response.generic_patterns = ['*'] in your models?

On Mon, Sep 12, 2011 at 9:50 PM, HughBarker  wrote:

> Hi all,
> So I've got a controller that builds a dict of strings and returns
> them - although I'm building the dict dynamically, essentially what
> I'm doing is this:
>
> def getsensors():
>  d = {'airTemp' : 'Air Temperature', 'PAR' : 'PAR',
> 'IMOSPortRadiometer' : 'IMOS Port Radiometer'}
>  return d
>
> When I call the URL, ie ../default/getsensors, I get 'invalid view
> (default/getsensors.html)'.
>
> My understanding was that if a dict is returned from a controller and
> you call the appropriate URL, the dict will get processed and
> displayed on screen (ultimately what I'm trying to do is call
> getsensors.json and process the returned JSON, kind of like Example 3
> at http://web2py.com/examples/default/examples).
>
> I've played around with this a fair bit now, and I can't understand
> why it isn't working. I'm sure it's some elementary mistake on my
> part, but any help would be appreciated.
>
> -Hugh




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


Re: [web2py] Returning a dict from a controller

2011-09-12 Thread Jonathan Lundell
On Sep 12, 2011, at 6:10 PM, Bruno Rocha wrote:

> do you have response.generic_patterns = ['*'] in your models?

The stock line (for security) is

response.generic_patterns = ['*'] if request.is_local else []




> 
> On Mon, Sep 12, 2011 at 9:50 PM, HughBarker  wrote:
> Hi all,
> So I've got a controller that builds a dict of strings and returns
> them - although I'm building the dict dynamically, essentially what
> I'm doing is this:
> 
> def getsensors():
>  d = {'airTemp' : 'Air Temperature', 'PAR' : 'PAR',
> 'IMOSPortRadiometer' : 'IMOS Port Radiometer'}
>  return d
> 
> When I call the URL, ie ../default/getsensors, I get 'invalid view
> (default/getsensors.html)'.
> 
> My understanding was that if a dict is returned from a controller and
> you call the appropriate URL, the dict will get processed and
> displayed on screen (ultimately what I'm trying to do is call
> getsensors.json and process the returned JSON, kind of like Example 3
> at http://web2py.com/examples/default/examples).
> 
> I've played around with this a fair bit now, and I can't understand
> why it isn't working. I'm sure it's some elementary mistake on my
> part, but any help would be appreciated.
> 
> -Hugh
> 
> 
> 
> -- 
> 
> 
> 
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
> [ Aprenda a programar: http://CursoDePython.com.br ]
> [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
> [ Consultoria em desenvolvimento web: http://www.blouweb.com ]
> 




[web2py] Re: Returning a dict from a controller

2011-09-12 Thread Hugh Barker
This is my db.py:

from gluon.tools import Service

db = DAL('postgres://postgres:@server/geospatial')
response.generic_patterns = ['*']
service = Service()


On Sep 13, 11:13 am, Jonathan Lundell  wrote:
> On Sep 12, 2011, at 6:10 PM, Bruno Rocha wrote:
>
> > do you have response.generic_patterns = ['*'] in your models?
>
> The stock line (for security) is
>
> response.generic_patterns = ['*'] if request.is_local else []
>
>
>
>
>
>
>
>
>
> > On Mon, Sep 12, 2011 at 9:50 PM, HughBarker  wrote:
> > Hi all,
> > So I've got a controller that builds a dict of strings and returns
> > them - although I'm building the dict dynamically, essentially what
> > I'm doing is this:
>
> > def getsensors():
> >  d = {'airTemp' : 'Air Temperature', 'PAR' : 'PAR',
> > 'IMOSPortRadiometer' : 'IMOS Port Radiometer'}
> >  return d
>
> > When I call the URL, ie ../default/getsensors, I get 'invalid view
> > (default/getsensors.html)'.
>
> > My understanding was that if a dict is returned from a controller and
> > you call the appropriate URL, the dict will get processed and
> > displayed on screen (ultimately what I'm trying to do is call
> > getsensors.json and process the returned JSON, kind of like Example 3
> > athttp://web2py.com/examples/default/examples).
>
> > I've played around with this a fair bit now, and I can't understand
> > why it isn't working. I'm sure it's some elementary mistake on my
> > part, but any help would be appreciated.
>
> > -Hugh
>
> > --
>
> > --
> > Bruno Rocha
> > [ About me:http://zerp.ly/rochacbruno]
> > [ Aprenda a programar:http://CursoDePython.com.br]
> > [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
> > [ Consultoria em desenvolvimento web:http://www.blouweb.com]


[web2py] Re: Custom auth_user with different fileds name

2011-09-12 Thread Massimo Di Pierro
The web2py Auth requires the auth_user table to have an id column. I
suggest you move the data from your table to a new table wich has the
correct field name. It is the easiest solution.

On Sep 12, 8:30 am, white fox  wrote:
> hi, I have a website which is written by PHP, so i decided to move to
> python and use web2py for new version of my site.
> anyway, in my Mysql Database i have lots of tables, one of them is
> "Users" table. the table is like this
>
> db.define_table ("qbp_user",
>      Field ("userid", "integer"),
>      Field ("email_address", "string", length = 50, required=True),
>      Field ("username", "string", length = 25, required=True),
>      Field ("PASSWORD", type='password', readable=False, length = 255,
> required=True),
>      Field ("user_level", "string", length = 11, default=2),
>      Field ("signup_date", "datetime", default=now),
>      Field ("last_login", "datetime"),
>      Field ("country", "string", length = 50),
>      Field ("ip", "string", length = 50),
>      Field ("homepage", "string", length = 50),
>      Field ("activated", "integer", default=0),
>      Field ("session", "string", length = 255),
>      Field ("avatar", "string", length = 100),
>      Field ("signature", "text"),
>      Field ("messenger2", "string", length = 55),
>      Field ("title", "string", length = 20, default='Registered'),
>      Field ("Tell", "string", length = 20),
>      Field ("Address", "string", length = 500),
>      Field ("score", "integer"),
>      Field ("FullName", "string", length = 70),
>      Field ("ZipCode", "string", length = 50),
>      Field ("mode_state", "integer"),
>      Field ("status", "integer"),
>      Field ("active_mail", "string", length = 50, default=-1),
>      Field ("tanksto", "integer"),
>      Field ("tanksfrom", "integer"),
>      Field ("type", "integer"),
>      Field ("blog_url", "string", length = 100),
>      Field ("settings", "integer", default=1),
>      Field ('registration_key', length=512, writable=False,
> readable=False, default=''),
>      Field ('reset_password_key', length=512, writable=False,
> readable=False, default=''),
>      migrate = False)
>
> As you can see i have `userid` instead of `id` and have `FullName`
> instead of `fist_name` and `last_name`,  and at last i have
> `email_address` as `email`,
> this is  a very big website and have different parts, so i can't
> change fields name, because i'm sure my code broken in other parts.
>
> i know i can change the auth_user table name(i read about this 
> inhttp://web2py.com/book/default/chapter/08#Customizing-Auth), but is it
> possible to change auth_users'fields names too? is it possible that i
> migrate web2py authentication with my database? or i should my own
> athentication?
>
> p.s: sorry for my bad english :)


Re: [web2py] Re: Returning a dict from a controller

2011-09-12 Thread Jonathan Lundell
On Sep 12, 2011, at 6:45 PM, Hugh Barker wrote:

> This is my db.py:
> 
> from gluon.tools import Service
> 
> db = DAL('postgres://postgres:@server/geospatial')
> response.generic_patterns = ['*']
> service = Service()

Nothing jumps out at me. As a sanity check, you might try copying 
views/generic.html to views/default/getsensors.html and verify that it works as 
expected that way. If it doesn't work, at least it'd tell us that things were 
seriously strange (and if it does work you'd have a workaround).

If you feel like troubleshooting, try this.

In gluon/compileapp.py, find run_view_in. A local string badv is defined early 
on, which is the path you see below in the error message. Leave that definition 
along, but search forward for the two double uses of badv, in a pair of raise 
statements. I'm assuming that you haven't compiled your app? No 
appname/compiled/ directory? In that case we want the second raise.

Just before the raise, insert: badv = filename

We *should* see a full path ending views/generic.html. 






> 
> 
> On Sep 13, 11:13 am, Jonathan Lundell  wrote:
>> On Sep 12, 2011, at 6:10 PM, Bruno Rocha wrote:
>> 
>>> do you have response.generic_patterns = ['*'] in your models?
>> 
>> The stock line (for security) is
>> 
>> response.generic_patterns = ['*'] if request.is_local else []
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> On Mon, Sep 12, 2011 at 9:50 PM, HughBarker  wrote:
>>> Hi all,
>>> So I've got a controller that builds a dict of strings and returns
>>> them - although I'm building the dict dynamically, essentially what
>>> I'm doing is this:
>> 
>>> def getsensors():
>>>  d = {'airTemp' : 'Air Temperature', 'PAR' : 'PAR',
>>> 'IMOSPortRadiometer' : 'IMOS Port Radiometer'}
>>>  return d
>> 
>>> When I call the URL, ie ../default/getsensors, I get 'invalid view
>>> (default/getsensors.html)'.
>> 
>>> My understanding was that if a dict is returned from a controller and
>>> you call the appropriate URL, the dict will get processed and
>>> displayed on screen (ultimately what I'm trying to do is call
>>> getsensors.json and process the returned JSON, kind of like Example 3
>>> athttp://web2py.com/examples/default/examples).
>> 
>>> I've played around with this a fair bit now, and I can't understand
>>> why it isn't working. I'm sure it's some elementary mistake on my
>>> part, but any help would be appreciated.
>> 
>>> -Hugh
>> 
>>> --
>> 
>>> --
>>> Bruno Rocha
>>> [ About me:http://zerp.ly/rochacbruno]
>>> [ Aprenda a programar:http://CursoDePython.com.br]
>>> [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
>>> [ Consultoria em desenvolvimento web:http://www.blouweb.com]




[web2py] mywiki RSS feed failure

2011-09-12 Thread Mark Abajian
It seems that the "mywiki" tutorial in Chapter 3 of the book is no
longer accurate.  I had a problem with it.  If this can be
corroborated by someone else, perhaps this should be updated in the
book.

Environment..
* web2py 1.98.2 downloaded as "source", not as .app
* Mac OS X 10.6.8
* Python 2.7.2 -- EPD 7.1-1 (32-bit)

I followed all the examples in the book (Chapter 3).  When I completed
the "mywiki" app, I had a problem with this link:

http://127.0.0.1:8000/mywiki/default/news.rss

Instead of showing me the RSS feed, I got an error message that
default/news is an "invalid view".  There was no trouble ticket
created, just an error message.

Trolling around the web, I found this post related to an invalid view:


>  [pbreit  View profile   More options Jun 30, 1:51 am]
>  Or this if you can get by with them only being available on "localhost":
>
>  # by default give a view/generic.extension to all actions from localhost
>  # none otherwise. a pattern can be 'controller/function.extension'
>  response.generic_patterns = ['*'] if request.is_local else []


I added this code to my db.py, and that seemed to resolve the
problem.  After that, when I visited

http://127.0.0.1:8000/mywiki/default/news.rss

it actually brought up the RSS feed page in my Safari browser.

Am I the only one affected by this, or have others encountered this?

Thanks in advance.


[web2py] mywiki XML-RPC failure

2011-09-12 Thread Mark Abajian
I encountered a problem in the mywiki example of the tutorial in
Chapter 3 of the book.

Mac OS X 10.6.8
web2py 1.98.2 downloaded as source
Python 7.2.2 (EPD 7.1-1)

When I tried to run the example in the book

for item in server.find_by('wiki'):
print item.created_on, item.title

it raised an exception that item did not have a created_on attribute.

Instead, I changed it to item['created_on'] and item['title'], and it
worked fine.

Maybe xmlrpc no longer returns items as objects, but as dicts instead?

Thanks in advance.


[web2py] Re: mywiki XML-RPC failure

2011-09-12 Thread mabajian86
Sorry, that was Python 2.7.2.

On Sep 12, 2011, at 7:04 PM, Mark Abajian wrote:

> I encountered a problem in the mywiki example of the tutorial in
> Chapter 3 of the book.
> 
> Mac OS X 10.6.8
> web2py 1.98.2 downloaded as source
> Python 7.2.2 (EPD 7.1-1)
> 
> When I tried to run the example in the book
> 
>for item in server.find_by('wiki'):
>print item.created_on, item.title
> 
> it raised an exception that item did not have a created_on attribute.
> 
> Instead, I changed it to item['created_on'] and item['title'], and it
> worked fine.
> 
> Maybe xmlrpc no longer returns items as objects, but as dicts instead?
> 
> Thanks in advance.



[web2py] Re: Returning a dict from a controller

2011-09-12 Thread Hugh Barker
Yeah, copying the default generic.html to getsensors.html (and ditto
for *.json) worked.

I'll try the debugging steps you suggested, see what I come up with.

On Sep 13, 12:08 pm, Jonathan Lundell  wrote:
> On Sep 12, 2011, at 6:45 PM, Hugh Barker wrote:
>
> > This is my db.py:
>
> > from gluon.tools import Service
>
> > db = DAL('postgres://postgres:@server/geospatial')
> > response.generic_patterns = ['*']
> > service = Service()
>
> Nothing jumps out at me. As a sanity check, you might try copying 
> views/generic.html to views/default/getsensors.html and verify that it works 
> as expected that way. If it doesn't work, at least it'd tell us that things 
> were seriously strange (and if it does work you'd have a workaround).
>
> If you feel like troubleshooting, try this.
>
> In gluon/compileapp.py, find run_view_in. A local string badv is defined 
> early on, which is the path you see below in the error message. Leave that 
> definition along, but search forward for the two double uses of badv, in a 
> pair of raise statements. I'm assuming that you haven't compiled your app? No 
> appname/compiled/ directory? In that case we want the second raise.
>
> Just before the raise, insert: badv = filename
>
> We *should* see a full path ending views/generic.html.
>
>
>
>
>
>
>
>
>
> > On Sep 13, 11:13 am, Jonathan Lundell  wrote:
> >> On Sep 12, 2011, at 6:10 PM, Bruno Rocha wrote:
>
> >>> do you have response.generic_patterns = ['*'] in your models?
>
> >> The stock line (for security) is
>
> >> response.generic_patterns = ['*'] if request.is_local else []
>
> >>> On Mon, Sep 12, 2011 at 9:50 PM, HughBarker  wrote:
> >>> Hi all,
> >>> So I've got a controller that builds a dict of strings and returns
> >>> them - although I'm building the dict dynamically, essentially what
> >>> I'm doing is this:
>
> >>> def getsensors():
> >>>  d = {'airTemp' : 'Air Temperature', 'PAR' : 'PAR',
> >>> 'IMOSPortRadiometer' : 'IMOS Port Radiometer'}
> >>>  return d
>
> >>> When I call the URL, ie ../default/getsensors, I get 'invalid view
> >>> (default/getsensors.html)'.
>
> >>> My understanding was that if a dict is returned from a controller and
> >>> you call the appropriate URL, the dict will get processed and
> >>> displayed on screen (ultimately what I'm trying to do is call
> >>> getsensors.json and process the returned JSON, kind of like Example 3
> >>> athttp://web2py.com/examples/default/examples).
>
> >>> I've played around with this a fair bit now, and I can't understand
> >>> why it isn't working. I'm sure it's some elementary mistake on my
> >>> part, but any help would be appreciated.
>
> >>> -Hugh
>
> >>> --
>
> >>> --
> >>> Bruno Rocha
> >>> [ About me:http://zerp.ly/rochacbruno]
> >>> [ Aprenda a programar:http://CursoDePython.com.br]
> >>> [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
> >>> [ Consultoria em desenvolvimento web:http://www.blouweb.com]


[web2py] SQLFORM.grid representation

2011-09-12 Thread Simon Ashley
Have a Model as follows:

from gluon.tools import Auth
auth=Auth(db)
auth.define_tables()
db.define_table('person',Field('name'),format='%(name)s')
db.define_table('dog',Field('name'),Field('owner',db.person))
db.dog.owner.requires = IS_IN_DB(db, 'person.id', db.person._format)

and a controller:

def index():
  db.dog.id.readable=False
  fields = (db.dog.id, db.dog.name, db.dog.owner)
  table = SQLFORM.grid(db.dog, fields)
  return dict(table=table)

Main issue:
the grid returns the id rather than the name for the owner.
Edit and view both return the name (as expected).
Is there a problem with the model/ controller syntax?

Side issue:
In the controller, fields line, if db.dog.id is left out, the grid
returns an id ticket error.

Traceback (most recent call last):
  File "gluon/restricted.py", line 194, in restricted
  File "C:/web2py/applications/pt2/controllers/dogs.py", line 7, in

  File "gluon/globals.py", line 145, in 
  File "C:/web2py/applications/pt2/controllers/dogs.py", line 4, in
index
  File "gluon/sqlhtml.py", line 1647, in grid
  File "gluon/dal.py", line 3835, in __getitem__
KeyError: 'id'

This occurs with or without the second line (... readable=False)
commented out.
Wanted to show the id in edit and view forms but not in the grid.
Can this be achieved?


Re: [web2py] Re: New UI package

2011-09-12 Thread Vasile Ermicioi
very nice, but as telerik is doing business selling components, isn't it
commercial?


[web2py] preparing for 1.99.1

2011-09-12 Thread Massimo Di Pierro
There is huge list of new features already in trunk that will be
included in 1.99.1

Here is a partial list:
- experimental gluon/scheduler.py
- scripts/make_min_web2py.py
- crud.search has more options, thanks Denes
- gluon/contrib/simplejsonrpc.py
- gluon/contrib/redis_cache.py
- new SQLFORM.grid and SQLFORM.smartgrid (should replace crud.search
and crud.select)
- support for natural language queries (english only) in SQLFORM.grid
- support for computed columns and additional links in SQLFORM.grid
- cleanup of code
- support for A(name,callback=url,target='id',delete='tr')
- support for A(name,component=url,target='id',delete='tr')
- isapiwsgihandler.py
- dal expression.coalesce(*options)
- new pip installer, thanks Chris Steel
- gluon/contrib/simplejsonrpc.py, thanks Mariano
- expire_sessions.py respects expiration time, thanks iceberg
- fixed problem with max text length
- addressed this issue: 
http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/
- x509 support (needs rocket upgrade, thanks Michele)
- form.process() and for.validate()
- rocket upgrade (1.2.4)
- jQuery upgrade (1.6.3)
- new syntax rows[i]('tablename.fieldname')
- new query syntax field.contains(list,all=True or False)
- request.utcnow
- cleaner/simpler welcome/models/db.py and welcome layout.html
- response.include_meta() and response.include_files(), thanks Denes
- dal auto-reconnect on time-out connections
- COL and COLGROUP helpers
- addressed OWASP #10, thanks Anthony and Eric
- Auth(auto_redirect=[URL(...)])
- auth.settings.login_after_registration=True
- detection of mobile devices and @mobilize helper (view.mobile.html)
- new style virtual fields (experimental):
db.table.field=Field.Lazy(...)
- many bug fixes  (thanks Jonathan, Michele, Fran and others)

I am forgetting something important? Am I forgetting to acknowledge
your contribution?
Please let me know, privately if you prefer.

Massimo


Re: [web2py] Re: New UI package

2011-09-12 Thread Anthony
On Monday, September 12, 2011 11:16:06 PM UTC-4, elffikk wrote:
>
> very nice, but as telerik is doing business selling components, isn't it 
> commercial?


Dual license -- commercial and GPLv2 (http://www.kendoui.com/faq.aspx). 


[web2py] Re: Making slides with web2py and markmin

2011-09-12 Thread guruyaya
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 
wrote:
> markmin requires [[...]] not [...]
>
> On Sep 11, 2:29 pm, guruyaya  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 
> > wrote:
>
> > > No. It makes the view. You just return it.
>
> > > On Sep 10, 3:53 pm, António Ramos  wrote:
>
> > > > Humm, dont i need a view?
>
> > > > Em 10 de setembro de 2011 21:52, António Ramos 
> > > > escreveu:
>
> > > > > Working now :)
>
> > > > > Em 10 de setembro de 2011 21:29, António Ramos 
> > > > > escreveu:
>
> > > > > 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 
>
> > > > >>> +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] Re: billing app

2011-09-12 Thread Gour-Gadadhara Dasa
On Tue, 13 Sep 2011 00:07:30 +0300
Kenneth Lundström
 wrote:

> if you want a copy of the code I can send it, or if somebody else
> wants a copy let me know. 

+1 

gour at atmarama dot net


Sincerely,
Gour


-- 
“In the material world, conceptions of good and bad are
all mental speculations…” (Sri Caitanya Mahaprabhu)

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810




signature.asc
Description: PGP signature


[web2py] Re: Making slides with web2py and markmin

2011-09-12 Thread Andrew
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  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 
> wrote:
>
>
>
> > markmin requires [[...]] not [...]
>
> > On Sep 11, 2:29 pm, guruyaya  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 
> > > wrote:
>
> > > > No. It makes the view. You just return it.
>
> > > > On Sep 10, 3:53 pm, António Ramos  wrote:
>
> > > > > Humm, dont i need a view?
>
> > > > > Em 10 de setembro de 2011 21:52, António Ramos 
> > > > > escreveu:
>
> > > > > > Working now :)
>
> > > > > > Em 10 de setembro de 2011 21:29, António Ramos 
> > > > > > escreveu:
>
> > > > > > 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 
>
> > > > > >>> +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: billing app

2011-09-12 Thread David

Kenneth;

Well done.

Can you post the code somewhere public for download?

I think many people would be interested in it.


Thanks.



On 9/13/11 1:25 AM, Gour-Gadadhara Dasa wrote:

On Tue, 13 Sep 2011 00:07:30 +0300
Kenneth Lundström
  wrote:


if you want a copy of the code I can send it, or if somebody else
wants a copy let me know.

+1

gour at atmarama dot net


Sincerely,
Gour






[web2py] Re: preparing for 1.99.1

2011-09-12 Thread Gour-Gadadhara Dasa
On Mon, 12 Sep 2011 20:21:39 -0700 (PDT)
Massimo Di Pierro
 wrote:

> There is huge list of new features already in trunk that will be
> included in 1.99.1

[...]

> I am forgetting something important? Am I forgetting to acknowledge
> your contribution?

What about the docs/book?

Will everything from the list become documented and the book updated
accordingly?



Sincerely,
Gour


-- 
“In the material world, conceptions of good and bad are
all mental speculations…” (Sri Caitanya Mahaprabhu)

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810




signature.asc
Description: PGP signature


[web2py] PostGresql

2011-09-12 Thread Web2Py Freak
Dear All ,

i want to use PostGresql  , now after i download it  , what to do so
it can work with web2py ??


[web2py] Re: preparing for 1.99.1

2011-09-12 Thread niknok
Yes. Eventually. :)

On Sep 13, 1:30 pm, Gour-Gadadhara Dasa  wrote:
> On Mon, 12 Sep 2011 20:21:39 -0700 (PDT)
> Massimo Di Pierro
>
>  wrote:
> > There is huge list of new features already in trunk that will be
> > included in 1.99.1
>
> [...]
>
> > I am forgetting something important? Am I forgetting to acknowledge
> > your contribution?
>
> What about the docs/book?
>
> Will everything from the list become documented and the book updated
> accordingly?
>
> Sincerely,
> Gour
>
> --
> “In the material world, conceptions of good and bad are
> all mental speculations…” (Sri Caitanya Mahaprabhu)
>
> http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
>
>  signature.asc
> < 1KViewDownload


Re: [web2py] PostGresql

2011-09-12 Thread David

On 9/13/11 1:43 AM, Web2Py Freak wrote:

Dear All ,

i want to use PostGresql  , now after i download it  , what to do so
it can work with web2py ??

How about install the postgres driver?

pip install psycopg

Then next time you run web2py you should see the driver is loaded

then change your db connection string to 
|postgres://username:password@localhost/test


as per the book web2py.com/book
|


[web2py] If you have not followed recent changes .....

2011-09-12 Thread Massimo Di Pierro
Here is a complete implementation of a multi-tenant todo list with
search, assignments, emails, janrain, etc
Try understand it. Requires trunk!

"""
Complete web2py program to create, search assign and manage
tasks
Has multi-tenancy supports (same app can manage different
hostnames)
Uses janrain for
login
"""

### File: models/db.py
#

from gluon.tools import Auth
db = DAL('sqlite://storage.sqlite')
auth = Auth(db,hmac_key=Auth.get_or_create_key())
auth.define_tables()

# configure email and
janrain
auth.settings.mailer.settings.server = 'logging' or 'smtp.gmail.com:
587'
auth.settings.mailer.settings.sender = 'y...@gmail.com'
auth.settings.mailer.settings.login = 'username:password'
from gluon.contrib.login_methods.rpx_account import use_janrain
use_janrain(auth,filename='private/janrain.key')

db._common_fields.append(Field('request_tenant',writable=False,default=request.env.host_name))

db.define_table('task',
Field('name',requires=IS_NOT_EMPTY()),
Field('assigned_to',db.auth_user),
Field('due_date','datetime'),
Field('notify','boolean'),
Field('note'),
auth.signature)

### File: controllers/default.py
#

response.menu = []
response.menu.append(('My Tasks',False,URL('index')))
response.menu.append(('Create/Manage
Tasks',False,URL('manage_tasks')))
link = 'http://%s%s' % (request.env.http_host,URL('view_task'))

@auth.requires_login()
def index():
""" Allows me to browse, search, view, update tasks assigned to me
"""
grid=SQLFORM.grid(db.task.assigned_to==auth.user_id,create=False)
form = grid.element('form')
if form and form.accepted:
mail.send(to=form.record.created_by,subject="todo",
  message = "task %s/%i updated" %
(link,form.record_id))
return dict(grid=grid)

@auth.requires_login()
def manage_tasks():
""" Allows me to browse, serach, view, create and assign new tasks
"""
grid=SQLFORM.grid(db.task.created_by==auth.user_id)
form = grid.element('form')
if form and form.accepted:
mail.send(to=form.vars.assigned_to,subject="todo",
  message = "task %s/%i assigned to you" %
(link,form.vars.id))
return dict(grid=grid)

def view_task():
task = db(db.task.id==request.args(0))\
  ((db.task.created_by==auth.user.id)|
(db.task.assigned_to==auth.user.id)).select().first()
return dict(task = task)

def user():
return dict(form=auth())

### File: views/default/index.html
#
{{extend 'layout.html'}}
{{=form}}

### File: views/default/manage_tasks.html
##
{{extend 'layout.html'}}
{{=form}}

### File: views/default/view_task.html
#
{{extend 'layout.html'}}
{{=form}}

### Requires scaffolding layout and static files
###


[web2py] Re: If you have not followed recent changes .....

2011-09-12 Thread Massimo Di Pierro
When you try... would you submit some screenshots in this thread?

On Sep 13, 1:13 am, Massimo Di Pierro 
wrote:
> Here is a complete implementation of a multi-tenant todo list with
> search, assignments, emails, janrain, etc
> Try understand it. Requires trunk!
>
> """
> Complete web2py program to create, search assign and manage
> tasks
> Has multi-tenancy supports (same app can manage different
> hostnames)
> Uses janrain for
> login
> """
>
> ### File: models/db.py
> #
>
> from gluon.tools import Auth
> db = DAL('sqlite://storage.sqlite')
> auth = Auth(db,hmac_key=Auth.get_or_create_key())
> auth.define_tables()
>
> # configure email and
> janrain
> auth.settings.mailer.settings.server = 'logging' or 'smtp.gmail.com:
> 587'
> auth.settings.mailer.settings.sender = '...@gmail.com'
> auth.settings.mailer.settings.login = 'username:password'
> from gluon.contrib.login_methods.rpx_account import use_janrain
> use_janrain(auth,filename='private/janrain.key')
>
> db._common_fields.append(Field('request_tenant',writable=False,default=requ 
> est.env.host_name))
>
> db.define_table('task',
>                 Field('name',requires=IS_NOT_EMPTY()),
>                 Field('assigned_to',db.auth_user),
>                 Field('due_date','datetime'),
>                 Field('notify','boolean'),
>                 Field('note'),
>                 auth.signature)
>
> ### File: controllers/default.py
> #
>
> response.menu = []
> response.menu.append(('My Tasks',False,URL('index')))
> response.menu.append(('Create/Manage
> Tasks',False,URL('manage_tasks')))
> link = 'http://%s%s' % (request.env.http_host,URL('view_task'))
>
> @auth.requires_login()
> def index():
>     """ Allows me to browse, search, view, update tasks assigned to me
> """
>     grid=SQLFORM.grid(db.task.assigned_to==auth.user_id,create=False)
>     form = grid.element('form')
>     if form and form.accepted:
>         mail.send(to=form.record.created_by,subject="todo",
>                   message = "task %s/%i updated" %
> (link,form.record_id))
>     return dict(grid=grid)
>
> @auth.requires_login()
> def manage_tasks():
>     """ Allows me to browse, serach, view, create and assign new tasks
> """
>     grid=SQLFORM.grid(db.task.created_by==auth.user_id)
>     form = grid.element('form')
>     if form and form.accepted:
>         mail.send(to=form.vars.assigned_to,subject="todo",
>                   message = "task %s/%i assigned to you" %
> (link,form.vars.id))
>     return dict(grid=grid)
>
> def view_task():
>     task = db(db.task.id==request.args(0))\
>                   ((db.task.created_by==auth.user.id)|
> (db.task.assigned_to==auth.user.id)).select().first()
>     return dict(task = task)
>
> def user():
>     return dict(form=auth())
>
> ### File: views/default/index.html
> #
> {{extend 'layout.html'}}
> {{=form}}
>
> ### File: views/default/manage_tasks.html
> ##
> {{extend 'layout.html'}}
> {{=form}}
>
> ### File: views/default/view_task.html
> #
> {{extend 'layout.html'}}
> {{=form}}
>
> ### Requires scaffolding layout and static files
> ###