[web2py] pagination previous and next on the controller

2011-05-15 Thread 黄祥
hi,

i've test the pagination from : 
http://web2py.com/book/default/chapter/12?search=pagination#Pagination
and tried to change the next and previous that on view into the
controller

e.g.
from view:
{{if page:}}
a href={{=URL(args=[page-1])}}previous/a
{{pass}}

{{if len(rows)items_per_page:}}
a href={{=URL(args=[page+1])}}next/a
{{pass}}

into controller:
def list_items():
if len(request.args): page=int(request.args[0])
else: page=0
items_per_page=20
limitby=(page*items_per_page,(page+1)*items_per_page+1)
rows=db().select(db.prime.ALL,limitby=limitby)
if page:
previous = a href={{=URL(args=[page-1])}}previous/a

if len(rows)items_per_page:
next = a href={{=URL(args=[page+1])}}next/a
return
dict(rows=rows,page=page,items_per_page=items_per_page,previous=previous,next=next)


but returned an error, is there any solution for this?
thank you very much before


[web2py] differntial of request.args[0] and request.args(0)

2011-05-15 Thread 黄祥
hi,

is there anybody knows the differntial between request.args[0] and
request.args(0)?
which better to be used on the application?

thank you so much.


[web2py] Re: pagination previous and next on the controller

2011-05-15 Thread pbreit
You don't put {{ and }} in controllers. Just do it like it is in the book. 
HTML typically belongs in the view.

[web2py] Re: differntial of request.args[0] and request.args(0)

2011-05-15 Thread ron_m
In the core chapter of the book I found this:

In the above example, both request.args[i] and request.args(i) can be used 
to retrieve the i-th element of the request.args, but while the former 
raises an exception if the list does not have such an index, the latter 
returns None in this case.

I would use request.args(0) and test for None if it is legal for the arg to 
not to be there on some requests. Conversely, if arg 0 is always supposed to 
be part of the request then request.args[0] would generate an exception and 
a ticket indicating a failure condition when it is missing.



Re: [web2py] Re: differntial of request.args[0] and request.args(0)

2011-05-15 Thread Stifan Kristi
i'm understand right now, thank you so much for your detail explaination ron

On Sun, May 15, 2011 at 2:08 PM, ron_m ron.mco...@gmail.com wrote:

 In the core chapter of the book I found this:

 In the above example, both request.args[i] and request.args(i) can be used
 to retrieve the i-th element of the request.args, but while the former
 raises an exception if the list does not have such an index, the latter
 returns None in this case.

 I would use request.args(0) and test for None if it is legal for the arg to
 not to be there on some requests. Conversely, if arg 0 is always supposed to
 be part of the request then request.args[0] would generate an exception and
 a ticket indicating a failure condition when it is missing.




Re: [web2py] Re: pagination previous and next on the controller

2011-05-15 Thread Stifan Kristi
i've already tried to moved curly brackets {{ }} in the controllers and
still gettin an error, my intention is because all of my views is using
pagination and i want to simplified it to just put on the centralize db
functions.
is there any ways to do this?
thank you so much

On Sun, May 15, 2011 at 1:48 PM, pbreit pbreitenb...@gmail.com wrote:

 You don't put {{ and }} in controllers. Just do it like it is in the book.
 HTML typically belongs in the view.


[web2py] show multiple tables in 1 page

2011-05-15 Thread 黄祥
hi,

is it possible to show multiple tables in 1 page?

e.g. like on http://web2py.com/book/default/chapter/03#A-Wiki
but i want to add the comment on the index function like :
def index():
 pages = db().select(db.page.id, db.page.title, orderby =
db.page.title)
 this_page = db.page(request.args(0))
 db.comment.page_id.default = this_page.id
 form = crud.create(db.comment) if auth.user else None
 pagecomments = db(db.comment.page_id == this_page.id).select()
 return dict(pages = pages, page = this_page, comments =
pagecomments, form = form)

my above code return an error :

Traceback (most recent call last):
  File /home/sugizo/web2py/gluon/restricted.py, line 181, in
restricted
exec ccode in environment
  File /home/sugizo/web2py/applications/a/controllers/default.py,
line 67, in module
  File /home/sugizo/web2py/gluon/globals.py, line 133, in lambda
self._caller = lambda f: f()
  File /home/sugizo/web2py/applications/a/controllers/default.py,
line 9, in index
db.comment.page_id.default = this_page.id
AttributeError: 'NoneType' object has no attribute 'id'

is there another way to do this?
any hints or pointer is greatly appreciate, thank you very much before


[web2py] Re: default usage

2011-05-15 Thread villas
It is simply how that record id will be displayed when used in a
foreign key.

e.g.

table colors:
   id: 1,  name: red,
   id: 2,  name: yellow,

table cars:
   id: 1,  descr: sport,  color_id: 1

When you create a form for 'cars',  how would you like the color_id
field to appear?

a) a drop-down box showing id numbers 1,2
b) a drop-down box showing red, yellow

Most people would say b).  Therefore they use record representation to
enable this to happen automatically.

