[web2py] Re: Sum issues while computing the total of a table field

2016-09-29 Thread stifan kristi
pls try :
query = (db.payslip.state == 'Confirmed')
sum = db.payslip.gross.sum()
print db(query).select(sum).first()[sum]

*ref:*
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len

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.


Re: [web2py] Re: Skytoop : a web desktop like, created with Web2Py on server side

2011-06-14 Thread Stifan Kristi
great job, cool apps...


Re: [web2py] Re: When would one load a component with ajax=True as opposed to ajax_trap=True

2011-06-14 Thread Stifan Kristi
a, i c, thank you so much for your detail explaination and reference,
anthony.


Re: [web2py] Re: When would one load a component with ajax=True as opposed to ajax_trap=True

2011-06-13 Thread Stifan Kristi
pardon, me, what's cid used for? is it mandatory to use trap?
thank you so much.


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

2011-06-13 Thread Stifan Kristi
thank you so much for your hints and suggestion, anthony and pbreit. i'll
figure it out my wrong code.


Re: [web2py] Re: When would one load a component with ajax=True as opposed to ajax_trap=True

2011-06-12 Thread Stifan Kristi
a, it's clear for me know, thank you very much for your detail explaination
and reference, anthony, i think this is the answer about my ajax component
problems question, sorry, oot in the wrong room. again, thank you so much.

On Mon, Jun 13, 2011 at 7:53 AM, Anthony  wrote:

> On Sunday, June 12, 2011 7:11:10 PM UTC-4, 黄祥 wrote:
>>
>> pardon me, btw, what is the function of ajax_trap = True? what can do by
>> ajax_trap = True?
>> thank you so much.
>>
>
> ajax=True means the entire component is always loaded via Ajax (by calling
> the web2py_component() function in /static/js/web2py_ajax.js) -- this
> includes trapping any forms in the component, submitting them to the
> component action via Ajax, and rendering the result in the component div.
>
> ajax_trap=True is only relevant when ajax=False. When ajax=False, the
> component is inserted in the page on the server side, before the parent page
> is returned to the browser. In that case, if there is a form in the
> component and you want the form submitted to the component action via Ajax,
> then you have to set ajax_trap=True. Otherwise, the form will be submitted
> normally and the entire page will be reloaded.
>
> As Massimo suggested, if you've got a form in the component and would like
> it trapped via Ajax, you're probably better off just setting ajax=True so
> the whole component will always be loaded/reloaded via Ajax. Setting
> ajax=False probably makes more sense when you just need to load the
> component once and don't need any further interaction/reloading (i.e., no
> forms).
>
> This is explained in the book here:
> http://web2py.com/book/default/chapter/13#Components
>
> Anthony
>


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

2011-06-12 Thread Stifan Kristi
honestly, i'm newbie in programming both in python and web2py, actually i'm
using chrome and use developer tools, but, i don't know how to trace back my
error component elements, any suggestion? i will redevelop my code from
scratch again, as your suggested to start from simple. if you want to take a
look my code, i've already put and share it on
http://web2py.com/appliances
which
is http://web2py.com/appliances/default/show/76 and
http://web2py.com/appliances/default/show/77
the
bug that i want to fix on there is related with the comment.

On Mon, Jun 13, 2011 at 7:18 AM, Anthony  wrote:

> On Sunday, June 12, 2011 7:07:28 PM UTC-4, 黄祥 wrote:
>>
>> thank you so much for your explaination about onaccept argument,
>> anthony, yeah, i admit my failure code on the e.g. 2 but in e.g.1. the
>> result is same no error appears just never ending loading... on the list
>> view comments component.
>>
>
> I'm not sure why the list view isn't loading for you. I would suggest
> trying to simplify it to get something to work, and then add in complexity.
> I don't think it has anything to do with response.js, because it's not even
> loading the first time when the page first loads. You might try to do some
> diagnostics within the browser (e.g., Firebug in Firefox) to see what the
> source HTML ends up looking like and what Ajax requests and responses are
> coming and going.
>
> Anthony
>


Re: [web2py] Re: When would one load a component with ajax=True as opposed to ajax_trap=True

2011-06-12 Thread Stifan Kristi
a, i understand, right now, thank you so much for your explaination, massimo


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

2011-06-12 Thread Stifan Kristi
a, i c, thank you so much for your explaination and example code, sahil. did
you mind if i want to store the video file and image in the database as
blob? how to do it?
thank you very much before.


Re: [web2py] Re: When would one load a component with ajax=True as opposed to ajax_trap=True

2011-06-12 Thread Stifan Kristi
pardon me, btw, what is the function of ajax_trap = True? what can do by
ajax_trap = True?
thank you so much.


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

2011-06-12 Thread Stifan Kristi
thank you so much for your explaination about onaccept argument,
anthony, yeah, i admit my failure code on the e.g. 2 but in e.g.1. the
result is same no error appears just never ending loading... on the list
view comments component.

On Sun, Jun 12, 2011 at 7:15 PM, Anthony  wrote:

> What error are you getting? Note, the onaccept argument has to be a
> function (respons.js is just a string). Is that the source of your error?
>
> On Sunday, June 12, 2011 7:28:18 AM UTC-4, 黄祥 wrote:
>
>> your example is work fine on me, anthony, thank you so much, but when i
>> tried to implement on my application it returns an error.
>>
>> e.g. 1.
>>  def __add_2(table_0, index_link, table_1, field):
>> page = table_0(request.args(0)) or redirect(URL(index_link))
>> response.js = 'web2py_component(action = "%s", target = "%s")' %
>> (URL('blog_comment_show.load'), 'blog_comment_show')
>> field.default = page.id
>> form = crud.create(table_1, message = T('Record Inserted'), onaccept =
>> response.js)
>> return dict(page = page, form = form)
>>
>> e.g. 2.
>>  def __add_2(table_0, index_link, table_1, field):
>> page = table_0(request.args(0)) or redirect(URL(index_link))
>> field.default = page.id
>> form = crud.create(table_1, message = T('Record Inserted'), onaccept
>> = response.js = 'web2py_component(action = "%s", target = "%s")' %
>> (URL('blog_comment_show.load'), 'blog_comment_show'))
>> return dict(page = page, form = form)
>>
>> i'm new in python and web2py, so that i don't know how to implement this
>> on my application, any idea about this problem? thank you so much.
>>
>


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

2011-06-12 Thread Stifan Kristi
your example is work fine on me, anthony, thank you so much, but when i
tried to implement on my application it returns an error.

e.g. 1.
def __add_2(table_0, index_link, table_1, field):
page = table_0(request.args(0)) or redirect(URL(index_link))
response.js = 'web2py_component(action = "%s", target = "%s")' %
(URL('blog_comment_show.load'), 'blog_comment_show')
field.default = page.id
form = crud.create(table_1, message = T('Record Inserted'), onaccept =
response.js)
return dict(page = page, form = form)

e.g. 2.
def __add_2(table_0, index_link, table_1, field):
page = table_0(request.args(0)) or redirect(URL(index_link))
field.default = page.id
form = crud.create(table_1, message = T('Record Inserted'),
onaccept = response.js
= 'web2py_component(action = "%s", target = "%s")' %
(URL('blog_comment_show.load'), 'blog_comment_show'))
return dict(page = page, form = form)

i'm new in python and web2py, so that i don't know how to implement this on
my application, any idea about this problem? thank you so much.


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

2011-06-11 Thread Stifan Kristi
thank you so much for your hints, anthony, i've already move out the hidden
class div but got the same results, the components show as a loading
i don't know where is the problem.


Re: [web2py] Re: Social network plug-in

2011-06-11 Thread Stifan Kristi
thank you so much for your shared, massimo.


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

2011-06-11 Thread Stifan Kristi
thank you so much for corrected my mistook code, anthony, but the results is
same now the blog comment show appears loading...  First time my incorrect
code show the blog comment form page appears loading... and then right now
the blog comment show. actually i come from the simple things one (without
ajax, jquery, and component) and right now i try to learn and implement both
of it's.

any hints, suggestion or references?
thank you so much before.

On Sat, Jun 11, 2011 at 12:44 PM, Anthony  wrote:

