Re: [web2py] too many redirect during checking condition

2011-04-05 Thread Stifan Kristi
it clear for me right now, thank you so much


On Wed, Apr 6, 2011 at 7:02 AM, Martín Mulone wrote:

> @auth.requires_login()
> def index():
>return dict(message=T('Hello World'))
>
> 2011/4/5 黄祥 
>
>> hi,
>>
>> i want to use condition that if user not log in will redirect to login
>> page, and if logged in will redirect to index page, heres my
>> controller :
>>
>> if not session.authorized:
>>redirect(URL('user'))
>> else:
>>redirect(URL('index'))
>>
>> def index():
>>return dict(message=T('Hello World'))
>>
>> def user():
>>return dict(form = auth())
>>
>> i know there is a mistook code on my own, could there anybody show me
>> where is the wrong part?
>> i've tried the other code too, but got the same result :
>>
>> if not auth.is_logged_in():
>>redirect(URL('user'))
>> else:
>>redirect(URL('index'))
>>
>> def index():
>>return dict(message=T('Hello World'))
>>
>> def user():
>>return dict(form = auth())
>>
>> thank you so much before
>
>
>
>
> --
> My blog: http://martin.tecnodoc.com.ar
> Expert4Solution: http://www.experts4solutions.com/e4s/default/expert/6
> http://www.cvstash.com/profile/Xzi5bWCdD
>
>
>


Re: [web2py] change default controller into another controller

2011-04-08 Thread Stifan Kristi
it's clear for me now, thank you so much for your detail explaination.


Re: [web2py] is web2py support html 5 and css 3?

2011-04-08 Thread Stifan Kristi
a, i c, i mean is it support the python format for html 5 and css 3 tags,
like :
e.g.
{{=BR()}}

thank you

On Fri, Apr 8, 2011 at 8:46 PM, Vasile Ermicioi  wrote:

> web2py is a server side framework, html5 and css3 are client side
> technologies, and  they should be supported by browsers not by servers


Re: [web2py] is web2py support html 5 and css 3?

2011-04-08 Thread Stifan Kristi
no, i mean html 5 tag is it support to be converted by python format,
actually, i've tried to convert audio and video tag using html 5 (references
from w3schools), but it's not goin to work (audio n video), any solution for
this problem?

thanks very much


On Fri, Apr 8, 2011 at 9:27 PM, Jonathan Lundell  wrote:

> On Apr 8, 2011, at 7:02 AM, Stifan Kristi wrote:
>
> a, i c, i mean is it support the python format for html 5 and css 3 tags,
> like :
> e.g.
> {{=BR()}}
>
>
> web2py always generates  for BR(), which is OK for html5 (though not
> really great for html4...).
>
> Just be sure to generate an html5 doctype:
>
>
> thank you
>
> On Fri, Apr 8, 2011 at 8:46 PM, Vasile Ermicioi  wrote:
>
>> web2py is a server side framework, html5 and css3 are client side
>> technologies, and  they should be supported by browsers not by servers
>
>
>
>
>


Re: [web2py] Re: is web2py support html 5 and css 3?

2011-04-08 Thread Stifan Kristi
actually, my intention is to embed audio or video file into web2py apps,
i've tried embed and object but it's not going to work, so that i tried to
use html 5 tags audio and video, but got the same result, i ever posted to
this forum too about my detail error using embed tag. pardon me, what do u
mean with TAG.video() is it same like {{=TAG.video()}} ?
do you have any documentation for that tag?
thank you so much

On Fri, Apr 8, 2011 at 10:13 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> We have no plan to add more tags since you can generate any tag you
> need as Jonathan suggests.
> If we need to change the behavior of some tags, please let me know
> with a concrete example.
>
> Massimo
>
> On Apr 8, 9:57 am, Jonathan Lundell  wrote:
> > On Apr 8, 2011, at 7:37 AM, Stifan Kristi wrote:
> >
> > > no, i mean html 5 tag is it support to be converted by python format,
> actually, i've tried to convert audio and video tag using html 5 (references
> from w3schools), but it's not goin to work (audio n video), any solution for
> this problem?
> >
> > Do you mean, for example, something like =VIDEO()? Not yet, but you can
> use TAG.video()
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > thanks very much
> >
> > > On Fri, Apr 8, 2011 at 9:27 PM, Jonathan Lundell 
> wrote:
> > > On Apr 8, 2011, at 7:02 AM, Stifan Kristi wrote:
> > >> a, i c, i mean is it support the python format for html 5 and css 3
> tags, like :
> > >> e.g.
> > >> {{=BR()}}
> >
> > > web2py always generates  for BR(), which is OK for html5 (though
> not really great for html4...).
> >
> > > Just be sure to generate an html5 doctype:
> >
> > >> thank you
> >
> > >> On Fri, Apr 8, 2011 at 8:46 PM, Vasile Ermicioi 
> wrote:
> > >> web2py is a server side framework, html5 and css3 are client side
> technologies, and  they should be supported by browsers not by servers
>


Re: [web2py] Re: session.forget()

2011-04-09 Thread Stifan Kristi
i'm understand right now, thank you very much for your detail explaination.
what is the different within session.forget(response) and session.forget()?
1 more things, it is best practice to save the session in database?
like i read in
http://web2py.com/book/default/chapter/11#Sessions-in-Database
i've already tested your step to put session.forget(), but i can't using
crud, like i've read on that web2py book url, is there anyways to do this?

thank you so much.

steve van christie


Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
thank you so much for your explaination, i've already read that url,
honestly i'm the newbie in python and web2py, could you please give an
example how to pass the global objects to the function as arguments?
i've already test for the simple thing, it work, but for global objects i'm
still confused.
e,g,
For Modules :
#!/usr/bin/env python
# coding: utf8
from gluon.html import *
from gluon.http import *
from gluon.validators import *
from gluon.sqlhtml import *
# request, response, session, cache, T, db(s)
# must be passed and cannot be imported!

def manage(x):
return x

For Controller:
# coding: utf8
# try something like

exec('import applications.%s.modules.manage as manage' %
request.application)
reload(manage)

def index():
return manage.manage(T('Hello'))

thank you so much

steve van christie


Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
i've tried to run what you suggested, but still have a problem:
On Modules:

#!/usr/bin/env python
# coding: utf8
from gluon.html import *
from gluon.http import *
from gluon.validators import *
from gluon.sqlhtml import *
# request, response, session, cache, T, db(s)
# must be passed and cannot be imported!

from gluon.tools import *

db = DAL('sqlite://storage.sqlite')
crud = Crud(globals(),db)

def manage(title, table, request):
form = crud.update(table, request.args(1))
 table.id.represent = lambda id: A('Edit:', id,  _href = URL(args =
(request.args(0), id)))
search, rows = crud.search(table)
 return dict(title = title,  form = form, search = search, rows = rows)

On Controller :

# coding: utf8

exec('import applications.%s.modules.manage as manage' %
request.application)
reload(manage)

def blog():
title = T('Blog')
table = db.blog
return manage.manage(title, table, request)

i got an error :


Traceback (most recent call last):

  File "/home/sugizo/web2py/gluon/restricted.py", line 188, in restricted

exec ccode in environment

  File "/home/sugizo/web2py/applications/stevevanchristie/controllers/manage.py"
,
line 4, in 

reload(manage)

  File "applications/stevevanchristie/modules/manage.py", line 13, in 

crud = Crud(globals(),db)

  File "/home/sugizo/web2py/gluon/tools.py", line 2671, in __init__

self.settings.delete_next = self.url()

  File "/home/sugizo/web2py/gluon/tools.py", line 2659, in url

f=f, args=args, vars=vars)

  File "/home/sugizo/web2py/gluon/html.py", line 218, in URL

raise SyntaxError, 'not enough information to build the url'
SyntaxError: not enough information to build the url


did anyone know how to fixed it?

thank you very much


Re: [web2py] Re: session.forget()

2011-04-09 Thread Stifan Kristi
thank you so much for your explaination. i'm quite understand right now.

best regards,

steve van christie

On Sun, Apr 10, 2011 at 1:02 AM, Anthony  wrote:

> On Saturday, April 9, 2011 12:44:06 PM UTC-4, 黄祥 wrote:
>>
>> i'm understand right now, thank you very much for your detail
>> explaination.
>> what is the different within session.forget(response)
>> and session.forget()?
>>
>
> session.forget() just tells web2py not to bother saving the current session
> to the session file at the end of the current request.
> session.forget(response) does the same thing, but also immediately unlocks
> and closes the session file (rather than at the end of the request).
> Unlocking the session file can be useful if you've got a long running action
> -- otherwise, if it remains locked during the entire request, other requests
> within the same session (e.g., Ajax requests) will be blocked until the long
> running request is complete.
>
>
>>  1 more things, it is best practice to save the session in database?
>> like i read in
>> http://web2py.com/book/default/chapter/11#Sessions-in-Database
>>
>
> I'm not sure about that one. You're probably OK with the filesystem in most
> cases.
>
>
>>  i've already tested your step to put session.forget(), but i can't using
>> crud, like i've read on that web2py book url, is there anyways to do this?
>>
>
> Note, in order to protect against CSRF attacks and double form submission,
> web2py forms (using FORM, SQLFORM, or Crud) store a one-time key in the
> session (see http://web2py.com/book/default/chapter/07#Hidden-fields). So,
> for any actions dealing with form submission, you probably should not do
> session.forget().
>
> Anthony
>


Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
actually my real intention is :

i have the same function that repeated many times in 1 controller (repeated
to different tables), so that i would to make it simple just put it on
modules, what do you think about it?

if i created the new function in 1 controller and then the other function
access it, i don't like because it can be access by the browser url, is
there any way to prevent it? (i mean i created 1 function, and the other
function access it, and can't be accessed via browser url)

pardon, if i'm not wrong, i read that to put the function on the model is
not the best practice, what do you think about it?

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

steve van christie

On Sun, Apr 10, 2011 at 1:14 AM, pbreit  wrote:

> The one project I've seen that is sort of designed how you are suggesting
> is InstantPress:
> http://code.google.com/p/instant-press/
>
> But I agree with Anthony, I always encourage keeping it simple. There's a
> saying about premature optimization and it's not good.
>


Re: [web2py] Re: T usage

2011-04-09 Thread Stifan Kristi
Hi,

is it possible to translate the output data table using T()?

thank you so much

On Sun, Apr 10, 2011 at 5:45 AM, niknok  wrote:

> Beautiful one liner. I have to write an ugly hack to make it work. I
> was forcing the translations because I need to translate certain
> sections only.
>
> def babel(lang, s):
># forced translation of Q&A section
>T.force(lang)
>if type(s)==list:
>loc_string=[]
>for i in s:
>loc_string.append(str(T(i)))
>else:
>loc_string=str(T(s))
>T.set_current_languages('en') # reset to English
>return loc_string
>
> and in my controller:
>
>my_dialog=babel(session.locale, question['dialog'])
>my_choices=babel(session.locale, question['choices'])
>form=SQLFORM.factory(
>Field('english', writable=False, default=question['dialog']),
>Field('translation', writable=False, default=my_dialog,
> label=settings.locale[session.locale]),
>Field('answer','list:string',
> default=answer_value,
>requires=IS_IN_SET(question['choices'], my_choices,
> zero=None,
> multiple=True)))
>
>
>
> On Apr 7, 9:43 pm, DenesL  wrote:
> > Assuming
> > options = a retrieved list:string record
> >
> > then
> > choices = dict([(x,T(x)) for x in options])
> >
> > should work. Note: untested.
> >
> > On Apr 7, 3:29 am,niknok wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Thanks DenesL.
> >
> > > What if the options are retrieved from a field of list:string type?
> >
> > > On Apr 4, 10:39 pm, DenesL  wrote:
> >
> > > > Use
> >
> > > > choices = {'Gold':T('Gold'), 'Silver':T('Silver')}
> >
> > > > and update your language translations strings.
> > > > Not sure how "answer" is obtained.
> >
> > > > On 4 abr, 09:16,niknok wrote:
> >
> > > > > I tried:
> > > > > Field('color', 'list:string', default=answer,
> > > > > requires=IS_IN_SET(T(question['choices']), zero=None,
> multiple=True))
> >
> > > > > I would like to display the choices in the translated language but
> the
> > > > > selection will be stored in the database in the orginal language.
> For
> > > > > example:
> >
> > > > > choices = ['Gold', 'Silver']
> > > > > What the user sees: ['Oro', 'Plata']
> > > > > What is stored in the database (as the case, maybe): |Gold|Silver|
> >
> > > > > And if I need to display the selection (default=answer), Oro and
> Plata
> > > > > will be re-selected.


Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
hi, all,

thank you so much for your detail explaination, i'm understand right now.

i can simplified the other function (show and view) but for search result
and feed, i can't pass it to another function.

1. why i can't pass row.title into variable?
def blog_result():
pattern = '%' + request.vars.keyword.lower() + '%'
 pages = db(db.blog.title.lower().like(pattern)).select(orderby =
db.blog.title)
items = [A(T(*row.title*), _href = URL('blog_show', args = row.id)) for row
in pages]
 return UL(*items).xml()

2. rss feed error, when i tried to passed the variable into it (title, link,
description)?
def blog_feed():
blogs = db().select(db.blog.ALL, orderby = db.blog.title)
return dict(title = *'Blog Feed'*, link = *'
http://127.0.0.1:8000/stevevanchristie/main/blog'*, description = *'Blog RSS
Feed'*, created_on = request.now, items = [dict(title = row.title, link =
URL('blog_show', args = row.id), description =
MARKMIN(row.content).xml(), created_on = row.created_on) for row in blogs])

