[web2py] Re: newbie question Can't use versioning in web2py

2019-08-12 Thread Dave S


On Sunday, August 11, 2019 at 10:34:32 AM UTC-7, Jirawat Kusolpredee wrote:
>
> Access admin page -> edit -> versioning -> throw exception ??? versioning 
> just doesn't work I never messing up the core ? What happened here ?
>

Source control?  Use an external source control, like Tortoise HG or Git.  
 The built-in one is deprecated because it used an unstable interface 
(Mercurial, but not the official Mercuiral API).

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/966d596e-947d-46ad-9250-f85aa37ebd2f%40googlegroups.com.


Re: [web2py] Re: Newbie question about github / trunk

2017-09-11 Thread Nico Zanferrari
Well, if you cannot use git, in fact you can do this:

- download https://github.com/web2py/web2py/archive/master.zip and
uncompress it (for example in /tmp/web2py.master)
- download https://github.com/web2py/pydal/archive/master.zip and
uncompress it. Move its content inside the web2py directory (in the above
example, under /tmp/web2py.master/gluon/packages/dal


By the way, using git you'll get all the latest updates, while using the
downloaded zip you'll get the current nightly build.

Nico


2017-06-22 16:37 GMT+02:00 Anthony :

> On Thursday, June 22, 2017 at 4:05:15 AM UTC-4, Nico Zanferrari wrote:
>>
>> You can also download the current "master branch" directly from the link
>> https://github.com/web2py/web2py/archive/master.zip
>>
>> No, the web2py repo includes PyDal as a Git submodule, and the download
> zip file generated by Github does not include submodules, so that zip file
> will not work.
>
> Anthony
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Newbie question about github / trunk

2017-06-22 Thread Anthony
On Thursday, June 22, 2017 at 4:05:15 AM UTC-4, Nico Zanferrari wrote:
>
> You can also download the current "master branch" directly from the link 
> https://github.com/web2py/web2py/archive/master.zip
>
> No, the web2py repo includes PyDal as a Git submodule, and the download 
zip file generated by Github does not include submodules, so that zip file 
will not work.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Newbie question about github / trunk

2017-06-22 Thread Nico Zanferrari
You can also download the current "master branch" directly from the link
https://github.com/web2py/web2py/archive/master.zip

Nico



2017-06-21 17:38 GMT+02:00 Anthony :

> That just means test the master branch on Github. You can get it via:
>
> git clone --recursive g...@github.com:web2py/web2py.git
>
> Of course, you need Git installed.
>
> Anthony
>
>
> On Wednesday, June 21, 2017 at 3:53:55 AM UTC-4, Karoly Kantor wrote:
>>
>> I raised an issue in github about Google Cloud SQL (
>> https://github.com/web2py/web2py/issues/1613 ), and I received a request
>> to test the new code in trunk. I have never used trunk and I have no idea
>> where to find it, can someone point me to the right direction, please?
>>
>> Thanks.
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie question about github / trunk

2017-06-21 Thread Anthony
That just means test the master branch on Github. You can get it via:

git clone --recursive g...@github.com:web2py/web2py.git

Of course, you need Git installed.

Anthony

On Wednesday, June 21, 2017 at 3:53:55 AM UTC-4, Karoly Kantor wrote:
>
> I raised an issue in github about Google Cloud SQL ( 
> https://github.com/web2py/web2py/issues/1613 ), and I received a request 
> to test the new code in trunk. I have never used trunk and I have no idea 
> where to find it, can someone point me to the right direction, please?
>
> Thanks.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie question about github / trunk

2017-06-21 Thread Karoly Kantor
Sorry I don't get it. The code under that link seems old to me, the 
particular pdal adapter file I am interested in is from 2016 May 10.

On Wednesday, June 21, 2017 at 10:05:03 AM UTC+2, 黄祥 wrote:
>
> in http://web2py.com/init/default/download you can see there are several 
> links for tester (trunk)
> e.g. for source code
> https://mdipierro.pythonanywhere.com/examples/static/nightly/web2py_src.zip
>
> best regards,
> stifan
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie question about github / trunk

2017-06-21 Thread 黄祥
in http://web2py.com/init/default/download you can see there are several 
links for tester (trunk)
e.g. for source code
https://mdipierro.pythonanywhere.com/examples/static/nightly/web2py_src.zip

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie to Web2Py...Integration with Bootstrap3...PyCharm How-To's

2017-05-17 Thread Dave S


On Tuesday, May 16, 2017 at 8:22:19 PM UTC-7, pbreit wrote:

> On Saturday, May 13, 2017 at 1:53:42 PM UTC-7, Christopher wrote:
>>
>> Greetings,
>>
>> I'm a WEB2PY newbie and I'm looking to quickly prototype a web 
>> application.
>>
>> I'm hoping to use http://www.layoutit.com/ with Bootstrap 3 for the page 
>> design.
>>
>> I'm going through the training videos on the Web2Py site now to get up to 
>> speed.
>>
>> I have a few questions...
>>
>> *1.*  Are there any issues with Web2Py and Bootstrap 3 (using 
>> LayoutIt.com) that I should be aware of?  (as a newbie)
>>
>
I think web2py is currently using BS3.
 

>
>> *2.*  As a newbie should I use PyCharm as an IDE or would you recommend 
>> I use the embedded Web2Py editor?
>>
>> *3.*  When using PyCharm, is there any HOW-TO documents on how to get 
>> PyCharm working with Web2Py?
>>
> If you're looking to prototype rapidly, forget all that stuff and just 
> build something in a text editor (ie Atom) with the pre-installed 
> Bootstrap. Don't over-complicate it.
>

Using PyCharm is discussed in the book:
http://web2py.com/books/default/chapter/29/14/other-recipes#PyCharm>
 
It seems to have some popularity in this group, and this thread may be 
relevant.


That said, I have never tried it.  I use both the built-in IDE and an 
external text editor (emacs on linux, the ancient PFE on Windows), choosing 
based on ephemeral ideas of convenience.

(Long ago, I had a couple of experiences with Eclipse, and still have to 
deal with Visual Studio sometimes.  But those weren't introduced until 
after I had a lot of development habits already in place, so IDEs can seem 
to me like driving a truck rather than a sportscar.  The built-in IDE is 
much lighter than Eclipse.)

/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie to Web2Py...Integration with Bootstrap3...PyCharm How-To's

2017-05-16 Thread pbreit
If you're looking to prototype rapidly, forget all that stuff and just 
build something in a text editor (ie Atom) with the pre-installed 
Bootstrap. Don't over-complicate it.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie question regarding controllers and views

2016-08-06 Thread Massimo Di Pierro
The controller is executed fully every time the page is requested by the 
browser. The output is passed to the view which is also rendered every time 
the page is requested. No execution is ever paused by the server.

The first time .accpets() is false. When you submit the form, .accepts() is 
true. The second time it acts on a new form object, not the same as the 
previous form object. The form object is re-created at every request. They 
just look identical.

Mind that today we prefer form.process() instead of form.accepts(request, 
session)




On Saturday, 6 August 2016 01:59:34 UTC-5, Scott ODonnell wrote:
>
> I'm trying to understand the relationship between controllers and views 
> and the general flow of code.
>
> Per the documentation , the display_form() function will run and then feed 
> the "view" with the dict(form=form)
> At that point the view "default/display_form.html" would be processed and 
> sent to the client browser to be rendered.
>
> Questions :
> 1.) Unless the display_form() is run again after the form is returned to 
> the client browser , how would "if form.accepts(request,session) ever be 
> executed?
> 1a.) Is execution of the display_form() function paused while the 
> {{=form}} is executed?
>
> 2.)  Given "the default/display_form.html" , what logic prevents all the 
> content after {{=form}} from being sent to the client browser ?
> 2a.) What logic prevents the  for "submitted variables", "Accepted 
> Variables" and "Errors in form" from being sent immediately while 
> processing the view html file?
>
>
> Thank you in advance for helping me understand this. I'm sure I'm just 
> thinking about it all incorrectly.
> -Scott
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: newbie question about login

2014-11-03 Thread Leonel Câmara
Yes that's possible, web2py can work as a Central Authentication Service.

http://www.web2py.com/books/default/chapter/29/09/access-control#Central-Authentication-Service

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie Web2Py Questions

2014-05-18 Thread Massimo Di Pierro
1) You can return anything your want:

def index():
a = {}
b = {}
return {'a':a, 'b':b}

2) Not really but you should look into gluon/contrib/webclient.py and 
doctests. Web2py runs doctests in controllers automatically.

On Saturday, 17 May 2014 07:23:33 UTC-5, Christopher Power wrote:

 Hi all,

 I'm a relatively new user of Web2Py.  I looked at it about a year ago and 
 loved a lot of its features, but ended up having to teach PHP to my 
 undergrads for a variety of reasons that are too boring to go into.  Blech.

 Anyways ... this year I'm insisting on using Web2Py for my course. I'm 
 also going to be using it on a few of my own projects to get up to speed on 
 the idiosyncrasies on the framework.  I've been successful doing some 
 relatively complex queries and pulling data from some ugly legacy database, 
 so that has all gone pretty well.

 With all of that boring information out of the way - I'm looking for a bit 
 of advice on a few things (probably the first of many).  Hopefully these 
 questions aren't too basic - I did a search and didn't find anything.

 1) Is there a way that I can return multiple dict's from a Controller to a 
 View?  I have a situation where I need to return the results of two 
 different queries back to the
 view for display.  I certainly can do that by manipulating the dict's and 
 slamming them together - but is there a way to return multiple dicts as in 
 regular python?  When I tried the python way or returning multiple dicts 
 the server just couldn't return anything (even an error) - I just got a 303.

 2) I currently have information pulling from a collection of documents 
 called a cartulary (long story on that project).  So when I select from 
 default/index the name
 of a collection I go from:
 http://127.0.0.1:8000/deeds/default/index
 to
 http://127.0.0.1:8000/deeds/default/cartulary/0001

 As expected, where 0001 is the identifier for the cartulary.

 Now, on that page is a list of documents.  I would like to have the 
 situation where if the user selects a document id, the system displays a 
 page of the document at
 the URL:
 http://127.0.0.1:8000/deeds/default/cartulary/0001/document/1

 Where 1 is the id of the document in the collection.  How is the best way 
 to do this?  Right now I have it directing to /default/documents/1 through 
 the default controller and that is okay - but not quite what I want.

 3) I teach my students test driven development.  Before I start diving 
 into it myself - is there anything built into Web2Py that I've missed for 
 doing test driven development or the related behaviour driven development?  

 Cheers
 Chris


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie Web2Py Questions

2014-05-18 Thread Anthony


 2) I currently have information pulling from a collection of documents 
 called a cartulary (long story on that project).  So when I select from 
 default/index the name
 of a collection I go from:
 http://127.0.0.1:8000/deeds/default/index
 to
 http://127.0.0.1:8000/deeds/default/cartulary/0001

 As expected, where 0001 is the identifier for the cartulary.

 Now, on that page is a list of documents.  I would like to have the 
 situation where if the user selects a document id, the system displays a 
 page of the document at
 the URL:
 http://127.0.0.1:8000/deeds/default/cartulary/0001/document/1

 Where 1 is the id of the document in the collection.  How is the best way 
 to do this?  Right now I have it directing to /default/documents/1 through 
 the default controller and that is okay - but not quite what I want.


In the cartulary action, just include some logic to check request.args, and 
return different content depending on the args:

def cartulary():
if request.args(1) == 'document':
doc_id = request.args(2)
[return document doc_id from cartulary request.args(0)]
else:
[return list of documents for cartulary request.args(0)]

3) I teach my students test driven development.  Before I start diving into 
 it myself - is there anything built into Web2Py that I've missed for doing 
 test driven development or the related behaviour driven development? 


In addition to what Massimo pointed out, have a look at 
https://github.com/viniciusban/web2py.test and 
https://github.com/niphlod/welcome_augmented.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie - SQLFORM ordering of reference fields

2014-04-25 Thread M Bailey


On Thursday, 24 April 2014 14:05:45 UTC+1, Massimo Di Pierro wrote:

 db.search_form.pet_type_ref.requires = 
 IS_IN_DB(db,'pet_type',orderby=db.pet_type.description)

 OR this may work too:

 db.search_form.pet_type_ref.requires.orderby = db.pet_type.description 



Massimo thank you, that second option you suggested is ideal

Thanks for a great framework
Mark

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie - SQLFORM ordering of reference fields

2014-04-24 Thread Massimo Di Pierro
db.search_form.pet_type_ref.requires = 
IS_IN_DB(db,'pet_type',orderby=db.pet_type.description)

OR this may work too:

db.search_form.pet_type_ref.requires.orderby = db.pet_type.description 

On Thursday, 24 April 2014 07:31:40 UTC-5, M Bailey wrote:

 I'm trying to migrate a django project to web2py. I have defined a search 
 form with selectoption fields populated from the database and using 
 code similar to below, but I can't see a way of changing the ordering of 
 the SQLFORM fields:

 db.define_table('pet_type',
 Field('description', 'string', required=True, notnull=True, length=75),
 format = '%(description)s')

 db.define_table('colour_type',
 Field('description', 'string', required=True, notnull=True, length=75),
 format = '%(description)s')


 db.define_table('search_form',
 Field('pet_type_ref', 'reference pet_type', label='Pet'),
 Field('colour_type_ref', 'reference colour_type', label='Pet colour'))

 In index controller:
 form = SQLFORM(db.search_form)
 return dict(form=form)

 In the view:
 {{=form}}


 In the admin section, I add some pets into the pet_type table but not in 
 alphabetical order, e.g. Dog, Budgie, Cat

 All works brilliantly in the view with select controls being used for 
 the reference fields. 

 However I can't see a way of changing the ordering of the pets for the 
 select. Currently it defaults to pet_type.description ASC but how would I 
 change it to the pet_type.id so that the records are displayed in the 
 order they are inserted?

 Thanks for any advice
 Mark



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie print question

2014-04-18 Thread jimbo
Dave S, followed you instructions and added that at the end of the 
bootstrap css file, worked a treat thanks!

On Thursday, 17 April 2014 11:25:14 UTC+1, jimbo wrote:

 Right, I have made a simple database which works well and looks nice on 
 screen. That is in 'edit' everything looks as it should, everything in nice 
 neat boxes and that is how I would like it to print.

 However when I print the page a lot of other stuff appears which I gather 
 are link details, a Google lead me to believe that this is caused by some 
 code in the css of web2py. I have looked through the css but can't see 
 which bit I could alter/remove.


 Any ideas, explained simply please?

 Thanks, Jimmy


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie print question

2014-04-17 Thread LightDot
I think there is a bit of vocabulary mismatch happening here. I assume you, 
by print, mean displaying generated html in the browser?

In that case, please be more specific about what exactly you want removed 
or altered. Show us your code or a screenshot and state *exactly* what's 
the issue.

Regards

On Thursday, April 17, 2014 12:25:14 PM UTC+2, jimbo wrote:

 Right, I have made a simple database which works well and looks nice on 
 screen. That is in 'edit' everything looks as it should, everything in nice 
 neat boxes and that is how I would like it to print.

 However when I print the page a lot of other stuff appears which I gather 
 are link details, a Google lead me to believe that this is caused by some 
 code in the css of web2py. I have looked through the css but can't see 
 which bit I could alter/remove.


 Any ideas, explained simply please?

 Thanks, Jimmy


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie print question

2014-04-17 Thread jimbo
Sorry, the page displays on screen fine, it is when I send it to the 
printer that the extra 'garbage' appears.

Thanks.

On Thursday, 17 April 2014 11:57:48 UTC+1, LightDot wrote:

 I think there is a bit of vocabulary mismatch happening here. I assume 
 you, by print, mean displaying generated html in the browser?

 In that case, please be more specific about what exactly you want removed 
 or altered. Show us your code or a screenshot and state *exactly* what's 
 the issue.

 Regards

 On Thursday, April 17, 2014 12:25:14 PM UTC+2, jimbo wrote:

 Right, I have made a simple database which works well and looks nice on 
 screen. That is in 'edit' everything looks as it should, everything in nice 
 neat boxes and that is how I would like it to print.

 However when I print the page a lot of other stuff appears which I gather 
 are link details, a Google lead me to believe that this is caused by some 
 code in the css of web2py. I have looked through the css but can't see 
 which bit I could alter/remove.


 Any ideas, explained simply please?

 Thanks, Jimmy



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie print question

2014-04-17 Thread Anthony
Bootstrap includes some @media print CSS rules, one of which displays the 
href of links right after the link (this is in bootstrap.min.css). See 
http://drupal.stackexchange.com/questions/59900/how-to-get-rid-of-added-urls-when-printing-a-bootstrap-themed-page.
 
If you'd like, you can go to http://getbootstrap.com/customize/ and 
generate a custom Bootstrap file that excludes the print media styles.

Anthony

On Thursday, April 17, 2014 6:25:14 AM UTC-4, jimbo wrote:

 Right, I have made a simple database which works well and looks nice on 
 screen. That is in 'edit' everything looks as it should, everything in nice 
 neat boxes and that is how I would like it to print.

 However when I print the page a lot of other stuff appears which I gather 
 are link details, a Google lead me to believe that this is caused by some 
 code in the css of web2py. I have looked through the css but can't see 
 which bit I could alter/remove.


 Any ideas, explained simply please?

 Thanks, Jimmy


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie print question