> I think you're specifying the target div name in the wrong place. Instead
> of:
>
>  {{=LOAD('default', 'blog_comment_show.load', args = page.id, ajax =
> True)}}
> {{=LOAD('default', 'blog_comment_add.load', args = page.id,
> target = 'comments_%s hidden' % page.id, ajax = True)}}
>
> I think you want:
>
>  {{=LOAD('default', 'blog_comment_show.load', args = page.id,
> target = 'comments_%s hidden' % page.id, ajax = True)}}
> {{=LOAD('default', 'blog_comment_add.load', args = page.id, ajax = True)}}
>
>
> Does that change help?
>
> Also, in __add_2(), you might want to return response.js conditionally,
> only when a new comment has actually been added -- otherwise, when the page
> first loads, the blog_comment_show() component will be called/load twice
> (once because of the LOAD, and once because of the response.js from the
> blog_component_add() component).
>
> If you're still having problems, I recommend creating a simplified version
> of the setup just to see if you can get the basic inter-component
> communication working -- then add in all the complexity and see where it
> breaks down.
>
> Anthony
>
> On Saturday, June 11, 2011 12:46:29 AM UTC-4, 黄祥 wrote:
>
>> yes, i have.
>>
>>  def blog_comment_show():
>> return
>> __show_2(blog, blog_index, blog_comment, blog_comment_blog_id, 
>> blog_comment_active)
>>
>> @auth.requires_login()
>> def __show_2(table_0, index_link, table_1, field, active):
>> page = table_0(request.args(0)) or redirect(URL(index_link))
>> results = db((field == page.id) & (active == True)).select(orderby =
>> ~table_1.id,
>>cache =
>> (cache.ram,
>>
>> 10))
>> return dict(page = page, results = results)
>>
>> i think the error is on target load, so that my page keep showing
>> loading...
>>
>> did you have any way out for this probelm?
>> thank you so much.
>>
>> On Sat, Jun 11, 2011 at 11:05 AM, Anthony  wrote:
>>
>>> Do you have a blog_comment_show() action in your controller?
>>>
>>> On Friday, June 10, 2011 10:58:56 PM UTC-4, 黄祥 wrote:
>>>
   thank you so much for your hints, anthony, but, pardon me, the
 results on the form components is loading..., the page didn't show an 
 error,
 but keep loading..., is there something i missed in my code?

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

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

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

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

 *=== view ===*

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

 *=== blog_comment_show.load ===*

 {{if len(results):}}
 
 {{=A(T('Comments (%s)' % len(results)), _href = '#')}}
 

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

 
 {{=A(T('Like'), _href = '#')}}
 
 {{=BR()}}
 {{pass}}
 
 {{else:}}
 {{=DIV(B(T('No Comment Posted Yet')))}}
 {{pass}}

 *=== blog_comment_add.load ===*

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

 {{=DIV(form, _class = 'form_%s hidden' % page.id,
_onsub

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

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

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

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

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

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

On Sat, Jun 11, 2011 at 11:05 AM, Anthony  wrote:

> Do you have a blog_comment_show() action in your controller?
>
> On Friday, June 10, 2011 10:58:56 PM UTC-4, 黄祥 wrote:
>
>> thank you so much for your hints, anthony, but, pardon me, the results on
>> the form components is loading..., the page didn't show an error, but keep
>> loading..., is there something i missed in my code?
>>
>> e.g.
>>  *=== controller ===*
>>
>> blog = db.blog
>> blog_comment = db.blog_comment
>> blog_comment_blog_id = db.blog_comment.blog_id
>> blog_comment_active = db.blog_comment.is_active
>>
>> def blog_comment_add():
>> return __add_2(blog, blog_index, blog_comment, blog_comment_blog_id)
>>
>> @auth.requires_login()
>> def __add_2(table_0, index_link, table_1, field):
>> page = table_0(request.args(0)) or redirect(URL(index_link))
>> field.default = page.id
>> form = crud.create(table_1, message = T('Record Inserted'),
>>next = URL(args = page.id))
>> *response.js = 'web2py_component(action = "%s", target = "%s")' *
>> *  % (URL('blog_comment_show.load'), *
>> *  'comments_%s hidden' % page.id)*
>> return dict(page = page, form = form)
>>
>> *=== view ===*
>>
>> {{=LOAD('default', 'blog_comment_show.load', args = page.id, ajax =
>> True)}}
>> *{{=LOAD('default', 'blog_comment_add.load', args = page.id, *
>> *target = 'comments_%s hidden' % page.id, ajax = True)}}*
>>
>> *=== blog_comment_show.load ===*
>>
>> {{if len(results):}}
>> 
>> {{=A(T('Comments (%s)' % len(results)), _href = '#')}}
>> 
>>
>> 
>> {{for blog_comment in results:}}
>> {{=SPAN(db.auth_user[blog_comment.created_by].first_name, T(' on
>> '),
>> blog_comment.created_on, T(' Said '),
>>  blog_comment.comment)}}
>> {{=BR()}}
>> {{=SPAN(blog_comment.like,
>> _id = 'blog_comment_like_%s' % blog_comment.id)}}
>> {{=SPAN(T('People Like This'))}}
>>
>> 
>> {{=A(T('Like'), _href = '#')}}
>> 
>> {{=BR()}}
>> {{pass}}
>> 
>> {{else:}}
>> {{=DIV(B(T('No Comment Posted Yet')))}}
>> {{pass}}
>>
>> *=== blog_comment_add.load ===*
>>
>> {{=DIV(A(T('Post a Comment'), _href = '#'), _class = 'post',
>>_onclick = "jQuery('.form_%s').slideToggle('slow');" % page.id)}}
>>
>> {{=DIV(form, _class = 'form_%s hidden' % page.id,
>>_onsubmit = "ajax('blog_comment_add', [], 'comments_%s hidden');" %
>> page.id)}}
>>
>> On Sat, Jun 11, 2011 at 8:28 AM, Anthony  wrote:
>>
>>> Maybe try having the post comment action return some JS via response.js
>>> that calls the web2py_component JS function to update the list component:
>>>
>>> def post_comment():
>>> # do some stuff
>>> response.js='web2py_component(action="%s",target="%s")' %
>>> (URL('list_comments.load'), 'comment_list')
>>> return dict(...)
>>>
>>> def list_comments():
>>> # code to list comments
>>>
>>> In view:
>>>
>>> {{=LOAD('post_comment.load', ajax=True)}}
>>> {{=LOAD('list_comments.load', target='comment_list', ajax=True)}}
>>>
>>>
>>> See
>>> http://web2py.com/book/default/chapter/13#Client-Server-Component-Communications
>>> .
>>>
>>> Anthony
>>>
>>> On Friday, June 10, 2011 8:44:26 PM UTC-4, 黄祥 wrote:
>>>
 hi,

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

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


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

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


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

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

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

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

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

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

*=== view ===*

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

*=== blog_comment_show.load ===*

{{if len(results):}}

{{=A(T('Comments (%s)' % len(results)), _href = '#')}}



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


{{=A(T('Like'), _href = '#')}}

{{=BR()}}
{{pass}}

{{else:}}
{{=DIV(B(T('No Comment Posted Yet')))}}
{{pass}}

*=== blog_comment_add.load ===*

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

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

On Sat, Jun 11, 2011 at 8:28 AM, Anthony  wrote:

> Maybe try having the post comment action return some JS via response.js
> that calls the web2py_component JS function to update the list component:
>
> def post_comment():
> # do some stuff
> response.js='web2py_component(action="%s",target="%s")' %
> (URL('list_comments.load'), 'comment_list')
> return dict(...)
>
> def list_comments():
> # code to list comments
>
> In view:
>
> {{=LOAD('post_comment.load', ajax=True)}}
> {{=LOAD('list_comments.load', target='comment_list', ajax=True)}}
>
>
> See
> http://web2py.com/book/default/chapter/13#Client-Server-Component-Communications
> .
>
> Anthony
>
> On Friday, June 10, 2011 8:44:26 PM UTC-4, 黄祥 wrote:
>
>> hi,
>>
>> is ajax can work in components? i mean let say that i separated the
>> comment into 2 components, 1 for list of view comments and the other
>> is form to post the comment. i have a problem when i post the comment
>> using the form, the data that have been posted is not directly change
>> on list of comments (the other components), i must refresh my browser
>> many times so that the list comments can show the latest posted
>> comment. is there any clue or solution to implement ajax that works in
>> other components?
>>
>> any hints, suggestion is greatly appreciate.
>> thank you very much.
>
>


Re: [web2py] Re: ajax form submission

2011-06-09 Thread Stifan Kristi
it works on me too, pbreit, thank you so much. when i use the simple it
works fine, but when i try to expand it (i mean using components, ajax and
jquery it's not work).

On Thu, Jun 9, 2011 at 5:11 AM, pbreit  wrote:

> It worked for me with a normal query:
>
> db(db.post.id>0).select(orderby = ~db.post.id)
>


Re: [web2py] FYI Data Brewery - anyone used it?

2011-06-09 Thread Stifan Kristi
nice info, will try and take a look, thank you.


Re: [web2py] Re: Cubrid?

2011-06-09 Thread Stifan Kristi
glad to know that, thank you so much.


Re: [web2py] Re: New Features in Book

2011-06-09 Thread Stifan Kristi
a, i c, pardon me, if i'm not wrong massimo said he will get the book update
on this august. so that i confirm it, hehe...


Re: [web2py] Re: vars vs. kwargs

2011-06-09 Thread Stifan Kristi
pardon me, what is the meaning of *args and **vars?
thank you.


Re: [web2py] Re: New Features in Book

2011-06-08 Thread Stifan Kristi
is the book has already been updated right now?
thank you


Re: [web2py] Re: I created a little app to be able to share some files over the net without authentication

2011-06-08 Thread Stifan Kristi
great job, szimszon, thanks for sharing and announcing it. happy web2pying.

On Wed, Jun 8, 2011 at 4:41 PM, szimszon  wrote:

> I updated the app and uploaded the new already to
> http://web2py.com/appliances/default/show/78
>
> Changelog
>
> 110608
>
>- data about the file downloads
>- authorized user can delete individual uploaded file
>- separate code for download and upload urls
>
>
>


Re: [web2py] Re: web2py 1.96.4 is OUT

2011-06-07 Thread Stifan Kristi
good job, everyone, hope web2py improve day by day, thank you so much.
\(^o^)/


Re: [web2py] Draw Tabs with one form

2011-06-07 Thread Stifan Kristi
had you already normalize your database table?

On Tue, Jun 7, 2011 at 9:03 PM, Neveen Adel  wrote:

> Hello,
>
>
>  I have table has 30 field, so for readability i want to using tabs
> and each tab include 10 fields and allow the user to switch between
> them and at the end there is one "save" button for all tabs that will
> insert a new record.
>
>
> How can i do that??
>
> Thanks in Advance


Re: [web2py] Re: SQL help

2011-06-06 Thread Stifan Kristi
a, i c, i mean in database definition that have field type list:string, have
the valid value that is describe in belongs, is it possible or not?

thank you.

On Tue, Jun 7, 2011 at 7:58 AM, pbreit  wrote:

> I'm not sure I understand the question. Validators apply to forms.
> "belongs" is used to query the database.


Re: [web2py] Re: SQL help

2011-06-06 Thread Stifan Kristi
is it possible to use belongs to replace IS_IN_SET validation in database
definition?

thank you

On Tue, Jun 7, 2011 at 7:29 AM, pbreit  wrote:

> "belongs":
> http://web2py.com/book/default/chapter/06#belongs
>


Re: [web2py] Re: components and timers

2011-06-06 Thread Stifan Kristi
hi, massimo

did you have the documentation for do this?

thank you so much

On Tue, Jun 7, 2011 at 5:15 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> look into gluon/contrib/comet_messaging.py
>
> On Jun 6, 5:08 pm, blackthorne  wrote:
> > hi
> >
> > Let's say I have a component that gets the last 10 tweets from some
> > list or that shows current CPU and memory metrics and requires to be
> > cyclically reloaded once every 5 mins for example. How can I do this?
> >
> > Thank you
> > Best regards
>


Re: [web2py] Re: Field reference type and notnull parameter

2011-06-05 Thread Stifan Kristi
a, i c, pardon me and thank you so much for correcting me, anthony.

On Mon, Jun 6, 2011 at 9:00 AM, Anthony  wrote:

> On Sunday, June 5, 2011 9:52:23 PM UTC-4, 黄祥 wrote:
>>
>> i think notnull = TRUE is same like requires = IS_NOT_EMPTY()
>>
>
> Not exactly -- notnull=True is enforced by the database, whereas
> requires=IS_NOT_EMPTY() is a validator that is enforced by web2py forms (as
> well as the DAL validate_and_insert method).
>
> Anthony
>
>


Re: [web2py] Re: Field reference type and notnull parameter

2011-06-05 Thread Stifan Kristi
i think notnull = TRUE is same like requires = IS_NOT_EMPTY()


Re: [web2py] Re: ajax run unexpected in show page

2011-06-03 Thread Stifan Kristi
thank you so much for your hint and correction, massimo, it works, now.
web2py is so cool

On Sat, Jun 4, 2011 at 9:28 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

>  ajax('blog_like',...
>
> should be
>
>  ajax('{{=URL('blog_like.load')}}',..
>
> > hi,
> >
> > i have an ajax run unexpected in show page but not in index page, when
> > i click the ajax in show page it will return an index page, not to
> > update the value when i click like it work in index page. actually the
> > ajax code is same for index and show page.
> >
> > === show.html ===
> > 
> > 
> > 
> > {{=H1(page.title)}}
> > {{=DIV(page.content)}}
> > {{=DIV(db.blog_category[page.category_id].category)}}
> > {{=SPAN(page.like,
> > _id = 'blog_like_%s' % page.id)}}
> > {{=SPAN(T('People Like This'))}}
> > 
> > {{=A(T('Like'),
> >  _href = '#')}}
> > 
> >
> > i know it seems like i missed something in my code, did anyone know
> > which part i missed and how to solve it?
> > any hints, corrections is greatly appreciate, thank you so much in
> > advance.


Re: [web2py] components in related tables

2011-06-03 Thread Stifan Kristi
o, i c, thanks so much for showing my code fault, pbreit, i'll try to fix
and test it.

On Sat, Jun 4, 2011 at 5:02 AM, pbreit  wrote:

> I'm not sure exactly how your code works but I'd didn't seen an arg in this
> load:
> {{=LOAD('default', 'blog_comment_show.load', ajax = True)}}


Re: [web2py] components in related tables

2011-06-03 Thread Stifan Kristi
thank you so much for your hint, pbreit, i'd already put an id on the
controller.

e.g.
page = table_0(request.args(0)) or redirect(URL(index_link))

any idea, hints or suggestion to solve this problem?
thank you so much in advance.

On Fri, Jun 3, 2011 at 9:12 PM, pbreit  wrote:

> You need to pass an I'd to show controller so it knows what comments to
> pull.


Re: [web2py] Re: Social network plug-in

2011-06-02 Thread Stifan Kristi
very cool, massimo, hope you can share it, so that we can learn from it,
thank you so much.

On Fri, Jun 3, 2011 at 4:03 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I have it somewhere. I will post it on web2py appliances asap.
>
> On Jun 2, 3:06 pm, François  wrote:
> > Thank you, this is nice and impressive !
> >
> > Is there a place where I can download the code ?
> >
> > François
> >
> > On 2 juin, 17:57, Massimo Di Pierro 
> > wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Something like this?http://vimeo.com/21364178
> >
> > > On Jun 2, 10:09 am, François  wrote:
> >
> > > > Hello everybody,
> >
> > > > Is there a social network plug-in for Web2py, which for example
> allows
> > > > users to send messages to each other ?
> >
> > > > Thank you very much,
> > > > François- Masquer le texte des messages précédents -
> >
> > > - Afficher le texte des messages précédents -
>


Re: [web2py] Re: slug ???

2011-06-02 Thread Stifan Kristi
what is the differences between gluon.contrib.urlify and
IS_SLUG..urlify(...)?
is it same? which is the best for use?
thank you so much

On Thu, Jun 2, 2011 at 7:12 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Oops we are not talking about the same thing. Looks like there is some
> duplication of code.
>
> I was thinking about :
>
> IS_SLUG..urlify()
>
> gluon.contrib.urlify should go away or IS_SLUG..urlify should call
> gluon.contrib.urlify
>
> On Jun 1, 11:47 pm, pbreit  wrote:
> > from gluon.contrib.urlify import urlify


Re: [web2py] Re: slug ???

2011-06-01 Thread Stifan Kristi
a, i see, thank you so much for your explaination, massimo.

On Thu, Jun 2, 2011 at 7:59 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Converts text into a SLUG.
>
> On Jun 1, 7:32 pm, Stifan Kristi  wrote:
> > pardon me, what urlify is use for? i've already search in the book but
> > return a null. thank you so much.
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Jun 2, 2011 at 7:29 AM, pbreit  wrote:
> > > There's a validator if you want to save a slug to the DB:
> > >http://web2py.com/book/default/chapter/07?search=IS_SLUG
> >
> > > Here's how I do it. I have a computed field for my records:
> >
> > > def slug(self):
> > > return '%s-%s' % (urlify(self.item.title, max_length=50),
> self.item.id
> > > )
> >
> > > And a function to return the id from a slug:
> >
> > > def id_from_slug(slug):
> > > id = slug.split('-')[-1]
> > > if id.isdigit():
> > > return id
> > > else:
> > > return None
> >
> > > So I can do things like:
> > > 
> > > and
> > > item = db(db.item.id==id_from_slug(request.args(0))).select().first()


Re: [web2py] Re: slug ???

2011-06-01 Thread Stifan Kristi
pardon me, what urlify is use for? i've already search in the book but
return a null. thank you so much.

On Thu, Jun 2, 2011 at 7:29 AM, pbreit  wrote:

> There's a validator if you want to save a slug to the DB:
> http://web2py.com/book/default/chapter/07?search=IS_SLUG
>
> Here's how I do it. I have a computed field for my records:
>
> def slug(self):
> return '%s-%s' % (urlify(self.item.title, max_length=50), self.item.id
> )
>
> And a function to return the id from a slug:
>
> def id_from_slug(slug):
> id = slug.split('-')[-1]
> if id.isdigit():
> return id
> else:
> return None
>
> So I can do things like:
> 
> and
> item = db(db.item.id==id_from_slug(request.args(0))).select().first()
>
>
>


Re: [web2py] Re: slug ???

2011-06-01 Thread Stifan Kristi
a, so that's what slug used for, thank you so much for your sharing, pbreit. at
first i read in the book, and don't know, what slug is use for.

On Thu, Jun 2, 2011 at 6:08 AM, pbreit  wrote:

> I create and decode "slugs" on-the-fly so that my URLs are more
> descriptive:
>
> http://pricetack.com/item/nike-vintage-stripe-polo-shirt-lg-51
> same as:
> http://pricetack.com/item/51
>
> This is the "slug": nike-vintage-stripe-polo-shirt-lg-
>


Re: [web2py] web2py 1.96.1 is OUT

2011-06-01 Thread Stifan Kristi
awesome, great job, everyone, thank you so much


Re: [web2py] slug ???

2011-06-01 Thread Stifan Kristi
a, i'm quite understand right now, thank you so much for your explaination,
all.


Re: [web2py] Re: jquery effect

2011-06-01 Thread Stifan Kristi
thank you so much for your hints, i'm using select input with 3 options,
public, private and protected, on the form. so when user choose the
protected value the field password will appears. i just modified what was
written on the book. any idea?

thank you so much in advance.


On Thu, Jun 2, 2011 at 12:07 AM, Ross Peoples wrote:

> I'm not exactly sure what's going here, but at first glance, this is what I
> see:
>
> I think you are using attr() wrong. In the first section of code, you are
> checking the 'Protected' attribute, but in the second block of code, you are
> setting an 'onchange' attribute to the value of 'Protected', Maybe this
> should read attr('Protected', true) instead?


Re: [web2py] Re: web2py rpc

2011-06-01 Thread Stifan Kristi
pardon me, i still learning and tried what was written on the book, but got
confused about what is use for my application, so that i asked to the web2py
forum community.

On Wed, Jun 1, 2011 at 9:50 PM, David J.  wrote:

> How do you handle remote authentication using json-rpc?
>
> I would like to try it;
>
> Thanks.
>
>
>
> On 6/1/11 10:48 AM, Stifan Kristi wrote:
>
>> a, i understand right now, it seems so widely implementation for rpc,
>> thank you so much for sharing
>>
>
>


Re: [web2py] Re: web2py rpc

2011-06-01 Thread Stifan Kristi
a, i understand right now, it seems so widely implementation for rpc, thank
you so much for sharing


Re: [web2py] I created a little app to be able to share some files over the net without authentication

2011-06-01 Thread Stifan Kristi
please go to 
http://web2py.com/appliances/default/edit/
you
will asked to login with janrain, after that, you can upload and share your
application in there. great job, happy web2pying zimszon
\(^o^)/


Re: [web2py] I created a little app to be able to share some files over the net without authentication

2011-06-01 Thread Stifan Kristi
congratulation, nice application szimszon, had already put in the
appliances?


Re: [web2py] Re: web2py rpc

2011-05-31 Thread Stifan Kristi
Thank you so much for your detail explaination, example and reference,
pbreit, honestly, i'm new in this feature, and don't know what is the use
for when i follow the guidance in the book, now, my mind is open and i'll
learn it on the book.

On Wed, Jun 1, 2011 at 8:46 AM, pbreit  wrote:

> I'm not sure you're going to get a better explanation than what's in the
> book, which is excellent. These are sort of easy, sort of standardized ways
> way to create interfaces between different systems. For example, PayPal
> supports a SOAP interface in which case you can use the SOAP capabilities
> included with Web2py to interact with the PayPal system.
>
> XMLRPC was gaining popularity awhile back but not so much anymore. More
> info: http://www.xmlrpc.com/
>
> JSONRPC is similar but uses the JSON data format instead of XML. JSON is
> easier to work with, especially with JavaScript.
>


Re: [web2py] Re: uuid and id comparation

2011-05-31 Thread Stifan Kristi
thank you so much for your detail explaination and reference, pbreit.

On Wed, Jun 1, 2011 at 6:48 AM, pbreit  wrote:

> The two are mostly unrelated.
>
> uuid is a python library that you generally don't need to use or worry
> about. It basically generates a unique string.
> http://docs.python.org/library/uuid.html
>
> id, when talking about web2py, usually refers to the "id" field that Web2py
> automatically adds to every table definition that serves as a table's
> primary key.
>


Re: [web2py] new site in web2py

2011-05-31 Thread Stifan Kristi
very cool, congratulations, keep happy web2pying...


Re: [web2py] Thanks to all members for all you time and effort !!

2011-05-30 Thread Stifan Kristi
congratulations for complete your course, happy web2py forever...
\(^o^)/


Re: [web2py] Re: New web2py app: Airea.me

2011-05-27 Thread Stifan Kristi
great, nice application, hope you win the competition
\(^o^)/


Re: [web2py] Re: What if Massimo got hit by a Bus?

2011-05-26 Thread Stifan Kristi
lol, i think everything will be fine, long live massimo and web2py, both are
nice...


Re: [web2py] relational database example app

2011-05-24 Thread Stifan Kristi
had already checked web2py appliances? http://web2py.com/appliances

On Wed, May 25, 2011 at 1:19 PM, Markandeya  wrote:

> Dear Friends of Web2Py,
> I am just getting started and need an example application using a
> relational database. A possible example:
> 1) with customers, items, purchases tables So the purchases table
> would use customerId and itemId numbers from their related tables. So
> a customer can select an item in a form page from a list of items and
> make a purchase or find more detailed info on the item.
>
>  2) books, users, lending tables.  the lending table uses  userId and
> bookId  from their related tables.  So a user can select a book to
> borrow from a list of books and get more info on the book by clicking
> a button or link.
>  You get the idea. I can write this as a regular desktop application
> but need to know how to do this in a Web2Py web application. Following
> an existing program, possibly with some help files or tutorial would
> jump start me into web apps with Web2Py. Many thanks for your
> suggestions, Markandeya
>


Re: [web2py] Dynamic Table Generation

2011-05-24 Thread Stifan Kristi
i think the logic is same like wizard, have you tried it?

On Wed, May 25, 2011 at 7:39 AM, Ialejandro  wrote:

> Hi everyone, I'm trying to make an app where a user can create its own
> tables bases in some attributes, I have this:
>
> View:
>
> {{extend 'layout.html'}}
>
>   action="{{=URL()}}" method="post">
> Project Name:
> 
> Number Of Fields:
> 
> Name of Fields:
> 
> 
> 
> Submitted variables
> {{=BEAUTIFY(request.vars)}}
>
>
> Controller:
>
> def config():
>
>if request.vars:
>proj_name = session.projname = request.vars.projname
>num_fields= session.numfields= request.vars.numfields
>nam_fields= session.namfields= request.vars.namfields
>
>tblname = proj_name + "_custom"
>response.flash = tblname
>
>
>createtable(tblname)
>
>return dict()
>
>
> And in utils.py (inside models folder)
>
> def createtable(tablename):
>tbl = db.define_table(tablename,Field('a'))
>
>
> But it doesn't work :(
> The form works, I can get the variables by request.vars, but the table
> is not created, how could I create dynamic tables??
> If an user needs a table called "project1" with 2 fields "F1 and F2"
> and another user needs more different fields and table name, how could
> I make this??
>
> Thanks!


Re: [web2py] form in loop view

2011-05-23 Thread Stifan Kristi
thank you so much for your detail explaination and example miguel, i'm
really appreciate it. i'll follow what you n massimo suggest to put the
logic in the controlller. should i change it for example in the example
before.
e.g.
from :
=== view ===
{{for i, row in enumerate(rows):}}
   {{if i == items_per_page: break}}

   {{db.blog_comment.blog_id.default = row.id}}
   {{form = crud.create(db.blog_comment,
message = T('Record Inserted'))}}

   {{=DIV(form)}}
{{pass}}

into :
=== controller ===
def blog_index():
for i, row in enumerate(rows):
   if i == items_per_page: break

   db.blog_comment.blog_id.default = row.id
   form = crud.create(db.blog_comment,
message = T('Record Inserted'))
return dict (form, rows.id, rows.title, rows.content)

please give an advice, thanks


Re: [web2py] Re: form in loop view

2011-05-22 Thread Stifan Kristi
a, i c, thank you so much for your suggestion pbreit.

On Mon, May 23, 2011 at 9:52 AM, pbreit  wrote:

> I'd suggesting adding an element:
>
> http://web2py.com/book/default/chapter/07#Adding-extra-form-elements-to-SQLFORM
>
> Or customizing the form:
> http://web2py.com/book/default/chapter/07#Custom-forms
>


Re: [web2py] Re: when to use CRUD versus SQLFORM

2011-05-22 Thread Stifan Kristi
a, i c, i've already re read the book that it seems that the SQLFORM
parameter is same like on the parameter in DAL model, can it be collide?
which one is use DAL model or SQLFORM?
e.g.
i set in DAL model : writable = False
and in SQLFORM : readonly = False

Thank you

On Mon, May 23, 2011 at 8:19 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> a *lot of* overlap.
>
> On May 22, 8:08 pm, Stifan Kristi 
> wrote:
> > log overlap? is it for CRUD? i've already checked in web2py.com/bookthat
> > the log is related with crud.message? please correct me if i'm wrong.
> > thank you
> >
> > On Mon, May 23, 2011 at 7:53 AM, Massimo Di Pierro <
> >
> >
> >
> >
> >
> >
> >
> > massimo.dipie...@gmail.com> wrote:
> > > Use crud for fast prototyping. Use SQLFORM when you need more control.
> > > The good thing is that they have a log overlap and you can always
> > > change one for the other.
> >
> > > On May 22, 7:50 pm, Stifan Kristi 
> > > wrote:
> > > > same for me, still confuse about exact comparation between SQLFORM
> and
> > > CRUD,
> > > > plus and minus side overview, but i usually use CRUD, because it's
> simple
> > > > (just my opinion).
> >
> > > > On Mon, May 23, 2011 at 7:39 AM, Ismael Alejandro <
> > > ialejandr...@gmail.com>wrote:
> >
> > > > > Hi apple! I'm my own experience (may me I'm wrong) I use SQLFORM
> when I
> > > > > need to customize a little the form, or when I have to deal with an
> > > specific
> > > > > var.
> >
> > > > > But, is a good question, same doubt here :s
> >
> > > > > On Sat, May 21, 2011 at 1:35 PM, apple  wrote:
> >
> > > > >> Can you do everything using CRUD that you can do with SQLFORM?
> >
> > > > >> Under what circumstances would you choose SQLFORM rather than
> CRUD?


Re: [web2py] Re: when to use CRUD versus SQLFORM

2011-05-22 Thread Stifan Kristi
log overlap? is it for CRUD? i've already checked in web2py.com/book that
the log is related with crud.message? please correct me if i'm wrong.
thank you

On Mon, May 23, 2011 at 7:53 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Use crud for fast prototyping. Use SQLFORM when you need more control.
> The good thing is that they have a log overlap and you can always
> change one for the other.
>
> On May 22, 7:50 pm, Stifan Kristi 
> wrote:
> > same for me, still confuse about exact comparation between SQLFORM and
> CRUD,
> > plus and minus side overview, but i usually use CRUD, because it's simple
> > (just my opinion).
> >
> > On Mon, May 23, 2011 at 7:39 AM, Ismael Alejandro <
> ialejandr...@gmail.com>wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi apple! I'm my own experience (may me I'm wrong) I use SQLFORM when I
> > > need to customize a little the form, or when I have to deal with an
> specific
> > > var.
> >
> > > But, is a good question, same doubt here :s
> >
> > > On Sat, May 21, 2011 at 1:35 PM, apple  wrote:
> >
> > >> Can you do everything using CRUD that you can do with SQLFORM?
> >
> > >> Under what circumstances would you choose SQLFORM rather than CRUD?
>


Re: [web2py] Re: form in loop view

2011-05-22 Thread Stifan Kristi
thank you so much for your hint, massimo, i want to follow your advice to
put the logic in controller but, i can't , because i'm using the variable
that produced by for loop in view side, that i can't do it in controller
side. do you have any solutions to put the logic in controller side that
have the for loop function that i learn from web2py.com/book?

any suggestion, correction is greatly appreciate.
thank you very much in advance.

On Mon, May 23, 2011 at 7:59 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Technically nothing prevents from doing this:
>
> {{
> form=SQLFORM()
> if form.accepts(request): redirect(...)
> }}{{=form}}
>
> but don't. ;-)
>
> Put the logic in the controller.
>
>
> On May 22, 7:12 pm, pbreit  wrote:
> > I'm still not sure how this woud work since the controller needs to
> create
> > the form in order to do the form.accepts() processing. What does your
> > controller look like. Are there any examples in the book of creating the
> > form in a view? If not, I'm guessing it's not possible.
>


Re: [web2py] Re: form in loop view

2011-05-22 Thread Stifan Kristi
hi pbreitenbach,

my controller not create any form, i just create it on the view side,
because i'm using the variable that produced by for loop in view side, that
i can't do it in controller side. at the book there is no examples for
creating the form in view, just the other one that i use (i mean :
http://web2py.com/book/default/chapter/10#Voting-and-Rating), actually my
code is share on http://web2py.com/appliances/default/show/76 and
http://web2py.com/appliances/default/show/77
 about the strange behaviour
that i said before, i still want to know why that code is work (i mean the
form can  working when i put {{pass}} and {{continue}}, but the result is
code after is now show (i don't want this)).

any other ideas, hints or solutions is greatly appreciate.

thank you so much in advance.

On Mon, May 23, 2011 at 7:12 AM, pbreit  wrote:

> I'm still not sure how this woud work since the controller needs to create
> the form in order to do the form.accepts() processing. What does your
> controller look like. Are there any examples in the book of creating the
> form in a view? If not, I'm guessing it's not possible.


Re: [web2py] when to use CRUD versus SQLFORM

2011-05-22 Thread Stifan Kristi
same for me, still confuse about exact comparation between SQLFORM and CRUD,
plus and minus side overview, but i usually use CRUD, because it's simple
(just my opinion).

On Mon, May 23, 2011 at 7:39 AM, Ismael Alejandro wrote:

> Hi apple! I'm my own experience (may me I'm wrong) I use SQLFORM when I
> need to customize a little the form, or when I have to deal with an specific
> var.
>
> But, is a good question, same doubt here :s
>
> On Sat, May 21, 2011 at 1:35 PM, apple  wrote:
>
>> Can you do everything using CRUD that you can do with SQLFORM?
>>
>> Under what circumstances would you choose SQLFORM rather than CRUD?
>>
>
>


Re: [web2py] Re: form in loop view

2011-05-22 Thread Stifan Kristi
hi pbreit,

html source was fine, the strange things, that the form can be submit after
i put {{pass}} or {{continue}} after i declared the form, but i don't want
to put {{pass}} or {{continue}} because the whole code after i put {{pass}}
or {{continue}} is not working, any ideas, hints or pointers how to do this?

thank you very much.

On Sun, May 22, 2011 at 10:18 PM, pbreit  wrote:

> Can you look at the HTML source to see if the form looks correct? I was not
> aware that you could create the form in the view.


Re: [web2py] form in loop view

2011-05-22 Thread Stifan Kristi
thank you so much for your replied marin, my intention is to show up blog
comment form in the blog index, so that while the user see blog, they can
comment it in 1 page. actually i have 2 form in blog index, 1 is for pass
the hidden id when user click like. i just learn it from :
http://web2py.com/book/default/chapter/10#Voting-and-Rating
 the other form
is the blog comment form. the like form (hidden) is ok, but i stuck with the
blog comment form, do you have any idea, hints, or solutions?

thank you very much.

On Sun, May 22, 2011 at 3:10 PM, Marin Pranjic wrote:

> Not sure if i understood, but
> if you have multiple forms, you can use SQLFORM with form.accepts(formname
> = 'form_'+str(i), ...)
> each form has it's own formname, so form.accepts will know which one is
> submitted.
> Is that your problem?
>
>
> On Sun, May 22, 2011 at 10:02 AM, 黄祥  wrote:
>
>> hi,
>>
>> is it possible to use form in loop view?
>>
>> e.g.
>> {{for i, row in enumerate(rows):}}
>>{{if i == items_per_page: break}}
>>
>>{{db.blog_comment.blog_id.default = row.id}}
>>{{form = crud.create(db.blog_comment,
>> message = T('Record Inserted'))}}
>>
>>{{=DIV(form)}}
>> {{pass}}
>>
>> i just can show the form, but when i submit the data is not in
>> database blog comment, i've already tried sqlform too but got same
>> result.
>>
>> did anyone know how to fix it?
>> any hints, solutions is greatly appreciate, thank you so much before.
>
>
>


Re: [web2py] Re: class example on book

2011-05-21 Thread Stifan Kristi
thank you for your replied luifran, but, it's not working, any example or
url maybe?
thank you very much before

On Sat, May 21, 2011 at 7:26 PM, luifran  wrote:

> In the view must be for example {{=add}}
>
> On 21 mayo, 12:00, 黄祥  wrote:
> > hi,
> >
> > is there any class example on book or appliances, so that i can learn
> > from it?
> > i've already tried the simple things what written on book, but got an
> > error. do you have any hints or solutions?
> > thank you so much before
> >
> > e.g.
> > === controller ===
> >
> > class MyClass(object):
> > z = 2
> > def __init__(self, a, b):
> > self.x = a, self.y = b
> > def add(self):
> > return self.x + self.y + self.z
> >
> > def index():
> > myinstance = MyClass(3, 4)
> > add = myinstance.add()
> > return dict(add = add)
> >
> > === view ===
> > {{add}}


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

2011-05-16 Thread Stifan Kristi
thank you so much for your hints and pointers pbreit, btw, an error occured
when i tried to do it.

e.g. 1.
=== controller ===
def index():
pages = db(db.page.id > 0).select(orderby = db.page.title)
comments = db(db.comment.id > 0).select()
for comment in comments:
comment_groups[comment.page_id].append(comment)
return dict(pages = pages, comment_groups = comment_groups)

=== view ===

{{for page in pages:}}
{{=page.name}}
{{for comment in comment_groups[page.id]:}}
{{=comment.body}}
 {{pass}}

 
{{pass}}


=== traceback ===
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 61,
in 
  File "/home/sugizo/web2py/gluon/globals.py", line 133, in 
self._caller = lambda f: f()
  File "/home/sugizo/web2py/applications/a/controllers/default.py", line 6,
in index
return dict(pages = pages, comment_groups = comment_groups)
NameError: global name 'comment_groups' is not defined

e.g. 2.
=== controller ===
def index():
pages = db(db.page.id > 0).select(orderby = db.page.title)
comments = db(db.comment.id > 0).select()
return dict(pages = pages, comments = comments)

=== view ===

{{for page in pages:}}
{{=page.name}}
{{for comment in comments:}}
{{if comment.page_id == page.id:}}
{{=comment.body}}
{{pass}}
 {{pass}}

 
{{pass}}


=== traceback ===
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/views/default/index.html", line
4, in 
{{for comment in comments:}}
  File "/home/sugizo/web2py/gluon/dal.py", line 3532, in __getattr__
return self[key]
  File "/home/sugizo/web2py/gluon/dal.py", line 3523, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'name'

did anyone ever have the same problem to show multiple tables in 1 page?
any hints and pointers are greatly appreciate, thank you so much.

On Mon, May 16, 2011 at 9:53 AM, pbreit  wrote:

> Hard to say the best way to do it. This might be one way (not tested).
>
> === controller ===
> def index():
> pages = db(db.page.id>0).select(orderby = db.page.title)
> comments = db(db.comment.id>0).select()
> return dict(pages=pages, comments=comments)
>
> === view ===
> 
> {{for page in page:}}
> {{=page.name}}
> {{for comment in comments if comment.page_id==page.id:}}
> {{=comment.body}}
>  {{pass}}
> 
>  
> {{pass}}
> 
>
>
> 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 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.id>0).select(orderby = db.page.title)
> comments = db(db.comment.id>0).select()
> for comment in comments:
> comment_groups[coment.page_id].append(comment)
> return dict(pages=pages, comment_groups=comment_groups)
>
> 
> {{for page in page:}}
> {{=page.name}}
> {{for comment in comment_groups[page.id]:}}
> {{=comment.body}}
>  {{pass}}
> 
>  
> {{pass}}
> 
>


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  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  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  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 
> > > 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
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  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 
> wrote:
> > Who did this? Congratulations!
> >
> > http://sites.google.com/site/web2pyjapan/book/01


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  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]))
>


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  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 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: 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] 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  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  wrote:
> > I still don't understand Record Representation. Is there a plain english
> > description or, better, examples of what it actually does?


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  wrote:

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


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  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: default usage

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