db.define_table('colors', Field('name'), format='%(name)s')


On May 15, 5:39 am, pbreit pbreitenb...@gmail.com wrote:
 I still don't understand Record Representation. Is there a plain english
 description or, better, examples of what it actually does?


[web2py] Weird Error in modules files...

2011-05-15 Thread Jason Brower

I am using latest, not trunk...
I was testing some of my code and I got some index errors.  That's fine 
so I go into the file and make some changes.  Then it says the same 
error but this time a different line.  One that doesn't even use indexs.

So I put a comment on the line and this is what I got...

Traceback(most recent call last):
  File/home/encompass/Programming/Web 
Pages/web2py/gluon/restricted.py,line181,inrestricted
execccodeinenvironment
  File/home/encompass/Programming/Web 
Pages/web2py/applications/interestID_final/controllers/event.py  
http://127.0.0.1:8000/admin/default/edit/interestID_final/controllers/event.py,line470,inmodule
  File/home/encompass/Programming/Web 
Pages/web2py/gluon/globals.py,line133,inlambda
self._caller=lambdaf:f()
  File/home/encompass/Programming/Web Pages/web2py/gluon/tools.py,line2335,inf
returnaction(*a, **b)
  File/home/encompass/Programming/Web 
Pages/web2py/applications/interestID_final/controllers/event.py  
http://127.0.0.1:8000/admin/default/edit/interestID_final/controllers/event.py,line133,inindex
largest_item+size_variance-user._extra['COUNT(users_tags.id)'])):
  
Fileapplications/interestID_final/modules/placement_calculator.py,line62,inplace
#This is some commented stuff...
IndexError:list index out of range

Funny, but not really as I can't figure out what is wrong here.
I have deleted any traces of .pyc files, and run a clean on the app 
with no change in result.
I even put wrong syntax and it still doesn't change anything.  I have 
check many times to make sure I am working with the same file. I have 
even change the file's name and it doesn't crash but shows the same error.

BR,
Jason Brower


[web2py] Re: profiler: ImportError: No module named pstats?

2011-05-15 Thread Philip
Solved - default debian/ubuntu install of python no longer includes
the profiler because of license issues. The package python-profiler
needs to be installed. Sorry for wasting your time.

Thanks,
Philip

On May 14, 4:56 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I am running it with 2.5

 On May 14, 3:11 pm, Philip philip.el...@gmail.com wrote:







  python 2.6.5 running on Linux (ubuntu) using current web2py src. Does
  the profiler require 2.7?

  Thanks,
  Philip

  On May 14, 1:22 pm, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:

   -F profiler.log

   works for me. Which python version? which os?

   On May 13, 6:45 pm, Philip philip.el...@gmail.com wrote:

I am trying to use the web2py profiler (which I haven't used before).
I tried starting web2py with the -F option and a filename, and I get
the following error:

ImportError: No module named pstats

Any ideas on why it isn't working? I couldn't find any documentation
for the profiler feature other than a few posts on this group and the
listing of -F as one of the command line options.

Thanks,
Philip


[web2py] has anyone used fathom (or something alike) with web2py DAL ?

2011-05-15 Thread Stef Mientki
hello,

has anyone used pathom
http://code.google.com/p/fathom/downloads/list

especially the GraphViz representation looks usefull to me.

Are there other packages that can show a representatie like this ?

thanks,
Stef


Re: [web2py] Re: default usage

2011-05-15 Thread Stifan Kristi
a, i got it, thank you so much for your detail explaination and example,
villas.

On Sun, May 15, 2011 at 5:27 PM, villas villa...@gmail.com wrote:

 It is simply how that record id will be displayed when used in a
 foreign key.

 e.g.

 table colors:
   id: 1,  name: red,
   id: 2,  name: yellow,

 table cars:
   id: 1,  descr: sport,  color_id: 1

 When you create a form for 'cars',  how would you like the color_id
 field to appear?

 a) a drop-down box showing id numbers 1,2
 b) a drop-down box showing red, yellow

 Most people would say b).  Therefore they use record representation to
 enable this to happen automatically.

 db.define_table('colors', Field('name'), format='%(name)s')


 On May 15, 5:39 am, pbreit pbreitenb...@gmail.com wrote:
  I still don't understand Record Representation. Is there a plain english
  description or, better, examples of what it actually does?


[web2py] Re: Class-based controllers and prefixes in wizard

2011-05-15 Thread Dmitriy
Thanks all for the prompt answers! Massimo, I think that the flag in
Wizard can solve the prefixes issue.

Regarding the class-based controllers.

pbreit, the components and the load function can help me in the
composition, but can't help in the  inheritance.

Thanks for a good example, Bruno! I agree with you that domain
specific logic must be located in the Model and Flow specific logic
must be located in the Controller.
For such case we need ORM in the Model, but we have DAL. OK, suppose
we  have created an ORM over the DAL. It will give me a possibility to
inherit domain (model) specific logic. But I want to inherit work-flow
logic too.

Here is an example.
Suppose we have a class/table hierarchy:

Person-Customer-VipCustomer. Customer can Purchase something, Vip
Customer can Purchase goods with discount and get a branded gift.

1. The case of class-based controllers:

class Person(BaseController):
   def Create()
   def Read()
   def Update()
   def Delete()

class Customer(Person):
   def Purchase()

class VipCustomer(Customer):
   def Create()  #define discount
   def Purchase() #purchase a product with discount and direct a
user to a gift page
   def SelectGift()#select a gift after purchase

2. The case of function-based controllers:
Person_Create()
Person_Read()
Person_Update()
Person_Delete()

Person_Create()
Person_Read()
Person_Update()
Person_Delete()
Person_Purchase()

VipCustomer_Create()
VipCustomer_Read()
VipCustomer_Update()
VipCustomer_Delete()
VipCustomer_Purchase()
VipCustomer_SelectGift()

The functional case has 15 methods. In the first case there are 3
classes and 8 methods (more compact and readable). Why do I need to
repeat some methods in the successors?


[web2py] make project_id identical with isReply

2011-05-15 Thread Andrew Evans
Hello I have a commenting system I am working on and I am having a problem
with passing the arguments so they match up.

I am trying to make comments.project_id match up with the isReply field when
I add a Reply I am passing args=row.project_id as an argument to the
reply_comment form

My comment system works its passing a reply to the comment which is
troubling me any ideas are greatly appreciated

Here is my controller


@auth.requires_login()
def reply_comment():
post_reply = db(db.comments.project_id ==
request.args(0)).select().first()
form = SQLFORM(db.comments)
form.vars.isReply = post_reply.id
if form.accepts(request.vars, session):
response.flash = 'Task Comment Posted'
elif form.errors:
response.flash = 'Please fix the highlighted areas'
return dict(form = form)


and table

db.define_table('comments',
Field('userinfo', db.auth_user, default=auth.user_id, readable=False,
writable=False),
Field('project_id', db.project, requires = IS_IN_DB(db, db.project.id,
'%(project_title)s'), readable=False, writable=False),
Field('isReply', 'integer', default=0, readable=False, writable=False),
Field('comment_title', length=256, requires = IS_NOT_EMPTY()),
Field('comment_description', 'text'),
Field('created_on', 'datetime', default=datetime.datetime.now(),
readable=False, writable=False))

and what I am passiing from my view

a href={{=URL('comments', 'reply_comment', args=row.project_id)}}Reply
to Comment/a


What I see as out put for a reply in database app admin

14 
https://www.techshinobi.com/ourprojects/appadmin/update/db/comments/141https://www.techshinobi.com/ourprojects/appadmin/update/db/auth_user/1
Nonehttps://www.techshinobi.com/ourprojects/appadmin/update/db/project/None
6tetsing 44test 442011-05-15 05:19:57

The number 6 is the isReply Field and the word None is the project_id field
I think I am approaching this the right way but I am open to suggestions
*cheers


[web2py] Re: Multiple tables: update/insert/delete: in one form

2011-05-15 Thread Simon Ashley
Since no one has replied for a couple of days, I'll toss my 2 cents
in. Don't how much value this could be, as we just evaluating web2py
and python but in another environment we could have written data in
the normalised records to a temporary record in a denormalised,
virtual table, update and saved this record, and then do selective
updates, insertions and deletions on each normalised record in the
original tables. Not that elegant but ...

On May 13, 9:17 pm, Vineet vineet.deod...@gmail.com wrote:
 pbreit,
 As you say, wherever possible or required, I have already denormalized
 the table-structures.
 Apart from normalization / denormalization issue, in many other forms,
 I need to insert/update/delete records in multiple tables from one
 form.
 (as I mentioned earlier, there will be a mix of insert/update/delete
 of record(s) in different tables.)

 Massimo,
 If you too haven't understood what I intend to do with these 5 tables,
 I can elaborate the idea.
 Pl. tell me accordingly.
 The very success of developing my project using web2py hinges on this
 functionality.

 ---Vineet
 

 On May 11, 5:17 am, pbreit pbreitenb...@gmail.com wrote:







  Normalizing is not always the best approach. If the database has not yet
  been designed, perhaps reconsider. I still don't really understand what you
  are trying to do but 5 small tables might not be necessary.

  I would suggest getting some code working with 2 tables an then go from
  there.

  Some 
  options:http://web2py.com/book/default/chapter/07#One-form-for-multiple-table...

  Another approach would to use FORM or SQLFORM.factory and then coding the
  database updates. You lose some of the Web2py features but it might still be
  the easiest way to do it.

  But my first suggestion would be to try and simplify what you are intending
  to do.


[web2py] Re: Multiple tables: update/insert/delete: in one form

2011-05-15 Thread Vineet
Simon,
That is a good idea.
In fact, almost the same approach is being followed in VFP cursor
adaptor (the difference being that, data from MySQL tables is
reproduced in same table structures, i.e cursors).

Here, by virtual table, do you mean to say that we should reproduce
the data into dictionaries by fetching a dict cursor from MySQLdb?
(in DABO, they have an excellent concept of bizobj for this task).