2014-04-17 Thread jimbo
Cheers Anthony, will have a go at that. Can I just comment out or remove 
those lines. Thanks Jimmy.

On Thursday, 17 April 2014 11:25:14 UTC+1, jimbo wrote:

 Right, I have made a simple database which works well and looks nice on 
 screen. That is in 'edit' everything looks as it should, everything in nice 
 neat boxes and that is how I would like it to print.

 However when I print the page a lot of other stuff appears which I gather 
 are link details, a Google lead me to believe that this is caused by some 
 code in the css of web2py. I have looked through the css but can't see 
 which bit I could alter/remove.


 Any ideas, explained simply please?

 Thanks, Jimmy


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie print question

2014-04-17 Thread Anthony
Yes, you can just comment/remove those lines.

On Thursday, April 17, 2014 11:48:17 AM UTC-4, jimbo wrote:

 Cheers Anthony, will have a go at that. Can I just comment out or remove 
 those lines. Thanks Jimmy.

 On Thursday, 17 April 2014 11:25:14 UTC+1, jimbo wrote:

 Right, I have made a simple database which works well and looks nice on 
 screen. That is in 'edit' everything looks as it should, everything in nice 
 neat boxes and that is how I would like it to print.

 However when I print the page a lot of other stuff appears which I gather 
 are link details, a Google lead me to believe that this is caused by some 
 code in the css of web2py. I have looked through the css but can't see 
 which bit I could alter/remove.


 Any ideas, explained simply please?

 Thanks, Jimmy



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Newbie print question

2014-04-17 Thread Dave S


On Thursday, April 17, 2014 8:48:17 AM UTC-7, jimbo wrote:

 Cheers Anthony, will have a go at that. Can I just comment out or remove 
 those lines. Thanks Jimmy.


Been there, done that, got the turtleneck:
https://groups.google.com/d/msg/web2py/z_vjoBM9WlU/_3o3SBfnc7sJ

   :-)

/dps
 


 On Thursday, 17 April 2014 11:25:14 UTC+1, jimbo wrote:

 Right, I have made a simple database which works well and looks nice on 
 screen. That is in 'edit' everything looks as it should, everything in nice 
 neat boxes and that is how I would like it to print.

 However when I print the page a lot of other stuff appears which I gather 
 are link details, a Google lead me to believe that this is caused by some 
 code in the css of web2py. I have looked through the css but can't see 
 which bit I could alter/remove.


 Any ideas, explained simply please?

 Thanks, Jimmy



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: [newbie] example authorization

2013-06-04 Thread Anthony
The auth.login() action automatically verifies the login and logs the user 
in (which involves adding the user record to the user's session) -- you 
don't have to do any of that explicitly. If you want to redirect to a 
specific URL after login, you can set auth.settings.login_next to the 
desired URL. Another option is to use auth.settings.login_onaccept, which 
is a function that takes the login form object (after it has been 
processed).

Anthony

On Tuesday, June 4, 2013 1:13:47 PM UTC-4, lesssugar wrote:

 In my layoyt.html I have the following code

 {{=auth.login().update(_action=URL('default', 'login'), _name=
 'global_login')}}

 The login form takes user email and password. It generates correctly. 
 Let's assume there are test users in db.auth_user.

 I would be grateful if someone provided a short example of further login 
 implementation:
 1. validate the login data (is email in db? is password correct?)
 2. if data OK: redirect to a specific user profile


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: [newbie] example authorization

2013-06-04 Thread lesssugar
OK, I have this in my view:

{{if not auth.user:}}
{{auth.settings.login_next = URL('default', 'test')}}
{{=auth.login().update(_name='global_login')}}
a href=# id=pass_resetForgot password?/a
{{else:}}
a href={{=URL('default', 'user', args='logout')}} 
class=goldenLogout/a
{{pass}}

As you say, if login data are correct, user should be automatically logged 
in and [in this case] redirected to default/test.

But when I put (just to test) im my default.py:

@auth.requires_login()
def test():
return dict(message='you are logged in')

and then I try to log in with 100% correct data I am redirected to 
[appname]/#

So no redirection is taking place, neither is logging in (checked it: 
auth.user is False after submitting the form).

Any suggestions? I'm surely doing something wrong and it's supposed to be 
automatic and easy ;)