On Sun, May 15, 2011 at 5:02 AM, Anthony  wrote:

> On Saturday, May 14, 2011 5:37:39 PM UTC-4, 黄祥 wrote:
>>
>> hi,
>>
>> is there anyone can explain about the usage of default?
>>
>> e.g. on http://web2py.com/book/default/chapter/03#Adding-CRUD
>> db.comment.image_id.default = image.id
>
>
> You can read about it here:
> http://web2py.com/book/default/chapter/06#Record-Representation
>
> It sets the default value for a field for when an insert is done without
> specifying any value, and it is also used to pre-populate SQLFORM fields.
> You can specify it when you define your table, but you can also change it at
> other points in your code (e.g., you may specify a default where the table
> is defined in your model file, but then later change the default in a
> controller function). In the example above, it looks like it's being used to
> pre-populate the crud form with the currently selected image.
>
> Anthony
>


Re: [web2py] 2 or more query on db

2011-05-14 Thread Stifan Kristi
pardon me, it's my fault, i didn't realized the brackets, thank you so much.
it's solved now.


Re: [web2py] 2 or more query on db

2011-05-14 Thread Stifan Kristi
thank you so much for your replied vasile, but, unfortunately is not going
to work because the syntax error related with &

e.g. like this is return an error
comments = db(db.comment.image_id == image.id *&* db.comment.is_active
== True).select(orderby = ~db_comment.id)