I am not asking for exact code, but can you suggest an approach to
tackle the task?

Dear Massimo  other friends,
can you pl. suggest something to solve my problem?

Thanks,
Vineet.

=
On May 15, 5:07 pm, Simon Ashley gregs...@gmail.com wrote:
 Since no one has replied for a couple of days, I'll toss my 2 cents
 in. Don't how much value this could be, as we just evaluating web2py
 and python but in another environment we could have written data in
 the normalised records to a temporary record in a denormalised,
 virtualtable, update and saved this record, and then do selective
 updates, insertions and deletions on each normalised record in the
 original tables. Not that elegant but ...

 On May 13, 9:17 pm, Vineet vineet.deod...@gmail.com wrote:







  pbreit,
  As you say, wherever possible or required, I have already denormalized
  thetable-structures.
  Apart from normalization / denormalization issue, in many other forms,
  I need to insert/update/delete records inmultipletables from one
  form.
  (as I mentioned earlier, there will be a mix of insert/update/delete
  of record(s) in different tables.)

  Massimo,
  If you too haven't understood what I intend to do with these 5 tables,
  I can elaborate the idea.
  Pl. tell me accordingly.
  The very success of developing my project using web2py hinges on this
  functionality.

  ---Vineet
  

  On May 11, 5:17 am, pbreit pbreitenb...@gmail.com wrote:

   Normalizing is not always the best approach. If the database has not yet
   been designed, perhaps reconsider. I still don't really understand what 
   you
   are trying to do but 5 small tables might not be necessary.

   I would suggest getting some code working with 2 tables an then go from
   there.

   Some 
   options:http://web2py.com/book/default/chapter/07#One-form-for-multiple-table...

   Another approach would to use FORM or SQLFORM.factory and then coding the
   database updates. You lose some of the Web2py features but it might still 
   be
   the easiest way to do it.

   But my first suggestion would be to try and simplify what you are 
   intending
   to do.


[web2py] Re: Weird Error in modules files...

2011-05-15 Thread DenesL

It is hard to tell without the code but this looks suspicious

  size_variance-user._extra['COUNT(users_tags.id)']))

why is COUNT(...) in quotes?


On May 15, 7:12 am, Jason Brower encomp...@gmail.com wrote:
 I am using latest, not trunk...
 I was testing some of my code and I got some index errors.  That's fine
 so I go into the file and make some changes.  Then it says the same
 error but this time a different line.  One that doesn't even use indexs.
 So I put a comment on the line and this is what I got...

 Traceback(most recent call last):
    File/home/encompass/Programming/Web 
 Pages/web2py/gluon/restricted.py,line181,inrestricted
      execccodeinenvironment
    File/home/encompass/Programming/Web 
 Pages/web2py/applications/interestID_final/controllers/event.py  
 http://127.0.0.1:8000/admin/default/edit/interestID_final/controllers...,line470,inmodule
    File/home/encompass/Programming/Web 
 Pages/web2py/gluon/globals.py,line133,inlambda
      self._caller=lambdaf:f()
    File/home/encompass/Programming/Web 
 Pages/web2py/gluon/tools.py,line2335,inf
      returnaction(*a, **b)
    File/home/encompass/Programming/Web 
 Pages/web2py/applications/interestID_final/controllers/event.py  
 http://127.0.0.1:8000/admin/default/edit/interestID_final/controllers...,line133,inindex
      largest_item+size_variance-user._extra['COUNT(users_tags.id)'])):
    
 Fileapplications/interestID_final/modules/placement_calculator.py,line62,inplace
      #This is some commented stuff...
 IndexError:list index out of range

 Funny, but not really as I can't figure out what is wrong here.
 I have deleted any traces of .pyc files, and run a clean on the app
 with no change in result.
 I even put wrong syntax and it still doesn't change anything.  I have
 check many times to make sure I am working with the same file. I have
 even change the file's name and it doesn't crash but shows the same error.
 BR,
 Jason Brower


[web2py] Re: show multiple tables in 1 page

2011-05-15 Thread DenesL

The error is due to the possibility of not finding a record in db.page
using request.args(0) as id.
Your program has to be able to deal with this eventuality.


On May 15, 4:34 am, 黄祥 steve.van.chris...@gmail.com wrote:
 hi,

 is it possible to show multiple tables in 1 page?

 e.g. like onhttp://web2py.com/book/default/chapter/03#A-Wiki
 but i want to add the comment on the index function like :
 def index():
      pages = db().select(db.page.id, db.page.title, orderby =
 db.page.title)
      this_page = db.page(request.args(0))
      db.comment.page_id.default = this_page.id
      form = crud.create(db.comment) if auth.user else None
      pagecomments = db(db.comment.page_id == this_page.id).select()
      return dict(pages = pages, page = this_page, comments =
 pagecomments, form = form)

 my above code return an error :

 Traceback (most recent call last):
   File /home/sugizo/web2py/gluon/restricted.py, line 181, in
 restricted
     exec ccode in environment
   File /home/sugizo/web2py/applications/a/controllers/default.py,
 line 67, in module
   File /home/sugizo/web2py/gluon/globals.py, line 133, in lambda
     self._caller = lambda f: f()
   File /home/sugizo/web2py/applications/a/controllers/default.py,
 line 9, in index
     db.comment.page_id.default = this_page.id
 AttributeError: 'NoneType' object has no attribute 'id'

 is there another way to do this?
 any hints or pointer is greatly appreciate, thank you very much before