could anyone explain to me where is my fault?

thank you very much

steve van christie

On Sun, Apr 10, 2011 at 6:10 AM, Anthony  wrote:

> On Saturday, April 9, 2011 6:40:03 PM UTC-4, 黄祥 wrote:
>>
>> actually my real intention is :
>>
>> i have the same function that repeated many times in 1 controller
>> (repeated to different tables), so that i would to make it simple just put
>> it on modules, what do you think about it?
>>
>> if i created the new function in 1 controller and then the other function
>> access it, i don't like because it can be access by the browser url, is
>> there any way to prevent it? (i mean i created 1 function, and the other
>> function access it, and can't be accessed via browser url)
>>
>
> As explained here (http://web2py.com/book/default/chapter/04#Dispatching),
> any function in a controller that either (a) takes any arguments or (b)
> starts with an underscore cannot be accessed via a URL. In your case, the
> 'manage' function takes arguments, so it cannot be accessed directly via URL
> (try it). If it didn't take any arguments and you still wanted to make it
> inaccessible, you could rename it to '_manage' (or simply give it a dummy
> argument that isn't used).
>
>
>>
>> pardon, if i'm not wrong, i read that to put the function on the model is
>> not the best practice, what do you think about it?
>>
>
> I think it's OK to put a function in a model file if it is used across
> multiple controllers, particularly if the function needs access to the
> web2py global objects (that way, you don't have to worry about passing the
> globals to the function). If you have a few such helper functions, it would
> probably make sense to put them into a special helper model file (rather
> than sticking them all in your db.py file). At some point, it might make
> sense to start moving some functions out into modules and importing them
> when needed, but that's probably not necessary until your app starts to get
> a lot bigger and more complex. One thing to keep in mind -- model files are
> executed in alphabetical order, so don't put something in a model file if it
> needs to refer to something that's defined in another model file that comes
> later in alphabetical order.
>
> Anthony
>


Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
thank you so much for your explaination.
pardon, because i'm a newbie in python n web2py, i just learn, try to
implement what have been written in the http://web2py.com/book/default/
 the other controller that can't be passed
is *blog_result* like on below :

def blog():
title = T('Blog')
form = FORM(INPUT(_id = 'keyword', _name = 'keyword', _onkeyup = "ajax('
*blog_result*', ['keyword'], 'result');"))
result = DIV(_id = 'result')
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.blog.ALL, limitby = limitby)
return dict(title = title, form = form, result = result, rows =
rows, page = page, items_per_page = items_per_page)

could someone can explain to me, where is my fault code?

thank you very much,

steve van christie

On Sun, Apr 10, 2011 at 9:53 AM, pbreit  wrote:

> T() is for text translations and I'm not sure you can use it (or would want
> to) with non-static text.
>
> That dict() looks a little messy. For one thing, you can simply include
> blogs=blogs. Some of those things I would put in the view instead
> (MARKMIN(().xml(), URL('blog_show')). Also, since views are typically
> linked to one controller, you would not ordinarily pass hard-coded text to
> the view. And request.now is available in the view.
>
> I would expect to see a controller like this:
>
> def blog_feed():
> blogs = db().select(db.blog.ALL, orderby = db.blog.title)
> return(blogs=blogs)
>
> And then the view blog_feed.html something like this (not tested):
>
> {{extend layout.html}}
> Blog Feed
> Home
> Blog RSS Feed - created on {{=request.now}}
> 
> {{for blog in blogs:}}
>   {{=blog.title}} - created on
> {{=blog.created_on}}
>   {{=MARKMIN(blog.content).xml()}}
> {{pass}}
> 
>
> I would definitely suggest going through Chapter 3 of the book:
> http://web2py.com/book/default/chapter/03
>


Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
pardon me, i just follow the example that was written on the book:
http://web2py.com/book/default/chapter/03
and it works fine, but i want to make it simple, i mean create
__view(parameters), __feed(parameters), __result(parameters), and then the
other function call it and pass the arguments.
i've already read the whole book,
because i'm a newbie, a lot of things that i don't understand, so i start to
test what was written on the book, any suggestion?

thank you so much

steve van christie

On Sun, Apr 10, 2011 at 11:19 AM, pbreit  wrote:

> That code has *lots* of problems.
>
> First, there's no db() call so you're not going to have any rows.
>
> You don't do the "onkeyup" like that. You need to do it in the view as
> shown in the book:
> http://web2py.com/book/default/chapter/10#The-ajax-Function
>
> You're going to have a problem if "len(request.args)" is True since if
> that's the case, page and items_per_page will not exist.
>
> I very strongly encourage you to start at the beginning of the book and
> work you're way through it. Don't even look at chapters 9-13 until you have
> mastered 1-8.
>
> And when you post problems here, go ahead and copy paste the exact error
> message you are receiving.
>


Re: [web2py] Re: bulk insert form

2011-04-12 Thread Stifan Kristi
a, i am understand right now, thank you so much for your explaination, greg.

best regards,

steve van christie


Re: [web2py] Re: Powerpack

2011-04-12 Thread Stifan Kristi
amazing, i'll try it...


Re: [web2py] Re: bulk insert form

2011-04-12 Thread Stifan Kristi
thank you so much villas for your share, i'll try to modify it for inserts.

best regards,

steve van christie

On Wed, Apr 13, 2011 at 8:43 AM, villas  wrote:

> I use this code for updating multiple records,  maybe you could use
> something similar for inserts.
>
>  controller --
> myrecords=db(query).select(db.table.ALL)
> if form.accepts ...
>for r in myrecords:
>if request.vars.has_key('id%i_price' % r.table.id):
>r.table.update_record(price=request.vars['id%i_price'%
> r.table.id])
>
> - view --
> 
> {{for record in myrecords:}}
>  
>{{=record.carprice.id}}
> value={{=record.table.price}}/>
>  
> {{pass}}
> ...
>
> On Apr 12, 5:31 am, 黄祥  wrote:
> > hi,
> >
> > is it possible to insert several data simultanously (bulk insert) in
> > web2py using crud or sqlform? i mean, like select several image file
> > and then upload it, or maybe using jquery add or remove form field
> > any suggestion or reference for doing that?
> >
> > thank you so much


Re: [web2py] request.args error on module

2011-04-13 Thread Stifan Kristi
thank you so much for your advice.
what is the difference between put it on the models folder,
controllers folder and modules folder? i mean in performance, or maybe
syntax

thank you so much and best regards,

steve van christie

On 2011-04-13, pbreit  wrote:
> I usually just put those functions in the models folder. Much easier.
>
> I would highly recommend trying to keep things simple.


-- 
*

[image: 黄祥]

スティファン クリスティ (黄祥)

Stifan Kristi (Kou Shou)

ジャカルタ、 インドネシア

Jakarta, Indonesia

携帯。 +六二 八一八 七八三 一一八

Cell. +62 818 783 118

ウェブサイト : http://stevevanchristie.net

Website : http://stevevanchristie.net
*


Re: [web2py] request.args error on module

2011-04-13 Thread Stifan Kristi
a, i c, it's open my mind, thank you so much for your advised. i'll try to
follow your advised. which is better to put the menu functionality that been
used by many views (same code in many views, the link is related with
database (request.args))?

thank you so much in advance.

best regards,

steve van christie

On Wed, Apr 13, 2011 at 4:04 PM, pbreit  wrote:

> If used by one controller, put in controller.
> If used by multiple controllers, put in models.
> If has little or no access to the DB or other Web2py global functionality,
> put in module.
>
> In theory there is a minor performance hit in adding code to models since
> all models are loaded on every call. But it's generally not something that
> most projects need to worry about and definitely not something to worry
> about in the beginning.
>
> It's best to keep things simple and focus on building your application
> functionality.
>


Re: [web2py] request.args error on module

2011-04-13 Thread Stifan Kristi
a, i c, got it, thank you so much for your advised.

best regards,

steve van christie


Re: [web2py] Re: Bookings Manager

2011-04-13 Thread Stifan Kristi
i'll test the pbreitenbach's code and it works fine, pardon, which browser
that u used?

best regards,

steve van christie


Re: [web2py] Re: Bookings Manager

2011-04-13 Thread Stifan Kristi
hi ismail,

i've tested it, your apps work fine on me, i think it's related with your
browser.

best regards,

steve van christie


Re: [web2py] Re: Bookings Manager

2011-04-13 Thread Stifan Kristi
same for me, i run it on url:
http://127.0.0.1:8000/booking/default/index

best regards,

steve van christie


Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-13 Thread Stifan Kristi
yes, i've tried to implement the code from that url.
here is my function :

models/db_functions.py:

def __index(table):
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(table.ALL, limitby = limitby, cache = (cache.ram, 60))
return dict(rows = rows, page = page, items_per_page = items_per_page)

and my controller :
controllers/book.py

# coding: utf8

table = db.author

def index():
return __index(table)

please give a suggestion or advice for this?

thank you so much in advance

steve van christie


Re: [web2py] Re: functions

2011-04-13 Thread Stifan Kristi
hi antony,

thank you so much for your adviced, in my case (please see attached file),
would you prefer to put it on models or modules?
right now i put it on models, please give an advice or suggestion?

thank you very much in advance.

steve van christie


On Thu, Apr 14, 2011 at 7:17 AM, Anthony  wrote:

> If it's just a few (small) functions, go ahead and put them in model files,
> as reading a few extra function definitions will probably have a negligible
> impact on performance. In particular, if the functions are used in many/most
> requests, you would save little by moving them to modules because you would
> end up importing them on most requests anyway.
>
> On Wednesday, April 13, 2011 8:11:00 PM UTC-4, 黄祥 wrote:
>
>> hi,
>>
>> i try to follow the advise about functions from :
>> http://web2py.com/book/default/chapter/11#Efficiency-and-Scalability
>>
>> - Minimize the code in models: do not define functions there, define
>> functions in the controllers that need them or - even better - define
>> functions in modules, import them and use those functions as needed.
>> - Do not put many functions in the same controller but use many
>> controllers with few functions.
>>
>> i have a functions (e.g, add data, select data, update data) that been
>> used in many controller, i got an adviced to put my functions on the
>> models instead of on modules to make it simple, but the book said do
>> not define functions in models.
>> my intention is not to repeat the same code in many controller
>> (inefficiency) and make my code simple
>>
>> any suggestion or advice for this?
>>
>> thank you so much.
>>
>> steve van christie
>
>
def __index(table):
	menu = ('[ ', 
			A(T('Add'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'add'), 
			  _title = T('Add')), 
			' | ', 
			A(T('Search'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'search'), 
			  _title = T('Search')), 
			' ]')
	title = T('List')
	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(table.ALL, 
		   limitby = limitby)
	return dict(menu = menu, 
title = title, 
rows = rows, 
page = page, 
items_per_page = items_per_page)

def __add(table):
	menu = ('[ ', 
			A(T('Index'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'index'), 
			  _title = T('Index')), 
			' | ', 
			A(T('Search'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'search'), 
			  _title = T('Search')), 
			' ]')
	title = T('Add')
	form = crud.create(table, 
	   next = URL(request.application, 
  request.controller, 
  'index'))
	return dict(menu = menu, 
title = title, 
form = form)

def __edit(table):
	menu = ('[ ', 
			A(T('Index'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'index'), 
			  _title = T('Index')), 
			' | ', 
			A(T('Add'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'add'), 
			  _title = T('Add')), 
			' | ', 
			A(T('Search'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'search'), 
			  _title = T('Search')),  
			' | ', 
			A(T('Show'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'show', 
		  args = request.args), 
			  _title = T('Show')), 
			' ]')
	title = T('Edit')
	page = table(request.args(0)) or redirect(URL(request.application, 
  request.controller, 
  'index'))
	form = crud.update(table, 
	   page, 
	   next = URL(request.application, 
  request.controller, 
  'show', 
  args = request.args))
	return dict(menu = menu, 
title = title, 
form = form)

def __show(table):
	menu = ('[ ', 
			A(T('Index'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'index'), 
			  _title = T('Index')), 
			' | ', 
			A(T('Add'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'add'), 
			  _title = T('Add')), 
			' | ', 
			A(T('Search'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'search'), 
			  _title = T('Search')),  
			' | ', 
			A(T('Edit'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'edit', 
		  args = request.args), 
			  _title = T('Edit')), 
			' ]')
	page = table(request.args(0)) or redirect(URL(request.application, 
  request.controller, 
  'index'))
	return dict(menu = menu, 
page = page)

def __show_review(table, table_review, field):
	menu = ('[ ', 
			A(T('Index'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'index'), 
			  _title = T('Index')), 
			' | ', 
			A(T('Add'), 
			  _href = URL(request.application, 
		  request.controller, 
		  'add'), 
			  _

Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-13 Thread Stifan Kristi
pardon me, for not explain it more clearly, when i put *cache = (cache.ram,
60)* the new data is not show immediately after i inserted it, after a few
minutes, it will appears, but when i delete *cache = (cache.ram, 60)*, the
new data is show immediately after i inserted it. is it the behaviour of
cache or there is something wrong in my code function?

please give an advice, thanks.

best regards,

steve van christie


On Thu, Apr 14, 2011 at 7:25 AM, Anthony  wrote:

> How do you know it's not working? What behavior are you observing?
>
> On Wednesday, April 13, 2011 8:20:25 PM UTC-4, 黄祥 wrote:
>
>> yes, i've tried to implement the code from that url.
>> here is my function :
>>
>> models/db_functions.py:
>>
>>  def __index(table):
>> 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(table.ALL, limitby = limitby, cache = (cache.ram, 60))
>> return dict(rows = rows, page = page, items_per_page = items_per_page)
>>
>> and my controller :
>> controllers/book.py
>>
>>  # coding: utf8
>>
>> table = db.author
>>
>> def index():
>> return __index(table)
>>
>> please give a suggestion or advice for this?
>>
>> thank you so much in advance
>>
>> steve van christie
>>
>


Re: [web2py] Re: functions

2011-04-13 Thread Stifan Kristi
ok, i'll follow your adviced to put it on models, it's clear for me as a
newbie in python and web2py. pardon me, to asked many times about this
matter.

thanks and best regards,

steve van christie


Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-13 Thread Stifan Kristi
yes, after i inserted a new data, i immediately checked the new one, but it
didn't appears, after i checked it many times, and after few minutes, the
data is show up. i think for now, i'll try to not use *cache = (cache.ram,
60)*, because i'm still learning the python and web2py.

thank you so much for your adviced.

best regards,

steve van christie


Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-13 Thread Stifan Kristi
hi massimo,

i'll try your adviced, pardon, how / where to put expire_time = 0? i've
already search it on the book :
http://web2py.com/book/default/docstring/expire_time
 <http://web2py.com/book/default/docstring/expire_time>but it returns null

thank you so much in advance.

best regards,

steve van christie

On Thu, Apr 14, 2011 at 9:28 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> If you call it with expire_time=0 it will force a cache reset.
>
> On Apr 13, 7:49 pm, Stifan Kristi 
> wrote:
> > yes, after i inserted a new data, i immediately checked the new one, but
> it
> > didn't appears, after i checked it many times, and after few minutes, the
> > data is show up. i think for now, i'll try to not use *cache =
> (cache.ram,
> > 60)*, because i'm still learning the python and web2py.
> >
> > thank you so much for your adviced.
> >
> > best regards,
> >
> > steve van christie


Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-13 Thread Stifan Kristi
a, i c, thank you so much for your explaination, massimo.

best regards,

steve van christie



On Thu, Apr 14, 2011 at 9:48 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Hello Stifan,
>
> for a db(...).select(...) you would do
>
> db(query).select(cache=(cache.ram,0))
>
> the zero will reset the cache for this query.
>
>
>
> On Apr 13, 2011, at 9:43 PM, Stifan Kristi wrote:
>
> hi massimo,
>
> i'll try your adviced, pardon, how / where to put expire_time = 0? i've
> already search it on the book :
> http://web2py.com/book/default/docstring/expire_time
>  <http://web2py.com/book/default/docstring/expire_time>but it returns null
>
> thank you so much in advance.
>
> best regards,
>
> steve van christie
>
> On Thu, Apr 14, 2011 at 9:28 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> If you call it with expire_time=0 it will force a cache reset.
>>
>> On Apr 13, 7:49 pm, Stifan Kristi 
>> wrote:
>> > yes, after i inserted a new data, i immediately checked the new one, but
>> it
>> > didn't appears, after i checked it many times, and after few minutes,
>> the
>> > data is show up. i think for now, i'll try to not use *cache =
>> (cache.ram,
>> > 60)*, because i'm still learning the python and web2py.
>> >
>> > thank you so much for your adviced.
>> >
>> > best regards,
>> >
>> > steve van christie
>
>
>
>


Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-13 Thread Stifan Kristi
so what u suggested? use cache.ram or not or maybe try memcache?

please advice...
thanks and best regards,

steve van christie

On Thu, Apr 14, 2011 at 11:50 AM, VP  wrote:

>  I think cache.ram is funky.   I tried a small test by cache.ram'ing a
> controller function, like this:
>
> @cache(request.env.path_info, time_expire=10, cache_model=cache.ram\
> )
> def test():
>d = dict(x = 30)
>return response.render(d)
>
> and in test.html
>
> {{=x}}
>
> ..
>
> If you change 30 to 40, for example, the behavior is that the value
> during the 10 seconds could be 30 or 40 after each refresh.   The
> behavior is not deterministic, so it's difficult to debug.
>
> cache.disk doesn't seem to have this behavior.
>
>
>
>
>
>
> On Apr 13, 7:49 pm, Stifan Kristi 
> wrote:
> > yes, after i inserted a new data, i immediately checked the new one, but
> it
> > didn't appears, after i checked it many times, and after few minutes, the
> > data is show up. i think for now, i'll try to not use *cache =
> (cache.ram,
> > 60)*, because i'm still learning the python and web2py.
> >
> > thank you so much for your adviced.
> >
> > best regards,
> >
> > steve van christie


Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-14 Thread Stifan Kristi
ok, thank you so much for your adviced, pbreitenbach.

best regards,

steve van christie

On Thu, Apr 14, 2011 at 12:23 PM, pbreit  wrote:

> Neither. You probably won't need them. Focus on your app's functionality.


Re: [web2py] Re: web2py as the best choice for newstarters in web frameworks

2011-04-14 Thread Stifan Kristi
same for me, i love simplicity and dry, and choose to learn this web
framework.

On Thu, Apr 14, 2011 at 2:06 PM, luckysmack  wrote:

> yea same here. coming from php i find python and web2py awesome. im
> trying to get my work to make the shift over to python. building a
> base website for all our sites will be half the fun... I hope
>
> On Apr 13, 8:16 pm, Jason Brower  wrote:
> > It's great to see you using web2py!
> > I am also working to make web2py a popular tool in the small and medium
> > business markets.  And it is serving me well here in Finland.
> > ---
> > Good Luck!
> > Jason
> > On 04/14/2011 01:47 AM, Todor Todorov wrote:
> >
> >
> >
> >
> >
> >
> >
> > > I am running a small IT company in Bulgaria. We are not software
> > > developers, but mainly in the business of IT consultancy and support.
> > > Lately we felt the need of our customers for small business specific
> > > web applications. We have researched our possibilities for easy to
> > > learn web frameworks and *not surprisingly* found web2py as our best
> > > choice for development environment. We have described our research in
> > > one BLOG entry at our website:
> >
> > >http://goodspring-tech.com/index.php?option=com_content&view=article&;.
> ..
> > > (any comments on the completeness or non-completeness of our research
> > > are appreciated)
> >
> > > ... so we are starting as newcomers in the web2py community. Wishing
> > > web2py to become more and more popular, because it deserves this!


Re: [web2py] Re: how to share my apps in web2py appliance

2011-04-14 Thread Stifan Kristi
hi massimo & pbreitenbach,

thank you so much for your hints.
i've already shared it, please give a feedback, suggestion or advice about
it.

thanks and best regards,

steve van christie


Re: [web2py] Re: how to share my apps in web2py appliance

2011-04-14 Thread Stifan Kristi
done, please checked it out, and please give an advice or suggestion.

thanks and best regards,

steve van christie


Re: [web2py] Re: insert repeated many times when put it on models

2011-04-14 Thread Stifan Kristi
hi, anthony,

thank you so much for your detail explaination, right now, i use appadmin, i
think there is another way to put it on a code like on sql script.

best regards,

steve van christie


On Thu, Apr 14, 2011 at 11:33 PM, Anthony  wrote:

> Your model files are run on every request, so you shouldn't put any
> one-time code in a model file. The easiest way to do this would be manually
> via appadmin (see
> http://web2py.com/book/default/chapter/03#More-on-appadmin). You could
> also do it from a web2py shell or by putting the code in a Python script
> file and executing the file with web2py command line options (see
> http://web2py.com/book/default/chapter/04#Command-Line-Options, in
> particular, the -S and -R options).
>
> Anthony
>
> On Thursday, April 14, 2011 11:54:17 AM UTC-4, 黄祥 wrote:
>
>> hi,
>>
>> is there possible to insert the data auth_group during database
>> creation for the first time?
>> e.g.
>> db.auth_group.insert(role = "Admin", description = "Admin")
>>
>> i've already tried to put it on models but, the data inserted is
>> repeated many times.
>>
>> any idea, suggestion or correction?
>>
>> thanks and best regards,
>>
>> steve van christie
>
>


Re: [web2py] Re: submit forms to press the enter key

2011-04-14 Thread Stifan Kristi
is your focus is on the text area, check box or drop down list?

best regards,

steve van christie


Re: [web2py] Re: insert repeated many times when put it on models

2011-04-14 Thread Stifan Kristi
a, i c, thank you so much denes and anthony for your adviced, it opened my
mind right now.

kind regards,

steve van christie


Re: [web2py] Re: how to share my apps in web2py appliance

2011-04-14 Thread Stifan Kristi
On Fri, Apr 15, 2011 at 4:23 AM, pbreit  wrote:

> 1) there's a lot of duplicate code that I bet you could reduce. For
> example, all the controllers could be collapsed down into one controller
> since they are all nearly identical.
>

Thank you so much for your adviced, I'll try to simplified my controllers
and my views.

>
> 2) this is a personal preference but indenting with spaces is more common
> among Python programmers
>

Thank you so much for your adviced, I'll try to change my programming style
into python programmers.

>
> 3) also a personal preference but Python programmers tend to write their
> without as many newlines. Just read some other people's code and you will
> see a lot of commonality on when to start a new line, etc.
>

Thank you so much for your adviced, I'll try to change my programming
style.

>
> 4) you might want to put the define_tables in db.py which is common. and
> the menus in menu.py.
>

Thank you so much for your adviced, I've already changed it.

>
> 5) there is a db feature called "auth.signature" which will take care of
> the created_by/modified_by/modified_on. Ise it like this:
> db.define_table('tablename', Field('fieldname'), auth.signature)
>

Thank you so much for your adviced, Did you mean :
http://web2py.com/book/default/chapter/06#Table-Inheritance ?
I've follow those link to use db signature, because when i tested :
db.define_table('tablename', Field('fieldname'), auth.signature)
it's not going to work
any other reference?

>
> 6) you should make it so that app/default/index works since that is usually
> where people start.
>