comments = db(db.comment.image_id == image.id *&&* db.comment.is_active
== True).select(orderby = ~db_comment.id)

is there any solutions for this?
thank you so much in advance


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

2011-05-14 Thread Stifan Kristi
i hope there are a lots of examples on the next book version. e.g. class
implement on models, modules, controllers. because people learned from the
book and sharpened it through testing and experience, especially when an
error occured. lol.

thank you so much.


Re: [web2py] Re: check if len error in view

2011-05-13 Thread Stifan Kristi
it's my fault, thank you so much for corrected me pbreit.

On Sat, May 14, 2011 at 10:16 AM, pbreit  wrote:

> If you're going to do it in the view, you need some {{pass}} statements to
> close up the "for" and the "if" blocks.


Re: [web2py] Where in the book does it talk about the modules directory?

2011-05-11 Thread Stifan Kristi
a, i c, i followed the forum discussion too about web2py new version, but, i
think it'll be great if the new feature is well documented how to use,
combine and improve it.

btw, thanks for your info, anthony

On Thu, May 12, 2011 at 10:48 AM, Anthony  wrote:

> On Wednesday, May 11, 2011 11:41:32 PM UTC-4, 黄祥 wrote:
>>
>> when the updates come, bruno?
>> is it for web2py package or web2py books?
>>
>
> The changes he's referring to are already in trunk and are mentioned here:
> https://groups.google.com/forum/?fromgroups#!topic/web2py/p2v_QVdLjxQ.
> Assuming testing is going well, I guess they would likely be included in the
> next release (so, pretty soon). Who knows when the book will be updated
> (hopefully not long after)?
>
> Anthony
>
>