Re: [web2py] Re: Weird Error in modules files...

2011-05-15 Thread Jason Brower
After restarting the server it seems the issue was fixed.  It could be 
that the modules are loaded and then assumed that they don't change so 
they are placed in memory for speed reasons or something like that.

BR,
Jason Brower

On 05/15/2011 06:18 PM, DenesL wrote:

It is hard to tell without the code but this looks suspicious

   size_variance-user._extra['COUNT(users_tags.id)']))

why is COUNT(...) in quotes?


On May 15, 7:12 am, Jason Browerencomp...@gmail.com  wrote:

I am using latest, not trunk...
I was testing some of my code and I got some index errors.  That's fine
so I go into the file and make some changes.  Then it says the same
error but this time a different line.  One that doesn't even use indexs.
So I put a comment on the line and this is what I got...

Traceback(most recent call last):
File/home/encompass/Programming/Web 
Pages/web2py/gluon/restricted.py,line181,inrestricted
  execccodeinenvironment
File/home/encompass/Programming/Web 
Pages/web2py/applications/interestID_final/controllers/event.pyhttp://127.0.0.1:8000/admin/default/edit/interestID_final/controllers...,line470,inmodule
File/home/encompass/Programming/Web 
Pages/web2py/gluon/globals.py,line133,inlambda
  self._caller=lambdaf:f()
File/home/encompass/Programming/Web 
Pages/web2py/gluon/tools.py,line2335,inf
  returnaction(*a, **b)
File/home/encompass/Programming/Web 
Pages/web2py/applications/interestID_final/controllers/event.pyhttp://127.0.0.1:8000/admin/default/edit/interestID_final/controllers...,line133,inindex
  largest_item+size_variance-user._extra['COUNT(users_tags.id)'])):

Fileapplications/interestID_final/modules/placement_calculator.py,line62,inplace
  #This is some commented stuff...
IndexError:list index out of range

Funny, but not really as I can't figure out what is wrong here.
I have deleted any traces of .pyc files, and run a clean on the app
with no change in result.
I even put wrong syntax and it still doesn't change anything.  I have
check many times to make sure I am working with the same file. I have
even change the file's name and it doesn't crash but shows the same error.
BR,
Jason Brower




[web2py] Two fields with autocomplete in a single form fail

2011-05-15 Thread nekrox
db.define_table('cities',
Field('name', 'string'),
Field('state', db.states)
)


db.define_table('categories',
Field('name', 'string')
)


db.define_table('places',
Field('name', 'string', required=True),
Field('address1', 'string'),
Field('address2', 'string'),
Field('phone', 'string'),
Field('city',
widget=SQLFORM.widgets.autocomplete(request,
db.cities.name,
id_field=db.cities.id)),
Field('zip', 'integer'),
Field('category',
widget=SQLFORM.widgets.autocomplete(request,
db.categories.name,
id_field=db.categories.id)),
Field('web', 'string'),
Field('email', 'string'),
Field('description', 'string')
)

I havae this tables wit ha two fields with autocomplete, but only show
results for the firts field in both fields! I think the problem is in
javascript because only consult an first url, something with the html
inputs id maybe, the code is highly obfuscated so I have not been able
to review it.


[web2py] Re: show multiple tables in 1 page

2011-05-15 Thread pbreit
That's why you would not usually structure it like this. Your index page is 
going to show all of the pages but then the comments for just one page. And 
as Denes points out, if someone just goes to /index, you're going to be 
missing a request.args(0). I don't really understand why you would set it up 
like this.

Re: [web2py] Re: pagination previous and next on the controller

2011-05-15 Thread pbreit
You could check out this approach:
http://packages.python.org/web2py_utils/paginate.html

{{ }} *ONLY* work in views. The other thing you could consider if you want 
to put it in a controller, model or module is using HTML tag helpers like 
this:

if page: 
previous = A('previous', _href=URL(args=[page-1]))


Re: [web2py] Re: differntial of request.args[0] and request.args(0)

2011-05-15 Thread pbreit
Just remember that the () method is unique to Web2py strorage objects and 
cannot be used generally in Python.

Same for request.vars (web2py) vs. request['vars'] (python).

http://web2py.com/book/default/chapter/04#request

Is that correct everyone?


[web2py] Re: make project_id identical with isReply

2011-05-15 Thread pbreit
Do you have a reply_comment view?

It should at least have in it {{=form}}


Re: [web2py] Re: Class-based controllers and prefixes in wizard