Thank you so much for your adviced, I'll try to change my apps into
default.

>
> 7) you might want to create your own layout that is different from the
> default web2py look-and-feel
>

Thank you so much for your adviced, I'll try to modified it.

>
> 8) if you are going to be making improvements to the service, you might
> consider using version control (Mercurial) and hosting it Google Code or
> Bitbucket
>

Thank you so much for your adviced, I've tried to installed it, but an error
occured :
*error: Setup script exited with Python headers are required to build
Mercurial*
do you know how to fixed it?
currently i'm using ubuntu 10.10 64 bit


Re: [web2py] Re: bak files and size using space

2011-04-14 Thread Stifan Kristi
hi dharriman morgan,

a, i c, i've already set my editor (gedit) to insert space insteads of tabs,
with tabs width = 4.

thanks and kind regards,

steve van christie


Re: [web2py] Re: how to share my apps in web2py appliance

2011-04-15 Thread Stifan Kristi
a, i c, thank you so much for your adviced, arun.

best regards,

steve van christie

On Fri, Apr 15, 2011 at 9:52 PM, Arun K.Rajeevan wrote:

> your system doesn't have python-dev package.
> If you are compiling mercurial from source you need that.
> Install that first and try again.
>
> (on debian based systems)
> $> sudo apt-get install python-dev
>
> I prefer this, because, one in ubuntu repo is older than latest version
> available,
> And since some of my repo's are created with newer version, older versions
> of mercurial can't operate on them.
>