Re: [web2py] Where in the book does it talk about the modules directory?

2011-05-11 Thread Stifan Kristi
when the updates come, bruno?
is it for web2py package or web2py books?

i'll wait for both, thank you so much for your info.


On Thu, May 12, 2011 at 10:35 AM, Bruno Rocha  wrote:

> here:
> http://web2py.com/book/default/chapter/04#Third-Party-Modules
>
> --
>
> web2py provides another way to import modules in such a way that the
> global sys.path is not altered: by placing them in the "modules" folder of
> an application. One side benefit is that the module will be automatically
> copied and distributed with the application; however, there are certain
> restrictions that apply. web2py provides alocal_import function that must
> be used to import modules from the "modules" folder. Here is an example of
> usage:
>
>
> 1.
>
>
> mymodule = local_import 
> ('mymodule')
>
> The function looks for mymodule in the app local modules folder and
> imports it with the name on the left-hand side of equal.
>
> This function takes three arguments: name, reload and app.
> -
>
> *but wait! there are updates coming*, now web2py hs gluon.current and
> custom importer which is better than that old way.
>
> 
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
>
>
>
> On Thu, May 12, 2011 at 12:10 AM, Jason Brower wrote:
>
>> Looked and looked but I couldn't fine where you place a file with methods
>> and classes in the modules directory and then you can import them.
>> Could I see where that is in the book or perhaps some instruction here?
>> Best Regards,
>> Jason
>>
>
>