2011-05-15 Thread Bruno Rocha
The functional case has 15 methods. In the first case there are 3
classes and 8 methods (more compact and readable). Why do I need to
repeat some methods in the successors?

Now, with new web2py in trunk you can create this logic under /modules (as
normal Python modules)

in your controllers you will just need to instantiate your classes and work
with inheritance,
take a look the new global scope in trunk, now you can bind your db and
other application specific objects as request,session, response in to a
global object called current so you can access that objects in modules.

I am doing some tests and I will use DAL to create my ORM too using the new
importer and global scope.

http://martin.tecnodoc.com.ar/default/post/2011/05/13/20_optimize-your-web2py-app-using-the-new-import-method


--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


Re: [web2py] Re: differntial of request.args[0] and request.args(0)

2011-05-15 Thread Jason Brower
That is correct, except it really is python that Massimo has done here.  
It's a convenience method that he has created for this very issue as it 
happens a lot.


On 05/15/2011 08:51 PM, pbreit wrote:
Just remember that the () method is unique to Web2py strorage 
objects and cannot be used generally in Python.


Same for request.vars (web2py) vs. request['vars'] (python).

http://web2py.com/book/default/chapter/04#request

Is that correct everyone?




[web2py] web2py japan - congratulations

2011-05-15 Thread Massimo Di Pierro
Who did this? Congratulations!

http://sites.google.com/site/web2pyjapan/book/01



[web2py] web2py syntax for vim

2011-05-15 Thread pancurster
Hi,
I was looking today for vim syntax for web2py templates but I didn't
find it. So I make my own. If some one want this syntax files here u
go:
http://dl.dropbox.com/u/18809604/vim_web2py_syntax/htmlweb2py.vim
http://dl.dropbox.com/u/18809604/vim_web2py_syntax/web2py.vim
htmlweb2py.vim is main syntax file.
I want apologize if something don't work. If someone know how to fix
this files, mail me or fork this and mail me :)

ps. I'm sorry for my English.


Re: [web2py] Re: show multiple tables in 1 page

2011-05-15 Thread Stifan Kristi
thank you so much for your hints and pointers denes  pbreit, pardon me, i
just wan to show up all of the content of wiki page on index page and also
the comments that related with it. is there a way to do this?

i've already modified it into (learned from kenneth damian blog on
appliances):

def index():
 pages = db().select(db.page.ALL, orderby = db.page.title)
 db.comment.page_id.default = db.page.id
 form = crud.create(db.comment) if auth.user else None
 comments = db(db.comment.page_id == db.page.id).select()
 return dict(pages = pages, comments = comments, form = form)

but still gettin an error, the strange is in kenneth damian blog appliance,
this code is workin, did anyone know how to fix it?

thank you very much before


Re: [web2py] web2py japan - congratulations

2011-05-15 Thread Stifan Kristi
great job, congratulations!


On Mon, May 16, 2011 at 2:51 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Who did this? Congratulations!

 http://sites.google.com/site/web2pyjapan/book/01




Re: [web2py] Re: differntial of request.args[0] and request.args(0)

2011-05-15 Thread Stifan Kristi
a, i'm understand right now, thank you so much for your detail explaination
all.


On Mon, May 16, 2011 at 12:51 AM, pbreit pbreitenb...@gmail.com wrote:

 Just remember that the () method is unique to Web2py strorage objects and
 cannot be used generally in Python.

 Same for request.vars (web2py) vs. request['vars'] (python).

 http://web2py.com/book/default/chapter/04#request

 Is that correct everyone?



Re: [web2py] web2py syntax for vim

2011-05-15 Thread contatogilson...@gmail.com
Fork the project for add files: https://github.com/lvidarte/web2py-snippets
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/5/15 pancurster pancurs...@gmail.com

 Hi,
 I was looking today for vim syntax for web2py templates but I didn't
 find it. So I make my own. If some one want this syntax files here u
 go:
 http://dl.dropbox.com/u/18809604/vim_web2py_syntax/htmlweb2py.vim
 http://dl.dropbox.com/u/18809604/vim_web2py_syntax/web2py.vim
 htmlweb2py.vim is main syntax file.
 I want apologize if something don't work. If someone know how to fix
 this files, mail me or fork this and mail me :)

 ps. I'm sorry for my English.


Re: [web2py] Re: pagination previous and next on the controller

2011-05-15 Thread Stifan Kristi
thank you so much for your hints and pointers, pbreit. i've already read the
url, but still don't understand, what is the intent of the url. but i get it
what you've said, again thank you very much.

On Mon, May 16, 2011 at 12:44 AM, pbreit pbreitenb...@gmail.com wrote:

 You could check out this approach:
 http://packages.python.org/web2py_utils/paginate.html

 {{ }} *ONLY* work in views. The other thing you could consider if you want
 to put it in a controller, model or module is using HTML tag helpers like
 this:

 if page:
 previous = A('previous', _href=URL(args=[page-1]))



[web2py] Domains and Web2Py

2011-05-15 Thread Oscar
Hi,