On Tuesday, June 4, 2013 7:47:41 PM UTC+2, Anthony wrote:

 The auth.login() action automatically verifies the login and logs the user 
 in (which involves adding the user record to the user's session) -- you 
 don't have to do any of that explicitly. If you want to redirect to a 
 specific URL after login, you can set auth.settings.login_next to the 
 desired URL. Another option is to use auth.settings.login_onaccept, which 
 is a function that takes the login form object (after it has been 
 processed).

 Anthony

 On Tuesday, June 4, 2013 1:13:47 PM UTC-4, lesssugar wrote:

 In my layoyt.html I have the following code

 {{=auth.login().update(_action=URL('default', 'login'), _name=
 'global_login')}}

 The login form takes user email and password. It generates correctly. 
 Let's assume there are test users in db.auth_user.

 I would be grateful if someone provided a short example of further login 
 implementation:
 1. validate the login data (is email in db? is password correct?)
 2. if data OK: redirect to a specific user profile



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: [newbie] example authorization

2013-06-04 Thread Anthony
You didn't update the action of the login form, so it's trying to post to 
the URL of the page it is on. Should be:

auth.login().update(_action=URL('default', 'user', args='login'), ...)

or whatever your login URL is.

Anthony

On Tuesday, June 4, 2013 6:33:28 PM UTC-4, lesssugar wrote:

 OK, I have this in my view:

 {{if not auth.user:}}
 {{auth.settings.login_next = URL('default', 'test')}}
 {{=auth.login().update(_name='global_login')}}
 a href=# id=pass_resetForgot password?/a
 {{else:}}
 a href={{=URL('default', 'user', args='logout')}} 
 class=goldenLogout/a
 {{pass}}

 As you say, if login data are correct, user should be automatically logged 
 in and [in this case] redirected to default/test.

 But when I put (just to test) im my default.py:

 @auth.requires_login()
 def test():
 return dict(message='you are logged in')

 and then I try to log in with 100% correct data I am redirected to 
 [appname]/#

 So no redirection is taking place, neither is logging in (checked it: 
 auth.user is False after submitting the form).

 Any suggestions? I'm surely doing something wrong and it's supposed to be 
 automatic and easy ;)




 On Tuesday, June 4, 2013 7:47:41 PM UTC+2, Anthony wrote:

 The auth.login() action automatically verifies the login and logs the 
 user in (which involves adding the user record to the user's session) -- 
 you don't have to do any of that explicitly. If you want to redirect to a 
 specific URL after login, you can set auth.settings.login_next to the 
 desired URL. Another option is to use auth.settings.login_onaccept, which 
 is a function that takes the login form object (after it has been 
 processed).

 Anthony

 On Tuesday, June 4, 2013 1:13:47 PM UTC-4, lesssugar wrote:

 In my layoyt.html I have the following code

 {{=auth.login().update(_action=URL('default', 'login'), _name=
 'global_login')}}

 The login form takes user email and password. It generates correctly. 
 Let's assume there are test users in db.auth_user.

 I would be grateful if someone provided a short example of further login 
 implementation:
 1. validate the login data (is email in db? is password correct?)
 2. if data OK: redirect to a specific user profile



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Newbie Tables Question

2013-04-17 Thread 黄祥
i think it can be achieve in the view part by jquery.

e.g. i assume you use sqlform.grid with the table food and have the table 
field food_type (requires=IS_IN_SET('Pizza', 'Steak')) and field 
specific_food
*default/food.html*
{{extend 'layout.html'}}

{{=grid}}

script
jQuery(document).ready(function(){
if(jQuery('#food_food_type').val() == 'Pizza'){
jQuery('#food_specific_food__row').show();
jQuery('#food_food_type').change(function(){
if(jQuery('#food_food_type').val() == 'Pizza')
jQuery('#food_specific_food__row').show();
else 
jQuery('#food_specific_food__row').hide();});}
else {
jQuery('#food_specific_food__row').hide();
jQuery('#food_food_type').change(function(){
if(jQuery('#food_food_type').val() == 'Pizza')
jQuery('#food_specific_food__row').show();
else 
jQuery('#food_specific_food__row').hide();});}
});
/script

hope this can help
best regards

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Newbie Tables Question

2013-04-17 Thread Anthony
On the client side, you can handle the UI changes using Javascript/Ajax. 
The problem is modeling the data in the DAL and the database. If there 
aren't too many distinct attributes across the types of items, you can use 
a single database table as usual, only populating the fields that are 
relevant for each given type. Another option might be a separate table for 
each type, again, if there is a relatively small fixed number of types. 
However, if there are a large number of types and/or attributes, and if you 
must be able to easily add more and more types/attributes over time 
(perhaps allowing users to do so directly), then you'll probably need a 
different modeling approach, such as the EAV 
modelhttp://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model.
 
web2py doesn't have any built-in facilities for defining and managing such 
a model, so you'd have to manually code the CRUD operations for such a 
model.

This kind of situation is actually better handled by a document-based 
datastore, such as MongoDB, which doesn't require a fixed schema for each 
document. The DAL does have an adapter for MongoDB, but it probably 
wouldn't be useful here because the DAL still expects a fixed schema. You 
would probably just have to use a native driver and queries with something 
like MongoDB.

Anthony

On Tuesday, April 16, 2013 7:34:40 PM UTC-4, Doug Girard wrote:

 I want to create a form which I can add multiple 'items' of different 
 'types' that have different 'attributes'

 For example, lets use two types of food, pizza and steak

 You would start by selecting the type of food. Say pizza

 Upon selecting this type you would get more form fields, specific to the 
 type chosen. Maybe,

 dough:
 cheese:
 sauce:
 topping:

 Where if you had chosen steak, you would get a different set of 
 attributes. Maybe,

 cut:
 rarity:

 etc..

 I hope I've made myself clear, I'm just a beginner at python and am a bit 
 stuck. Thank You!



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: newbie question about digitally signed URLs using hmac

2013-04-10 Thread Massimo Di Pierro
No. If you chose to use the hmac key than you have to handle it.

Normally you use URL(user_signature=True). In this case the key is per user 
and per session and managed for you.

On Wednesday, 10 April 2013 07:36:14 UTC-5, Tim Richardson wrote:

 the book has an example to use hmac digitally signed URLs, where the KEY 
 seems to be a global variable, ie always the same.
 Is this a good idea? 


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: newbie question about digitally signed URLs using hmac

2013-04-10 Thread Tim Richardson
Ah, thank you. I now understand much more about userSignature.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: [Newbie]How to query and display table records defined in db.py in pages of auth.wiki()

2013-03-26 Thread Alan Etkin


 I've going through the web2py group trying various keywords but didn't 
 find a clear answer: in the pages of auth.wiki, how can I query and display 
 tables defined in db.py? Or, more importantly is this possible. Accordingly 
 to the introduction of auth.wiki it sounds like a Swiss knife that handles 
 a lot of needs, so I believe there is a simple way out. It would be 
 wonderful if it can be achieved with Markmin just embedding youtube video.


AFAIK, there's no support for simple db queries within markmin code. This 
can be achieved by using custom markup and using the extra MARKMIN function 
argument as documented in the book (in The Views), but it would require 
building a custom wiki without the auth.wiki shortcut, and overriding the 
class markmin parser or a similar workaround.

I think this will be suported after adding the wiki settings feature, as 
noted in another post (in roadmap).

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: [Newbie]How to query and display table records defined in db.py in pages of auth.wiki()

2013-03-26 Thread Niphlod
though the current recommended way is to code such views on a different 
controller and embed those views as components 
http://web2py.com/books/default/chapter/29/03?search=wiki#Components

On Tuesday, March 26, 2013 4:40:17 PM UTC+1, Alan Etkin wrote:

 I've going through the web2py group trying various keywords but didn't 
 find a clear answer: in the pages of auth.wiki, how can I query and display 
 tables defined in db.py? Or, more importantly is this possible. Accordingly 
 to the introduction of auth.wiki it sounds like a Swiss knife that handles 
 a lot of needs, so I believe there is a simple way out. It would be 
 wonderful if it can be achieved with Markmin just embedding youtube video.


 AFAIK, there's no support for simple db queries within markmin code. This 
 can be achieved by using custom markup and using the extra MARKMIN function 
 argument as documented in the book (in The Views), but it would require 
 building a custom wiki without the auth.wiki shortcut, and overriding the 
 class markmin parser or a similar workaround.

 I think this will be suported after adding the wiki settings feature, as 
 noted in another post (in roadmap).



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: [Newbie]How to query and display table records defined in db.py in pages of auth.wiki()

2013-03-26 Thread Spring
Thanks for explaining. 

在 2013年3月26日星期二UTC+8下午10时33分05秒,Spring写道:

 Hi there,

 I've going through the web2py group trying various keywords but didn't 
 find a clear answer: in the pages of auth.wiki, how can I query and display 
 tables defined in db.py? Or, more importantly is this possible. Accordingly 
 to the introduction of auth.wiki it sounds like a Swiss knife that handles 
 a lot of needs, so I believe there is a simple way out. It would be 
 wonderful if it can be achieved with Markmin just embedding youtube video.

 Any reply appreciated.

 Spring


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Newbie: Cascading deletes with SQLFORM.grid and GAE

2012-11-27 Thread howesc
Julian,

can you add logging to your delete_linked method to prove to yourself that 
it is being called, and that it is not throwing an exception?  that will 
help us track down where it's gone astray

thanks!

cfh

On Sunday, November 25, 2012 5:43:16 PM UTC-8, Julian Sanchez wrote:

 Oh, I see.  I thought that were you mentioned logs you were referring to 
 the built-in logs inside web2py (I assume there are some?).  As far as my 
 'test app' is concerned all there is is the code I posted a couple of posts 
 ago.  I also added these controllers for testing the deletion of records:

 def phones():
 form = SQLFORM.grid(query=(db.phone.id  0))
 return dict(form=form)
 
 def carriers():
 form = SQLFORM.grid(query=(db.carrier.id  0))
 return dict(form=form)
 
 def manufacturers():
 form = SQLFORM.grid(query=(db.manufacturer.id  0))
 return dict(form=form)


 All I do is invoke those controllers, add a couple of test entries, and 
 then delete a carrier that is being referenced by a couple of phones.  With 
 the _before_delete even nothing gets deleted and nothing special is shown 
 in the GAE console.  That's what puzzling me.



 On Sunday, November 25, 2012 12:13:41 AM UTC-6, howesc wrote:

 honestly, i'm not smart enough to use logging.conf.  i'm not sure how 
 much of it is GAE overriding things, and how much of it is my inability to 
 read the docs and understand how it works!  anyhow, i don't have a 
 logging.conf in my GAE setups, but i use logging extensively and it all 
 seems to show up in the GAE console logs just fine.

 if you have no logging.conf and you have logging.info statements in your 
 code, can you find the messages in your logs?

 cfh

 On Saturday, November 24, 2012 5:29:41 AM UTC-8, Julian Sanchez wrote:

 Are there any specific things I need to do to enable logging under GAE? 
  This is what I did:

- renamed the logging.example.conf file to logging.conf
- added an entry for the test app I created above
- removed all references to all handlers except consoleHandler

 Any page I request gives me an IOError: invalid mode: a in the GAE 
 logging console.  If I renamed the logging file back to 
 logging.example.conf then I can request pages and run the app just fine. 

 On Friday, November 23, 2012 7:47:26 PM UTC-6, howesc wrote:

 can you add some logging in and let us know if there are exceptions?

 about the delete limitations - web2py iterates over the set of items to 
 delete and deletes them (the version in trunk is improved over the last 
 release, but both still work).  if the set of items to delete is large the 
 query to get the items to delete may take too long and timeout.  in the 
 latest released version it actually can timeout before any rows are 
 deleted.  in the trunk version it will delete at least some rows before 
 the 
 first timeout (in most cases), so over a series of retries all the rows 
 will be deleted.  This behavior is all to deal with how GAE implements 
 delete, so it is GAE specific.

 cfh


 On Wednesday, November 21, 2012 5:04:32 PM UTC-8, Julian Sanchez wrote:

 Massimo,

 I created a small test to try your function:

 db.define_table('carrier',
 Field('name', type='string'),
 Field('description', type='string')
)

 db.carrier.name.requires = IS_NOT_IN_DB(db(db.carrier.id  0), '
 carrier.name')   

 db.define_table('manufacturer',
 Field('name', type='string'),
 Field('country', type='string')
)


 db.manufacturer.name.requires = IS_NOT_IN_DB(db(db.manufacturer.id  0
 ), 'manufacturer.name')  
   
 db.define_table('phone',
 Field('model', type='string'),
 Field('manufacturer', db.manufacturer),
 Field('carrier', db.carrier)
)

 db.phone.manufacturer.requires = IS_IN_DB(db, 'manufacturer.id', 
 '%(name)s')
 db.phone.carrier.requires = IS_IN_DB(db, 'carrier.id', '%(name)s')




 def delete_linked(query, table=db.carrier):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()


 db.carrier._before_delete.append(delete_linked)

 I can create an Apple iPhone on Verizon and an Apple iPhone on Sprint. 
  If I run this under sqlite and I delete the carrier 'Sprint' I see one 
 of 
 the phones deleted as well (even without the '_before_delete' event which 
 makes sense since that's the default behavior). 
 However if I run this under GAE:

- Without the '_before_delete' event the carrier 'Sprint' is 
deleted but not the phone.  This is expected since cascading doesn't 
 work.
- With the '_before_delete' event (code just as above) *nothing*gets 
 deleted, not even the carrier.  I can see it disappear from the list 
but if I refresh the 

[web2py] Re: Newbie: Cascading deletes with SQLFORM.grid and GAE

2012-11-27 Thread Julian Sanchez
Aha!!  I don't know how I missed that before but indeed the event was 
throwing an exception and GAE kept on going on its merry way.  Found a 
couple of things I was doing wrong.  The delete event method takes only one 
parameter (the query) and once you get the query you can do a straight 
'select()' from that and figure out which ID's are being deleted.

Thanks so much for the help!!  I appreciate the guidance and coaching.

On Tuesday, November 27, 2012 10:39:54 AM UTC-6, howesc wrote:

 Julian,

 can you add logging to your delete_linked method to prove to yourself that 
 it is being called, and that it is not throwing an exception?  that will 
 help us track down where it's gone astray

 thanks!

 cfh

 On Sunday, November 25, 2012 5:43:16 PM UTC-8, Julian Sanchez wrote:

 Oh, I see.  I thought that were you mentioned logs you were referring to 
 the built-in logs inside web2py (I assume there are some?).  As far as my 
 'test app' is concerned all there is is the code I posted a couple of posts 
 ago.  I also added these controllers for testing the deletion of records:

 def phones():
 form = SQLFORM.grid(query=(db.phone.id  0))
 return dict(form=form)
 
 def carriers():
 form = SQLFORM.grid(query=(db.carrier.id  0))
 return dict(form=form)
 
 def manufacturers():
 form = SQLFORM.grid(query=(db.manufacturer.id  0))
 return dict(form=form)


 All I do is invoke those controllers, add a couple of test entries, and 
 then delete a carrier that is being referenced by a couple of phones.  With 
 the _before_delete even nothing gets deleted and nothing special is shown 
 in the GAE console.  That's what puzzling me.



 On Sunday, November 25, 2012 12:13:41 AM UTC-6, howesc wrote:

 honestly, i'm not smart enough to use logging.conf.  i'm not sure how 
 much of it is GAE overriding things, and how much of it is my inability to 
 read the docs and understand how it works!  anyhow, i don't have a 
 logging.conf in my GAE setups, but i use logging extensively and it all 
 seems to show up in the GAE console logs just fine.

 if you have no logging.conf and you have logging.info statements in 
 your code, can you find the messages in your logs?

 cfh

 On Saturday, November 24, 2012 5:29:41 AM UTC-8, Julian Sanchez wrote:

 Are there any specific things I need to do to enable logging under GAE? 
  This is what I did:

- renamed the logging.example.conf file to logging.conf
- added an entry for the test app I created above
- removed all references to all handlers except consoleHandler

 Any page I request gives me an IOError: invalid mode: a in the GAE 
 logging console.  If I renamed the logging file back to 
 logging.example.conf then I can request pages and run the app just fine. 

 On Friday, November 23, 2012 7:47:26 PM UTC-6, howesc wrote:

 can you add some logging in and let us know if there are exceptions?

 about the delete limitations - web2py iterates over the set of items 
 to delete and deletes them (the version in trunk is improved over the 
 last 
 release, but both still work).  if the set of items to delete is large 
 the 
 query to get the items to delete may take too long and timeout.  in the 
 latest released version it actually can timeout before any rows are 
 deleted.  in the trunk version it will delete at least some rows before 
 the 
 first timeout (in most cases), so over a series of retries all the rows 
 will be deleted.  This behavior is all to deal with how GAE implements 
 delete, so it is GAE specific.

 cfh


 On Wednesday, November 21, 2012 5:04:32 PM UTC-8, Julian Sanchez wrote:

 Massimo,

 I created a small test to try your function:

 db.define_table('carrier',
 Field('name', type='string'),
 Field('description', type='string')
)

 db.carrier.name.requires = IS_NOT_IN_DB(db(db.carrier.id  0), '
 carrier.name')   

 db.define_table('manufacturer',
 Field('name', type='string'),
 Field('country', type='string')
)


 db.manufacturer.name.requires = IS_NOT_IN_DB(db(db.manufacturer.id  
 0), 'manufacturer.name')  
   
 db.define_table('phone',
 Field('model', type='string'),
 Field('manufacturer', db.manufacturer),
 Field('carrier', db.carrier)
)

 db.phone.manufacturer.requires = IS_IN_DB(db, 'manufacturer.id', 
 '%(name)s')
 db.phone.carrier.requires = IS_IN_DB(db, 'carrier.id', '%(name)s')




 def delete_linked(query, table=db.carrier):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()


 db.carrier._before_delete.append(delete_linked)

 I can create an Apple iPhone on Verizon and an Apple iPhone on 
 Sprint.  If I run this under sqlite and I delete the carrier 

[web2py] Re: Newbie: Cascading deletes with SQLFORM.grid and GAE

2012-11-25 Thread Julian Sanchez
Oh, I see.  I thought that were you mentioned logs you were referring to 
the built-in logs inside web2py (I assume there are some?).  As far as my 
'test app' is concerned all there is is the code I posted a couple of posts 
ago.  I also added these controllers for testing the deletion of records:

def phones():
form = SQLFORM.grid(query=(db.phone.id  0))
return dict(form=form)

def carriers():
form = SQLFORM.grid(query=(db.carrier.id  0))
return dict(form=form)

def manufacturers():
form = SQLFORM.grid(query=(db.manufacturer.id  0))
return dict(form=form)


All I do is invoke those controllers, add a couple of test entries, and 
then delete a carrier that is being referenced by a couple of phones.  With 
the _before_delete even nothing gets deleted and nothing special is shown 
in the GAE console.  That's what puzzling me.



On Sunday, November 25, 2012 12:13:41 AM UTC-6, howesc wrote:

 honestly, i'm not smart enough to use logging.conf.  i'm not sure how much 
 of it is GAE overriding things, and how much of it is my inability to read 
 the docs and understand how it works!  anyhow, i don't have a logging.conf 
 in my GAE setups, but i use logging extensively and it all seems to show up 
 in the GAE console logs just fine.

 if you have no logging.conf and you have logging.info statements in your 
 code, can you find the messages in your logs?

 cfh

 On Saturday, November 24, 2012 5:29:41 AM UTC-8, Julian Sanchez wrote:

 Are there any specific things I need to do to enable logging under GAE? 
  This is what I did:

- renamed the logging.example.conf file to logging.conf
- added an entry for the test app I created above
- removed all references to all handlers except consoleHandler

 Any page I request gives me an IOError: invalid mode: a in the GAE 
 logging console.  If I renamed the logging file back to 
 logging.example.conf then I can request pages and run the app just fine. 

 On Friday, November 23, 2012 7:47:26 PM UTC-6, howesc wrote:

 can you add some logging in and let us know if there are exceptions?

 about the delete limitations - web2py iterates over the set of items to 
 delete and deletes them (the version in trunk is improved over the last 
 release, but both still work).  if the set of items to delete is large the 
 query to get the items to delete may take too long and timeout.  in the 
 latest released version it actually can timeout before any rows are 
 deleted.  in the trunk version it will delete at least some rows before the 
 first timeout (in most cases), so over a series of retries all the rows 
 will be deleted.  This behavior is all to deal with how GAE implements 
 delete, so it is GAE specific.

 cfh


 On Wednesday, November 21, 2012 5:04:32 PM UTC-8, Julian Sanchez wrote:

 Massimo,

 I created a small test to try your function:

 db.define_table('carrier',
 Field('name', type='string'),
 Field('description', type='string')
)

 db.carrier.name.requires = IS_NOT_IN_DB(db(db.carrier.id  0), '
 carrier.name')   

 db.define_table('manufacturer',
 Field('name', type='string'),
 Field('country', type='string')
)


 db.manufacturer.name.requires = IS_NOT_IN_DB(db(db.manufacturer.id  0
 ), 'manufacturer.name')  
   
 db.define_table('phone',
 Field('model', type='string'),
 Field('manufacturer', db.manufacturer),
 Field('carrier', db.carrier)
)

 db.phone.manufacturer.requires = IS_IN_DB(db, 'manufacturer.id', 
 '%(name)s')
 db.phone.carrier.requires = IS_IN_DB(db, 'carrier.id', '%(name)s')




 def delete_linked(query, table=db.carrier):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()


 db.carrier._before_delete.append(delete_linked)

 I can create an Apple iPhone on Verizon and an Apple iPhone on Sprint. 
  If I run this under sqlite and I delete the carrier 'Sprint' I see one of 
 the phones deleted as well (even without the '_before_delete' event which 
 makes sense since that's the default behavior). 
 However if I run this under GAE:

- Without the '_before_delete' event the carrier 'Sprint' is 
deleted but not the phone.  This is expected since cascading doesn't 
 work.
- With the '_before_delete' event (code just as above) *nothing*gets 
 deleted, not even the carrier.  I can see it disappear from the list 
but if I refresh the page it comes right back.  I can also verify the 
record is still there by looking at the GAE admin page (Datastore 
 viewer). 
 Also, none of the phones are deleted either.

 Am I missing something?

 Also, when you say that if I delete too many records the operation may 
 fail midway... is that a GAE 

[web2py] Re: Newbie: Cascading deletes with SQLFORM.grid and GAE

2012-11-24 Thread Julian Sanchez
Are there any specific things I need to do to enable logging under GAE? 
 This is what I did:

   - renamed the logging.example.conf file to logging.conf
   - added an entry for the test app I created above
   - removed all references to all handlers except consoleHandler

Any page I request gives me an IOError: invalid mode: a in the GAE 
logging console.  If I renamed the logging file back to 
logging.example.conf then I can request pages and run the app just fine. 

On Friday, November 23, 2012 7:47:26 PM UTC-6, howesc wrote:

 can you add some logging in and let us know if there are exceptions?

 about the delete limitations - web2py iterates over the set of items to 
 delete and deletes them (the version in trunk is improved over the last 
 release, but both still work).  if the set of items to delete is large the 
 query to get the items to delete may take too long and timeout.  in the 
 latest released version it actually can timeout before any rows are 
 deleted.  in the trunk version it will delete at least some rows before the 
 first timeout (in most cases), so over a series of retries all the rows 
 will be deleted.  This behavior is all to deal with how GAE implements 
 delete, so it is GAE specific.

 cfh


 On Wednesday, November 21, 2012 5:04:32 PM UTC-8, Julian Sanchez wrote:

 Massimo,

 I created a small test to try your function:

 db.define_table('carrier',
 Field('name', type='string'),
 Field('description', type='string')
)

 db.carrier.name.requires = IS_NOT_IN_DB(db(db.carrier.id  0), '
 carrier.name')   

 db.define_table('manufacturer',
 Field('name', type='string'),
 Field('country', type='string')
)


 db.manufacturer.name.requires = IS_NOT_IN_DB(db(db.manufacturer.id  0), 
 'manufacturer.name')  
   
 db.define_table('phone',
 Field('model', type='string'),
 Field('manufacturer', db.manufacturer),
 Field('carrier', db.carrier)
)

 db.phone.manufacturer.requires = IS_IN_DB(db, 'manufacturer.id', 
 '%(name)s')
 db.phone.carrier.requires = IS_IN_DB(db, 'carrier.id', '%(name)s')




 def delete_linked(query, table=db.carrier):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()


 db.carrier._before_delete.append(delete_linked)

 I can create an Apple iPhone on Verizon and an Apple iPhone on Sprint. 
  If I run this under sqlite and I delete the carrier 'Sprint' I see one of 
 the phones deleted as well (even without the '_before_delete' event which 
 makes sense since that's the default behavior). 
 However if I run this under GAE:

- Without the '_before_delete' event the carrier 'Sprint' is deleted 
but not the phone.  This is expected since cascading doesn't work.
- With the '_before_delete' event (code just as above) *nothing* gets 
deleted, not even the carrier.  I can see it disappear from the list but 
 if 
I refresh the page it comes right back.  I can also verify the record is 
still there by looking at the GAE admin page (Datastore viewer).  Also, 
none of the phones are deleted either.

 Am I missing something?

 Also, when you say that if I delete too many records the operation may 
 fail midway... is that a GAE limitation?  Is the 1000 record limit I've 
 read somewhere about?

 Thanks,
 Julian

 On Saturday, November 17, 2012 1:06:01 PM UTC-6, Massimo Di Pierro wrote:

 You can try something like

 def delete_linked(query, table=table):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()

 db.table._before_delete.append(delete_linked)

 but you will run into consistency problems. If there are too many 
 records this may fail midway.

 On Wednesday, 14 November 2012 19:07:02 UTC-6, Julian Sanchez wrote:

 Hi Everyone!!  Long time lurker  first time posting...

 I am working on a simple application that I intend to deploy in GAE.  I 
 have a few tables with fields that reference other tables which by default 
 enables the ondelete=CASCADE behavior.  This works fine when I run the app 
 locally using sqlite as the database.
 I believe GAE doesn't support cascading deletes natively. 
 I presume web2py doesn't support cascading deletes when running under 
 GAE because I don't see that happening.  When I delete a row (rendered 
 through SQLFORM.grid) only that row is deleted an all dependent tables 
 remain untouched.

 The problem I have is that I can't find a way for me to implement the 
 cascading behavior manually.  I added a 'ondelete=mydelete' event for the 
 SQLFORM.grid where I do the manual delete of the dependent tables and 
 commit in the database, but that doesn't seem to work 

[web2py] Re: Newbie: Cascading deletes with SQLFORM.grid and GAE

2012-11-24 Thread howesc
honestly, i'm not smart enough to use logging.conf.  i'm not sure how much 
of it is GAE overriding things, and how much of it is my inability to read 
the docs and understand how it works!  anyhow, i don't have a logging.conf 
in my GAE setups, but i use logging extensively and it all seems to show up 
in the GAE console logs just fine.

if you have no logging.conf and you have logging.info statements in your 
code, can you find the messages in your logs?

cfh

On Saturday, November 24, 2012 5:29:41 AM UTC-8, Julian Sanchez wrote:

 Are there any specific things I need to do to enable logging under GAE? 
  This is what I did:

- renamed the logging.example.conf file to logging.conf
- added an entry for the test app I created above
- removed all references to all handlers except consoleHandler

 Any page I request gives me an IOError: invalid mode: a in the GAE 
 logging console.  If I renamed the logging file back to 
 logging.example.conf then I can request pages and run the app just fine. 

 On Friday, November 23, 2012 7:47:26 PM UTC-6, howesc wrote:

 can you add some logging in and let us know if there are exceptions?

 about the delete limitations - web2py iterates over the set of items to 
 delete and deletes them (the version in trunk is improved over the last 
 release, but both still work).  if the set of items to delete is large the 
 query to get the items to delete may take too long and timeout.  in the 
 latest released version it actually can timeout before any rows are 
 deleted.  in the trunk version it will delete at least some rows before the 
 first timeout (in most cases), so over a series of retries all the rows 
 will be deleted.  This behavior is all to deal with how GAE implements 
 delete, so it is GAE specific.

 cfh


 On Wednesday, November 21, 2012 5:04:32 PM UTC-8, Julian Sanchez wrote:

 Massimo,

 I created a small test to try your function:

 db.define_table('carrier',
 Field('name', type='string'),
 Field('description', type='string')
)

 db.carrier.name.requires = IS_NOT_IN_DB(db(db.carrier.id  0), '
 carrier.name')   

 db.define_table('manufacturer',
 Field('name', type='string'),
 Field('country', type='string')
)


 db.manufacturer.name.requires = IS_NOT_IN_DB(db(db.manufacturer.id  0), 
 'manufacturer.name')  
   
 db.define_table('phone',
 Field('model', type='string'),
 Field('manufacturer', db.manufacturer),
 Field('carrier', db.carrier)
)

 db.phone.manufacturer.requires = IS_IN_DB(db, 'manufacturer.id', 
 '%(name)s')
 db.phone.carrier.requires = IS_IN_DB(db, 'carrier.id', '%(name)s')




 def delete_linked(query, table=db.carrier):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()


 db.carrier._before_delete.append(delete_linked)

 I can create an Apple iPhone on Verizon and an Apple iPhone on Sprint. 
  If I run this under sqlite and I delete the carrier 'Sprint' I see one of 
 the phones deleted as well (even without the '_before_delete' event which 
 makes sense since that's the default behavior). 
 However if I run this under GAE:

- Without the '_before_delete' event the carrier 'Sprint' is deleted 
but not the phone.  This is expected since cascading doesn't work.
- With the '_before_delete' event (code just as above) *nothing*gets 
 deleted, not even the carrier.  I can see it disappear from the list 
but if I refresh the page it comes right back.  I can also verify the 
record is still there by looking at the GAE admin page (Datastore 
 viewer). 
 Also, none of the phones are deleted either.

 Am I missing something?

 Also, when you say that if I delete too many records the operation may 
 fail midway... is that a GAE limitation?  Is the 1000 record limit I've 
 read somewhere about?

 Thanks,
 Julian

 On Saturday, November 17, 2012 1:06:01 PM UTC-6, Massimo Di Pierro wrote:

 You can try something like

 def delete_linked(query, table=table):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()

 db.table._before_delete.append(delete_linked)

 but you will run into consistency problems. If there are too many 
 records this may fail midway.

 On Wednesday, 14 November 2012 19:07:02 UTC-6, Julian Sanchez wrote:

 Hi Everyone!!  Long time lurker  first time posting...

 I am working on a simple application that I intend to deploy in GAE. 
  I have a few tables with fields that reference other tables which by 
 default enables the ondelete=CASCADE behavior.  This works fine when I 
 run 
 the app locally using sqlite as the database.
 I believe GAE doesn't 

[web2py] Re: Newbie: Cascading deletes with SQLFORM.grid and GAE

2012-11-23 Thread howesc
can you add some logging in and let us know if there are exceptions?

about the delete limitations - web2py iterates over the set of items to 
delete and deletes them (the version in trunk is improved over the last 
release, but both still work).  if the set of items to delete is large the 
query to get the items to delete may take too long and timeout.  in the 
latest released version it actually can timeout before any rows are 
deleted.  in the trunk version it will delete at least some rows before the 
first timeout (in most cases), so over a series of retries all the rows 
will be deleted.  This behavior is all to deal with how GAE implements 
delete, so it is GAE specific.

cfh


On Wednesday, November 21, 2012 5:04:32 PM UTC-8, Julian Sanchez wrote:

 Massimo,

 I created a small test to try your function:

 db.define_table('carrier',
 Field('name', type='string'),
 Field('description', type='string')
)

 db.carrier.name.requires = IS_NOT_IN_DB(db(db.carrier.id  0), '
 carrier.name')   

 db.define_table('manufacturer',
 Field('name', type='string'),
 Field('country', type='string')
)


 db.manufacturer.name.requires = IS_NOT_IN_DB(db(db.manufacturer.id  0), '
 manufacturer.name')  
   
 db.define_table('phone',
 Field('model', type='string'),
 Field('manufacturer', db.manufacturer),
 Field('carrier', db.carrier)
)

 db.phone.manufacturer.requires = IS_IN_DB(db, 'manufacturer.id', 
 '%(name)s')
 db.phone.carrier.requires = IS_IN_DB(db, 'carrier.id', '%(name)s')




 def delete_linked(query, table=db.carrier):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()


 db.carrier._before_delete.append(delete_linked)

 I can create an Apple iPhone on Verizon and an Apple iPhone on Sprint.  If 
 I run this under sqlite and I delete the carrier 'Sprint' I see one of the 
 phones deleted as well (even without the '_before_delete' event which makes 
 sense since that's the default behavior). 
 However if I run this under GAE:

- Without the '_before_delete' event the carrier 'Sprint' is deleted 
but not the phone.  This is expected since cascading doesn't work.
- With the '_before_delete' event (code just as above) *nothing* gets 
deleted, not even the carrier.  I can see it disappear from the list but 
 if 
I refresh the page it comes right back.  I can also verify the record is 
still there by looking at the GAE admin page (Datastore viewer).  Also, 
none of the phones are deleted either.

 Am I missing something?

 Also, when you say that if I delete too many records the operation may 
 fail midway... is that a GAE limitation?  Is the 1000 record limit I've 
 read somewhere about?

 Thanks,
 Julian

 On Saturday, November 17, 2012 1:06:01 PM UTC-6, Massimo Di Pierro wrote:

 You can try something like

 def delete_linked(query, table=table):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()

 db.table._before_delete.append(delete_linked)

 but you will run into consistency problems. If there are too many records 
 this may fail midway.

 On Wednesday, 14 November 2012 19:07:02 UTC-6, Julian Sanchez wrote:

 Hi Everyone!!  Long time lurker  first time posting...

 I am working on a simple application that I intend to deploy in GAE.  I 
 have a few tables with fields that reference other tables which by default 
 enables the ondelete=CASCADE behavior.  This works fine when I run the app 
 locally using sqlite as the database.
 I believe GAE doesn't support cascading deletes natively. 
 I presume web2py doesn't support cascading deletes when running under 
 GAE because I don't see that happening.  When I delete a row (rendered 
 through SQLFORM.grid) only that row is deleted an all dependent tables 
 remain untouched.

 The problem I have is that I can't find a way for me to implement the 
 cascading behavior manually.  I added a 'ondelete=mydelete' event for the 
 SQLFORM.grid where I do the manual delete of the dependent tables and 
 commit in the database, but that doesn't seem to work either.  I searched 
 through this forum but didn't find any suggestions either.  Any suggestions 
 as to what could I do to solve this??  Do I have to stay away from 
 SQLFORM.grid to avoid this problem?

 Many Thanks!!
 Julian

 I am using web2py Version 2.2.1 (2012-10-21 16:57:04) stable on OS X 
 Mountain Lion and GoogleAppEngineLauncher version 1.7.3 (1.7.3.333)



-- 





[web2py] Re: Newbie: Cascading deletes with SQLFORM.grid and GAE

2012-11-21 Thread Julian Sanchez
Massimo,

I created a small test to try your function:

db.define_table('carrier',
Field('name', type='string'),
Field('description', type='string')
   )
   
db.carrier.name.requires = IS_NOT_IN_DB(db(db.carrier.id  0), 
'carrier.name')   
   
db.define_table('manufacturer',
Field('name', type='string'),
Field('country', type='string')
   )


db.manufacturer.name.requires = IS_NOT_IN_DB(db(db.manufacturer.id  0), 
'manufacturer.name')  
  
db.define_table('phone',
Field('model', type='string'),
Field('manufacturer', db.manufacturer),
Field('carrier', db.carrier)
   )
   
db.phone.manufacturer.requires = IS_IN_DB(db, 'manufacturer.id', '%(name)s')
db.phone.carrier.requires = IS_IN_DB(db, 'carrier.id', '%(name)s')




def delete_linked(query, table=db.carrier):
ids = [t.id in db(query).select(db.table.id)]
for field in table._referenced_by:
 db(field._table._id.belongs(ids)).delete()


db.carrier._before_delete.append(delete_linked)

I can create an Apple iPhone on Verizon and an Apple iPhone on Sprint.  If 
I run this under sqlite and I delete the carrier 'Sprint' I see one of the 
phones deleted as well (even without the '_before_delete' event which makes 
sense since that's the default behavior). 
However if I run this under GAE:

   - Without the '_before_delete' event the carrier 'Sprint' is deleted but 
   not the phone.  This is expected since cascading doesn't work.
   - With the '_before_delete' event (code just as above) *nothing* gets 
   deleted, not even the carrier.  I can see it disappear from the list but if 
   I refresh the page it comes right back.  I can also verify the record is 
   still there by looking at the GAE admin page (Datastore viewer).  Also, 
   none of the phones are deleted either.
   
Am I missing something?

Also, when you say that if I delete too many records the operation may fail 
midway... is that a GAE limitation?  Is the 1000 record limit I've read 
somewhere about?

Thanks,
Julian

On Saturday, November 17, 2012 1:06:01 PM UTC-6, Massimo Di Pierro wrote:

 You can try something like

 def delete_linked(query, table=table):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()

 db.table._before_delete.append(delete_linked)

 but you will run into consistency problems. If there are too many records 
 this may fail midway.

 On Wednesday, 14 November 2012 19:07:02 UTC-6, Julian Sanchez wrote:

 Hi Everyone!!  Long time lurker  first time posting...

 I am working on a simple application that I intend to deploy in GAE.  I 
 have a few tables with fields that reference other tables which by default 
 enables the ondelete=CASCADE behavior.  This works fine when I run the app 
 locally using sqlite as the database.
 I believe GAE doesn't support cascading deletes natively. 
 I presume web2py doesn't support cascading deletes when running under GAE 
 because I don't see that happening.  When I delete a row (rendered through 
 SQLFORM.grid) only that row is deleted an all dependent tables remain 
 untouched.

 The problem I have is that I can't find a way for me to implement the 
 cascading behavior manually.  I added a 'ondelete=mydelete' event for the 
 SQLFORM.grid where I do the manual delete of the dependent tables and 
 commit in the database, but that doesn't seem to work either.  I searched 
 through this forum but didn't find any suggestions either.  Any suggestions 
 as to what could I do to solve this??  Do I have to stay away from 
 SQLFORM.grid to avoid this problem?

 Many Thanks!!
 Julian

 I am using web2py Version 2.2.1 (2012-10-21 16:57:04) stable on OS X 
 Mountain Lion and GoogleAppEngineLauncher version 1.7.3 (1.7.3.333)



-- 





[web2py] Re: Newbie: Cascading deletes with SQLFORM.grid and GAE

2012-11-17 Thread Massimo Di Pierro
You can try something like

def delete_linked(query, table=table):
ids = [t.id in db(query).select(db.table.id)]
for field in table._referenced_by:
 db(field._table._id.belongs(ids)).delete()

db.table._before_delete.append(delete_linked)

but you will run into consistency problems. If there are too many records 
this may fail midway.

On Wednesday, 14 November 2012 19:07:02 UTC-6, Julian Sanchez wrote:

 Hi Everyone!!  Long time lurker  first time posting...

 I am working on a simple application that I intend to deploy in GAE.  I 
 have a few tables with fields that reference other tables which by default 
 enables the ondelete=CASCADE behavior.  This works fine when I run the app 
 locally using sqlite as the database.
 I believe GAE doesn't support cascading deletes natively. 
 I presume web2py doesn't support cascading deletes when running under GAE 
 because I don't see that happening.  When I delete a row (rendered through 
 SQLFORM.grid) only that row is deleted an all dependent tables remain 
 untouched.

 The problem I have is that I can't find a way for me to implement the 
 cascading behavior manually.  I added a 'ondelete=mydelete' event for the 
 SQLFORM.grid where I do the manual delete of the dependent tables and 
 commit in the database, but that doesn't seem to work either.  I searched 
 through this forum but didn't find any suggestions either.  Any suggestions 
 as to what could I do to solve this??  Do I have to stay away from 
 SQLFORM.grid to avoid this problem?

 Many Thanks!!
 Julian

 I am using web2py Version 2.2.1 (2012-10-21 16:57:04) stable on OS X 
 Mountain Lion and GoogleAppEngineLauncher version 1.7.3 (1.7.3.333)


-- 





[web2py] Re: NewBie Question about crud.create

2012-09-06 Thread tommasot
I need to verify if 'incorso' field is True for the new record 
created,after this check i need to set all other records in False,The 
'incorso 'Field' is the equivalent for the current year in English

Il giorno mercoledì 5 settembre 2012 18:34:48 UTC+2, Anthony ha scritto:

 Do you want to manipulate it (a) after submission but before validation 
 (use request.vars.incorso), (b) after validation but before the insert (use 
 crud.settings.create_onvalidation), or (c) after the record is inserted 
 (use crud.settings.create_onaccept).

 Anthony

 On Wednesday, September 5, 2012 11:09:41 AM UTC-4, tommasot wrote:

 I have the following code in the controller about record creation

 *form = crud.create(db.anno,next='list_anno')*

 This is the model,how you can see is very simple :)

 *db.define_table('anno',
 Field('descrizione'),
 Field('incorso','boolean'),format='%(descrizione)s')*

 Now i want to catch the 'incorso' value posted from the form and 
 manipulate the value if some condition is satisfied.

 The question is how can i intercept the value, i hope there is something 
 like form.field


 Thanks



-- 





[web2py] Re: NewBie Question about crud.create

2012-09-06 Thread tommasot


Il giorno mercoledì 5 settembre 2012 17:09:41 UTC+2, tommasot ha scritto:

 I have the following code in the controller about record creation

 *form = crud.create(db.anno,next='list_anno')*

 This is the model,how you can see is very simple :)

 *db.define_table('anno',
 Field('descrizione'),
 Field('incorso','boolean'),format='%(descrizione)s')*

 Now i want to catch the 'incorso' value posted from the form and 
 manipulate the value if some condition is satisfied.

 The question is how can i intercept the value, i hope there is something 
 like form.field


 Thanks




Thank you for the answers, i have solved with the following code



*def validate_anno(incorso,descrizione):
if request.vars.incorso == 'on':
anni = db(db.anno).select()
for anno in anni:
anno.update_record(incorso=False) *

*def create_anno():
form = 
crud.create(db.anno,next='list_anno',onvalidation=validate_anno(request.vars.incorso,request.vars.descrizione))
response.view = 'private/write_anno.html'
return dict(form=form,viewaction='create')*

And here the changes on the domain 

*db.define_table('anno',
Field('descrizione',unique=True),
Field('incorso','boolean'),format='%(descrizione)s')*


Web2Py the Best :)

-- 





[web2py] Re: NewBie Question about crud.create

2012-09-05 Thread Anthony
Do you want to manipulate it (a) after submission but before validation 
(use request.vars.incorso), (b) after validation but before the insert (use 
crud.settings.create_onvalidation), or (c) after the record is inserted 
(use crud.settings.create_onaccept).

Anthony

On Wednesday, September 5, 2012 11:09:41 AM UTC-4, tommasot wrote:

 I have the following code in the controller about record creation

 *form = crud.create(db.anno,next='list_anno')*

 This is the model,how you can see is very simple :)

 *db.define_table('anno',
 Field('descrizione'),
 Field('incorso','boolean'),format='%(descrizione)s')*

 Now i want to catch the 'incorso' value posted from the form and 
 manipulate the value if some condition is satisfied.

 The question is how can i intercept the value, i hope there is something 
 like form.field


 Thanks


-- 





[web2py] Re: Newbie: interactive monitoring of a scheduler job?

2012-07-24 Thread Niphlod
If you don't want your user to click somewhere every n seconds to see it, 
the only two ways are ajax (polling at n seconds interval the status) or 
websocket.

The easier way is monitoring with ajax calls.

You can find complete examples online. I'm sure that there are a lot of 
implementations, but I made an app using extensively the scheduler (and 
tested it throughly). You can find the code on 
https://github.com/niphlod/w2p_tvseries/ .
I'm using the periodicalupdater jquery plugin to ease off the cruft for 
start monitoring, poll every n seconds, stop when done thingy. 
NB: it could be a lot simpler

https://github.com/niphlod/w2p_tvseries/blob/master/views/manage/add.html 
(view)
 and 
https://github.com/niphlod/w2p_tvseries/blob/master/controllers/manage.py 
(controller)

The called action performs the task queueing and the monitoring all in one 
function.

Basically on the first click the task gets enqueued and a task_id is saved 
on the button itself (a neat jquery feature). The task_id is then sent on 
the subsequent request as an argument, the controller see it and instead of 
enqueuing another task it monitors the status.
A message is passed back, and it replaces the button content (from add 
series to working on it...).
Finally, if task is completed, a command is passed back to stop the 
refreshing of the button.
If you don't understand how this works feel free to ask.

BTW: the trunk scheduler will be the one included when web2py 2.0 will be 
released. Feel free to use it, but for monitoring purposes there should be 
no changes (i.e. watching for the scheduler_run record status or the 
scheduler_task status, if you're not using repeating tasks)



On Tuesday, July 24, 2012 5:07:22 PM UTC+2, Tim Richardson wrote:

 I'm using the 'experimental' scheduler with 1.99.7 . I know there are 
 posts encouraging us to try the development version, but I'm just learning 
 web2py and I'm trying to keep things as controlled as possible. Plus I 
 don't know when the development version becomes stable. 

 I can send a job to the scheduler. I'm using it because I have some tasks 
 that could take a few minutes to finish. What's a recommended way for a 
 user still at their browser to see when a job is complete? Some kind of 
 ajax usage?




-- 





[web2py] Re: [Newbie] Using existing Mysql DB with web2py app

2012-07-09 Thread Anthony


 1. Can I use web2py to connect to the existing DB? Is there any automated 
 way of creating the model classes from existing DB tables? Any specific 
 things to keep in mind?


http://code.google.com/p/web2py/source/browse/scripts/extract_pgsql_models.py
 


[web2py] Re: Newbie Alert: A flow chart of how things happen

2012-06-07 Thread Anthony
It might be easier if you go through 
http://web2py.com/books/default/chapter/29/1#Model-View-Controller, 
http://web2py.com/books/default/chapter/29/4#Workflow, and 
http://web2py.com/books/default/chapter/29/4#Dispatching, and then come 
back with specific questions.

Anthony

On Thursday, June 7, 2012 6:15:26 AM UTC-4, Omar Ali wrote:

 I'm a total newbie. I have programmed extensively during the VB days 
 (event driven programming) (I know, you'd hardly call that programming!) so 
 ... Web programming is taking a toll on me.

 Could someone explain to me the dynamics of web2py programming in a way 
 that an event driven programming dude can understand, maybe using analogies 
 and such..




[web2py] Re: Newbie Alert: A flow chart of how things happen

2012-06-07 Thread pbreit
I'd suggest running through the Overview:
http://web2py.com/books/default/chapter/29/3

If I understand correctly, you're not going to see event driven 
programming. Basic web programming is Request  Build Response  Send 
Response back to the User.


On Thursday, June 7, 2012 3:15:26 AM UTC-7, Omar Ali wrote:

 I'm a total newbie. I have programmed extensively during the VB days 
 (event driven programming) (I know, you'd hardly call that programming!) so 
 ... Web programming is taking a toll on me.

 Could someone explain to me the dynamics of web2py programming in a way 
 that an event driven programming dude can understand, maybe using analogies 
 and such..




[web2py] Re: Newbie Alert: A flow chart of how things happen

2012-06-07 Thread Cliff Kachinske
Some googles:

http request
http response



On Thursday, June 7, 2012 6:15:26 AM UTC-4, Omar Ali wrote:

 I'm a total newbie. I have programmed extensively during the VB days 
 (event driven programming) (I know, you'd hardly call that programming!) so 
 ... Web programming is taking a toll on me.

 Could someone explain to me the dynamics of web2py programming in a way 
 that an event driven programming dude can understand, maybe using analogies 
 and such..




[web2py] Re: Newbie Alert: A flow chart of how things happen

2012-06-07 Thread Omar Ali
Thank you all for your feedback. I suppose that's correct. I should try to 
change my way of thinking about writing applications from plain simple 
event-driven programming. It just felt so natural thinking about it that 
way... 

I will definitely go through the online manuals thoroughly and then if I 
have more questions, will come back here. This is actually my first ever 
forum post. I was always reluctant to post questions thinking I'd never get 
timely responses, but I read somewhere that I should give web2py a shot and 
see how friendly the community is.. :) so Good first experience.

Hope to be able to add back to web2py. It looks good so far

On Thursday, June 7, 2012 2:15:26 PM UTC+4, Omar Ali wrote:

 I'm a total newbie. I have programmed extensively during the VB days 
 (event driven programming) (I know, you'd hardly call that programming!) so 
 ... Web programming is taking a toll on me.

 Could someone explain to me the dynamics of web2py programming in a way 
 that an event driven programming dude can understand, maybe using analogies 
 and such..




Re: [web2py] Re: Newbie Alert: A flow chart of how things happen

2012-06-07 Thread Bruno Rocha
This is a very nice tutorial --  http://killer-web-development.com/


*Bruno Cezar Rocha*

http://www.CursoDePython.com.br
[image: Facebook] http://facebook.com/rochacbruno [image:
Twitter]http://twitter.com/rochacbruno [image:
LinkedIn] http://linkedin.com/in/rochacbruno [image:
about.me]http://about.me/rochacbruno [image:
Amazon] http://amazon.com/author/rochacbruno [image:
AngelList]http://angel.co/rochacbruno [image:
Blog RSS] http://www.web2pyslices.com/slice/list.rss?author=1 [image:
Facebook Page] http://facebook.com/CursoDePython [image:
foursquare]http://foursquare.com/rochacbruno [image:
Google Plus] https://plus.google.com/u/0/116110204708544946953/posts [image:
pinterest] http://pinterest.com/rochacbruno [image:
SlideShare]http://slideshare.com/rochacbruno [image:
YouTube] http://youtube.com/user/brunovegan
 [image: Google Talk] rochacbruno [image: Skype] blouweb