Re: [web2py] Re: web2py and sencha

2011-05-10 Thread Stifan Kristi
thank you so much for your hints and pointers pbreit and bruno, i'll try
your advice.


Re: [web2py] Re: spatial page load by ajax

2011-05-07 Thread Stifan Kristi
thank you so much for your hints and pointers, anthony. i admited my fault
on the code, i've already corrected it and using that u've suggested but the
ajax function is still not working.

for components, i've already read it, i think components is not work in my
case, and that i caught on that chapter is the components is usable when it
related with the general table (i mean like in the web2py.com/book, that the
comment is general not related with any table, in my case, i created the
comment table related with 1 table, e.g. blog - blog_comment, video -
video_comment)

please correct me if i'm wrong, thank you so much.

and for my case, my intention is to create the index show 20 rows values for
the first time, and the comment related table (hidden with jquery slide
toggle function), and after the user click to view more, the content add 20
rows again without leave the page (just like on
facebook.com/home.php that
user can see the news feed partially, after click on the down side of the
page)

or maybe you have any idea to do this?
thank you very much

actually i just want to update my the index view code in :
http://web2py.com/appliances/default/show/76
 
http://web2py.com/appliances/default/show/77
 to be like facebook.com/home

any help is greatly appreciate, many thanks before


Re: [web2py] Very Soft Pre-Alpha Launch: Pricetack ecommerce service