Re: [web2py] Re: how to produce db select into xml

2011-04-15 Thread Stifan Kristi
thank you so much for your help, anthony, i've already tested your code, and
it works fine.
def mp3():
rows = db().select(db.audio.ALL)
from gluon.serializers import xml
xmlrows = xml(rows)
return dict(xmlrows = xmlrows)

i'll try to pass the xml output into the views but, the player didn't work
because of what i passed is xml content not xml file (*.xml), the error said
'can't find xml file', do you have any solutions to produce xml file?

i'm tryin to use jquerygrid too, refer to the radiologs appliances.
any suggestion about it?

thank you so much and best regards,

steve van christie


Re: [web2py] Re: how to produce db select into xml

2011-04-15 Thread Stifan Kristi
thank you so much for your info, arun, but it return an error when i execute
it :

This page contains the following errors:
error on line 162 at column 10: Opening and ending tag mismatch: link line 0
and head error on line 162 at column 10: Encoding error
Below is a rendering of the page up to the first error.do you have any
solution for this?

thanks and best regards,

steve van christie

On Fri, Apr 15, 2011 at 10:38 PM, Arun K.Rajeevan wrote:

> def mp3():
> import gluon.contenttype
> response.headers['Content-Type']
> = gluon.contenttype.contenttype('.xml')
> rows = db().select(db.audio.ALL)
> from gluon.serializers import xml
> xmlrows = xml(rows)
> return dict(xmlrows = xmlrows)
>


Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-15 Thread Stifan Kristi
a, i c, thank you so much for your adviced, arun.
i'll use the cache.ram, but lower the time in my dev learning.

kind regards,

steve van christie


On Fri, Apr 15, 2011 at 11:05 PM, Arun K.Rajeevan wrote:

> It should not be.
> After caching, it must not hit database, until cache expires.
>
> So, after the cache is set and you insert something, then it'll take time
> until cache expires, to have another db hit.
> Unless db is queried again, new data will not be there.
>
> It's as simple as that.
>
> As others said, you probably don't need caching, but if you do, set an
> expire time considering how fast the data in db get changed.
>


Re: [web2py] Web2py: the top notch productivity platform

2011-04-15 Thread Stifan Kristi
web2py is awesome, a lot of feature that can be use for all programmers.

best regards,

steve van christie

On Sat, Apr 16, 2011 at 6:19 AM, DJ  wrote:

> 
>
> I have been using web2py for the past few years and I feel it is one the
> Python world's hidden gems. While most people argue about Django and the
> like, what matters most when it comes to application development is
> deployment speed, reliability and low cost of maintenance. If you are in the
> software development business, you want to put things in your customers
> hands early (agile development), provide full web functionality (logins,
> security, https) all of which come inbuilt and the ability to work with
> legacy systems (Oracle, MySQL) on multiple platforms (Linux, Windows).
> Web2py does all of this without making you sweat and worry about library
> incompatibilities and platform specific issues.The range of deployments is
> amazing - GAE to EC2. For this alone, the team deserves a huge round of
> applause!
>
> The recent tool CSVstudio is a complete life saver. I recently delivered a
> project where I had to convert Excel files running into a few hundred
> columns and thousands of rows into searchable databases. Imagine doing this
> by hand - forget it! I initially used CloverETL (a leading enterprise ETL
> solution), but still had to ensure column compatibilities and fix Excel
> issues which were time consuming. Well, half-way into the project, client
> changes Excel formats, adds new files to the mix - typical scenario right?
> Enter CSVstudio. It not only cleans your Excel files, but recognizes column
> data types and the best part - it generates the Web2py model file for you. I
> went from Excel file to searchable web database in less than 5 minutes. This
> is a killer tool for application developers!
>
> I'm sure there are a number of volunteers from around the world along with
> Massimo who contribute to the Web2py project and I would like to say - thank
> you, keep up the good work and make Web2py the #1 application development
> platform out there!
>
> For those of you who are contemplating using this platform or need
> assistance deploying this within your networks (academic or commercial),
> feel free to talk to the mailing list or ping me for corporate specific
> advise. I have deployed web2py in corporate settings, hospitals and research
> labs successfully and would be happy to help you.
>
> There's lots of good applications like Sahana people are building with
> Web2py and the recent news that our mailing list traffic has overtaken
> Django and Ruby is indication that people are moving in the right direction.
> Let the work talk, not the hype. And that's where web2py is the silent
> assassin.
>
> -Sebastian
>
>
>
>


Re: [web2py] Re: xml()

2011-04-15 Thread Stifan Kristi
a, i c, thank you so much for your explaination, massimo. i got it when i
use web2py wizard on 1.94.6 version.

best regards,

steve van christie

On Sat, Apr 16, 2011 at 9:12 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> This was a bad idea and it does not work with recent web2py. Should be
>
> URL('default','index')==URL()
>
> Is basically check  whether /app/default/index is the current
> requested path.
>
> On Apr 15, 8:07 pm, 黄祥  wrote:
> > hi,
> >
> > pardon me, i want to ask what's the meaning of this :
> > URL('default','index').xml()==URL().xml()
> >
> > here's the complete code:
> >
> > response.menu = [
> >
> >
> (T('Index'),URL('default','index').xml()==URL().xml(),URL('default','index'
> ),
> > []),
> > ]
> >
> > i mean it is convert the url into xml format page?
> >
> > thanks and best regards,
> >
> > steve van christie


Re: [web2py] Re: web2pyslices.com - broken registration

2011-04-16 Thread Stifan Kristi
what browser that you used?

best regards,

steve van christie


Re: [web2py] Re: connection pools

2011-04-17 Thread Stifan Kristi
thank you so much for your info, i've already read it.

best regards,

steve van christie


On Sun, Apr 17, 2011 at 1:23 PM, pbreit  wrote:

> It's "pool_size". SQLite and GAE disregard it. In theory it can improve
> your DB performance but it can also degrade performance (if you set it too
> high, have limited memory or if there is some sort of conflict in your
> environment).
>
> http://web2py.com/book/default/chapter/06#Connection-Pooling
>


Re: [web2py] Re: Ubuntu + Nginx + uWSGI + Web2py using PPA/Launchpad.net

2011-04-17 Thread Stifan Kristi
nice shared info, thank you so much.

best regards,

steve van christie

On Mon, Apr 18, 2011 at 12:40 AM, Mr. Electronic wrote:

> Hi
>
> I have used some of the code from your script :-)
>
> Feel free to copy from my script if you can use something.
>
> I have added the following lines to the configuration of Nginx:
> client_max_body_size 256M;
> uwsgi_read_timeout 300;
>
> to be able to upload an Web2py app on 160MB through the Web2py admin.
>
> Br.
> Rune Christensen
>
> On 17 Apr., 18:58, pbreit  wrote:
> > Interesting. I wonder if there is anything here I should incorporate into
> > these scripts?https://bitbucket.org/pbreit/web2py-automation/src
>


Re: [web2py] pygooglechart Issues

2011-04-17 Thread Stifan Kristi
hi,

had already tried :
jQuery(...).hide(): Makes the object hidden ??
http://web2py.com/book/default/chapter/10#jQuery-Effects

best regards,

steve van christie

On Sun, Apr 17, 2011 at 9:15 PM, Neveen Adel  wrote:

> Hello,
>
>  Am using pygooglechart lib to draw compound charts (e.g: Bar + line)
>  But I have some issues:
>  - I want to generate line chart on Bar Chart so i added a new data
> series (How can hide this series)
>chart.add_data([35,75,90,100,60,180]) # For Bar Chart
>chart.add_data([47,90,115,134,105,228]) # For Bar Chart
>chart.add_data([40,50,75,80,175,60]) # For Line Chart (How to hide
> this chart)
>chart.add_data_line('0033FF',2,1,1)
>
>  - I want to have axis on the right that represent the line chart
> (and the left axis is used by Bar chart)
>   I can add labels to right axis: chart.set_axis_labels(Axis.RIGHT,
> right_axis)  But how can make line plot the points according the RIGHT
> axis not LEFT axis.
>
>
> Thanks In Advance
>
>


Re: [web2py] Re: header detail form

2011-04-17 Thread Stifan Kristi
thanks, pbreitenbach for your ref, but, i want to create header and detail
form is on the same page, that can be submit simultaneously on the same
time.

best regards,

steve van christie

On Mon, Apr 18, 2011 at 12:04 AM, pbreit  wrote:

> I'm not sure I understand. That is very common. An example from the book
> Overview:
>
>
> db.define_table('image',
>Field ('title'),
>
>Field ('file', 'upload'))
>
> db.define_table('comment',
>Field ('image_id', 
> db.image),
>
>Field ('author'),
>
>Field ('email'),
>
>Field ('body', 'text'))
>
>


Re: [web2py] share : goosh

2011-04-17 Thread Stifan Kristi
nice shared richard.

thanks and best regards,

steve van christie

On Mon, Apr 18, 2011 at 2:04 AM, Richard Vézina  wrote:

> Hello web2by friends,
>
> I just would just let you know about Goosh a unix like command shell for
> google search...
>
> http://goosh.org/
>
> I learned it existance yesterday.
>
> Hope it will interest some of you...
>
> Richard
>


Re: [web2py] Re: gae error

2011-04-17 Thread Stifan Kristi
yes, i use python 2.6, i'll try your adviced to use python 2.5

thank you so much and best regards,

steve van christie

On Mon, Apr 18, 2011 at 5:34 AM, howesc  wrote:

> i didn't look at the slicebut you are using python 2.6.  GAE does not
> like python 2.6.  it's old skool and likes python 2.5
>
> check that you both have python 2.5 installed, and that you are invoking
> dev_appserver.py with python2.5
>
> cfh
>


Re: [web2py] Interesting tool, Maqetta

2011-04-19 Thread Stifan Kristi
nice info, thanks

On Tue, Apr 19, 2011 at 5:01 PM, Jason (spot) Brower wrote:

> http://maqetta.org/
> It's integration into web2py might be fun, and a monstorous challenge.
> BR,
> Jason
>


Re: [web2py] importing CSV / NameError: global name 'request' is not defined"

2011-04-19 Thread Stifan Kristi
please add request variable as parameter on your modules and your function,
because the modules can't pass global name like (response, request, db, t,
crud, etc) so that you must add it:
(not tested)
e.g.
initialize = local_import('initialize')
initialize.fillup(db, response)

please let me know if you still have this problem.

On Tue, Apr 19, 2011 at 3:56 PM, niknok  wrote:

>  I am trying to call this module that contains a series of import_csv_file
> statement like so:
>
> from my model, db_history.py I call up a module to import a series of csv
> files:
>
> initialize=local_import('initialize')
> initialize.fillup(db)
>
>
> my modules/fillup.py looks like this:
>
> import os
>
> def fillup():
> try:
> 
> db.question.import_from_csv_file(open(os.path.join(request.folder,'private/db_question.csv'),'r'))
> except Exception, e:
> print 'oops: %s' % e #XXX
> raise e
>
> ...
>
>
> Then I get: "NameError: global name 'request' is not defined"
>
> What's weird is that those import statements run from the shell.  They also
> work fine if I put them in the model that calls it. But, I'm hoping to
> database initialization by CSV from a single module file.
>
> I'm pretty sure I'm missing something here. Anyone?
>
>
>
>


Re: [web2py] Re: performance impact using record versioning

2011-04-19 Thread Stifan Kristi
a, i c, thank you so much for your explaination, massimo. so, record
versioning, is not recommended to be implemented on production environment,
is it?

On Tue, Apr 19, 2011 at 11:49 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> About a factor 2 I guess. because you need to perform one update and
> one insert as opposed to one update only.
>
> On Apr 19, 9:46 am, 黄祥  wrote:
> > hi,
> >
> > is there any performance impact using record versioning?
> http://web2py.com/book/default/chapter/07?search=crud.archive#Record-...
> > or is there anybody have another suggestion?
> >
> > thank you so much


Re: [web2py] Re: performance impact using record versioning

2011-04-19 Thread Stifan Kristi
thank you so much for your suggestion, pbreit.

On Wed, Apr 20, 2011 at 5:58 AM, pbreit  wrote:

> Totally depends on your situation. For most systems, performance is a
> non-issue. Improving performance is easy. Making a system that people want
> to use is hard. Focus on that.


Re: [web2py] Re: performance impact using record versioning

2011-04-19 Thread Stifan Kristi
a, it's more wisely, thank you so much for your shared, howesc

On Wed, Apr 20, 2011 at 7:45 AM, howesc  wrote:

> i use versioning selectively on tables depending on if i need that audit
> trail or not.  not all tables need it.
>


Re: [web2py] Howto create parent and children at same time?

2011-04-20 Thread Stifan Kristi
why not use jquery add / remove form field? i mean keep the parent (header),
and then you add the child (detail) as much as you want in the same form,
and then when it's submit, it'll insert simultaneously.


On Wed, Apr 20, 2011 at 10:19 PM, Keith Pettit wrote:

> I have a ticket system for trucks.  Each ticket or parent has 1 or more
> loads (children).  I'm having trouble figuring out how to create a (parent)
> and multiple children at the same time.
>
> I'm trying to avoid going through a dialog where they have to fillout a
> ticket, save, then add loads. I want to have a single screen where I can
> create the parent and multiple children at the same time.
>
>
> Here is my basic model:
> # Ticket Information
> db.define_table('ticket',
>Field('type', db.loadtype),
>Field('vehicle_id'),
>Field('misc', 'text'),
>Field('working', 'boolean'),
>Field('approved', 'boolean')
> )
> db.ticket.type.requires = IS_IN_DB(db, 'loadtype.id', 'loadtype.type')
>
>
> # Loads for a ticket (usually just one, but sometimes many)
> db.define_table('load',
>Field('ticket', db.ticket),
>Field('container_id'),
>Field('entered', 'datetime'),
>Field('updated', 'datetime'),
>Field('product', db.product)
> )
>
>
> Thanks for any help,
>
> -Keith
>


Re: [web2py] Re: create new record and update status simultaneously

2011-04-21 Thread Stifan Kristi
a, i c, thank you so much for your pointer anthony, is there any others way
to that without using update() or update_record()?

thank you very much

On Fri, Apr 22, 2011 at 1:33 AM, Anthony  wrote:

> I think onaccept has to be a function.
>
> On Thursday, April 21, 2011 1:12:24 PM UTC-4, 黄祥 wrote:
>
>> hi,
>>
>> is it possible to create new record and update status simultaneously?
>> e.g. update()
>> def __add_2():
>> form = crud.create(db.booking, next = URL(request.application,
>> request.controller, 'index'), onaccept = db.room(db.room.id ==
>> request.vars.room_id).update(status = 'Booked'))
>> return dict(form = form)
>>
>> an error occured said:
>> AttributeError: 'NoneType' object has no attribute 'update'
>>
>> i've tried another (update_record):
>> def __add_2():
>> form = crud.create(db.booking, next = URL(request.application,
>> request.controller, 'index'), onaccept = db.room(db.room.id ==
>> request.vars.room_id).update_record(status = 'Booked'))
>> return dict(form = form)
>>
>> an error occured said:
>> AttributeError: 'NoneType' object has no attribute 'update_record'
>>
>> i know i was wrong, but i'm not understand where is my fault code,
>> could there anybody give me a pointer and shows me how to fix it?
>>
>> thank you so much before
>
>


Re: [web2py] Re: create new record and update status simultaneously

2011-04-21 Thread Stifan Kristi
thank you so much for your pointer, bruno, it seems onaccept, can't receive
request.vars that been passed during form submit, because when i tried to
replace the request.vars into the value id (1, 2, etc), no errors occured.
did anyone have meet the same problem?

thank you very much before

On Fri, Apr 22, 2011 at 1:29 PM, Bruno Rocha  wrote:

> You can try to set default before the creation of the form, something like:
>
> db.booking.status.default="Booked"
> form = crud.create(db.booking)
>
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
>
>
>
> On Fri, Apr 22, 2011 at 2:24 AM, Stifan Kristi <
> steve.van.chris...@gmail.com> wrote:
>
>> a, i c, thank you so much for your pointer anthony, is there any others
>> way to that without using update() or update_record()?
>>
>> thank you very much
>>
>>
>>  On Fri, Apr 22, 2011 at 1:33 AM, Anthony  wrote:
>>
>>> I think onaccept has to be a function.
>>>
>>> On Thursday, April 21, 2011 1:12:24 PM UTC-4, 黄祥 wrote:
>>>
>>>> hi,
>>>>
>>>> is it possible to create new record and update status simultaneously?
>>>> e.g. update()
>>>> def __add_2():
>>>> form = crud.create(db.booking, next = URL(request.application,
>>>> request.controller, 'index'), onaccept = db.room(db.room.id ==
>>>> request.vars.room_id).update(status = 'Booked'))
>>>> return dict(form = form)
>>>>
>>>> an error occured said:
>>>> AttributeError: 'NoneType' object has no attribute 'update'
>>>>
>>>> i've tried another (update_record):
>>>> def __add_2():
>>>> form = crud.create(db.booking, next = URL(request.application,
>>>> request.controller, 'index'), onaccept = db.room(db.room.id ==
>>>> request.vars.room_id).update_record(status = 'Booked'))
>>>> return dict(form = form)
>>>>
>>>> an error occured said:
>>>> AttributeError: 'NoneType' object has no attribute 'update_record'
>>>>
>>>> i know i was wrong, but i'm not understand where is my fault code,
>>>> could there anybody give me a pointer and shows me how to fix it?
>>>>
>>>> thank you so much before
>>>
>>>
>>
>