I want to host a single Web2Py installation with few appliances or
apps installed on it, Can I redirecto with Web2Py every domain pointed
to my host to the related appliance? I mean at Web2Py level, not to
ngix or Apache level.

Regards,

Oscar.


[web2py] How to apply a layout?

2011-05-15 Thread Vinicius Assef
Guys, I'm certains this is very basic stuff, but I couldn't find an
explanation to apply a layout from www.web2py.com/layouts to my app.

I downloaded a file with w2p extension from there and I don't know how
to use it.

Please, send me a link because the book chapter about it doesn't touch
about using a w2p file.

Thanks.

--
Vinicius Assef.


[web2py] Re: Multiple tables: update/insert/delete: in one form

2011-05-15 Thread villas
Hi Vineet

I'm sorry you didn't get a satisfactory answer, but I imagine there
are group members like myself who would love to contribute but don't
quite understand.  Let's see if I got this right...

You have a tricky form which might affect several different tables
depending on which fields are completed?  I see the data model,  but
what is the problem?

Are you having difficulty writing some tricky logic into a
controller?  If so,  what do you have so far and what is the issue?

Maybe we could see the form?

Best regards,
D

On May 15, 4:15 pm, Vineet vineet.deod...@gmail.com wrote:
 Simon,
 That is a good idea.
 In fact, almost the same approach is being followed in VFP cursor
 adaptor (the difference being that, data from MySQL tables is
 reproduced in same table structures, i.e cursors).

 Here, by virtual table, do you mean to say that we should reproduce
 the data into dictionaries by fetching a dict cursor from MySQLdb?
 (in DABO, they have an excellent concept of bizobj for this task).

 I am not asking for exact code, but can you suggest an approach to
 tackle the task?

 Dear Massimo  other friends,
 can you pl. suggest something to solve my problem?

 Thanks,
 Vineet.

 =
 On May 15, 5:07 pm, Simon Ashley gregs...@gmail.com wrote:

  Since no one has replied for a couple of days, I'll toss my 2 cents
  in. Don't how much value this could be, as we just evaluating web2py
  and python but in another environment we could have written data in
  the normalised records to a temporary record in a denormalised,
  virtualtable, update and saved this record, and then do selective
  updates, insertions and deletions on each normalised record in the
  original tables. Not that elegant but ...

  On May 13, 9:17 pm, Vineet vineet.deod...@gmail.com wrote:

   pbreit,
   As you say, wherever possible or required, I have already denormalized
   thetable-structures.
   Apart from normalization / denormalization issue, in many other forms,
   I need to insert/update/delete records inmultipletables from one
   form.
   (as I mentioned earlier, there will be a mix of insert/update/delete
   of record(s) in different tables.)

   Massimo,
   If you too haven't understood what I intend to do with these 5 tables,
   I can elaborate the idea.
   Pl. tell me accordingly.
   The very success of developing my project using web2py hinges on this
   functionality.

   ---Vineet
   

   On May 11, 5:17 am, pbreit pbreitenb...@gmail.com wrote:

Normalizing is not always the best approach. If the database has not yet
been designed, perhaps reconsider. I still don't really understand what 
you
are trying to do but 5 small tables might not be necessary.

I would suggest getting some code working with 2 tables an then go from
there.

Some 
options:http://web2py.com/book/default/chapter/07#One-form-for-multiple-table...

Another approach would to use FORM or SQLFORM.factory and then coding 
the
database updates. You lose some of the Web2py features but it might 
still be
the easiest way to do it.

But my first suggestion would be to try and simplify what you are 
intending
to do.




[web2py] Re: web2py japan - congratulations

2011-05-15 Thread kenji4569
Hi Massimo,

the site is recently developed by a member of web2py-japan, Nakagaki-
san. The book translation and any information of web2py are written
and published here, by members of web2py-japan. The translation is
still in progress, and will be feedbacked to you when finished. Thanks
for your mention :)

On 5月16日, 午前4:51, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Who did this? Congratulations!

 http://sites.google.com/site/web2pyjapan/book/01


Re: [web2py] How to apply a layout?

2011-05-15 Thread Bruno Rocha
Layouts are plugins, un your app click in plugin and choose the file to
upload.
Em 15/05/2011 21:31, Vinicius Assef vinicius...@gmail.com escreveu:
 Guys, I'm certains this is very basic stuff, but I couldn't find an
 explanation to apply a layout from www.web2py.com/layouts to my app.

 I downloaded a file with w2p extension from there and I don't know how
 to use it.

 Please, send me a link because the book chapter about it doesn't touch
 about using a w2p file.

 Thanks.

 --
 Vinicius Assef.


[web2py] Re: Domains and Web2Py

2011-05-15 Thread Anthony
See http://web2py.com/book/default/chapter/04#Parameter-Based-System, in 
particular, this example:
 
routers = dict( 
  BASE  = dict( 
  domains = { 
  'domain1.com' : 'app1', 
  'domain2.com' : 'app2', 
  } 
  ), 
)
 
Anthony