2011-05-05 Thread Stifan Kristi
very nice, congrats and gud luck in your business...


Re: [web2py] Aw: Re: help testing

2011-05-02 Thread Stifan Kristi
if your functions is use with many controllers that related with database,
please put it on the models
if your functions is use with many controllers that not related with
database function, please put it on the controllers
if your functions is use by another application, please put it on the
modules

On Tue, May 3, 2011 at 12:41 PM, ma...@rockiger.com  wrote:

> I have a somewhat general question.
>
> Should be funtions to use with your controller somewhere in the controllers
> folder?
>
> Having so much functions in the model seems kind of odd to me or am I
> wrong?
>
> Please enlightenm me.
>
>
> That said, subfolder are a big improvement.
>
>
>
> Marco
>


Re: [web2py] Skytoop : a web desktop like, created with Web2Py on server side

2011-05-02 Thread Stifan Kristi
it's cool, congratulations


Re: [web2py] Re: notnull=true in web2py.com book

2011-05-02 Thread Stifan Kristi
so that's the reason ya, thank you so much for your detail explaination
pbreitenbach

On Mon, May 2, 2011 at 10:13 PM, pbreit  wrote:

> It's unnecessary. Optionality is enforced by Web2py so it's not necessary
> and less flexible to enforce it at the database level.


Re: [web2py] Re: difference between is_not_empty(), notnull=true and required=true

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


Re: [web2py] Re: nested list

2011-05-01 Thread Stifan Kristi
thank you so much for your reference link jose

On Sun, May 1, 2011 at 9:52 PM, Jose  wrote:

> Hi,
>
> You can see this:
>
> http://www.web2py.com/book/default/chapter/06
>
> [Self-Reference and Aliases]
>
> Best Regards,
> Jose


Re: [web2py] Total control over your web2py models

2011-05-01 Thread Stifan Kristi
just an example, i'm understand right now, thank you so much, martin

On Sun, May 1, 2011 at 8:29 PM, Martín Mulone wrote:

> mod_clients.py = what for?
>> mod_users.py = what for?
>
>
> It was an example, you can have mod_nameyouwant.py.
>
> and inside you have for example something like this:
>
> class Clients(object):
>
> def show():
> 'show a list of clients'
>
> def delete():
> 'delete ...'
>
> def add():
> 'add ...'
>
> 2011/5/1 Stifan Kristi 
>
>> thank you so much for your info, martin, i've already tried and learn from
>> powerpack plugins, it's cool but because i'm a newbie in python and web2py,
>> so that a lot of things on powerpack that i don't know the function is what
>> for?
>> pardon me, could you explain about:
>> mod_clients.py = what for?
>> mod_users.py = what for?
>>
>> many thanks before
>>
>> On Sun, May 1, 2011 at 7:58 PM, Martín Mulone wrote:
>>
>>> In powerpack I have this:
>>>
>>> config.py (application settings)
>>> data.py (all the db definition and menus)
>>> main.py (auth, mail, service, registration settings, etc) (this is
>>> independant of the app)
>>>
>>> then I usually do:
>>>
>>> mod_clients.py
>>> mod_users.py
>>> mod_someother.py
>>> mod_someother2.py
>>>
>>> I have classes like bruno show, but I don't have db definitions in this
>>> classes, instead I have all the db definition in data.py because surely I
>>> have link to another tables.
>>>
>>> Then came the plugins:
>>>
>>> plugins_1.py
>>> plugins_2.py
>>> plugins_3.py
>>> plugins_4.py
>>> plugins_zindex.py (here the execution order of plugins)
>>>
>>> 2011/5/1 Stifan Kristi 
>>>
>>>> i'd like your logic bruno, could you explain about the function, please?
>>>> 000_essentials.py = what for?
>>>> 100_authdatabase.py = what for?
>>>> 200_dbmodel.py = what for?
>>>> 300_validators.py = what for?
>>>> 400_utilities.py = what for?
>>>> 500_preload.py = what for?
>>>>
>>>> thank you so much
>>>>
>>>> On Sun, May 1, 2011 at 11:03 AM, Bruno Rocha wrote:
>>>>
>>>>> My point of views is that in a simple and smaller app this approach is
>>>>> a good (may be the only) option.
>>>>>
>>>>> I am now running with a different numerical order, using 3 digits
>>>>>
>>>>> 000_essentials.py
>>>>> 100_authdatabase.py
>>>>> 200_dbmodel.py
>>>>> 300_validators.py
>>>>> 400_utilities.py
>>>>> 500_preload.py
>>>>>
>>>>> why? because between every model I have 99 empty spaces if I need to
>>>>> include some new model without the need to rename all the others.
>>>>>
>>>>> But this is a mess if working with a large app, so I tried to create
>>>>> classes and methods as:
>>>>>
>>>>> class mymodel(object):
>>>>> def define_essentials():
>>>>> db = DAL('.')
>>>>>
>>>>> def define_auth():
>>>>> auth = Auth(db...)
>>>>>
>>>>> def define_model():
>>>>> db.define_table('mytable',Field())
>>>>>
>>>>>
>>>>> So I can call mymodel.define_essentials() directly from the controller
>>>>> or another main model, why?
>>>>>
>>>>> Imagine a large app with many models and many objects loaded in memory
>>>>> even if you do not need them.
>>>>>
>>>>> But, I think web2py has a good MVC pattern used for controllers and
>>>>> views, we are talking about how to have the same approach for model files.
>>>>>
>>>>>
>>>>> --
>>>>> Bruno Rocha
>>>>> [ About me: http://zerp.ly/rochacbruno ]
>>>>>
>>>>>
>>>>>
>>>>> On Sun, May 1, 2011 at 12:37 AM, pbreit wrote:
>>>>>
>>>>>> I think either way is fine. In a bigger app, you might separate them
>>>>>> out.
>>>>>>
>>>>>> Vinicius, I like that approach.
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>>  http://martin.tecnodoc.com.ar
>>>
>>>
>>
>
>
> --
>  http://martin.tecnodoc.com.ar
>
>


Re: [web2py] Total control over your web2py models

2011-05-01 Thread Stifan Kristi
thank you so much for your info, martin, i've already tried and learn from
powerpack plugins, it's cool but because i'm a newbie in python and web2py,
so that a lot of things on powerpack that i don't know the function is what
for?
pardon me, could you explain about:
mod_clients.py = what for?
mod_users.py = what for?

many thanks before

On Sun, May 1, 2011 at 7:58 PM, Martín Mulone wrote:

> In powerpack I have this:
>
> config.py (application settings)
> data.py (all the db definition and menus)
> main.py (auth, mail, service, registration settings, etc) (this is
> independant of the app)
>
> then I usually do:
>
> mod_clients.py
> mod_users.py
> mod_someother.py
> mod_someother2.py
>
> I have classes like bruno show, but I don't have db definitions in this
> classes, instead I have all the db definition in data.py because surely I
> have link to another tables.
>
> Then came the plugins:
>
> plugins_1.py
> plugins_2.py
> plugins_3.py
> plugins_4.py
> plugins_zindex.py (here the execution order of plugins)
>
> 2011/5/1 Stifan Kristi 
>
>> i'd like your logic bruno, could you explain about the function, please?
>> 000_essentials.py = what for?
>> 100_authdatabase.py = what for?
>> 200_dbmodel.py = what for?
>> 300_validators.py = what for?
>> 400_utilities.py = what for?
>> 500_preload.py = what for?
>>
>> thank you so much
>>
>> On Sun, May 1, 2011 at 11:03 AM, Bruno Rocha wrote:
>>
>>> My point of views is that in a simple and smaller app this approach is a
>>> good (may be the only) option.
>>>
>>> I am now running with a different numerical order, using 3 digits
>>>
>>> 000_essentials.py
>>> 100_authdatabase.py
>>> 200_dbmodel.py
>>> 300_validators.py
>>> 400_utilities.py
>>> 500_preload.py
>>>
>>> why? because between every model I have 99 empty spaces if I need to
>>> include some new model without the need to rename all the others.
>>>
>>> But this is a mess if working with a large app, so I tried to create
>>> classes and methods as:
>>>
>>> class mymodel(object):
>>> def define_essentials():
>>> db = DAL('.')
>>>
>>> def define_auth():
>>> auth = Auth(db...)
>>>
>>> def define_model():
>>> db.define_table('mytable',Field())
>>>
>>>
>>> So I can call mymodel.define_essentials() directly from the controller or
>>> another main model, why?
>>>
>>> Imagine a large app with many models and many objects loaded in memory
>>> even if you do not need them.
>>>
>>> But, I think web2py has a good MVC pattern used for controllers and
>>> views, we are talking about how to have the same approach for model files.
>>>
>>>
>>> --
>>> Bruno Rocha
>>> [ About me: http://zerp.ly/rochacbruno ]
>>>
>>>
>>>
>>> On Sun, May 1, 2011 at 12:37 AM, pbreit  wrote:
>>>
>>>> I think either way is fine. In a bigger app, you might separate them
>>>> out.
>>>>
>>>> Vinicius, I like that approach.
>>>>
>>>
>>>
>>
>
>
> --
>  http://martin.tecnodoc.com.ar
>
>


Re: [web2py] Total control over your web2py models

2011-05-01 Thread Stifan Kristi
i'd like your logic bruno, could you explain about the function, please?
000_essentials.py = what for?
100_authdatabase.py = what for?
200_dbmodel.py = what for?
300_validators.py = what for?
400_utilities.py = what for?
500_preload.py = what for?

thank you so much

On Sun, May 1, 2011 at 11:03 AM, Bruno Rocha  wrote:

> My point of views is that in a simple and smaller app this approach is a
> good (may be the only) option.
>
> I am now running with a different numerical order, using 3 digits
>
> 000_essentials.py
> 100_authdatabase.py
> 200_dbmodel.py
> 300_validators.py
> 400_utilities.py
> 500_preload.py
>
> why? because between every model I have 99 empty spaces if I need to
> include some new model without the need to rename all the others.
>
> But this is a mess if working with a large app, so I tried to create
> classes and methods as:
>
> class mymodel(object):
> def define_essentials():
> db = DAL('.')
>
> def define_auth():
> auth = Auth(db...)
>
> def define_model():
> db.define_table('mytable',Field())
>
>
> So I can call mymodel.define_essentials() directly from the controller or
> another main model, why?
>
> Imagine a large app with many models and many objects loaded in memory even
> if you do not need them.
>
> But, I think web2py has a good MVC pattern used for controllers and views,
> we are talking about how to have the same approach for model files.
>
>
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
>
>
>
> On Sun, May 1, 2011 at 12:37 AM, pbreit  wrote:
>
>> I think either way is fine. In a bigger app, you might separate them out.
>>
>> Vinicius, I like that approach.
>>
>
>


Re: [web2py] Total control over your web2py models

2011-05-01 Thread Stifan Kristi
thank you so much for your detail explaination, Vinicius Assef. i like what
u've wrote on your blog. just for info, i'd realized that if you want to
validate self reference table, it can do on the define table (returns an
error)

On Sun, May 1, 2011 at 10:22 AM, Vinicius Assef wrote:

> Stifan,
> a Field() may have many properties adjusted and it turns difficult to
> read define_table(), mainly due to multiple validators.
> Note that validators stablish FORM() behaviour, not a database table
> behaviour. So, mixing layers is not a good practice, right?
>
> Separating them will guarantee that if you need some cross reference,
> it will work, in spite of table order creation. An example here is the
> IS_IN_DB validator.
>
> Keeping them separeted from each other, allows you to make tests and
> debug in an a differente approach, isolating problems and behaviour.
>
> --
> Vinicius Assef.
>
>
> On Sat, Apr 30, 2011 at 11:30 PM, Stifan Kristi
>  wrote:
> > nice info, viniclusban, btw,
> > First, because web2py recommends you don't mix validators
> > with db.define_table().
> > is it the best practice to not mix requires on the same time with field
> > create?
> > e.g.
> > db.define_table('category',
> > Field('category'
> >   )
> > )
> > db.category.requires = IS_NOT_EMPTY()
> > is better than :
> > db.define_table('category',
> > Field('category',
> >   requires = IS_NOT_EMPTY()
> >   )
> > )
> > please give an advice or pointer about this?
> > thank you so much
> >
> > On Sun, May 1, 2011 at 9:22 AM, Vinicius Assef 
> > wrote:
> >>
> >> Buddies, I'd like to hear your oppinions about this post in my blog:
> >> http://bit.ly/mCH7rr
> >>
> >> --
> >> Vinicius Assef.
> >
> >
>


Re: [web2py] Re: index not show on sql log

2011-05-01 Thread Stifan Kristi
i'm understand right now, thank you so much for your detail reference,
pbreitenbach

On Sun, May 1, 2011 at 10:49 AM, pbreit  wrote:

> Because sql.log only tracks define_tables(). As noted in the Book:
>
> "Currently the DAL API does not provide a command to create indexes on
> tables, but this can be done using the *executesql* command. This is
> because the existence of indexes can make migrations complex, and it is
> better to deal with them explicitly."
>


Re: [web2py] Re: index not show on sql log

2011-04-30 Thread Stifan Kristi
thank you so much for your suggestion, massimo.

On Sun, May 1, 2011 at 9:30 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> add this to your views
>
> {{=BEAUTIFY(db._timings)}}
>
> all queries will be there, timed.
>
> On Apr 30, 8:00 pm, pbreit  wrote:
> > sql.log reflects SQL generated from the define_table() models and will
> not
> > include any queries performed with executesql().
>


Re: [web2py] Total control over your web2py models

2011-04-30 Thread Stifan Kristi
nice info, viniclusban, btw,
First, because web2py recommends you don't mix validators with
db.define_table().

is it the best practice to not mix requires on the same time with field
create?
e.g.
db.define_table('category',
Field('category'
  )
)
db.category.requires = IS_NOT_EMPTY()

is better than :

db.define_table('category',
Field('category',
  requires = IS_NOT_EMPTY()
  )
)

please give an advice or pointer about this?

thank you so much

On Sun, May 1, 2011 at 9:22 AM, Vinicius Assef wrote:

> Buddies, I'd like to hear your oppinions about this post in my blog:
> http://bit.ly/mCH7rr
>
> --
> Vinicius Assef.
>


Re: [web2py] Re: index not show on sql log

2011-04-30 Thread Stifan Kristi
i'm understand right now, btw, the indexing is working, i'm just curious why
it's not log by sql log on web2py appadmin, thank you so much for your
explaination, breitenbach.

On Sun, May 1, 2011 at 8:00 AM, pbreit  wrote:

> sql.log reflects SQL generated from the define_table() models and will not
> include any queries performed with executesql().


Re: [web2py] Re: Multi-Company System

2011-04-30 Thread Stifan Kristi
>
> In my experience even large DBs perform well when queries are on
> indexed fields and it is much easier to manage data when it is in one
> place.
>

i think indexed fields not every table must have it, because when you didn't
use it wisely it can drop your database performance. just indexed the field
that refered by another table.
e.g.
requires = IS_IN_DB(db, db.table.id, '%(field)s'


Re: [web2py] Re: Multi-Company System

2011-04-30 Thread Stifan Kristi
it's a good idea, pardon me, my point of view is focus on the performance
because the data will growth and the database process will be high. i think
it'll be so hard to maintain if the performance is degraded and the
application system had already live.

On Sat, Apr 30, 2011 at 9:03 PM, villas  wrote:

> On Apr 30, 2:14 pm, Stifan Kristi 
> wrote:
> > how about the performance difference between using single database or
> > multiple database? did you consider about it?
>
> I don't think that's an issue for me because DBs have to be really
> big, or large numbers of transactions before speed becomes a
> problem.
>
> Furthermore,  the model I have in mind is also inherently scalable
> because I can easily replicate the setup across different servers.
> e.g. sub-domains A-M routed to DBserver1 and N-Z routed to DBserver2
> etc.
>
> There will also be the option to move to GoogleSQL in future.


  1   2   >