Blog: Updated: uwsgi + nginx script for Ubuntu
11.10http://www.web2pyslices.com/slice/show/1495/updated-uwsgi-nginx-script-for-ubuntu-1110
  Want a signature like mine?
http://r1.wisestamp.com/r/landing?promo=16dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_16
Click
here.http://r1.wisestamp.com/r/landing?promo=16dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_16



On Thu, Jun 7, 2012 at 5:20 PM, Omar Ali omar.technolog...@gmail.comwrote:

 Thank you all for your feedback. I suppose that's correct. I should try to
 change my way of thinking about writing applications from plain simple
 event-driven programming. It just felt so natural thinking about it that
 way...

 I will definitely go through the online manuals thoroughly and then if I
 have more questions, will come back here. This is actually my first ever
 forum post. I was always reluctant to post questions thinking I'd never get
 timely responses, but I read somewhere that I should give web2py a shot and
 see how friendly the community is.. :) so Good first experience.

 Hope to be able to add back to web2py. It looks good so far


 On Thursday, June 7, 2012 2:15:26 PM UTC+4, Omar Ali wrote:

 I'm a total newbie. I have programmed extensively during the VB days
 (event driven programming) (I know, you'd hardly call that programming!) so
 ... Web programming is taking a toll on me.

 Could someone explain to me the dynamics of web2py programming in a way
 that an event driven programming dude can understand, maybe using analogies
 and such..





[web2py] Re: newbie - dreamweaver and web2py

2012-04-09 Thread villas
I recently did a few experiments with Dreamweaver and quickly decided that 
it would make things more complicated rather than easier.  

If you are starting to study web2py then I believe it is better to get used 
to working directly with the files before trying to use productivity aids. 
 A good choice of text editor with syntax highlighting is important and I 
think you will find a few threads in this group regarding users' chosen 
development environments.


On Monday, 9 April 2012 03:28:38 UTC+1, weheh wrote:

 Sure, you could use dreamweaver to generate some html page templates and 
 embed them in a web2py directory structure. But you would have to tell 
 dreamweaver where to store pages in the web2py views folders. In other 
 words, you would have to ensure they adhered to the structure expected by 
 web2py -- each controller would have to have its pages in a folder under 
 web2py/applications/myapp/views/mycontroller. There could be complications 
 with how dreamweaver generates css files ... it's been almost a decade 
 since I studied dreamweaver, so I don't recall. Anyway, if you insist on 
 using dreamweaver you may want to get it to inline your css code in the 
 webpage. Otherwise, you will have to get it to write the css to a known 
 location, like web2py/applications/myapp/static/css/mystyles.css and then 
 you will have to load them into the desired view. Once you get better at 
 this, you'll probably end up ditching dreamweaver altogether ...



 On Monday, April 9, 2012 1:29:39 AM UTC+8, jaideep kekre wrote:

 im a student trying to build a slick website as a hobby . can web2py be 
 used with dreamweaver to generate html and then add the web2py template 
 stuff ? any bugs or issues i should be aware of? 

 thanks a lot !!




[web2py] Re: newbie - dreamweaver and web2py

2012-04-08 Thread weheh
Sure, you could use dreamweaver to generate some html page templates and 
embed them in a web2py directory structure. But you would have to tell 
dreamweaver where to store pages in the web2py views folders. In other 
words, you would have to ensure they adhered to the structure expected by 
web2py -- each controller would have to have its pages in a folder under 
web2py/applications/myapp/views/mycontroller. There could be complications 
with how dreamweaver generates css files ... it's been almost a decade 
since I studied dreamweaver, so I don't recall. Anyway, if you insist on 
using dreamweaver you may want to get it to inline your css code in the 
webpage. Otherwise, you will have to get it to write the css to a known 
location, like web2py/applications/myapp/static/css/mystyles.css and then 
you will have to load them into the desired view. Once you get better at 
this, you'll probably end up ditching dreamweaver altogether ...



On Monday, April 9, 2012 1:29:39 AM UTC+8, jaideep kekre wrote:

 im a student trying to build a slick website as a hobby . can web2py be 
 used with dreamweaver to generate html and then add the web2py template 
 stuff ? any bugs or issues i should be aware of? 

 thanks a lot !!




[web2py] Re: newbie : Accessing specific form elements' values from a controller.

2012-02-04 Thread Anthony
When a form is submitted, the submitted values will be in request.post_vars 
as well as request.vars (the former is specifically for variables submitted 
via post requests, whereas the latter includes both post and get 
variables). So, you could do:

if request.vars:
do something with request.vars.search_keyword
else:
return dict()

However, if you want to take advantage of web2py's form creation and 
processing, you can use the FORM or SQLFORM.factory helpers as described 
here: http://web2py.com/books/default/chapter/29/7. In particular, if you 
want to write all the HTML manually but just use web2py's form processing 
in the controller, see: 
 http://web2py.com/books/default/chapter/29/7#SQLFORM-in-HTML (same would 
apply to using SQLFORM.factory). As an alternative to completely manual 
HTML, you might consider SQLFORM.factory along 
with http://web2py.com/books/default/chapter/29/7#Custom-forms.