On Sunday, May 15, 2011 8:23:46 PM UTC-4, Oscar wrote:

 Hi, 

 I want to host a single Web2Py installation with few appliances or 
 apps installed on it, Can I redirecto with Web2Py every domain pointed 
 to my host to the related appliance? I mean at Web2Py level, not to 
 ngix or Apache level. 

 Regards, 

 Oscar.



Re: [web2py] Re: web2py japan - congratulations

2011-05-15 Thread Stifan Kristi
hi, massimo,

why u didn't also put japanese translation language on web2py default?
it's just a suggestion.

thanks

On Mon, May 16, 2011 at 8:04 AM, kenji4569 hos...@s-cubism.jp wrote:

 Hi Massimo,

 the site is recently developed by a member of web2py-japan, Nakagaki-
 san. The book translation and any information of web2py are written
 and published here, by members of web2py-japan. The translation is
 still in progress, and will be feedbacked to you when finished. Thanks
 for your mention :)

 On 5月16日, 午前4:51, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:
  Who did this? Congratulations!
 
  http://sites.google.com/site/web2pyjapan/book/01


[web2py] Re: web2py japan - congratulations

2011-05-15 Thread kenji4569
 why u didn't also put japanese translation language on web2py default?
To do so, we have to arrange the translation in markmin format, and
will do it when the translation finished.

On 5月16日, 午前10:43, Stifan Kristi steve.van.chris...@gmail.com wrote:
 hi, massimo,

 why u didn't also put japanese translation language on web2py default?
 it's just a suggestion.

 thanks







 On Mon, May 16, 2011 at 8:04 AM, kenji4569 hos...@s-cubism.jp wrote:
  Hi Massimo,

  the site is recently developed by a member of web2py-japan, Nakagaki-
  san. The book translation and any information of web2py are written
  and published here, by members of web2py-japan. The translation is
  still in progress, and will be feedbacked to you when finished. Thanks
  for your mention :)

  On 5月16日, 午前4:51, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:
   Who did this? Congratulations!

  http://sites.google.com/site/web2pyjapan/book/01


Re: [web2py] Re: web2py japan - congratulations

2011-05-15 Thread Stifan Kristi
a, great to hear that hosoda kenji san. i'll wait and want to try it.

On Mon, May 16, 2011 at 9:23 AM, kenji4569 hos...@s-cubism.jp wrote:

  why u didn't also put japanese translation language on web2py default?
 To do so, we have to arrange the translation in markmin format, and
 will do it when the translation finished.

 On 5月16日, 午前10:43, Stifan Kristi steve.van.chris...@gmail.com wrote:
  hi, massimo,
 
  why u didn't also put japanese translation language on web2py default?
  it's just a suggestion.
 
  thanks
 
 
 
 
 
 
 
  On Mon, May 16, 2011 at 8:04 AM, kenji4569 hos...@s-cubism.jp wrote:
   Hi Massimo,
 
   the site is recently developed by a member of web2py-japan, Nakagaki-
   san. The book translation and any information of web2py are written
   and published here, by members of web2py-japan. The translation is
   still in progress, and will be feedbacked to you when finished. Thanks
   for your mention :)
 
   On 5月16日, 午前4:51, Massimo Di Pierro massimo.dipie...@gmail.com
   wrote:
Who did this? Congratulations!
 
   http://sites.google.com/site/web2pyjapan/book/01


Re: [web2py] Re: show multiple tables in 1 page

2011-05-15 Thread pbreit
Hard to say the best way to do it. This might be one way (not tested).

=== controller ===
def index():
pages = db(db.page.id0).select(orderby = db.page.title)
comments = db(db.comment.id0).select()
return dict(pages=pages, comments=comments)

=== view ===
ol
{{for page in page:}}
li{{=page.name}}br
ol{{for comment in comments if comment.page_id==page.id:}}
li{{=comment.body}}/li
 {{pass}}
/ol
 /li
{{pass}}
/ol


There's probably a much more efficient way to do it since the for comment 
in comments loop goes through all comments for each page. The way you had 
it didn't really make any sense because you were getting all the pages but 
then just the comments for one (unspecified) page. db(db.comment.page_id 
== db.page.id).select() is going to return ALL comments. If you want the 
comments for just one page you would do something like db(db.comment.page_id 
== r http://db.page.id/equest.args(0)).select().

To make it more efficient, you might be able to group the comments in the 
controller. I don't know if this works, it's kind of a guess.

def index():
pages = db(db.page.id0).select(orderby = db.page.title)
comments = db(db.comment.id0).select()
for comment in comments:
comment_groups[coment.page_id].append(comment)
return dict(pages=pages, comment_groups=comment_groups)

ol
{{for page in page:}}
li{{=page.name}}br
ol{{for comment in comment_groups[page.id]:}}
li{{=comment.body}}/li
 {{pass}}
/ol
 /li
{{pass}}
/ol


Re: [web2py] Re: Weird Error in modules files...

2011-05-15 Thread ron_m
If the second parameter on local_import is True it will reload each time the 
statement is executed. Otherwise it retains the first local_import until 
server restart.