Re: [web2py] Re: create new record and update status simultaneously

2011-04-22 Thread Stifan Kristi
hi, anthony, thank you so much for your kind attention, problem solved now

def __add_2(table):
form = crud.create(table,
   next = URL(request.application,
  request.controller,
  index_link),
   onaccept = *__update_table_2*
   )
return dict(form = form)

*def __update_table_2(form):*
*if request.function == 'check_out_add':*
*db.room(db.room.id == form.vars.room_id).update_record(status_id =
1)*
*elif request.function == 'booking_add':*
*db.room(db.room.id == form.vars.room_id).update_record(status_id =
2)*
*elif request.function == 'check_in_add':*
*db.room(db.room.id == form.vars.room_id).update_record(status_id =
3)*
*
*
or maybe you have another way out for this situation?

thank you very much.

On Fri, Apr 22, 2011 at 6:16 PM, Anthony  wrote:

> On Friday, April 22, 2011 2:46:44 AM UTC-4, 黄祥 wrote:
>>
>> thank you so much for your pointer, bruno, it seems onaccept, can't
>> receive request.vars that been passed during form submit, because when i
>> tried to replace the request.vars into the value id (1, 2, etc), no errors
>> occured. did anyone have meet the same problem?
>>
>
> This isn't quite clear -- can you show your code? Did you try form.vars?
>
> Anthony
>


Re: [web2py] Re: db field date time compare validation

2011-04-22 Thread Stifan Kristi
thank you so much for your hints anthony, the error didn't appears anymore,
but the validation is not run

def __date_comparation(form):
if request.function == 'booking_add':
if form.vars.from_date > form.vars.to_date:
form.errors.to_date = 'To Date must greater than From Date'

i know there is a mistaken on my validation code, could you give me a
pointer how to fixed it?

thank you very much

On Fri, Apr 22, 2011 at 6:07 PM, Anthony  wrote:

> The 'requires' attribute of a field has to be a validator or list of
> validators (validators are callable objects), not just any boolean test. I
> think you'll need a custom validator:
> http://web2py.com/book/default/chapter/07#Custom-Validators. You might
> also consider using an 'onvalidation' function with your form:
> http://web2py.com/book/default/chapter/07#onvalidation.
>
> Anthony
>
> On Friday, April 22, 2011 3:35:22 AM UTC-4, 黄祥 wrote:
>
>> hi,
>>
>> is it possible to compare db field datetime during form validation?
>> e.g.
>> db.define_table('duration',
>> Field('from',
>>   'datetime',
>>   requires = IS_DATE()
>>   ),
>> Field('to',
>>   'datetime',
>>   requires = [IS_DATE(),
>>   request.vars.from < request.vars.to]
>>   )
>> )
>>
>> an error occured said:
>> TypeError: 'bool' object is not callable
>>
>> also i tried:
>>
>> db.define_table('duration',
>> Field('from',
>>   'datetime',
>>   requires = IS_DATE()
>>   ),
>> Field('to',
>>   'datetime',
>>   requires = [IS_DATE(),
>>   form.vars.from < form.vars.to]
>>   )
>> )
>>
>> an error occured said :
>> NameError: name 'form' is not defined
>>
>> does anyone have a clue to solve it?
>>
>> thank you very much for your kind attention
>
>


Re: [web2py] Re: db field date time compare validation

2011-04-22 Thread Stifan Kristi
pardon me, the problem is solved after a few modification in function. thank
you so much for your kind help massimo. it seems that the validation on form
is run after the validation that define on the models (db.define_table).

On Sat, Apr 23, 2011 at 9:41 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I am on the road. I will take a look asap but may have to wait Sunday.
>
> On Apr 22, 2011, at 6:41 PM, Stifan Kristi (Kou Shou) wrote:
>
>  thank you so much for pointers pbreit and massimo, it's
> correct that before i changed my from database field into from_date because
> i think it's a keyword. i've already tried to modified my code, but the date
> validation is not run using crud, here's my code :
>
> db.define_table('booking',
> Field('from_date', 'date', requires = IS_DATE()),
> Field('to_date', 'date', requires = IS_DATE()))
>
> def __add_2(table):
> form = crud.create(table, onvalidation = __date_comparation, next =
> URL(request.application, request.controller, 'index'))
> return dict(form = form)
>
> def __date_comparation(form):
> if request.function == 'booking_add':
> if form.vars.from_date > form.vars.to_date:
> form.errors.to_date = 'To Date must start before From Date'
>
> def booking_add():
> return __add_2(db.booking)
>
> any hints or pointers for this problem is highly appreciate.
>
> thank you very much in advance
>
> On 04/23/2011 12:56 AM, Massimo Di Pierro wrote:
>
> mind that "end" is a keyword in sql and you can have problems with a
> field called "end".
>
> On Apr 22, 12:34 pm, pbreit   
> wrote:
>
>  I think you were on the right track. I think naming the field "from" might
> have been a problem. I assume with your last function you had renamed the
> fields from_date and to_date? The if request.function might not be
> necessary. Remember that any functions with parameters cannot be accessed
> from the browser.
>
> This works OK:
>
> db.define_table('duration',
> Field('start', 'datetime'),
> Field('end', 'datetime'))
>
> def process_duration_form(form):
> if form.vars.start > form.vars.end:
> form.errors.start = 'start must be before end'
>
> def duration():
> form = SQLFORM(db.duration)
> if form.accepts(request.vars, session,
> onvalidation=process_duration_form):
> response.flash = 'form accepted'
> elif form.errors:
> response.flash = 'form has errors'
> else:
> response.flash = 'please fill out the form'
> return dict(form=form)
>
>   
>
>
>


Re: [web2py] Re: [ad] Curso de Python e web2py

2011-04-23 Thread Stifan Kristi
great site...

2011/4/23 Anthony 