Anthony

On Saturday, February 4, 2012 6:41:39 AM UTC-5, Salvation wrote:

 Hi! 
 I have a html form in my default view. I don't want to create form 
 elements from my controller, but use pure HTML where possible. How can 
 I 
 1. Access the form elements, and their values into my controller, say 
 default.py. (something like GetElementById ) 
 2. Detect if the form has been submitted, so that I can use the values 
 I Accessed. 

 I went through many questions here, but couldn't work it out. 

 My View: 

 form id=mainForm class=well form-search 
  legendSearch Videos/legend 
  span class=input 
   input type=text size=45 name=search_keyword 
 id=searchKeyword class=xlarge 
  /span 

  span class=formactions 
   button class=btn primary type=submitSearch/ 
 button 
   /span 
 /form 

 My Controller: 

 def index(): 
 #is form submitted ? 
 #if Yes 
 #Access the form 
 #get the value inside the searchKeyword text box 
 #Use it elsewhere 
 #else 
 #display the form and wait 

 I have a feeling that this is not the correct approach. Please feel 
 free to point me in the right direction. 

 Thank You. 



[web2py] Re: newbie question about relationships in model

2012-02-04 Thread air_cooled
So the order is important I take it, I'll check out the order on the
ones that work, and see if moving the definitions around helps.

However, surely this isn't going to be possible in every situation.
What if you have A - B and B - C and C - A ?  You can't satisfy all
these by putting them in order.
How do you get around this problem?



On Feb 5, 3:04 am, Carlos Costa yamandu.co...@gmail.com wrote:
 Is t_winery being created after this line?

 2012/2/4 air_cooled jam...@billson.com:









  I've created a model in the GAE SQL tool - which was great, except it
  didn't work in web2py.  I just got errors.

  So I created a model from the wizard to get going, but I've got some
  strange behaviour around relationships.

  I have a table 'labels' which is linked to a number of other tables.
  A couple of these links work as you'd expect - in the edit screen you
  see a drop list of the 'name' field from the relate table.  For some
  reason I can't fathom ONE of these tables ('winery') shows a text
  field into which the ID of the related record has to be added.  That
  related table 'winery' is similar to the others that do work 'variety'
  and 'retailcategory', and has a 'name' field with the same data type
  as the others.  These relationships are modelled:

     Field('f_retailcategory', type='reference t_retailcategory',
           label=T('Retailcategory')),
     Field('f_winery', type='reference t_winery',
           label=T('Winery')),
  On searching the syntax is suggested as:

     Field('f_winery_id', db.winery),

  or

     Field('f_winery_id', db.t_winery)

  However adding these lines just causes it to blow up and show the
  error:
  type 'exceptions.KeyError' 'winery'

  This is all a bit arcane.  I can't understand why the GAE stuff
  does'nt work after fixing all the parsing errors.
  I've used PHP Cake a bit, so I get the concepts, but at this stage it
  seems the documentation != practice.

  Any tips?
  thanks

 --
 Carlos J. Costa
 Cientista da Computação
 Esp. Gestão em Telecom

 EL MELECH NEEMAN!
 אָמֵן