> Very nice site. Just added it to http://web2py.com/poweredby.
>
> Note, in IE8, there are some weird font display problems (see attached
> screenshot). Also, I'm not sure if this is intended, but the Facebook and
> Twitter buttons look like they're being cut off on the far right (also shown
> in screenshot).
>
> Great work.
>
> Anthony
>
>
> On Saturday, April 23, 2011 3:57:12 AM UTC-4, rochacbruno wrote:
>
>> Pessoal,
>>
>>
>> Desculpem a propaganda no grupo, mas gostaria de avisar a respeito do
>> CursoDePython.com.br
>>
>> Trata-se de um programa de treinamento em Python e web2py.
>>
>> O treinamento acontecerá em algumas datas em SP no modelo presencial, e
>> finalmente em Junho iniciaremos o curso à distância totalmente online e ao
>> vivo.
>>
>> Além disso em breve teremos uma série de screencasts especificos abordando
>> Python e web2py.
>>
>> Vejam o site do curso para mais informações:
>> http://www.cursodepython.com.br/
>>
>> **A data de ínicio da primeira turma online será confirmada em breve.
>>
>>
>> Obrigado
>>
>>
>>  --
>> Bruno Rocha
>> [ About me: http://zerp.ly/rochacbruno ]
>>
>>


Re: [web2py] Re: modified auth.signature

2011-04-23 Thread Stifan Kristi
thank you so much for your suggestion, massimo, pardon, before, i've used
that code (refered from the book), but, it seems, that web2py had already
this function so that i used web2py function. i mean, i want to add
created_from field that have default value ip address where the user submit
the form, but i don't know how to create it, is there a function in web2py
to do that?
e.g.

Field('created_from',requires=IS_IPV4(),* default=*
,writable=False,readable=False)
Field('modified_from',requires=IS_IPV4(),* default=*
,writable=False,readable=False)

any idea for this?

thank you so much before

On Sun, Apr 24, 2011 at 11:35 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> You can make your own
>
> signature = db.Table(db,'auth_signature',
>  Field('is_active','boolean',default=True),
>  Field('created_on','datetime',default=request.now,
>writable=False,readable=False),
>
> Field('created_by',auth.settings.table_user,default=auth.user_id,
>writable=False,readable=False),
>
> Field('modified_on','datetime',update=rquest.now,default=request.now,
>writable=False,readable=False),
>  Field('modified_by',auth.settings.table_user,
>default=auth.user_id,update=auth.user_id,
>writable=False,readable=False))
>
>
>
> On Apr 23, 11:28 pm, 黄祥  wrote:
> > hi,
> >
> > is it possible to modified auth.signature? actually, i want to insert
> > created_from and update_from that contain default ip address which is
> > the table is inserted or updated.
> >
> > any pointer, hint, or suggestion is highly appreciate, thank you very
> > much in advance


Re: [web2py] Re: different environment in web2py

2011-04-23 Thread Stifan Kristi
thank you so much for your pointer, massimo. a, i c, so that i must use the
different table and different ip for the different environment, and describe
it on the models (0.py or db.py).
is it possible to use it in 1 ip? i mean for dev, testing and staging i use
1 ip (127.0.0.1:8000)

thank you very much before

On Sun, Apr 24, 2011 at 11:37 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I usually in db.py or in 0.py
>
> development = request.env.host_name==''127.0.0.1:8000'
>
> if development:
>db=DAL('sqllite://development.sqlite')
>...
> else:
>db=DAL('mysql://')
>
>
>
>
> On Apr 23, 11:30 pm, 黄祥  wrote:
> > hi,
> >
> > is it possible to separate the different environment like in ruby on
> > rails? i mean, i want to make different environment for my dev
> > application, test application, staging application and live
> > application.
> >
> > any hint, pointer, suggestion is greatly appreciate. thank you very
> > much before


Re: [web2py] Re: different environment in web2py

2011-04-23 Thread Stifan Kristi
a, i'm quite understand right now, thank you very much for your suggestion,
massimo.

On Sun, Apr 24, 2011 at 12:00 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> You can manually set
>
> development = True or False
>
> or use any other condition you like.
>
>
> On Apr 23, 11:46 pm, Stifan Kristi 
> wrote:
> > thank you so much for your pointer, massimo. a, i c, so that i must use
> the
> > different table and different ip for the different environment, and
> describe
> > it on the models (0.py or db.py).
> > is it possible to use it in 1 ip? i mean for dev, testing and staging i
> use
> > 1 ip (127.0.0.1:8000)
> >
> > thank you very much before
> >
> > On Sun, Apr 24, 2011 at 11:37 AM, Massimo Di Pierro <
> >
> >
> >
> >
> >
> >
> >
> > massimo.dipie...@gmail.com> wrote:
> > > I usually in db.py or in 0.py
> >
> > > development = request.env.host_name==''127.0.0.1:8000'
> >
> > > if development:
> > >db=DAL('sqllite://development.sqlite')
> > >...
> > > else:
> > >db=DAL('mysql://')
> > >
> >
> > > On Apr 23, 11:30 pm, 黄祥  wrote:
> > > > hi,
> >
> > > > is it possible to separate the different environment like in ruby on
> > > > rails? i mean, i want to make different environment for my dev
> > > > application, test application, staging application and live
> > > > application.
> >
> > > > any hint, pointer, suggestion is greatly appreciate. thank you very
> > > > much before


Re: [web2py] Re: modified auth.signature

2011-04-23 Thread Stifan Kristi
a, i c, thank you very much for your pointer, massimo.

On Sun, Apr 24, 2011 at 11:59 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> you could use
>
> default=request.client
>
> mind that it is not guaranteed because it can be spoofed when behind a
> proxy.
>
> On Apr 23, 11:42 pm, Stifan Kristi 
> wrote:
> > thank you so much for your suggestion, massimo, pardon, before, i've used
> > that code (refered from the book), but, it seems, that web2py had already
> > this function so that i used web2py function. i mean, i want to add
> > created_from field that have default value ip address where the user
> submit
> > the form, but i don't know how to create it, is there a function in
> web2py
> > to do that?
> > e.g.
> >
> > Field('created_from',requires=IS_IPV4(),* default=*
> > ,writable=False,readable=False)
> > Field('modified_from',requires=IS_IPV4(),* default=*
> > ,writable=False,readable=False)
> >
> > any idea for this?
> >
> > thank you so much before
> >
> > On Sun, Apr 24, 2011 at 11:35 AM, Massimo Di Pierro <
> >
> >
> >
> >
> >
> >
> >
> > massimo.dipie...@gmail.com> wrote:
> > > You can make your own
> >
> > > signature = db.Table(db,'auth_signature',
> > >  Field('is_active','boolean',default=True),
> > >  Field('created_on','datetime',default=request.now,
> > >writable=False,readable=False),
> >
> > > Field('created_by',auth.settings.table_user,default=auth.user_id,
> > >writable=False,readable=False),
> >
> > > Field('modified_on','datetime',update=rquest.now,default=request.now,
> > >writable=False,readable=False),
> > >  Field('modified_by',auth.settings.table_user,
> > >default=auth.user_id,update=auth.user_id,
> > >writable=False,readable=False))
> >
> > > On Apr 23, 11:28 pm, 黄祥  wrote:
> > > > hi,
> >
> > > > is it possible to modified auth.signature? actually, i want to insert
> > > > created_from and update_from that contain default ip address which is
> > > > the table is inserted or updated.
> >
> > > > any pointer, hint, or suggestion is highly appreciate, thank you very
> > > > much in advance


Re: [web2py] Re: IS_IN_DB validator

2011-04-24 Thread Stifan Kristi
nice share nik, thank you.
i think
IS_IN_DB(db, db.table_name.id, '%(field_name)s')
is work too.

On Sun, Apr 24, 2011 at 1:11 PM, niknok  wrote:

> Found the answer: orderby is supported.
>
> IS_IN_DB(dbset, field, orderby='mytable.myfield', ...)
>
> On Apr 24, 8:31 am, niknok  wrote:
> > Thanks. But I guess I did not explain myself properly.
> >
> > I would like the list to display the titles, but sorted by say the ID
> > field, or another field.
> >
> > Right now, I do it like label='%(id)s%(title)s', but I'd like to
> > display it without the ID. I hope this makes sense.
> >
> > On Apr 23, 10:30 pm, DenesL  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Yes, use the label parameter e.g.
> >
> > > IS_IN_DB(dbset, field, label='%(title)s', ...)
> >
> > > On Apr 23, 8:59 am, niknok  wrote:
> >
> > > > Is there a way to sort the list generated by IS_IN_DB by another
> field
> > > > other than the one formatted for display?
> >
> > > > Thanks.
> >
> > > > /r
> > > > Nik


Re: [web2py] Re: web2py version

2011-04-24 Thread Stifan Kristi
thank you so much for your info, massimo. hope there are a lot of
improvement features and new features on the next version. great job, all,
thank you very much.

On Sun, Apr 24, 2011 at 8:51 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> We have this:
>
> http://web2py.com/examples/default/changelog
>
> A new version is coming out soon but we need to iron out some issues
> with current trunk.
>
> Massimo
>
> On Apr 24, 8:31 am, 黄祥  wrote:
> > hi,
> >
> > where can i get the information about web2py version feature? i mean
> > the feature's comparation between each version.
> > and 1 more things, is there any schedule upgrade version for web2py? i
> > mean like fedora or ubuntu have schedule update every 6 months
> >
> > thanks


Re: [web2py] Re: web2py version

2011-04-24 Thread Stifan Kristi
a, i c, thank you so much for your info, anthony.

On Mon, Apr 25, 2011 at 4:33 AM, Anthony  wrote:

> On Sunday, April 24, 2011 9:31:25 AM UTC-4, 黄祥 wrote:
>>
>> and 1 more things, is there any schedule upgrade version for web2py? i
>> mean like fedora or ubuntu have schedule update every 6 months
>
>
> There's no regular schedule. New releases tend to happen every 2-4 weeks.
>


Re: [web2py] web2py 1.95.1 and open issues

2011-04-25 Thread Stifan Kristi
great job, massimo n the others, i've download n test it. thank you so much.

On Mon, Apr 25, 2011 at 9:06 PM, Massimo Di Pierro
wrote:

> Hello everybody,
>
> web2py 1.95.1 is out with lots of improvements and bug fixes:
> ## 1.95.1
> - Google MySQL support (experimental)
> - pip support, thanks lifeeth
> - better setup_exe.py, thanks meredyk
> - importved pyfpdf
> - domain check in email_auth.py, thanks Gyuris
> - added change_password_onvalidation and change_password_onaccept
> - DAL(...,migrate_enabled=True)
> - login_methods/loginza.py, thanks Vladimir
> - bpython shell support, thanks Arun
> - request.uuid and response.uuid (for a future toolbar)
> - db._timings contains database query timing info
> - efficient db(...).isempty()
> - setup-web2py-nginx-uwsgi-ubuntu.sh
> - Many bug fixes, thanks Jonathan
>
> Please check it out.
>
> I have many pending patches still to be applied and tested:
> - those documented in googlecode issues
> - the new custom_import
>
> Is there any outstanding issue that has not been submitted as an issue to
> googlecode?
>
> Massimo
>
>
>


Re: [web2py] Re: Novice: form input, insert, update

2011-04-25 Thread Stifan Kristi
nice share, massimo, i want to learn it, but your video is too fast, i've
already tried to pause it many times, but it seems i lost some part, could
you share the code please?

thank you so much in advance

On Tue, Apr 26, 2011 at 12:15 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Did you see this?
>
> http://vimeo.com/20768689
>
> The functionality you need is implemented as an example via ajax.
>
> Massimo
>
> On Apr 25, 11:46 am, JoshC  wrote:
> > Dear Friends,
> >
> > As you may recall, I wrote before mentioning that I am working on a
> > project for a databases class (an e-store). We were successful at
> > implementing the model and some of the functions and views. However,
> > we are stuck trying to figure out how to implement the following types
> > of requirement:
> >
> > [1] generate a list of the rows of a table and append a text field and
> > submit button which adds a quantity of the item to the cart
> >  -- the cart is just a simple table which holds item number, qty,
> > and user id. The records matching auth.user_id are just dumped at the
> > bottom to show the cart.
> >
> > [2] generate a list of the rows of a table and put a text field that
> > can update one of the fields
> >
> > This is the non-functional code with which I tried to accomplish [1]:
> > --function
> > def category_toy():
> > toy = db(db.inventory.type=='Toy').select()
> > cart = db((db.cart.id>0)&(db.cart.uid == auth.user_id)).select()
> > form=FORM('Add quantity to cart:', INPUT(_name='qty'),
> > INPUT(_type='submit'))
> > return dict(toy=toy, cart=cart, form=form)
> > view
> >
> > 
> > {{for i in toy:}}
> >
> > {{=LI(H4("Item: ", i.item, ", Quantity: ",i.qty))}}
> > 
> >
> > {{pass}}
> > 
> >
> > The commented out part is where I tried using a link to another
> > function, but I couldn't get the dict to work right. The plan was then
> > to redirect back to the form page.
> >
> > I'm probably missing something obvious, but I've been studying the
> > book, and haven't figured it out. Advice would be much appreciated.
> >
> > Yours,
> > Josh Cason
>


Re: [web2py] Re: Some Advice for a Novice

2011-04-26 Thread Stifan Kristi
yeah, i think just like on crm application, the promotion known as campaign
on crm is separate with inventory table. just a little suggestion to move
out field status on orders table and field type on inventory table into the
new tables. i think users and admin is more convinience when they are select
it from drop down menu or if you don't want to use many tables maybe you can
use a file to store IS_IN_SET for status and type.

On Tue, Apr 26, 2011 at 7:27 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The price changes with time. You need to store how much each user paid
> for the item at the time of sale. It is not just for promotions.
>
> On Apr 26, 6:43 am, Stodge  wrote:
> > Why not move the 'promotion' field out of the 'inventory' table into a
> > new table? That way you don't have to store a promotion value for
> > every item. You might also then need to add a reference to the
> > promotion in the order. If that all makes sense.
> >
> > On Apr 24, 7:44 pm, JoshC  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > good news! We have our model and are starting to work on the
> > > controllers. Thanks for the advice.
> >
> > > db.define_table('users',
> > > #Field('id','string'), ID is implicit
> > > Field('first', 'string'),
> > > Field('last', 'string'),
> > > Field('address', 'string'),
> > > Field('email', 'string'),
> > > Field('pw', 'password'),
> > > Field('role', 'string'))
> >
> > > db.define_table('inventory',
> > > Field('item','string'),
> > > Field('type','string'),
> > > Field('price', 'decimal(9,2)'),
> > > Field('qty','integer'),
> > > Field('promotion','integer'))
> >
> > > db.define_table('cart',
> > > Field('uid', db.users),
> > > Field('item', db.inventory),
> > > Field('qty','integer'))
> >
> > > db.define_table('orders',
> > > Field('uid', db.users),
> > > Field('orderid', 'string'),
> > > Field('item', db.inventory),
> > > Field('qty','integer'),
> > > Field('date','date'),
> > > Field('status','string'),
> > > Field('total', 'decimal(9,2)'))
> >
> > > On Apr 24, 8:52 am, Stifan Kristi 
> > > wrote:
> >
> > > > hi, josh
> >
> > > > please read the book first and keep your code dry (don't repeat
> yourself)
> > > > and kis (keep it simple). if you want to build your application there
> are a
> > > > lot of samples on the book e.g.
> http://web2py.com/book/default/chapter/03
> > > >  <http://web2py.com/book/default/chapter/03>and there are a lot of
> > > > appliances too onhttp://web2py.com/appliances
> > > >  <http://web2py.com/appliances>if you are new in web2py, welcome,
> i'll
> > > > shared my course appliance code (please see attached file), you can
> download
> > > > it too on :http://web2py.com/appliances/default/show/76
> > > > please focus first on models first, then controllers and then your
> views.
> >
> > > > On Sun, Apr 24, 2011 at 12:12 PM, JoshC <
> joshua.aaron.ca...@gmail.com>wrote:
> >
> > > > > Dear Friends,
> >
> > > > > My partner and I are working on a small store website for a
> databases
> > > > > class. I have found that there is a lot of information about Web2py
> on
> > > > > the site and in the book. What I hope to find out from you guys is
> > > > > some pointers to specific parts of the technology and parts of the
> > > > > book that we will need to put this project together. In other
> words,
> > > > > there's a lot of stuff in the book that we seem not to need.
> >
> > > > > On one hand, I'm not asking anyone to do our homework for us. On
> the
> > > > > other, we can borrow code (like from existing apps, plugins, etc)
> as
> > > > > long as we design the SQL part.
> >
> > > > > This leads to another q

Re: [web2py] Documentation web2py

2011-04-26 Thread Stifan Kristi
good idea

On Tue, Apr 26, 2011 at 7:39 PM, Gilson Filho  wrote:

> The web2py has been a tool that is improving and evolving over time, and
> who uses itknows it. Only for people to learn these new features or fixes to
> existing becomes moredifficult when there is no consistent documentation. As
> far as I know, Massimo web2pywhich updates the book, but with so many
> issues in the project, it is complicated tocontinue with this activity. We
>  community web2py Brazil-users were discussing this, thatmany of the
> facilities of the framework are not documented, and I propose taking
> advantage of all this: to help update the documentation web2py undertaken
> to reviewexisting content and description of use of new features.
>
> What do you think?
> _
> *Gilson Filho*
> *Web Developer
> http://gilsondev.com*
>
>


Re: [web2py] Re: Filtering by date range (SQL date tye)

2011-04-26 Thread Stifan Kristi
pardon me, is timedelta is used for show the differ between 2 date time?
like timediff

On Wed, Apr 27, 2011 at 8:14 AM, DenesL  wrote:

>
> Scratch months;
> only days, seconds, microseconds, milliseconds, minutes, hours, or
> weeks.
>


Re: [web2py] Re: url for static file

2011-04-26 Thread Stifan Kristi
a, i c, thank you so much for your info, pbreit. i've tried to use the
janrain log in from the wizard one, but i don't know how to configure it,
for the absolute path, it seems the login form is appears, but it can't be
access after i log in, is there any problem in my code? and, is there any
information how to use janrain from web2py?

e.g.
from gluon.contrib.login_methods.rpx_account import RPXAccount
auth.settings.actions_disabled = ['register',
  'change_password',
  'request_reset_password']
auth.settings.login_form = RPXAccount(request,
  api_key =
'fddfe2efbc2bfe7fd219d175f13eb69ceb179555',
  domain = 'web2py',
  url = "
http://localhost:8000/%s/default/user/login"; % request.application)

any suggestion, pointer, is appreciate, thank you so much before.

On Wed, Apr 27, 2011 at 10:38 AM, pbreit  wrote:

> Needs to be absolute because it is used by Janrain.


Re: [web2py] Re: load and include

2011-04-28 Thread Stifan Kristi
a, i'm understood right now, thank you so much anthony. it seems that the
load only can be implement on the table that have general function like
comments (e.g. on the book), but for the specific one, i think it can't be
used (e.g. let say on the book example introduction, we have the image
comment table and wiki comment table), there are 2 comment tables but
related to different main tables (image and wiki),

please correct me if i'm wrong, many thanks before.

On Thu, Apr 28, 2011 at 2:07 PM, Anthony  wrote:

> In a view, {{include view_file}} simply includes another view. LOAD,
> however, actually calls a new action via a new request and inserts the
> output of that action/request in the current view (depending on whether
> ajax=True or False, LOAD either does this via Ajax after the original
> response is delivered, or server-side before the original response is
> delivered).
>
> Anthony
>
> On Thursday, April 28, 2011 2:24:29 AM UTC-4, 黄祥 wrote:
>
>> hi,
>>
>> is there anybody knows about detail comparation between load and
>> include in the views, please? i have already read the book and test to
>> implent it, i think it have the same function on views.
>>
>> thank you so much in advance
>
>


Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread Stifan Kristi
hello,

thank you so much for your pointer, salbefe. i can input the encrypted
password but the result not like i've expected before. i mean there is an
additional character on the field password.
e.g.
db.auth_user.bulk_insert([{'first_name' : 'a',
   'last_name' : 'a',
   'email' : 'a.a.com',
   'password' :
db.auth_user.password.validate('a')}])

i created 1 user with password string '*a' (without quotes)*, and second 1
register new password with the same password string '*a'** (without quotes)*,
when i compare it on the db the result that i entered manual password
string  '*a' (without quotes)* via register form is not match that i store
on the database via python script. the differnetial on the password field is
there is *|encrypted_password|None* when i put it via python script.

maybe i've missed something, please give me a hints about this, thank you
very much before.

On Thu, Apr 28, 2011 at 3:19 PM, salbefe  wrote:

> Hello,
>
> Yo can do this:
>
>
>
> db.auth_user.insert(first_name=...,last_name=...,email=...,password=db.auth_user.password.validate(myPassword))
>
>
>
> On 28 abr, 08:36, 黄祥  wrote:
> > hi,
> >
> > is there a way to input encrypted user password for the first time
> > execution? i mean like
> > e.g.
> > db.auth_user.bulk_insert([{'first name' : 'a', 'last name' : 'a',
> > 'email' : 'a.a.com', 'password' : 'a'}, {'first name' : 'b', 'last
> > name' : 'b', 'email' : 'b.b.com', 'password' : 'b'}])
> >
> > i can using this bulk insert but, the password didn't encryted. and
> > the other is there alternative way to do that maybe something like :
> > e.g.
> > auth.add_user('first name', 'last_name', 'email', 'password')
> >
> > please give an advice or pointer about this,
> >
> > thank you very much before


Re: [web2py] Re: ajax function submit on script

2011-04-28 Thread Stifan Kristi
thank you so much for your correction, massimo. it runs right now with:
jQuery(document).ready(function(){
jQuery('.view').click(function(){jQuery('.comments').slideToggle()});
jQuery('.post').click(function(){jQuery('.form').slideToggle()});
jQuery('.post').submit(function(){ajax('{{=request.controller}}', [],
'comments hidden')});
});

it seems for the first, second and third data inserted the ajax function is
not running properly, i mean, i must refresh the browser, but after the
third data, ajax function is running smoothly, where is my wrong code that i
must fix it?

currently i separate the javascript into the static js folder like code
above, and call it on the views.

thank you very much before

On Thu, Apr 28, 2011 at 9:12 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> yes but the syntax is incorrect:
>
> ajax('blog_show', 'comments hidden')
>
> should be
>
> ajax('blog_show', [], 'target_id')
>
>
>
> On Apr 28, 8:58 am, 黄祥  wrote:
> > hi,
> >
> > is it possible to put ajax function submit on script?
> > e.g.
> > 
> > jQuery(document).ready(function(){
> > jQuery('.view').click(function()
> > {jQuery('.comments').slideToggle()});
> > jQuery('.post').click(function(){jQuery('.form').slideToggle()});
> > jQuery('.post').submit(function(){ajax('blog_show', 'comments
> > hidden')});});
> >
> > 
> >
> > i've already tried it, no error occured but the ajax function didn't
> > work. my intention is when a user submit a comment form (using crud on
> > controller) it will show without reloading the page, or is there any
> > others way to do this?
> >
> > please give an advice and please correct me if my code is wrong.
> >
> > many thanks before


Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread Stifan Kristi
thank you so much for your pointer, anthony, the encrypted password is
without *|encrypted password|None.*
i've compared with the manual that i put on the register form is same. (same
password 'a' string)
but, pardon there is strange behaviour during login, the user that i
inserted via script couldn't login, but the manual one could login. is there
anything i missed on my code?
e.g.
db.auth_user.bulk_insert([{'first_name' : 'a',
   'last_name' : 'a',
   'email' : 'a.a.com',
   'password' :
db.auth_user.password.validate('a')[0]}])

thank you very much before.

On Thu, Apr 28, 2011 at 9:46 PM, Anthony  wrote:

> On Thursday, April 28, 2011 7:42:15 AM UTC-4, 黄祥 wrote:
>>
>> hello,
>>
>> thank you so much for your pointer, salbefe. i can input the encrypted
>> password but the result not like i've expected before. i mean there is an
>> additional character on the field password.
>> e.g.
>>  db.auth_user.bulk_insert([{'first_name' : 'a',
>>'last_name' : 'a',
>>'email' : 'a.a.com',
>>'password' :
>> db.auth_user.password.validate('a')}])
>>
>> i created 1 user with password string '*a' (without quotes)*, and second
>> 1 register new password with the same password string '*a'** (without
>> quotes)*, when i compare it on the db the result that i entered manual
>> password string  '*a' (without quotes)* via register form is not match
>> that i store on the database via python script. the differnetial on the
>> password field is there is *|encrypted_password|None* when i put it via
>> python script.
>>
>
> the validate() method of the field runs the validator associated with the
> field, and the validator returns a (value, error) tuple (where error = None
> if the validation passed). So, when you run
> db.auth_user.password.validate('a'), you're getting back a tuple like
> (hashed_password, None). When you try to insert a list or tuple into a field
> via DAL, it converts the items in the list into a string separated by '|'
> characters, which is why you're getting |encrypted_password|None. So,
> instead, just insert the first item in the tuple returned by validate:
> db.auth_user.password.validate('a')[0]
>
> Anthony
>
>>
>> maybe i've missed something, please give me a hints about this, thank you
>> very much before.
>>
>> On Thu, Apr 28, 2011 at 3:19 PM, salbefe  wrote:
>>
>>> Hello,
>>>
>>> Yo can do this:
>>>
>>>
>>>
>>> db.auth_user.insert(first_name=...,last_name=...,email=...,password=db.auth_user.password.validate(myPassword))
>>>
>>>
>>>
>>> On 28 abr, 08:36, 黄祥  wrote:
>>> > hi,
>>> >
>>> > is there a way to input encrypted user password for the first time
>>> > execution? i mean like
>>> > e.g.
>>> > db.auth_user.bulk_insert([{'first name' : 'a', 'last name' : 'a',
>>> > 'email' : 'a.a.com', 'password' : 'a'}, {'first name' : 'b', 'last
>>> > name' : 'b', 'email' : 'b.b.com', 'password' : 'b'}])
>>> >
>>> > i can using this bulk insert but, the password didn't encryted. and
>>> > the other is there alternative way to do that maybe something like :
>>> > e.g.
>>> > auth.add_user('first name', 'last_name', 'email', 'password')
>>> >
>>> > please give an advice or pointer about this,
>>> >
>>> > thank you very much before
>>>
>>
>>


Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread Stifan Kristi
yes, u right, ron, there is a mistaken on my field value, thanks for show me
my wrong code, it's work right now. thank you all for your pointer.

On Fri, Apr 29, 2011 at 12:10 AM, ron_m  wrote:

> email of a.a.com is not a valid email address according to your code.
> I am not sure if there is any validation during login
>


Re: [web2py] Re: ajax didn't run passing var when put it on static js folder

2011-04-28 Thread Stifan Kristi
thank you so much for your pointer, pbreit, i've followed what u said, but
it still not working. currently, i put it on the views/default/index.html
not in the layout.html.

it seems that vars on ajax can't be passed to another file, because when i
put script on the same page, it can be run. because there are another
function that need the same ajax function, so that i put it on the
static/js/cart.js and then called the file on the views.

does anybody know how to fix it?
many thanks before

On Fri, Apr 29, 2011 at 9:27 AM, pbreit  wrote:

> Are you including the script in your layout.html or other page?
>
> I like to put a  tag in the  section of my layout.html:
>