[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Anthony
Note the following line:

if request.vars.visitor_name:


That means it will only store the value in the session and do the redirect 
if visitor_name is in request.vars. If you're not submitting a visitor 
name, then that variable will not be in request.vars, and the conditional 
branch in the code will not be executed.

Anthony

On Tuesday, January 31, 2012 1:57:19 AM UTC-5, llanitedave wrote:

 I just downloaded web2py, and I'm going through the html book for the 
 first time.  I'm just getting to the point where I think I can understand 
 the web2py approach, and I'm starting to get enthused.

 I've gotten as far as the Postback section, and I'm running into problems. 
  The code does not seem to be working as posted, and I'm kind of at a loss.

 Using the code below: 









 def first():
 if request.vars.visitor_name:
 session.visitor_name = request.vars.visitor_name
 redirect(URL('second'))
 return dict()

 def second():
 return dict()

  default/first.html view:







 {{extend 'layout.html'}}
 What is your name?
 form
   input name=visitor_name /
   input type=submit /
 /form

  default/second.html view 



 {{extend 'layout.html'}}
 h1Hello {{=session.visitor_name or anonymous}}/h1


 (I first tried it slightly customized, then in frustration I copied and 
 pasted verbatem without a change in results), it works as long as I actually 
 input the visitor_name.  But if I don't input any value, then it does not 
 display Hello anonymous as it should.  It just resets back to first.html.

 I went a little further, to the next step down, but I had similar problems 
 there.  It doesn't seem to be treating null session data as it should.

 So what should I try next?  I'll settle for any hint I can get.

 *
 *



[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Benjamin
Hi,

I did the tutorial of the pdf last week (newest pdf of december) and
there is a missing step exactly at this spot of the PDF. (or actually
a not so clear change which needs to be made to run the tutorial
without any issue). I didn't know of the google groups at that time
so I didn't post the issue here...

I can't remember exactly how I solved it but if you look at the steps
very precisely you'll find the issue.

Cheers,

On 31 jan, 07:57, llanitedave llanited...@veawb.coop wrote:
 I just downloaded web2py, and I'm going through the html book for the first
 time.  I'm just getting to the point where I think I can understand the
 web2py approach, and I'm starting to get enthused.

 I've gotten as far as the Postback section, and I'm running into problems.
  The code does not seem to be working as posted, and I'm kind of at a loss.

 Using the code below:

 def first():
     if request.vars.visitor_name:
         session.visitor_name = request.vars.visitor_name
         redirect(URL('second'))
     return dict()

 def second():
     return dict()

  default/first.html view:

 {{extend 'layout.html'}}
 What is your name?
 form
   input name=visitor_name /
   input type=submit /
 /form

  default/second.html view

 {{extend 'layout.html'}}
 h1Hello {{=session.visitor_name or anonymous}}/h1

 (I first tried it slightly customized, then in frustration I copied and 
 pasted verbatem without a change in results), it works as long as I actually 
 input the visitor_name.  But if I don't input any value, then it does not 
 display Hello anonymous as it should.  It just resets back to first.html.

 I went a little further, to the next step down, but I had similar problems 
 there.  It doesn't seem to be treating null session data as it should.

 So what should I try next?  I'll settle for any hint I can get.

 *
 *


[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Benjamin
Hello again,

I'm pretty sure the first should be like this :



**

def first():
if request.vars.visitor_name:
session.visitor_name = request.vars.visitor_name
redirect(URL('second'))
return dict(form=form)

**

NOTICE THE return dict(form=form), I think it's what is missing at
this step in the book (one page later it's corrected with the
FORM(INPUT()) form creation technic.

I'm kind of a newbie too but I guess without this it's not really
postingback (?)

If it works for you we should try to be sure Massimo gets the error-
reporting (so newbies don't get lost ;-)) to gather some kind of
erratum.

Cheers,

On 31 jan, 16:33, Benjamin benjamin.aguet...@gmail.com wrote:
 Hi,

 I did the tutorial of the pdf last week (newest pdf of december) and
 there is a missing step exactly at this spot of the PDF. (or actually
 a not so clear change which needs to be made to run the tutorial
 without any issue). I didn't know of the google groups at that time
 so I didn't post the issue here...

 I can't remember exactly how I solved it but if you look at the steps
 very precisely you'll find the issue.

 Cheers,

 On 31 jan, 07:57, llanitedave llanited...@veawb.coop wrote:







  I just downloaded web2py, and I'm going through the html book for the first
  time.  I'm just getting to the point where I think I can understand the
  web2py approach, and I'm starting to get enthused.

  I've gotten as far as the Postback section, and I'm running into problems.
   The code does not seem to be working as posted, and I'm kind of at a loss.

  Using the code below:

  def first():
      if request.vars.visitor_name:
          session.visitor_name = request.vars.visitor_name
          redirect(URL('second'))
      return dict()

  def second():
      return dict()

   default/first.html view:

  {{extend 'layout.html'}}
  What is your name?
  form
    input name=visitor_name /
    input type=submit /
  /form

   default/second.html view

  {{extend 'layout.html'}}
  h1Hello {{=session.visitor_name or anonymous}}/h1

  (I first tried it slightly customized, then in frustration I copied and 
  pasted verbatem without a change in results), it works as long as I 
  actually input the visitor_name.  But if I don't input any value, then it 
  does not display Hello anonymous as it should.  It just resets back to 
  first.html.

  I went a little further, to the next step down, but I had similar problems 
  there.  It doesn't seem to be treating null session data as it should.

  So what should I try next?  I'll settle for any hint I can get.

  *
  *


[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Anthony


 I'm pretty sure the first should be like this : 



 ** 

 def first(): 
 if request.vars.visitor_name: 
 session.visitor_name = request.vars.visitor_name 
 redirect(URL('second')) 
 return dict(form=form) 

 ** 

 NOTICE THE return dict(form=form), I think it's what is missing at 
 this step in the book (one page later it's corrected with the 
 FORM(INPUT()) form creation technic. 


No, in that particular example, the form is not defined in the controller 
at all. If you do return dict(form=form), you will get an error, because 
form has not been defined. In this case, the form is defined in the view. 
The first() function simply receives the form post and checks whether 
visitor_name is one of the variables in the post -- otherwise, it simply 
returns the first.html view, which includes the empty form.

Anthony
 


[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread Benjamin
Oups you're right.

Now I remember what I didn't understand at this point, and probably
what the OP was expecting.

The book says :


Note that if the second action is ever called before a visitor name
is set, it will display Hello anonymous because session.visitor_name
returns None.


What the OP expected (and what I expected last week) was that by using
the form on the first url without entering anything and submitting
it it should display hello anonymous.

However it's not the case and it's not what the book refers to
(whereas it's pretty close, thus the misunderstanding).

BUT, and it's probably what the book tries to say :

If you DIRECTLY try to acces the url /second without EVER having
filled the first form with a name, you will get Hello Anonymous.

Of course you can probably reproduce this behavior after having
submitted a name on the first url by clearing your browser's cache/
cookies or trying to access the second url with another browser.

Cheers,


On 31 jan, 17:25, Anthony abasta...@gmail.com wrote:
  I'm pretty sure the first should be like this :

  **

  def first():
      if request.vars.visitor_name:
          session.visitor_name = request.vars.visitor_name
          redirect(URL('second'))
      return dict(form=form)

  **

  NOTICE THE return dict(form=form), I think it's what is missing at
  this step in the book (one page later it's corrected with the
  FORM(INPUT()) form creation technic.

 No, in that particular example, the form is not defined in the controller
 at all. If you do return dict(form=form), you will get an error, because
 form has not been defined. In this case, the form is defined in the view.
 The first() function simply receives the form post and checks whether
 visitor_name is one of the variables in the post -- otherwise, it simply
 returns the first.html view, which includes the empty form.

 Anthony


[web2py] Re: Newbie Tutorial Confusion

2012-01-31 Thread llanitedave
You hit the nail on the head.  So I'm really just misunderstanding the
tutorial.  And of course, looking at the code now it makes sense,
because it only redirects to the second page if there is actually a
value in visitor_name.  Now I get it.

Thanks, folks.  It's a self-facepalm.  But there will probably be
others, so don't expect this to be my last somewhat clueless question!

Dave

On Jan 31, 9:53 am, Benjamin benjamin.aguet...@gmail.com wrote:
 Oups you're right.

 Now I remember what I didn't understand at this point, and probably
 what the OP was expecting.

 The book says :

 
 Note that if the second action is ever called before a visitor name
 is set, it will display Hello anonymous because session.visitor_name
 returns None.
 

 What the OP expected (and what I expected last week) was that by using
 the form on the first url without entering anything and submitting
 it it should display hello anonymous.

 However it's not the case and it's not what the book refers to
 (whereas it's pretty close, thus the misunderstanding).

 BUT, and it's probably what the book tries to say :

 If you DIRECTLY try to acces the url /second without EVER having
 filled the first form with a name, you will get Hello Anonymous.

 Of course you can probably reproduce this behavior after having
 submitted a name on the first url by clearing your browser's cache/
 cookies or trying to access the second url with another browser.

 Cheers,

 On 31 jan, 17:25, Anthony abasta...@gmail.com wrote:







   I'm pretty sure the first should be like this :

   **

   def first():
       if request.vars.visitor_name:
           session.visitor_name = request.vars.visitor_name
           redirect(URL('second'))
       return dict(form=form)

   **

   NOTICE THE return dict(form=form), I think it's what is missing at
   this step in the book (one page later it's corrected with the
   FORM(INPUT()) form creation technic.

  No, in that particular example, the form is not defined in the controller
  at all. If you do return dict(form=form), you will get an error, because
  form has not been defined. In this case, the form is defined in the view.
  The first() function simply receives the form post and checks whether
  visitor_name is one of the variables in the post -- otherwise, it simply
  returns the first.html view, which includes the empty form.

  Anthony


[web2py] Re: newbie: How to match REST URL and extract path params

2011-12-23 Thread Anthony
All the elements of the URL after the controller and function are 
request.args (except the query string, of course). You could have a 
function called company(), and then companyid and storeid would be in 
request.args(0) and request.args(2), respectively. Or you might want a more 
general function, like api(), and then company, companyid, store, and 
storeid would be request.args[0:4]. If desired, you could hide the api 
function from the URL via routes.py.

Anthony

On Thursday, December 22, 2011 1:00:57 PM UTC-5, dum coder wrote:

 Hello everyone, i'm new to Python and web2py , In Java Jersey REST 
 framework i can map a REST URL to a function and get all the path 
 parameters eg., 

 /comapany/{comapnyid}/store/{storeid} 

 can be mapped to a particular function and companyid and storeid are 
 accessible as 
 parameters to function. 

 i'm trying to find how can i accomplish similar functionality in 
 web2py, where 

 GET /comapany/apple/store/567 

 gets mapped to a function and in side function i can retrieve 
 companyid and storeid variables. 

 I looked at function parse_as_rest but seems like it tried to run 
 query against db, in  my 
 case i just want to retrieve path parameters and then call other rest 
 api  in other systems 


 thanks 



[web2py] Re: newbie: How to match REST URL and extract path params

2011-12-22 Thread spiffytech
What you need is the pattern-based routing system:
http://web2py.com/books/default/chapter/29/4#Pattern-based-system

The pattern-based system allows you to route URLs based on regular
expressions. You can convert certain portions of a URL into GET args
or vars.

web2py does not allow you to map URLs to arbitrary functions (i.e.,
you can't map /index to SomeObject().index() ), so instead you need to
map your desired URL to fit the way web2py routes URLs internally. So
if you created a function that would normally be accessed by

/company/store/index

you can tell web2py to route

GET /comapany/apple/store/567

to that function with the following entry in routes.py:

routes_in = (
('/company/(?Pcompany.*)/store/(?Pstore.*)', '/company/
store/index?company=\gcompanystore=\gstore')
)

This will route the request to the function associated with /company/
store/index, with apple in request.vars[company] and 567 in
request.vars[store].


On Dec 22, 1:00 pm, dum coder wasi...@yahoo.com wrote:
 Hello everyone, i'm new to Python and web2py , In Java Jersey REST
 framework i can map a REST URL to a function and get all the path
 parameters eg.,

 /comapany/{comapnyid}/store/{storeid}

 can be mapped to a particular function and companyid and storeid are
 accessible as
 parameters to function.

 i'm trying to find how can i accomplish similar functionality in
 web2py, where

 GET /comapany/apple/store/567

 gets mapped to a function and in side function i can retrieve
 companyid and storeid variables.

 I looked at function parse_as_rest but seems like it tried to run
 query against db, in  my
 case i just want to retrieve path parameters and then call other rest
 api  in other systems

 thanks


[web2py] Re: Newbie - install on Apache not working...

2011-11-17 Thread Derek
I have check the logs - the only place that I see anything related is
in the access log, which shows the call to the URL (and nothing
else).  The call appears to get redirected to the home page for the
main site.

I have re-linked
  CustomLog /private/var/log/apache2/access.log common   ErrorLog /
private/var/log/apache2/error.log
to
  CustomLog /var/log/apache2/access.log
  ErrorLog /var/log/apache2/error.log
which are the directories and files used by all domains on this
server.

Only the call to the page shows up in the access log.

On Nov 15, 3:00 pm, juanduke juan.fu...@gmail.com wrote:
 Can you try:

 . check apache's logs
 . check permissions
 . move logs from  /private/var/log/apache2/ to other path and give www-data
 permissions

 HTH


Re: [web2py] Re: Newbie - install on Apache not working...

2011-11-17 Thread Kenneth Lundström
Is the name of the configuration file correct, on Red Hat deratives only 
.conf are read by Apache (if not otherwise configured in httpd.conf)?


Write some errors in the file, just add for example asdasd in the 
beginning of the file and try restarting Apache. If file read Apache 
should not be able to restart.


Comment out web2py settings in file and do a normal PHP site file and 
test that the PHP page is accessed.



Kenneth


I agree Apache does not see this - that is what I am wondering
about :)
Yes, there are other name-based webpages on the server; this is a
subdomain of them.
On Nov 15, 2:17 pm, Kenneth Lundströmkenneth.t.lundst...@gmail.com
wrote:

Hi Derek,

is this the first name based domain on the server? Do you have other
name based webpages on the server?

For some reason it sounds like Apache doesn't see this configuration and
doesn't understand to use web2py.

Kenneth








While I can run web2py on my development machine (Ubuntu 10.10)
without any problems, I cannot seem to get it to work on a production
server.
I have adapted the directions given 
inhttp://web2py.com/book/default/chapter/11#mod_wsgi
as follows:
$ cd /var/www/
$ sudo wgethttp://web2py.com/examples/static/web2py_src.zip
$ sudo unzip web2py_src.zip
$ sudo chown -R www-data:www-data /var/www/web2py
Then in a new config file /etc/apache2/sites-available/web2py I have
added:
VirtualHost *:80
ServerAdmin webmaster@localhost
ServerName subdomain.domain.com
DocumentRoot /var/www/web2py/
WSGIDaemonProcess web2py user=www-data group=www-data \
 display-name=%{GROUP}
WSGIProcessGroup web2py
WSGIScriptAlias / /var/www/web2py/wsgihandler.py
Directory /var/www/web2py
  AllowOverride None
  Order Allow,Deny
  Deny from all
  Files wsgihandler.py
Allow from all
  /Files
/Directory
AliasMatch ^/([^/]+)/static/(.*) \
 /var/www/web2py/applications/$1/static/$2
Directory /var/www/web2py/applications/*/static/
  Order Allow,Deny
  Allow from all
/Directory
Location /admin
Deny from all
/Location
LocationMatch ^/([^/]+)/appadmin
Deny from all
/LocationMatch
CustomLog /private/var/log/apache2/access.log common
ErrorLog /private/var/log/apache2/error.log
/VirtualHost
(Note: subdomain.domain.com is just a dummy entry here; on the real
server it contains the actual server details.)
However, browsing to the main entry page just results in the normal
main page for the server being displayed.
I will appreciate any boot up help you can give!
Thanks
Derek
2011/11/14
(As a small footnote, I have seen that most tutorials and directions
for web frameworks start with installing on a new/clean machine,
which is very frustrating because 95% of the time that is simply not
the case...)




[web2py] Re: Newbie - install on Apache not working...

2011-11-17 Thread juanduke
Do you have enable all the apache modules indicated in web2py book?



[web2py] Re: [Newbie] Best practice to set application wide settings

2011-07-26 Thread Jagmal
Thanks David for the link. I think I am not at a stage right now, where I 
need to store configurations in the database. I will definitely give this a 
try once I am at that stage.

[web2py] Re: [Newbie] Best practice to set application wide settings

2011-07-22 Thread David Marko
Look to this web2py utils ...
http://packages.python.org/web2py_utils/index.html

... there is an object for storing/accessing configurations values into 
database. Its very handy ...



Re: [web2py] Re: [Newbie] Best practice to set application wide settings

2011-07-22 Thread Bruno Rocha
look at this -
http://martin.tecnodoc.com.ar/default/post/2011/05/13/20_optimize-your-web2py-app-using-the-new-import-method


Re: [web2py] Re: Newbie questions

2011-03-19 Thread Niklas Rosencrantz
On Wed, Mar 16, 2011 at 12:46 PM, Anthony abasta...@gmail.com wrote:

 On Wednesday, March 16, 2011 5:29:09 AM UTC-4, Nick Rosencrantz wrote:

 Hi
 I just deployed my first attempt to try web2py with google app engine
 (http://matochsovklockan.appspot.com)
 Basically it works while a few links return invalid request eg
 http://matochsovklockan.appspot.com/examples/default/index


 That URL is looking for the 'examples' app that comes with web2py. Note, if
 you used the default app.yaml file that comes with web2py for GAE
 deployment, the 'examples' and 'admin' apps won't be deployed on GAE -- they
 are excluded in the skip_files section of app.yaml. If you want to deploy
 the 'examples' app, you'll have to edit app.yaml accordingly. This is
 explained in the Google App Engine section of chapter 11 of the book (I'd
 provide a link, but the online book happens to be down right now).

 Anthony

Thanks Anthony, now I understand what's going on with my start. I think
web2py seems an exciting and powerful approach to web development. /Nick
Rosencrantz


[web2py] Re: Newbie questions

2011-03-16 Thread Anthony
On Wednesday, March 16, 2011 5:29:09 AM UTC-4, Nick Rosencrantz wrote:

 Hi 
 I just deployed my first attempt to try web2py with google app engine 
 (http://matochsovklockan.appspot.com) 
 Basically it works while a few links return invalid request eg 
 http://matochsovklockan.appspot.com/examples/default/index 

 
That URL is looking for the 'examples' app that comes with web2py. Note, if 
you used the default app.yaml file that comes with web2py for GAE 
deployment, the 'examples' and 'admin' apps won't be deployed on GAE -- they 
are excluded in the skip_files section of app.yaml. If you want to deploy 
the 'examples' app, you'll have to edit app.yaml accordingly. This is 
explained in the Google App Engine section of chapter 11 of the book (I'd 
provide a link, but the online book happens to be down right now).
 
Anthony


Re: [web2py] Re: Newbie Problems with Cherokee + Web2py

2011-01-06 Thread Offray Vladimir Luna Cárdenas
Hi,

El 05/01/11 19:12, John-Kim Murphy escribió:
 Try using the most recent instructions for getting Web2Py working with 
 Cherokeehttp://stackoverflow.com/questions/4332514/set-up-cherokee-web2py-on-ubuntu-10-04-lucid/4528543#4528543
 . 
 I  documented the steps I took about two weeks ago. The other 
 instructionshttp://web2pyslices.com/main/slices/take_slice/110are very 
 recent, too.


Thanks a lot. The last one is working like a charm. I made some minor
changes to the slice to run it as a different user and group (soon I
will publish it, hopefully under my own web2py wiki). Now when I put
localhost it automatically loads and shows the web2py welcome
interface, after starting cherokee. I get an error related with proper
permissions for accessing the admin interface, that I'll study further
but is a good step in the proper direction

 It's not clear what steps you used to set up Cherokee + Web2Py because your 
 reference just shows [1]


Sorry. It was:

[1] http://web2py.com/book/default/chapter/11#Cherokee-with-FastGGI

Cheers,

Offray


[web2py] Re: Newbie Problems with Cherokee + Web2py

2011-01-05 Thread John-Kim Murphy
Try using the most recent instructions for getting Web2Py working with 
Cherokeehttp://stackoverflow.com/questions/4332514/set-up-cherokee-web2py-on-ubuntu-10-04-lucid/4528543#4528543
. 
I  documented the steps I took about two weeks ago. The other 
instructionshttp://web2pyslices.com/main/slices/take_slice/110are very 
recent, too.

It's not clear what steps you used to set up Cherokee + Web2Py because your 
reference just shows [1]

John-Kim


[web2py] Re: newbie

2010-12-13 Thread Mirek Zvolský
To understand the basic behaviour of web2py, you can try following:

In the default controller default.py make a function, f.e.
allstorylines():

def allstorylines():
rsStorylines = db().select(db.storyline.ALL)
return dict(rsStorylines=rsStorylines)

In addition you need a view default/allstorylines.html:

{{extend 'layout.html'}}
{{=rsStorylines}}

Now, write into your browser the address:
localhost:8000/applicationname/default/allstorylines

and you should see table of storyline records.

If this works, you can improve it in 2 ways:

-- change the db().select() in the controller to receive just records
you want to see,

-- change the view, f.e. instead of {{}} you can try list records in
cycle:
table
{{for recStoryline in rsStorylines:}}
tr
td{{=recStoryline.fieldname or ''}}/td
td{{=...}}/td
/tr
{{pass}}
/table

 or use some compoment to display records, f.e. see:
   http://www.trirand.com/blog/jqgrid/jqgrid.html


[web2py] Re: newbie

2010-12-13 Thread Shel
That clears up a lot.  Thank you both.


[web2py] Re: newbie

2010-12-13 Thread Shel
That clears up a lot.  Thank you both.


[web2py] Re: newbie

2010-12-12 Thread weheh
I assume you've got something like:

db.define_table('story',Field('text'), ...)
db.define_table('storyline',Field('story_id',db.story,requires=IS_IN_DB(db,'story.id','%
(text)s'), ...)


Then you can query the db:

rows=db(db.storyline.story_id==session.story_id).select(db.story.ALL,left=db.story.on(db.story.id==db.storyline.story_id))

You can return dict(rows=rows) or return dict(rows=SQLTABLE(rows)),
the latter providing more formatting and functionality.





On Dec 12, 8:49 pm, Shel joralemonshe...@gmail.com wrote:
 Hello,

 I am trying to create a form that displays all the rows in a table
 where, for example, db.storyline.story_id = session.story_id, and I
 cannot for the life of me figure out how to do this.  It seems like
 this should be very simple, but nothing I have tried works.  I am not
 sure how to use a query as the data source for a form, or how to
 create a form that shows all the rows returned by the query.  Any help
 would be appreciated.    Especially if anyone could point me to some
 sample code that does something similar, that would be great.

 Thank you,
 Shel


[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-06 Thread DenesL

See http://groups.google.com/group/web2py/msg/4a9e84fb5ceb2e4f
It only works if there are no common field names.
I have added this to the book.

On Dec 5, 5:07 pm, tomt tom_tren...@yahoo.com wrote:
 Hi,

 I'm unfamiliar with _filter_fields. I couldn't find it in the manual
 but eventually found it in the source in gluon/tools.py.
 Am I correct in assuming it is intended to return everything but the
 id field from a record? (I've just started to learn python)

 Is there some documentation available for this? I've tried some of the
 urls in the help and resources post:
  http://web2py.com/examples/default/dal
  http://web2py.com/examples/default/api
  http://web2py.com/examples/default/tools

 But I just get invalid function

 Thanks in advance,
   - Tom

 On Dec 5, 7:00 am, villas villa...@gmail.com wrote:

  Hi Nathan

  Just a small point, I tried your code example and it seems you have to
  set id==None otherwise it tries to add a duplicate row with the same
  id.

  Anyway, I thought you also might like this alternative using
  _filter_fields, just because it's shorter. Maybe it's got other
  issues,  but it seems to work!

  def things():
      form = SQLFORM(db.things)
      if form.accepts(request.vars,session):
          response.flash = 'Added a thing'
      if request.vars.dupe:

  db.things.insert(**db.things._filter_fields(db.things(request.vars.dupe)))
      things = db(db.things.id0).select()
      return dict(form=form,things=things)

  Best regards,
  -D

  On Dec 4, 3:30 am, mr.freeze nat...@freezable.com wrote:

   Here is an example:

   Model
   -
   db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
                   Field('age','integer'),Field('weight','double'))
   db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
                                        _onclick='return confirm(Copy
   %s?)' % v)

   Controller
   --
   def index():
       form = SQLFORM(db.things)
       if form.accepts(request.vars,session):
           response.flash = 'Added a thing'
       if request.vars.dupe:
           record = db.things(request.vars.dupe)
           vals = {}
           for k,v in record.items():
               if k in db.things.fields:
                   vals[k] = v
           db.things.insert(**vals)
       things = db(db.things.id0).select()
       return dict(form=form,things=things)

   On Dec 3, 6:12 pm, tomt tom_tren...@yahoo.com wrote:

Hi,

I've started to write a simple application to learn web2py. I am using
SQLFORM to insert, modify and delete records. So far everything is
working as planned.

I would like to give the user the ability add a new record as a copy
of an existing one.  The idea is that the user would view an existing
record, modify a couple fields, and select 'copy' which result in
adding a new record.

I assume that this requires additional code, and I was hoping that
someone would suggest an example, or let me know if SQLFORM can do
this automatically.

Thanks in advance,

- Tom




[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-06 Thread villas
Hi tomt

I believe it takes the fields from the specified source table and
lines them up with a target table.  Any fields which don't match and
the id are discarded.

What Denes means is that it wouldn't work when for example you use
form.vars from multiple tables which have some identical field names.
In that case, when it filters through the form.vars it doesn't know
which field comes from which table.

Hope that's right :)

-D

On Dec 5, 10:07 pm, tomt tom_tren...@yahoo.com wrote:
 Hi,

 I'm unfamiliar with _filter_fields. I couldn't find it in the manual
 but eventually found it in the source in gluon/tools.py.
 Am I correct in assuming it is intended to return everything but the
 id field from a record? (I've just started to learn python)

 Is there some documentation available for this? I've tried some of the
 urls in the help and resources post:
  http://web2py.com/examples/default/dal
  http://web2py.com/examples/default/api
  http://web2py.com/examples/default/tools

 But I just get invalid function

 Thanks in advance,
   - Tom

 On Dec 5, 7:00 am, villas villa...@gmail.com wrote:





  Hi Nathan

  Just a small point, I tried your code example and it seems you have to
  set id==None otherwise it tries to add a duplicate row with the same
  id.

  Anyway, I thought you also might like this alternative using
  _filter_fields, just because it's shorter. Maybe it's got other
  issues,  but it seems to work!

  def things():
      form = SQLFORM(db.things)
      if form.accepts(request.vars,session):
          response.flash = 'Added a thing'
      if request.vars.dupe:

  db.things.insert(**db.things._filter_fields(db.things(request.vars.dupe)))
      things = db(db.things.id0).select()
      return dict(form=form,things=things)

  Best regards,
  -D

  On Dec 4, 3:30 am, mr.freeze nat...@freezable.com wrote:

   Here is an example:

   Model
   -
   db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
                   Field('age','integer'),Field('weight','double'))
   db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
                                        _onclick='return confirm(Copy
   %s?)' % v)

   Controller
   --
   def index():
       form = SQLFORM(db.things)
       if form.accepts(request.vars,session):
           response.flash = 'Added a thing'
       if request.vars.dupe:
           record = db.things(request.vars.dupe)
           vals = {}
           for k,v in record.items():
               if k in db.things.fields:
                   vals[k] = v
           db.things.insert(**vals)
       things = db(db.things.id0).select()
       return dict(form=form,things=things)

   On Dec 3, 6:12 pm, tomt tom_tren...@yahoo.com wrote:

Hi,

I've started to write a simple application to learn web2py. I am using
SQLFORM to insert, modify and delete records. So far everything is
working as planned.

I would like to give the user the ability add a new record as a copy
of an existing one.  The idea is that the user would view an existing
record, modify a couple fields, and select 'copy' which result in
adding a new record.

I assume that this requires additional code, and I was hoping that
someone would suggest an example, or let me know if SQLFORM can do
this automatically.

Thanks in advance,

- Tom




[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-06 Thread tomt
Thanks for the example and the reference.   - Tom

On Dec 6, 5:58 pm, villas villa...@gmail.com wrote:
 Hi tomt

 I believe it takes the fields from the specified source table and
 lines them up with a target table.  Any fields which don't match and
 the id are discarded.

 What Denes means is that it wouldn't work when for example you use
 form.vars from multiple tables which have some identical field names.
 In that case, when it filters through the form.vars it doesn't know
 which field comes from which table.

 Hope that's right :)

 -D

 On Dec 5, 10:07 pm, tomt tom_tren...@yahoo.com wrote:

  Hi,

  I'm unfamiliar with _filter_fields. I couldn't find it in the manual
  but eventually found it in the source in gluon/tools.py.
  Am I correct in assuming it is intended to return everything but the
  id field from a record? (I've just started to learn python)

  Is there some documentation available for this? I've tried some of the
  urls in the help and resources post:
   http://web2py.com/examples/default/dal
   http://web2py.com/examples/default/api
   http://web2py.com/examples/default/tools

  But I just get invalid function

  Thanks in advance,
    - Tom

  On Dec 5, 7:00 am, villas villa...@gmail.com wrote:

   Hi Nathan

   Just a small point, I tried your code example and it seems you have to
   set id==None otherwise it tries to add a duplicate row with the same
   id.

   Anyway, I thought you also might like this alternative using
   _filter_fields, just because it's shorter. Maybe it's got other
   issues,  but it seems to work!

   def things():
       form = SQLFORM(db.things)
       if form.accepts(request.vars,session):
           response.flash = 'Added a thing'
       if request.vars.dupe:

   db.things.insert(**db.things._filter_fields(db.things(request.vars.dupe)))
       things = db(db.things.id0).select()
       return dict(form=form,things=things)

   Best regards,
   -D

   On Dec 4, 3:30 am, mr.freeze nat...@freezable.com wrote:

Here is an example:

Model
-
db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
                Field('age','integer'),Field('weight','double'))
db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
                                     _onclick='return confirm(Copy
%s?)' % v)

Controller
--
def index():
    form = SQLFORM(db.things)
    if form.accepts(request.vars,session):
        response.flash = 'Added a thing'
    if request.vars.dupe:
        record = db.things(request.vars.dupe)
        vals = {}
        for k,v in record.items():
            if k in db.things.fields:
                vals[k] = v
        db.things.insert(**vals)
    things = db(db.things.id0).select()
    return dict(form=form,things=things)

On Dec 3, 6:12 pm, tomt tom_tren...@yahoo.com wrote:

 Hi,

 I've started to write a simple application to learn web2py. I am using
 SQLFORM to insert, modify and delete records. So far everything is
 working as planned.

 I would like to give the user the ability add a new record as a copy
 of an existing one.  The idea is that the user would view an existing
 record, modify a couple fields, and select 'copy' which result in
 adding a new record.

 I assume that this requires additional code, and I was hoping that
 someone would suggest an example, or let me know if SQLFORM can do
 this automatically.

 Thanks in advance,

 - Tom




[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-05 Thread villas
Hi Nathan

Just a small point, I tried your code example and it seems you have to
set id==None otherwise it tries to add a duplicate row with the same
id.

Anyway, I thought you also might like this alternative using
_filter_fields, just because it's shorter. Maybe it's got other
issues,  but it seems to work!

def things():
form = SQLFORM(db.things)
if form.accepts(request.vars,session):
response.flash = 'Added a thing'
if request.vars.dupe:
 
db.things.insert(**db.things._filter_fields(db.things(request.vars.dupe)))
things = db(db.things.id0).select()
return dict(form=form,things=things)

Best regards,
-D


On Dec 4, 3:30 am, mr.freeze nat...@freezable.com wrote:
 Here is an example:

 Model
 -
 db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
                 Field('age','integer'),Field('weight','double'))
 db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
                                      _onclick='return confirm(Copy
 %s?)' % v)

 Controller
 --
 def index():
     form = SQLFORM(db.things)
     if form.accepts(request.vars,session):
         response.flash = 'Added a thing'
     if request.vars.dupe:
         record = db.things(request.vars.dupe)
         vals = {}
         for k,v in record.items():
             if k in db.things.fields:
                 vals[k] = v
         db.things.insert(**vals)
     things = db(db.things.id0).select()
     return dict(form=form,things=things)

 On Dec 3, 6:12 pm, tomt tom_tren...@yahoo.com wrote:

  Hi,

  I've started to write a simple application to learn web2py. I am using
  SQLFORM to insert, modify and delete records. So far everything is
  working as planned.

  I would like to give the user the ability add a new record as a copy
  of an existing one.  The idea is that the user would view an existing
  record, modify a couple fields, and select 'copy' which result in
  adding a new record.

  I assume that this requires additional code, and I was hoping that
  someone would suggest an example, or let me know if SQLFORM can do
  this automatically.

  Thanks in advance,

  - Tom




[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-05 Thread mr.freeze
Interesting, I didn't have to set id to None. Perhaps it's db
specific. I was using sqlite. Anyway, _filter_fields is better in
either case. Thanks!

On Dec 5, 7:00 am, villas villa...@gmail.com wrote:
 Hi Nathan

 Just a small point, I tried your code example and it seems you have to
 set id==None otherwise it tries to add a duplicate row with the same
 id.

 Anyway, I thought you also might like this alternative using
 _filter_fields, just because it's shorter. Maybe it's got other
 issues,  but it seems to work!

 def things():
     form = SQLFORM(db.things)
     if form.accepts(request.vars,session):
         response.flash = 'Added a thing'
     if request.vars.dupe:

 db.things.insert(**db.things._filter_fields(db.things(request.vars.dupe)))
     things = db(db.things.id0).select()
     return dict(form=form,things=things)

 Best regards,
 -D

 On Dec 4, 3:30 am, mr.freeze nat...@freezable.com wrote:

  Here is an example:

  Model
  -
  db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
                  Field('age','integer'),Field('weight','double'))
  db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
                                       _onclick='return confirm(Copy
  %s?)' % v)

  Controller
  --
  def index():
      form = SQLFORM(db.things)
      if form.accepts(request.vars,session):
          response.flash = 'Added a thing'
      if request.vars.dupe:
          record = db.things(request.vars.dupe)
          vals = {}
          for k,v in record.items():
              if k in db.things.fields:
                  vals[k] = v
          db.things.insert(**vals)
      things = db(db.things.id0).select()
      return dict(form=form,things=things)

  On Dec 3, 6:12 pm, tomt tom_tren...@yahoo.com wrote:

   Hi,

   I've started to write a simple application to learn web2py. I am using
   SQLFORM to insert, modify and delete records. So far everything is
   working as planned.

   I would like to give the user the ability add a new record as a copy
   of an existing one.  The idea is that the user would view an existing
   record, modify a couple fields, and select 'copy' which result in
   adding a new record.

   I assume that this requires additional code, and I was hoping that
   someone would suggest an example, or let me know if SQLFORM can do
   this automatically.

   Thanks in advance,

   - Tom




[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-05 Thread tomt
Hi,

I'm unfamiliar with _filter_fields. I couldn't find it in the manual
but eventually found it in the source in gluon/tools.py.
Am I correct in assuming it is intended to return everything but the
id field from a record? (I've just started to learn python)

Is there some documentation available for this? I've tried some of the
urls in the help and resources post:
 http://web2py.com/examples/default/dal
 http://web2py.com/examples/default/api
 http://web2py.com/examples/default/tools

But I just get invalid function

Thanks in advance,
  - Tom


On Dec 5, 7:00 am, villas villa...@gmail.com wrote:
 Hi Nathan

 Just a small point, I tried your code example and it seems you have to
 set id==None otherwise it tries to add a duplicate row with the same
 id.

 Anyway, I thought you also might like this alternative using
 _filter_fields, just because it's shorter. Maybe it's got other
 issues,  but it seems to work!

 def things():
     form = SQLFORM(db.things)
     if form.accepts(request.vars,session):
         response.flash = 'Added a thing'
     if request.vars.dupe:

 db.things.insert(**db.things._filter_fields(db.things(request.vars.dupe)))
     things = db(db.things.id0).select()
     return dict(form=form,things=things)

 Best regards,
 -D

 On Dec 4, 3:30 am, mr.freeze nat...@freezable.com wrote:

  Here is an example:

  Model
  -
  db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
                  Field('age','integer'),Field('weight','double'))
  db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
                                       _onclick='return confirm(Copy
  %s?)' % v)

  Controller
  --
  def index():
      form = SQLFORM(db.things)
      if form.accepts(request.vars,session):
          response.flash = 'Added a thing'
      if request.vars.dupe:
          record = db.things(request.vars.dupe)
          vals = {}
          for k,v in record.items():
              if k in db.things.fields:
                  vals[k] = v
          db.things.insert(**vals)
      things = db(db.things.id0).select()
      return dict(form=form,things=things)

  On Dec 3, 6:12 pm, tomt tom_tren...@yahoo.com wrote:

   Hi,

   I've started to write a simple application to learn web2py. I am using
   SQLFORM to insert, modify and delete records. So far everything is
   working as planned.

   I would like to give the user the ability add a new record as a copy
   of an existing one.  The idea is that the user would view an existing
   record, modify a couple fields, and select 'copy' which result in
   adding a new record.

   I assume that this requires additional code, and I was hoping that
   someone would suggest an example, or let me know if SQLFORM can do
   this automatically.

   Thanks in advance,

   - Tom




[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-04 Thread tomt
Thanks to both of the responders.  The reference and example have
answered my question. (and introduced some concepts I was unfamiliar
with)
  - Tom

On Dec 3, 9:30 pm, mr.freeze nat...@freezable.com wrote:
 Here is an example:

 Model
 -
 db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
                 Field('age','integer'),Field('weight','double'))
 db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
                                      _onclick='return confirm(Copy
 %s?)' % v)

 Controller
 --
 def index():
     form = SQLFORM(db.things)
     if form.accepts(request.vars,session):
         response.flash = 'Added a thing'
     if request.vars.dupe:
         record = db.things(request.vars.dupe)
         vals = {}
         for k,v in record.items():
             if k in db.things.fields:
                 vals[k] = v
         db.things.insert(**vals)
     things = db(db.things.id0).select()
     return dict(form=form,things=things)

 On Dec 3, 6:12 pm, tomt tom_tren...@yahoo.com wrote:

  Hi,

  I've started to write a simple application to learn web2py. I am using
  SQLFORM to insert, modify and delete records. So far everything is
  working as planned.

  I would like to give the user the ability add a new record as a copy
  of an existing one.  The idea is that the user would view an existing
  record, modify a couple fields, and select 'copy' which result in
  adding a new record.

  I assume that this requires additional code, and I was hoping that
  someone would suggest an example, or let me know if SQLFORM can do
  this automatically.

  Thanks in advance,

  - Tom




[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-03 Thread DenesL
Hi Tom,

you can use dbio=False in the accepts and do the insert manually as
explained in
http://web2py.com/book/default/chapter/07#SQLFORM-without-database-IO



On Dec 3, 7:12 pm, tomt tom_tren...@yahoo.com wrote:
 Hi,

 I've started to write a simple application to learn web2py. I am using
 SQLFORM to insert, modify and delete records. So far everything is
 working as planned.

 I would like to give the user the ability add a new record as a copy
 of an existing one.  The idea is that the user would view an existing
 record, modify a couple fields, and select 'copy' which result in
 adding a new record.

 I assume that this requires additional code, and I was hoping that
 someone would suggest an example, or let me know if SQLFORM can do
 this automatically.

 Thanks in advance,

 - Tom


[web2py] Re: Newbie question:add new record as a copy of an existing row in SQLFORM

2010-12-03 Thread mr.freeze
Here is an example:

Model
-
db.define_table('things',Field('name',requires=IS_NOT_EMPTY()),
Field('age','integer'),Field('weight','double'))
db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)),
 _onclick='return confirm(Copy
%s?)' % v)

Controller
--
def index():
form = SQLFORM(db.things)
if form.accepts(request.vars,session):
response.flash = 'Added a thing'
if request.vars.dupe:
record = db.things(request.vars.dupe)
vals = {}
for k,v in record.items():
if k in db.things.fields:
vals[k] = v
db.things.insert(**vals)
things = db(db.things.id0).select()
return dict(form=form,things=things)

On Dec 3, 6:12 pm, tomt tom_tren...@yahoo.com wrote:
 Hi,

 I've started to write a simple application to learn web2py. I am using
 SQLFORM to insert, modify and delete records. So far everything is
 working as planned.

 I would like to give the user the ability add a new record as a copy
 of an existing one.  The idea is that the user would view an existing
 record, modify a couple fields, and select 'copy' which result in
 adding a new record.

 I assume that this requires additional code, and I was hoping that
 someone would suggest an example, or let me know if SQLFORM can do
 this automatically.

 Thanks in advance,

 - Tom


[web2py] Re: newbie + resources on web design

2010-11-08 Thread cjrh
On Nov 9, 8:38 am, Markandeya mrc55...@gmail.com wrote:
 Dear Friends at Web2Py,
  i need some resources, books ebooks, tutorials, etc. on how to design
 a database driven web application that will help me with web2py
 development. Any advice will be appreciated.

http://web2py.com/book


[web2py] Re: newbie + resources on web design

2010-11-08 Thread mdipierro
http://vimeo.com/16048970
http://vimeo.com/13485916


On Nov 9, 12:38 am, Markandeya mrc55...@gmail.com wrote:
 Dear Friends at Web2Py,
  i need some resources, books ebooks, tutorials, etc. on how to design
 a database driven web application that will help me with web2py
 development. Any advice will be appreciated.

 i want to create web apps with web2py but know too little of web
 design for database driven web applications. i write same type
 programs for client-server or 3 tier applications not using the web.
 So i have questions like do i get all master and child tables rows
 into dictionaries on the client web page so they can click a parent
 record and then see the child detail records in a grid or do i get the
 detail records from the server when parent record is clicked? If there
 is an edit do i reload all the records again from the server to show
 in the grid or just check the edit was accepted by the database and
 then edit the record in the grid?

   So i need some resources, books ebooks, tutorials, etc. on how to
 design a database driven web application that will help me with web2py
 development.


[web2py] Re: Newbie Parent/Child editing- The right way

2010-10-19 Thread Markandeya
Thank you so very much for your lightening fast replies with real
help. So much appreciated. Now i will do my homework and learn. thank
you again, Markandeya



[web2py] Re: Newbie Parent/Child editing- The right way

2010-10-18 Thread mdipierro
Look at the source code of this app:

http://www.web2py.com/appliances/default/show/63

It does what you ask (although for radio logs but you can change table
names and add fields) and it is very compact. Done by the book.

On Oct 18, 12:59 am, Markandeya mrc55...@gmail.com wrote:
 Dear Friends of Web2py,
 i am starting out with Web2py and Web Apps. I have a Parent Table of
 Service Calls and a child table of Visits. When making an edit form
 with both tables visible, one below the other, I need to be able to
 click on a Parent (Service Calls) table cell or row and  have the
 child (visits) table then filter or lookup the records for that Parent
 Service Call Record. Then when a child record is edited or added it
 needs to be shown in the child html table. This is a usual and
 recurring situation in many webapps or pages. What is the best
 practices way to do this? Bring in all 50-100 child records in a
 dictionary or array and then have a function that displays them in the
 Child Html table? or go to the database each time? And what event on
 the page or in the html table can be used to show when a Cell or Row
 is clicked by the user? Also if my Parent table has a field for number
 of calls, then with each added or deleted call record the parent  db
 and html table also has to be changed. How best to accomplish this.
   Maybe there is tutorial or example or simple web2py program/webapp
 that might help.
   Thanks for putting up with beginners ignorance. Any guidance will be
 welcome, Thanks Markandeya


[web2py] Re: Newbie question: Access to data loaded via ajax in view

2010-09-30 Thread mdipierro
You cannot in the page that calls web2py but you can do it
'mydata.load'

On Sep 30, 6:17 pm, Relaxd relax...@gmail.com wrote:
 I'm a web2py newbie. I have some data that gets updated constantly. I
 used the following code to load the data via ajax every few seconds.
 The data is updated as expected automatically. But I have no access to
 the response vars in the view to process the data. Is it possible for
 me to access response data in the view. I'd like to do something like
 {{for x in data:}} etc.

 script
 function load_tables() {
     //load data
     web2py_component('{{=URL('mydata.load')}}','tabdata');
     setTimeout(load_mydata,1);

 }

 jQuery(document).ready(load_tables);

 /script

 div id=tabdata
 {{=response.vars}}
 /div

 Thanks
 Prad


[web2py] Re: newbie, import csv table file

2010-09-16 Thread Markandeya
Many thanks. Such a quick a helpful response and much needed. I can't
get it to work yet, keep getting an error, but am trying to debug it.
(no group for a nontype). Thanks again. Markandeya


[web2py] Re: newbie, import csv table file

2010-09-14 Thread mdipierro
You can use this script

http://code.google.com/p/web2py/source/browse/scripts/extract_mysql_models.py

to generate a model from the mysql database.



On Sep 14, 7:42 am, Markandeya mrc55...@gmail.com wrote:
 Dear Friends of web2py,
 Sorry for this repeated question, but i can't seem to understand
 properly. I have been looking it up for an hour or two.
 I have CSV file for a database table created by sqlite. It is in the
 format that is first line delimited column names then a separate line
 with delimited field values for each table row.

 Can this be imported in any way so that one doesn't have to hand write
 db.define_table statements defining each field??

 If i have a Mysql table can this be imported(or even the schema) so
 that there is no need to hand write the db.define_table statements??

 Many thanks. This will save me lots of time searching whatever the
 proper answer is and i can get to the programming.


Re: [web2py] Re: Newbie needs help

2010-08-22 Thread Michele Alzetta
On Sun, Aug 22, 2010 at 12:12 AM, mdipierro mdipie...@cs.depaul.edu wrote:

 My guess is that this is a problem with sqlite. You had the field, you
 removed it (but sqlite does not support drop), then you put it back
 (and web2py tried to define it again).

 Delete everything in applications/yourapp/databases then run it
 again.

 You have a typo

 db.define_table('SchemaTurni',
...
Field('OreServizo','integer'), 


That was indeed the problem. Thank you very much indeed!


[web2py] Re: Newbie needs help

2010-08-21 Thread mdipierro
My guess is that this is a problem with sqlite. You had the field, you
removed it (but sqlite does not support drop), then you put it back
(and web2py tried to define it again).

Delete everything in applications/yourapp/databases then run it
again.

You have a typo

db.define_table('SchemaTurni',
...
Field('OreServizo','integer'), 

On Aug 21, 5:01 pm, Michele Alzetta michele.alze...@gmail.com wrote:
 Dear web2py-users,

 I tried to create the database schema of my application by adding the
 following code in db.py ; I am pasting the entire code, but in fact
 the problem appears already at the first table definition, because te
 ticket I get is the following:

 Traceback (most recent call last):
   File /home/mike/web2py/gluon/restricted.py, line 186, in
 restricted
     exec ccode in environment
   File /home/mike/web2py/applications/TurniPS/models/db.py, line 28,
 in module
     Field('OrarioSett','integer',default='38'))
   File /home/mike/web2py/gluon/sql.py, line 1359, in define_table
     t._create(migrate=migrate, fake_migrate=fake_migrate)
   File /home/mike/web2py/gluon/sql.py, line 1845, in _create
     fake_migrate=fake_migrate)
   File /home/mike/web2py/gluon/sql.py, line 1914, in _migrate
     self._db._execute(sub_query)
   File /home/mike/web2py/gluon/sql.py, line 947, in lambda
     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
 OperationalError: duplicate column name: lnott

 This is the code, of course there is no duplicate column name...

 ... so - is this a silly mistake (missing bracket or apostrophe =
 better use an editor instead of the web interface to develop)
 ... is it a crass error (young man, if you had read the manual on page
 n, you would know that field definitions whatever)
 ... or what ? And how would it be best to go about debugging this sort
 of error ?

 Thank you for any suggestions. Here follows the code:

 # Tabella 1 - dati personali dei medici

 db.define_table('Medici',

 Field('SiglaMedico','string',required=True,length=5,notnull=True,unique=True),

 Field('NomeCognome','string',length=5,required=True,notnull=True,unique=True),
   Field('Email'),
   Field('LNott','boolean',default=True),
   Field('LPref','boolean',default=True),
   Field('LFest','boolean',default=True),
   Field('OrarioSett','integer',default='38'))

 db.Medici.Email.requires=IS_EMAIL(error_message=T('Indirizzo email
 invalido!'))
 db.Medici.OrarioSett.requires=IS_INT_IN_RANGE(0,40)

 # Tabella 2 - periodi di assenza dei medici

 db.define_table('Assenze',
     Field('Medici_id',db.Medici),
     Field('Inizio','datetime'),
     Field('Fine','datetime'),
     Field('PesoMotivazione','integer'),
     Field('Motivazione','string'))

 db.Assenze.Inizio.requires=IS_DATETIME()
 db.Assenze.Fine.requires=IS_DATETIME()
 db.Assenze.PesoMotivazione.requires=IS_INT_IN_RANGE(0,10)

 # Tabella 3 - tipi di servizio

 db.define_table('Servizi',

 Field('SiglaServizio','string',length=5,required=True,notnull=True,unique=True),
     Field('TipoServizio','string'))

 # Tabella 4 - tipi di turno

 db.define_table('Turni',

 Field('SiglaTurno','string',length=5,required=True,notnull=True,unique=True),
     Field('OraInizio','time'),
     Field('OraFine','time'),
     Field('DescizioneTurno','string'))

 db.Turni.OraInizio.requires=IS_TIME()
 db.Turni.OraFine.requires=IS_TIME()

 # Tabella 5 - associamo i diversi tipi di turno a diversi tipi di
 servizio

 db.define_table('ServiziTurno',
     Field('Servizi_id',db.Servizi),
     Field('Turni_id',db.Turni))

 # Tabella 6 - associamo ogni medico a diversi tipi di servizio

 db.define_table('ServiziMedici',
     Field('Servizi_id',db.Servizi),
     Field('Medici_id',db.Medici),
     Field('Preferenza','integer'))

 db.ServiziMedici.Preferenza.requires=IS_INT_IN_RANGE(0,10)

 # Tabella 7 - infine il nostro schema turni !

 db.define_table('SchemaTurni',
     Field('Data','date'),
     Field('Turni_id',db.Turni),
     Field('Medici_id',db.Medici),
     Field('Gettone','boolean',default=False),
     Field('OreServizo','integer'),
     Field('Festivo','boolean'),
     Field('Preferenza','integer'))

 db.SchemaTurni.Data.requires=IS_DATE()
 db.SchemaTurni.OreServizio.requires=IS_INT_IN_RANGE(0,12)
 db.SchemaTurni.Preferenza.requires=IS_INT_IN_RANGE(0,10)


[web2py] Re: Newbie question on self-submitting form

2010-06-06 Thread NoNoNo
Can anyone help me with this? Still not get it.=_=


[web2py] Re: Newbie question on self-submitting form

2010-06-06 Thread mr.freeze
Try changing your redirect to this:
redirect(URL(r=request, f='gotopage',args=request.vars.page_no))

On Jun 6, 6:50 am, NoNoNo coldspring830...@gmail.com wrote:
 Can anyone help me with this? Still not get it.    =_=


[web2py] Re: Newbie question on self-submitting form

2010-06-02 Thread NoNoNo
actually, what i was trying to achieve is provide a form to the
visitor to input a page number if there are multi pages. The current
problem is, when a page number is submitted, the visitor is not
redirected to that page. I hope I made the question clear. Thank you.

BTW, there is a CRUD to submit a new entry for db.whoelse, and it
works perfectly.

spring



On May 27, 8:58 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Do I understand correctly? When you submit a new db.whoelse. you want
 to be redirected to a page in the list that shows it.
 But messages are timestamped. When you submit a new now don't you get
 redirected to page 1 which shows the last message?

 Perhaps I do not understand what you mean.

 Massimo

 On May 26, 11:28 pm, NoNoNo coldspring830...@gmail.com wrote:



  Hi Massimo,

  Thanks for the reply. I tried your codes and the Previous and Next
  works well, however the self-submitting form is still not functioning.
  Input any page number and submit, still on the current page.
  I'm not sure about the mechanism how the progrom respond to a form
  submission, because you mentioned actions are not needed. Now the case
  is, there is no response. Which part of code is supposed to receive
  and process the submitted content?  I also tried to move input form
  clause from VIEW to CONTROLLER to see if it would work, and it didn't.

  BTW, for this line: 
  messages=db(db.whoelse.id0).select(orderby=~db.whoelse.created_on,limitby=­­limitby)

  an error was raise saying 'invalid sytax' which pionts to 'l' after
  '='. After inserting a space inbetween, it's ok.


[web2py] Re: Newbie question on self-submitting form

2010-05-27 Thread mdipierro
Do I understand correctly? When you submit a new db.whoelse. you want
to be redirected to a page in the list that shows it.
But messages are timestamped. When you submit a new now don't you get
redirected to page 1 which shows the last message?

Perhaps I do not understand what you mean.

Massimo





On May 26, 11:28 pm, NoNoNo coldspring830...@gmail.com wrote:
 Hi Massimo,

 Thanks for the reply. I tried your codes and the Previous and Next
 works well, however the self-submitting form is still not functioning.
 Input any page number and submit, still on the current page.
 I'm not sure about the mechanism how the progrom respond to a form
 submission, because you mentioned actions are not needed. Now the case
 is, there is no response. Which part of code is supposed to receive
 and process the submitted content?  I also tried to move input form
 clause from VIEW to CONTROLLER to see if it would work, and it didn't.

 BTW, for this line: 
 messages=db(db.whoelse.id0).select(orderby=~db.whoelse.created_on,limitby=­limitby)

 an error was raise saying 'invalid sytax' which pionts to 'l' after
 '='. After inserting a space inbetween, it's ok.


[web2py] Re: Newbie question on self-submitting form

2010-05-26 Thread mdipierro
The problem is that form should be before select. Anyway you do not
need to actions.

I suggest the following changes:

def index():
items_page=20
page_no=int(request.args(0) or 0)
limitby=(items_page*page_no,items_page*page_no+items_page+1)
#notice + 1
form=crud.create(db.whoelse,next=URL(r=request),message='Your
message is posted')
 
messages=db(db.whoelse.id0).select(orderby=~db.whoelse.created_on,limitby=limitby)
prev = (page0) and URL(r=request,args=page_no-1)
next = (len(messages)==items_page+1) and URL(r=request,args=page_no
+1)
return dict(messages=messages[:items_page], entries=entries,
form=form,page=page_no,prev=prev,next=next)

and corresponding view part:
--
{{=form}}
{{=messages}}
{{if prev:}}a href={{=prev}}previous/a{{pass}}
{{if next:}}a href={{=next}}previous/a{{next}}

--

On May 26, 3:12 am, NoNoNo coldspring830...@gmail.com wrote:
 Hi,

 I'm quite new to web2py and currently building a simple application: a
 message board, listing latest 20 messages by index(). For earlier
 messages, there is a  self-submitting form to enter page number (20
 message each page) to go to, and after submitting the form, redirects
 to that page. Here is the question on the self-submitting form:
 nothing changed (always showing the 1st page) whatever number is input
 into the form. Controller as follows:

 def index():
     page_no=1
     entries=db(db.whoelse.id  0).count()
     messages=db((db.whoelse.id(entries-20)) 
 (db.whoelse.id=entries)).select(db.whoelse.ALL,
 orderby=~db.whoelse.created_on)

     if request.vars.page_no:
         if request.vars.page_no(entries/20+1):
             redirect(URL(r=request, f='index'))
         else:
             redirect(URL(r=request, f='gotopage')
     form=crud.create(db.whoelse,
 next=URL(r=request,args=1),message='Your message is posted')
     return dict(messages=messages, entries=entries,
 form=form,page=page_no)

 def gotopage():
     entries=db(db.whoelse.id  0).count()
     messages=db((db.whoelse.id(entries-request.vars.page_no*20)) 
 (db.whoelse.id=((entries-
 (request.vars.page_no-1)*20.select(db.whoelse.ALL,
 orderby=~db.whoelse.created_on)

     form=crud.create(db.whoelse,
 next=URL(r=request,args=1),message='Your message is posted')
     return dict(messages=messages, entries=entries, form=form,
 page=request.vars.page_no)
 --
 and corresponding view part:
  h5{{=page}}/{{=entries/20+1}} Pagesnbsp;nbsp;nbsp;nbsp;Go to
 page:forminput name=page_no /  input type=submit //form/
 h5
 --

 Any reply will be appreciated.

 Spring


[web2py] Re: Newbie question on self-submitting form

2010-05-26 Thread NoNoNo
Hi Massimo,

Thanks for the reply. I tried your codes and the Previous and Next
works well, however the self-submitting form is still not functioning.
Input any page number and submit, still on the current page.
I'm not sure about the mechanism how the progrom respond to a form
submission, because you mentioned actions are not needed. Now the case
is, there is no response. Which part of code is supposed to receive
and process the submitted content?  I also tried to move input form
clause from VIEW to CONTROLLER to see if it would work, and it didn't.

BTW, for this line:
 messages=db(db.whoelse.id0).select(orderby=~db.whoelse.created_on,limitby=­limitby)
an error was raise saying 'invalid sytax' which pionts to 'l' after
'='. After inserting a space inbetween, it's ok.



  1   2   >