[web2py] Re: CLEANUP() removing too many characters

2011-05-01 Thread pbreit
I guess one question is what is the point.

It's very similar to the regex [:print:] which apparently in PERL includes 
[:space:] which includes \t. I was actually using it to strip out tabs but I 
ended up going with a custom validator.

http://en.wikipedia.org/wiki/Regular_expression


Re: [web2py] really nice interview on hackerpublicradio about web2py

2011-05-01 Thread Jason Brower

On 05/01/2011 07:18 AM, Massimo Di Pierro wrote:

http://hackerpublicradio.org/eps/hpr0711.mp3

OH NICE!!!
Very good!
BR,
Jason Brower



[web2py] Run a method when ever logout is reached.

2011-05-01 Thread Jason Brower
I need to make sure curtain session data is wiped when the user is 
logged out.

This bring up two things:
1: How can I run a method like that to make sure this happens when ever 
the logout is clicked.
2: I wonder if there could be a spacial area of sessions that is just 
for that users authenticated session.

BR,
Jason Brower



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

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

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

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


Re: [web2py] Total control over your web2py models

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

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

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


Re: [web2py] Total control over your web2py models

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

thank you so much

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

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


Re: [web2py] Re: Powerpack

2011-05-01 Thread Martín Mulone
Thanks, now is working

2011/4/30 villas 

> Hi Martin
> I was just trying out powerpack but it seems there are a few things
> broken, I suppose you are working on that?
> plugin_ip2_admin.py   def editcat  should be  catedit
> .xml() has been cancelled etc.
> Regards,  D




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


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

2011-05-01 Thread 黄祥
hi,

is there anybody know the difference between is_not_empty(),
notnull=true and required=true?
should i use both or just 1 of it's?
please give an advice or pointer about this

thank you so much in advance


Re: [web2py] Total control over your web2py models

2011-05-01 Thread Martín Mulone
In powerpack I have this:

config.py (application settings)
data.py (all the db definition and menus)
main.py (auth, mail, service, registration settings, etc) (this is
independant of the app)

then I usually do:

mod_clients.py
mod_users.py
mod_someother.py
mod_someother2.py

I have classes like bruno show, but I don't have db definitions in this
classes, instead I have all the db definition in data.py because surely I
have link to another tables.

Then came the plugins:

plugins_1.py
plugins_2.py
plugins_3.py
plugins_4.py
plugins_zindex.py (here the execution order of plugins)

2011/5/1 Stifan Kristi 

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


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


[web2py] nested list

2011-05-01 Thread 黄祥
hi,

is anybody know how to create nested list? my intention is to create
category that have sub category (parent child list), should i use 2
table or just one table that refer to itself?
e.g.
db.define_table('category',
Field('title'
  )
)

db.define_table('sub_category',
Field('title',
  label = T('Title')
  ),
Field('category_id',
  db.category
  )
)
db.sub_category.category_id.requires = IS_IN_DB(db, db.category.id, '%
(title)s')

or

db.define_table('category',
Field('title',
  label = T('Title')
  ),
Field('parent_category_id',
  'reference category'
  ),
)
db.category.parent_category_id.requires = IS_IN_DB(db, db.category.id,
'%(title)s')

and how about the controller and the views to display it?
please give an advice, pointer or suggestion.
thank you very much in advance


Re: [web2py] Total control over your web2py models

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

many thanks before

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

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

 Vinicius, I like that approach.

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


Re: [web2py] Total control over your web2py models

2011-05-01 Thread Martín Mulone
>
> mod_clients.py = what for?
> mod_users.py = what for?


It was an example, you can have mod_nameyouwant.py.

and inside you have for example something like this:

class Clients(object):

def show():
'show a list of clients'

def delete():
'delete ...'

def add():
'add ...'

2011/5/1 Stifan Kristi 

> thank you so much for your info, martin, i've already tried and learn from
> powerpack plugins, it's cool but because i'm a newbie in python and web2py,
> so that a lot of things on powerpack that i don't know the function is what
> for?
> pardon me, could you explain about:
> mod_clients.py = what for?
> mod_users.py = what for?
>
> many thanks before
>
> On Sun, May 1, 2011 at 7:58 PM, Martín Mulone wrote:
>
>> In powerpack I have this:
>>
>> config.py (application settings)
>> data.py (all the db definition and menus)
>> main.py (auth, mail, service, registration settings, etc) (this is
>> independant of the app)
>>
>> then I usually do:
>>
>> mod_clients.py
>> mod_users.py
>> mod_someother.py
>> mod_someother2.py
>>
>> I have classes like bruno show, but I don't have db definitions in this
>> classes, instead I have all the db definition in data.py because surely I
>> have link to another tables.
>>
>> Then came the plugins:
>>
>> plugins_1.py
>> plugins_2.py
>> plugins_3.py
>> plugins_4.py
>> plugins_zindex.py (here the execution order of plugins)
>>
>> 2011/5/1 Stifan Kristi 
>>
>>> i'd like your logic bruno, could you explain about the function, please?
>>> 000_essentials.py = what for?
>>> 100_authdatabase.py = what for?
>>> 200_dbmodel.py = what for?
>>> 300_validators.py = what for?
>>> 400_utilities.py = what for?
>>> 500_preload.py = what for?
>>>
>>> thank you so much
>>>
>>> On Sun, May 1, 2011 at 11:03 AM, Bruno Rocha wrote:
>>>
 My point of views is that in a simple and smaller app this approach is a
 good (may be the only) option.

 I am now running with a different numerical order, using 3 digits

 000_essentials.py
 100_authdatabase.py
 200_dbmodel.py
 300_validators.py
 400_utilities.py
 500_preload.py

 why? because between every model I have 99 empty spaces if I need to
 include some new model without the need to rename all the others.

 But this is a mess if working with a large app, so I tried to create
 classes and methods as:

 class mymodel(object):
 def define_essentials():
 db = DAL('.')

 def define_auth():
 auth = Auth(db...)

 def define_model():
 db.define_table('mytable',Field())


 So I can call mymodel.define_essentials() directly from the controller
 or another main model, why?

 Imagine a large app with many models and many objects loaded in memory
 even if you do not need them.

 But, I think web2py has a good MVC pattern used for controllers and
 views, we are talking about how to have the same approach for model files.


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



 On Sun, May 1, 2011 at 12:37 AM, pbreit  wrote:

> I think either way is fine. In a bigger app, you might separate them
> out.
>
> Vinicius, I like that approach.
>


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


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


Re: [web2py] Re: CLEANUP() removing too many characters

2011-05-01 Thread Jonathan Lundell
On Apr 30, 2011, at 11:13 PM, Massimo Di Pierro wrote:
> 
> I am not convinced about tab. I hate tab, it only causes problems.

In Python it does, but it solves problems elsewhere. I don't know what the 
expected use case is for CLEANUP; I don't see it used anywhere in the web2py 
apps.

It might also be useful (and trivial) to add an option to pass in the retained 
character set as a string, or as a compiled regex. 

> 
> On May 1, 12:29 am, Jonathan Lundell  wrote:
>> On Apr 25, 2011, at 7:46 PM, Massimo Di Pierro wrote:
>> 
>> 
>> 
>>> I agree.
>> 
>> Perhaps tab should be retained as well.
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> On Apr 25, 8:59 pm, Jonathan Lundell  wrote:
 On Apr 25, 2011, at 6:49 PM, Massimo Di Pierro wrote:
>> 
> True. It should do what the book says.
>> 
 Except that we should probably change the definition to exclude 127, seems 
 to me.
>> 
> On Apr 25, 6:43 pm, pbreit  wrote:
>> CLEANUP() seems to be removing more characters than the Book would 
>> suggest.
>> 
>> "It just removes all characters whose decimal ASCII codes are not in the
>> list [10, 13, 32-127]"
>> 
>> However the regex is '[^ \n\w]' which I think is more like alphanumeric 
>> plus
>> underscore. Is that right?




Re: [web2py] Total control over your web2py models

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

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

> mod_clients.py = what for?
>> mod_users.py = what for?
>
>
> It was an example, you can have mod_nameyouwant.py.
>
> and inside you have for example something like this:
>
> class Clients(object):
>
> def show():
> 'show a list of clients'
>
> def delete():
> 'delete ...'
>
> def add():
> 'add ...'
>
> 2011/5/1 Stifan Kristi 
>
>> thank you so much for your info, martin, i've already tried and learn from
>> powerpack plugins, it's cool but because i'm a newbie in python and web2py,
>> so that a lot of things on powerpack that i don't know the function is what
>> for?
>> pardon me, could you explain about:
>> mod_clients.py = what for?
>> mod_users.py = what for?
>>
>> many thanks before
>>
>> On Sun, May 1, 2011 at 7:58 PM, Martín Mulone wrote:
>>
>>> In powerpack I have this:
>>>
>>> config.py (application settings)
>>> data.py (all the db definition and menus)
>>> main.py (auth, mail, service, registration settings, etc) (this is
>>> independant of the app)
>>>
>>> then I usually do:
>>>
>>> mod_clients.py
>>> mod_users.py
>>> mod_someother.py
>>> mod_someother2.py
>>>
>>> I have classes like bruno show, but I don't have db definitions in this
>>> classes, instead I have all the db definition in data.py because surely I
>>> have link to another tables.
>>>
>>> Then came the plugins:
>>>
>>> plugins_1.py
>>> plugins_2.py
>>> plugins_3.py
>>> plugins_4.py
>>> plugins_zindex.py (here the execution order of plugins)
>>>
>>> 2011/5/1 Stifan Kristi 
>>>
 i'd like your logic bruno, could you explain about the function, please?
 000_essentials.py = what for?
 100_authdatabase.py = what for?
 200_dbmodel.py = what for?
 300_validators.py = what for?
 400_utilities.py = what for?
 500_preload.py = what for?

 thank you so much

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

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

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


Re: [web2py] Re: URL rewrite throwning invalid request when URL contains spaces or hyphens

2011-05-01 Thread Syed Mushtaq
Thanks Massimo for the reply ,

I tried with the comma at the end but no luck :(

I traced it back to the code where it was giving a 400 and found that its
not able to match the regular expression in
rewrite.py function regex_url_in line 542 , The regular expression for this
is

regex_url = re.compile(r'''
 (^(  # (/a/c/f.e/s)
 /(?P [\w\s+]+ )   # /a=app
 (# (/c.f.e/s)
 /(?P [\w\s+]+ )   # /a/c=controller
 (# (/f.e/s)
 /(?P [\w\s+]+ )   # /a/c/f=function
 (# (.e)
 \.(?P [\w\s+]+ )  # /a/c/f.e=extension
 )?
 (# (/s)
 /(?P  # /a/c/f.e/r=raw_args
 .*
 )
 )?
 )?
 )?
 )?
 /?$)
 ''', re.X)

now it has \w which means it checks only for [A-Za-z0-9_] so a - or space
will not be matched leading to 400 . I am using a workaround of replacing
space/hyphens with underscore for now

Thanks
-Syed

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

> yes
>
> routes_in = (( r'/$id/$name' , r'/app/default/view/$id/$name'), )
> routes_out = ( ( r'/app/default/view/$id/$name' , r'/$id/$name'), )
>
> the extra comma at the end. ;-)
>
>
>
> On May 1, 12:58 am, Syed Mushtaq  wrote:
> > Hi ,
> >
> > I was using rewrite for making the URL reader friendly . When I use a
> space
> > or hypen in the URL instead of passing it to the controller , it gives an
> > invalid request .
> >
> > I have configured the routes as follows
> >
> > routes_in = (( r'/$id/$name' , r'/app/default/view/$id/$name') )
> >
> > routes_out = ( ( r'/app/default/view/$id/$name' , r'/$id/$name') )
> >
> > Is there something I am missing ?
> >
> > Thanks
> > -Syed
>


Re: [web2py] Re: URL rewrite throwning invalid request when URL contains spaces or hyphens

2011-05-01 Thread Jonathan Lundell
On May 1, 2011, at 7:23 AM, Syed Mushtaq wrote:
> Thanks Massimo for the reply , 
> 
> I tried with the comma at the end but no luck :(
> 
> I traced it back to the code where it was giving a 400 and found that its not 
> able to match the regular expression in 
> rewrite.py function regex_url_in line 542 , The regular expression for this 
> is 

Notice that this regex includes \s for the fields it's checking, which will 
pass spaces (and tabs!) (they get converted to underscores later).

OTOH, regex_args does not permit whitespace, and also results in a 400 
response, which may be what you're running into. The parametric router gives 
you a little more control over this stuff; see router.example.py.

> 
> regex_url = re.compile(r'''
>  (^(  # (/a/c/f.e/s)
>  /(?P [\w\s+]+ )   # /a=app
>  (# (/c.f.e/s)
>  /(?P [\w\s+]+ )   # /a/c=controller
>  (# (/f.e/s)
>  /(?P [\w\s+]+ )   # /a/c/f=function
>  (# (.e)
>  \.(?P [\w\s+]+ )  # /a/c/f.e=extension
>  )?
>  (# (/s)
>  /(?P  # /a/c/f.e/r=raw_args
>  .*
>  )
>  )?
>  )?
>  )?
>  )?
>  /?$)
>  ''', re.X)
> 
> now it has \w which means it checks only for [A-Za-z0-9_] so a - or space 
> will not be matched leading to 400 . I am using a workaround of replacing 
> space/hyphens with underscore for now 
> 
> Thanks 
> -Syed
> 
> On Sun, May 1, 2011 at 11:44 AM, Massimo Di Pierro 
>  wrote:
> yes
> 
> routes_in = (( r'/$id/$name' , r'/app/default/view/$id/$name'), )
> routes_out = ( ( r'/app/default/view/$id/$name' , r'/$id/$name'), )
> 
> the extra comma at the end. ;-)
> 
> 
> 
> On May 1, 12:58 am, Syed Mushtaq  wrote:
> > Hi ,
> >
> > I was using rewrite for making the URL reader friendly . When I use a space
> > or hypen in the URL instead of passing it to the controller , it gives an
> > invalid request .
> >
> > I have configured the routes as follows
> >
> > routes_in = (( r'/$id/$name' , r'/app/default/view/$id/$name') )
> >
> > routes_out = ( ( r'/app/default/view/$id/$name' , r'/$id/$name') )
> >
> > Is there something I am missing ?
> >
> > Thanks
> > -Syed
> 




[web2py] Re: nested list

2011-05-01 Thread Jose
Hi,

You can see this:

http://www.web2py.com/book/default/chapter/06

[Self-Reference and Aliases]

Best Regards,
Jose


[web2py] Re: Run a method when ever logout is reached.

2011-05-01 Thread Massimo Di Pierro
try this:

auth.sesttings.logout_onlogout = lambda user,s=session:
session.clear()

On May 1, 2:46 am, Jason Brower  wrote:
> I need to make sure curtain session data is wiped when the user is
> logged out.
> This bring up two things:
> 1: How can I run a method like that to make sure this happens when ever
> the logout is clicked.
> 2: I wonder if there could be a spacial area of sessions that is just
> for that users authenticated session.
> BR,
> Jason Brower


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

2011-05-01 Thread Massimo Di Pierro
notnull = True is enforced at the level of the database and the field
value cannot be None/NULL
requires=is_not_empty() is enforced in forced in forms ate web2py
level

required=True is completely different. It has nothing to do with the
field value. It requires that a value always be specified in
db.table.include(...) even if the field has a default or a computed
attribute. It is a measure to prevent some programming errors. I never
use it myself.


On May 1, 7:42 am, 黄祥  wrote:
> hi,
>
> is there anybody know the difference between is_not_empty(),
> notnull=true and required=true?
> should i use both or just 1 of it's?
> please give an advice or pointer about this
>
> thank you so much in advance


[web2py] Re: CLEANUP() removing too many characters

2011-05-01 Thread Massimo Di Pierro
I do not have a strong opinion. I can make it accept tab. Uploading to
trunk.

On May 1, 8:57 am, Jonathan Lundell  wrote:
> On Apr 30, 2011, at 11:13 PM, Massimo Di Pierro wrote:
>
>
>
> > I am not convinced about tab. I hate tab, it only causes problems.
>
> In Python it does, but it solves problems elsewhere. I don't know what the 
> expected use case is for CLEANUP; I don't see it used anywhere in the web2py 
> apps.
>
> It might also be useful (and trivial) to add an option to pass in the 
> retained character set as a string, or as a compiled regex.
>
>
>
>
>
>
>
>
>
> > On May 1, 12:29 am, Jonathan Lundell  wrote:
> >> On Apr 25, 2011, at 7:46 PM, Massimo Di Pierro wrote:
>
> >>> I agree.
>
> >> Perhaps tab should be retained as well.
>
> >>> On Apr 25, 8:59 pm, Jonathan Lundell  wrote:
>  On Apr 25, 2011, at 6:49 PM, Massimo Di Pierro wrote:
>
> > True. It should do what the book says.
>
>  Except that we should probably change the definition to exclude 127, 
>  seems to me.
>
> > On Apr 25, 6:43 pm, pbreit  wrote:
> >> CLEANUP() seems to be removing more characters than the Book would 
> >> suggest.
>
> >> "It just removes all characters whose decimal ASCII codes are not in 
> >> the
> >> list [10, 13, 32-127]"
>
> >> However the regex is '[^ \n\w]' which I think is more like 
> >> alphanumeric plus
> >> underscore. Is that right?


Re: [web2py] Re: nested list

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

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

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


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

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


[web2py] mod_alias ? Redirecting subdomain directly to an web2py app

2011-05-01 Thread Alexandre Strzelewicz
Hi,

I used  the script 'setup-web2py-nginx-uwsgi-ubuntu.sh' to configure
my server.

But now when I go to http://myserver.com, it automatically redirect me
to http://myserver.com/welcome

Now I want to configure apache to map  http://MYAPP.domain.com/ to
http://myserver.com/MYAPP.

So I think I have to use mod_alias, Im right ?

This doesnt work :


 ServerName MYAPP.domain.com
 Alias / /MYAPP


Thank you


Re: [web2py] Re: postgress outer join

2011-05-01 Thread Pawel Jasinski
hi Massimo,

how about the following:

the _select/select would accept extra parameter 'inner_join' with
syntax/semantic analog to 'left', but emit JOIN at the sql level.
In case of such a unpleasant query as mine, it would be possible to
construct it with inner_join instead of the usual way.

My original query would look like this:

db(db.first).select(db.first.ALL, db.second.ALL, db.third.ALL, db.fourth.ALL,
inner_join=db.second.on(db.first.id==db.second.r12_first_id),
left=[db.third.on(db.third.r13_first_id==db.first.id),
db.fourth.on(db.fourth.r14_second_id==db.second.id)])


--pawel

--- dal.py.orig 2011-04-29 14:19:16.150627000 +0200
+++ dal.py  2011-05-01 19:54:55.316651002 +0200
@@ -717,6 +717,9 @@
 def AGGREGATE(self,first,what):
 return "%s(%s)" % (what,self.expand(first))

+def JOIN(self):
+return 'JOIN'
+
 def LEFT_JOIN(self):
 return 'LEFT JOIN'

@@ -969,7 +972,7 @@
 def _select(self, query, fields, attributes):
 for key in set(attributes.keys())-set(('orderby','groupby','limitby',
'required','cache','left',
-   'distinct','having')):
+   'distinct','having',
'inner_join')):
 raise SyntaxError, 'invalid select attribute: %s' % key
 # ## if not fields specified take them all from the requested tables
 new_fields = []
@@ -1003,6 +1006,7 @@
 sql_o = ''
 sql_s = ''
 left = attributes.get('left', False)
+inner_join = attributes.get('inner_join', False)
 distinct = attributes.get('distinct', False)
 groupby = attributes.get('groupby', False)
 orderby = attributes.get('orderby', False)
@@ -1012,6 +1016,15 @@
 sql_s += 'DISTINCT'
 elif distinct:
 sql_s += 'DISTINCT ON (%s)' % distinct
+if inner_join:
+ijoin = attributes['inner_join']
+icommand = self.JOIN()
+if not isinstance(ijoin, (tuple, list)):
+ijoin = [ijoin]
+ijoint = [t._tablename for t in ijoin if not
isinstance(t,Expression)]
+ijoinon = [t for t in ijoin if isinstance(t, Expression)]
+ijoinont = [t.first._tablename for t in ijoinon]
+iexcluded = [t for t in tablenames if not t in ijoint + ijoinont]
 if left:
 join = attributes['left']
 command = self.LEFT_JOIN()
@@ -1026,14 +1039,26 @@
 [tables_to_merge.pop(t) for t in joinont if t in tables_to_merge]
 important_tablenames = joint + joinont + tables_to_merge.keys()
 excluded = [t for t in tablenames if not t in
important_tablenames ]
+if inner_join and not left:
+sql_t = ', '.join(iexcluded)
+for t in ijoinon:
+sql_t += ' %s %s' % (icommand, str(t))
+elif not inner_join and left:
 sql_t = ', '.join([ t for t in excluded + tables_to_merge.keys()])
 if joint:
 sql_t += ' %s %s' % (command, ','.join([t for t in joint]))
-#/patch join+left patch
+for t in joinon:
+sql_t += ' %s %s' % (command, str(t))
+elif inner_join and left:
+sql_t = ','.join([ t for t in excluded +
tables_to_merge.keys() if t in iexcluded ])
+for t in ijoinon:
+sql_t += ' %s %s' % (icommand, str(t))
+if joint:
+sql_t += ' %s %s' % (command, ','.join([t for t in joint]))
 for t in joinon:
 sql_t += ' %s %s' % (command, str(t))
 else:
-sql_t = ', '.join(tablenames)
+sql_t = ', '.join(tablenames)
 if groupby:
 if isinstance(groupby, (list, tuple)):
 groupby = xorify(groupby)


On Fri, Apr 29, 2011 at 3:53 PM, Massimo Di Pierro
 wrote:
> Can you please try:
>
> db(db.first.id.belongs(db()._select(db.second.r12_first_id)))
> .select(db.first.ALL,db.second.ALL,db.third.ALL,db.fourth.ALL,
> left= [
> db.second.on(db.first.id==db.second.r12_first_id),
> db.third.on(db.third.r13_first_id==db.first.id),
> db.fourth.on(db.fourth.r14_second_id==db.second.id),
> ])
>
>
>
> On Apr 28, 2:22 pm, Pawel Jasinski  wrote:
>> hi,
>>
>> this appears to be an old issue already discussed and marked as
>> solved:http://groups.google.com/group/web2py/browse_thread/thread/d7f5e58201...http://groups.google.com/group/web2py/browse_thread/thread/f4ef82fd34...
>> but, I got it again :-(
>>
>> Here is my model:
>>
>> db.define_table('first',
>>     Field('f11'))
>> db.define_table('second',
>>     Field('f12'),
>>     Field('r12_first_id', db.first))
>> db.define_table('third',
>>     Field('f13'),
>>     Field('r13_first_id', db.first))
>> db.define_table('fourth',
>>     Field('f14'),
>>     Field('r14_second_id', db.second))
>>
>> # and the problem:
>> db((db.first.id==db.second.r

[web2py] Re: mod_alias ? Redirecting subdomain directly to an web2py app

2011-05-01 Thread pbreit
The Nginx web server has it's own way to configure routing. Have a look at:
http://nginx.org/en/docs/http/server_names.html

You might be able to get what you want simply by setting a 
default_application in routes.py:
1. in "web2py" directory, open "router.example.py"
2. modify "default_application = 'welcome'," to "default_application = 
'myapp',"
3. save as "routes.py"
4. restart web2py


[web2py] Re: mod_alias ? Redirecting subdomain directly to an web2py app

2011-05-01 Thread Alexandre Strzelewicz
Sorry Its not with the nginx script but the apache script !

I want to redirect each subdomains on different web application of
we2py :

sub1.domain.com
-> welcome app

sub2.domain.com
-> application2



So changing only the default application on routes.py its not the
prefered solution

On 1 mai, 19:32, pbreit  wrote:
> The Nginx web server has it's own way to configure routing. Have a look 
> at:http://nginx.org/en/docs/http/server_names.html
>
> You might be able to get what you want simply by setting a
> default_application in routes.py:
> 1. in "web2py" directory, open "router.example.py"
> 2. modify "default_application = 'welcome'," to "default_application =
> 'myapp',"
> 3. save as "routes.py"
> 4. restart web2py


[web2py] Re: deal with CSV

2011-05-01 Thread cyber
Any ideas please!
*

On 1 май, 00:20, cyber  wrote:
> hi everyone!
>
> I need a help/hint/advase again.
>
> I have a code in the controller:
> results=db((db.autos.dt>=t1) &
> (db.autos.dt<=t2)).select(orderby=~db.autos.dt)
>     export = csv.writer(open('export.csv', 'wb'), delimiter=' ',
> quotechar='|', quoting=csv.QUOTE_MINIMAL)
>     for r in results:
>         export.writerow([r.id] + [r.num] + [r.ves] + [r.dt] + [r.usr])
>
> I want to export search results to csv file. But in this case
> export.csv file is created automaticly.
> And I want users to choose file name and destination folder. How to
> settle the matter?
>
> And another problem is: all results are wrote in a one cell. Is there
> a way to write each db.table.field value in one row but into each cell?


[web2py] Re: mod_alias ? Redirecting subdomain directly to an web2py app

2011-05-01 Thread Anthony
Have you tried using the new parameter-based routing system to map 
subdomains to different apps (see 
http://web2py.com/book/default/chapter/04#Parameter-Based-System)? If that 
doesn't work, maybe you can do it with the older pattern-based system (
http://web2py.com/book/default/chapter/04#Pattern-Based-System).

On Sunday, May 1, 2011 1:40:02 PM UTC-4, Alexandre Strzelewicz wrote:

> Hi, 
>
> I used  the script 'setup-web2py-nginx-uwsgi-ubuntu.sh' to configure 
> my server. 
>
> But now when I go to http://myserver.com, it automatically redirect me 
> to http://myserver.com/welcome 
>
> Now I want to configure apache to map  http://MYAPP.domain.com/ to 
> http://myserver.com/MYAPP. 
>
> So I think I have to use mod_alias, Im right ? 
>
> This doesnt work : 
>
>  
>  ServerName MYAPP.domain.com 
>  Alias / /MYAPP 
>  
>
> Thank you



[web2py] Correction Pagination web2py ebook

2011-05-01 Thread Gilson Filho
I wanted to spend a correction on the logical layout. Removing the sum of the
amount+ 1, pq instead of displaying 5 records per page, for example, is
showing 6.

http://web2py.com/book/default/chapter/12#Pagination


>
> _limit = (page * per_page, (page + 1) * per_page)

_
*Gilson Filho*
*Web Developer
http://gilsondev.com*


[web2py] Re: deal with CSV

2011-05-01 Thread DenesL

You can provide a link to the controller below, instructing the user
to right click on it and then select 'save link as...', he can store
the response in any selected directory using his choice of filename (a
name ending in .csv):

def tocsv():
  response.headers['content-type']='text/csv'
  rr=db((db.autos.dt>=t1) &
(db.autos.dt<=t2)).select(orderby=~db.autos.dt)
  return '\n'.join([','.join(map(str,[r.id, r.num, r.ves, r.dt,
r.usr])) for r in rr])



[web2py] Re: really nice interview on hackerpublicradio about web2py

2011-05-01 Thread VP
There have many many positive articles written about web2py.  It's a
good idea to collect them and place on the web2py.org website.

On Apr 30, 11:18 pm, Massimo Di Pierro 
wrote:
> http://hackerpublicradio.org/eps/hpr0711.mp3


[web2py] Re: really nice interview on hackerpublicradio about web2py

2011-05-01 Thread Massimo Di Pierro
I try to collect them all using twitter.

Massimo

On May 1, 4:09 pm, VP  wrote:
> There have many many positive articles written about web2py.  It's a
> good idea to collect them and place on the web2py.org website.
>
> On Apr 30, 11:18 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> >http://hackerpublicradio.org/eps/hpr0711.mp3


[web2py] more layout plugins

2011-05-01 Thread Massimo Di Pierro
I remind you that, for months we had these:

http://web2py.com/layouts

but also these:

http://web2py.com/drupal

and these:

http://web2py.com/zengarden

they are all converted automatically so some may work and some may
not. If you can help improve the drupal anes and the zengarden ones, I
will be happy to add them to layouts.


[web2py] help testing

2011-05-01 Thread Massimo Di Pierro
In trunk we have - experimentally - conditional web2py models

1) models/anything.py (for all controllers)
2) models//anything.py (only forfunction in controller )
3) models///anything.py (only for function f in controller )

when you can http:////
all models 1 are executed alphabetically, the 2 alphabetically then 3
alphabetically.

Please help us test that:
1) it works
2) it works if you bytecode compile the app
3) it does not apps that were bytecode compiled with a previous web2py
version

This should provide a major speedup for those apps with lots of tables
like ShanaEden.

Massimo






[web2py] Re: mod_alias ? Redirecting subdomain directly to an web2py app

2011-05-01 Thread Alexandre Strzelewicz
Thanks I found that for each domains :

In routes.py on web2py root folder :

routers = dict(
BASE = dict(
# default_controller =
'default',
domains = {
"app1.com" : "app1",
"app2.com" : "app2"
}
),
)

But I can't use Parameter-Based System + Pattern-Based System at the
same time ?

Parameter Based System for domain pointing and Pattern Based System
for internal application routing
as :
routes_in = (('/login', '/app1/default/user/login'))

Thanks

On May 1, 9:28 pm, Anthony  wrote:
> Have you tried using the new parameter-based routing system to map
> subdomains to different apps 
> (seehttp://web2py.com/book/default/chapter/04#Parameter-Based-System)?If that
> doesn't work, maybe you can do it with the older pattern-based system 
> (http://web2py.com/book/default/chapter/04#Pattern-Based-System).
>
>
>
>
>
>
>
> On Sunday, May 1, 2011 1:40:02 PM UTC-4, Alexandre Strzelewicz wrote:
> > Hi,
>
> > I used  the script 'setup-web2py-nginx-uwsgi-ubuntu.sh' to configure
> > my server.
>
> > But now when I go tohttp://myserver.com, it automatically redirect me
> > tohttp://myserver.com/welcome
>
> > Now I want to configure apache to map  http://MYAPP.domain.com/to
> >http://myserver.com/MYAPP.
>
> > So I think I have to use mod_alias, Im right ?
>
> > This doesnt work :
>
> > 
> >              ServerName MYAPP.domain.com
> >              Alias / /MYAPP
> > 
>
> > Thank you


[web2py] Markmin + Markitup

2011-05-01 Thread villas
As I understand it,  we only get the Markitup editor for a text field
when we install plugin_wiki.
Does anyone have an easy step-by-step method to do it otherwise?


[web2py] Re: Markmin + Markitup

2011-05-01 Thread Massimo Di Pierro
you just need this code in your views and plugin_wiki/markitup under
static/.


{{
response.files.append(URL('static','plugin_wiki/markitup/
jquery.markitup.pack.js'))
response.files.append(URL('static','plugin_wiki/markitup/sets/markmin/
set.js'))
response.files.append(URL('static','plugin_wiki/markitup/skins/
markitup/style.css'))
response.files.append(URL('static','plugin_wiki/markitup/sets/markmin/
style.css'))
}}

jQuery(document).ready(function() {
 
jQuery('textarea').css('width','700px').css('height','400px').markItUp(mySettings);
});



Massimo


On May 1, 5:49 pm, villas  wrote:
> As I understand it,  we only get the Markitup editor for a text field
> when we install plugin_wiki.
> Does anyone have an easy step-by-step method to do it otherwise?


[web2py] Re: Markmin + Markitup

2011-05-01 Thread Massimo Di Pierro
p.s. you need the markiup js that comes with plugin_wiki because the
official one does not support markmin. One year ago I have submitted a
patch to the author but never got back from him. Perhaps you can help
by contacting him and advocating for it.

On May 1, 6:18 pm, Massimo Di Pierro 
wrote:
> you just need this code in your views and plugin_wiki/markitup under
> static/.
>
> {{
> response.files.append(URL('static','plugin_wiki/markitup/
> jquery.markitup.pack.js'))
> response.files.append(URL('static','plugin_wiki/markitup/sets/markmin/
> set.js'))
> response.files.append(URL('static','plugin_wiki/markitup/skins/
> markitup/style.css'))
> response.files.append(URL('static','plugin_wiki/markitup/sets/markmin/
> style.css'))}}
>
> 
> jQuery(document).ready(function() {
>
> jQuery('textarea').css('width','700px').css('height','400px').markItUp(mySe 
> ttings);});
>
> 
>
> Massimo
>
> On May 1, 5:49 pm, villas  wrote:
>
>
>
>
>
>
>
> > As I understand it,  we only get the Markitup editor for a text field
> > when we install plugin_wiki.
> > Does anyone have an easy step-by-step method to do it otherwise?


Re: [web2py] help testing

2011-05-01 Thread Bruno Rocha
great improvement, I am testing right now.

A question that will raise soon is: How do I execute a model on demand? if I
am in /default/foo and want an object defined in /default/bar, how do I
force this model file to run?

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



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

> In trunk we have - experimentally - conditional web2py models
>
> 1) models/anything.py (for all controllers)
> 2) models//anything.py (only forfunction in controller )
> 3) models///anything.py (only for function f in controller )
>
> when you can http:////
> all models 1 are executed alphabetically, the 2 alphabetically then 3
> alphabetically.
>
> Please help us test that:
> 1) it works
> 2) it works if you bytecode compile the app
> 3) it does not apps that were bytecode compiled with a previous web2py
> version
>
> This should provide a major speedup for those apps with lots of tables
> like ShanaEden.
>
> Massimo
>
>
>
>
>


[web2py] Re: mod_alias ? Redirecting subdomain directly to an web2py app

2011-05-01 Thread Alexandre Strzelewicz
I tried lot of things and I cant use  Parameter Based System + Pattern-
Based System at same time

How can I do to map controllers and other when I use :

routers = dict(
BASE = dict(
# default_controller =
'default',
domains = {
"app1.com" : "app1",
"app2.com" : "app2"
}
),
)
?

routes_in = (('/login', '/app1/default/user/login'))  -> doesn't work.
It says that default/login is not avaible ...

On May 2, 12:36 am, Alexandre Strzelewicz
 wrote:
> Thanks I found that for each domains :
>
> In routes.py on web2py root folder :
>
> routers = dict(
>     BASE = dict(
>         # default_controller =
> 'default',
>         domains = {
>             "app1.com" : "app1",
>             "app2.com" : "app2"
>             }
>         ),
>     )
>
> But I can't use Parameter-Based System + Pattern-Based System at the
> same time ?
>
> Parameter Based System for domain pointing and Pattern Based System
> for internal application routing
> as :
> routes_in = (('/login', '/app1/default/user/login'))
>
> Thanks
>
> On May 1, 9:28 pm, Anthony  wrote:
>
>
>
>
>
>
>
> > Have you tried using the new parameter-based routing system to map
> > subdomains to different apps 
> > (seehttp://web2py.com/book/default/chapter/04#Parameter-Based-System)?Ifthat
> > doesn't work, maybe you can do it with the older pattern-based system 
> > (http://web2py.com/book/default/chapter/04#Pattern-Based-System).
>
> > On Sunday, May 1, 2011 1:40:02 PM UTC-4, Alexandre Strzelewicz wrote:
> > > Hi,
>
> > > I used  the script 'setup-web2py-nginx-uwsgi-ubuntu.sh' to configure
> > > my server.
>
> > > But now when I go tohttp://myserver.com, it automatically redirect me
> > > tohttp://myserver.com/welcome
>
> > > Now I want to configure apache to map  http://MYAPP.domain.com/to
> > >http://myserver.com/MYAPP.
>
> > > So I think I have to use mod_alias, Im right ?
>
> > > This doesnt work :
>
> > > 
> > >              ServerName MYAPP.domain.com
> > >              Alias / /MYAPP
> > > 
>
> > > Thank you


[web2py] Re: mod_alias ? Redirecting subdomain directly to an web2py app

2011-05-01 Thread Anthony
On Sunday, May 1, 2011 8:27:39 PM UTC-4, Alexandre Strzelewicz wrote: 
>
> I tried lot of things and I cant use  Parameter Based System + Pattern- 
> Based System at same time

 
No, currently you cannot mix the two systems. However, you might be able to 
use the pattern-based system to do the subdomain mapping, as the host can be 
included in the routes_in regular expression (see near the end of this 
section in the book: 
http://web2py.com/book/default/chapter/04#Pattern-Based-System).
 

>
> How can I do to map controllers and other when I use : 
>
> routers = dict( 
> BASE = dict( 
> # default_controller = 
> 'default', 
> domains = { 
> "app1.com" : "app1", 
> "app2.com" : "app2" 
> } 
> ), 
> ) 
> ? 
>
> routes_in = (('/login', '/app1/default/user/login'))  -> doesn't work.

 
If you've only got one or two pattern-based routes_in like this, maybe just 
switch to the parameter-based system, and then instead of this routes_in, 
just create an explicit 'login' action in your default controller to display 
the login form (so you won't need to do any special routing to get to the 
login page).
 
Anthony


[web2py] Re: help testing

2011-05-01 Thread Massimo Di Pierro
not that I recommend this but you can do

def index():
execfile(os.path.join(request.folder,'models','mymodel.py'))
...
return locals()

The execfile can be outside.

I do not think it is a good idea because it would not take advantage
of pyc caching, bytecode compilation would break and because it is
better to define code to be executed on demand in modules (not
models), import them and call functions that do what you need
conditionally.


On May 1, 7:04 pm, Bruno Rocha  wrote:
> great improvement, I am testing right now.
>
> A question that will raise soon is: How do I execute a model on demand? if I
> am in /default/foo and want an object defined in /default/bar, how do I
> force this model file to run?
>
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]
>
> On Sun, May 1, 2011 at 7:30 PM, Massimo Di Pierro <
>
>
>
>
>
>
>
> massimo.dipie...@gmail.com> wrote:
> > In trunk we have - experimentally - conditional web2py models
>
> > 1) models/anything.py (for all controllers)
> > 2) models//anything.py (only forfunction in controller )
> > 3) models///anything.py (only for function f in controller )
>
> > when you canhttp:////
> > all models 1 are executed alphabetically, the 2 alphabetically then 3
> > alphabetically.
>
> > Please help us test that:
> > 1) it works
> > 2) it works if you bytecode compile the app
> > 3) it does not apps that were bytecode compiled with a previous web2py
> > version
>
> > This should provide a major speedup for those apps with lots of tables
> > like ShanaEden.
>
> > Massimo


[web2py] Cookie help

2011-05-01 Thread Pystar
In dealing with authentication and session do I need to deal with raw
cookies? or does web2py handle that for me?


Re: [web2py] Re: mod_alias ? Redirecting subdomain directly to an web2py app

2011-05-01 Thread Jonathan Lundell
On May 1, 2011, at 5:27 PM, Alexandre Strzelewicz wrote:
> 
> I tried lot of things and I cant use  Parameter Based System + Pattern-
> Based System at same time
> 
> How can I do to map controllers and other when I use :
> 
> routers = dict(
>BASE = dict(
># default_controller =
> 'default',
>domains = {
>"app1.com" : "app1",
>"app2.com" : "app2"
>}
>),
>)
> ?
> 
> routes_in = (('/login', '/app1/default/user/login'))  -> doesn't work.
> It says that default/login is not avaible ...

You can't mix, but you don't need to.

Functions aren't omitted by default. To omit functions (only in the default 
controller) create another router for your app, thus:

routers = dict(
   BASE = dict(
   domains = {
   "app1.com" : "app1",
   "app2.com" : "app2"
   }
),
   app1 = dict(
  functions = ["user", ...},
   )
)

...where functions is a list of *all* the functions in app1/default. 

Alternatively, don't bother, and access user/login instead of login.


> 
> On May 2, 12:36 am, Alexandre Strzelewicz
>  wrote:
>> Thanks I found that for each domains :
>> 
>> In routes.py on web2py root folder :
>> 
>> routers = dict(
>> BASE = dict(
>> # default_controller =
>> 'default',
>> domains = {
>> "app1.com" : "app1",
>> "app2.com" : "app2"
>> }
>> ),
>> )
>> 
>> But I can't use Parameter-Based System + Pattern-Based System at the
>> same time ?
>> 
>> Parameter Based System for domain pointing and Pattern Based System
>> for internal application routing
>> as :
>> routes_in = (('/login', '/app1/default/user/login'))
>> 
>> Thanks
>> 
>> On May 1, 9:28 pm, Anthony  wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Have you tried using the new parameter-based routing system to map
>>> subdomains to different apps 
>>> (seehttp://web2py.com/book/default/chapter/04#Parameter-Based-System)?Ifthat
>>> doesn't work, maybe you can do it with the older pattern-based system 
>>> (http://web2py.com/book/default/chapter/04#Pattern-Based-System).
>> 
>>> On Sunday, May 1, 2011 1:40:02 PM UTC-4, Alexandre Strzelewicz wrote:
 Hi,
>> 
 I used  the script 'setup-web2py-nginx-uwsgi-ubuntu.sh' to configure
 my server.
>> 
 But now when I go tohttp://myserver.com, it automatically redirect me
 tohttp://myserver.com/welcome
>> 
 Now I want to configure apache to map  http://MYAPP.domain.com/to
 http://myserver.com/MYAPP.
>> 
 So I think I have to use mod_alias, Im right ?
>> 
 This doesnt work :
>> 
 
  ServerName MYAPP.domain.com
  Alias / /MYAPP
 
>> 
 Thank you




[web2py] Re: Cookie help

2011-05-01 Thread Massimo Di Pierro
it does.

if 'counter' in request.cookies:
  # retrieve cookie
  counter = request.cookies['counter'].value +1
else:
  counter=1

# set cookie
response.cookies['counter'] = counter

request.cookies[name] is a Morsel Object
http://docs.python.org/library/cookie.html

Massimo

On May 1, 7:36 pm, Pystar  wrote:
> In dealing with authentication and session do I need to deal with raw
> cookies? or does web2py handle that for me?


[web2py] Re: Cookie help

2011-05-01 Thread Pystar
Ok, thanks
Example:
How do I allow a user to stay logged in to my site for as long as
possible? Or have the site remeber the user? without allowing the user
log in again and again

On May 2, 1:56 am, Massimo Di Pierro 
wrote:
> it does.
>
> if 'counter' in request.cookies:
>   # retrieve cookie
>   counter = request.cookies['counter'].value +1
> else:
>   counter=1
>
> # set cookie
> response.cookies['counter'] = counter
>
> request.cookies[name] is a Morsel 
> Objecthttp://docs.python.org/library/cookie.html
>
> Massimo
>
> On May 1, 7:36 pm, Pystar  wrote:
>
>
>
>
>
>
>
> > In dealing with authentication and session do I need to deal with raw
> > cookies? or does web2py handle that for me?


Re: [web2py] Re: help testing

2011-05-01 Thread Thadeus Burgess
Nononononononono

This breaks the way it currently works. I have multile web2py apps that take
advantage of subfolders for models to group them in the way they should
execute.

This feature means i could NEVER upgrade my apps again.
On May 1, 2011 7:44 PM, "Massimo Di Pierro" 
wrote:
> not that I recommend this but you can do
>
> def index():
> execfile(os.path.join(request.folder,'models','mymodel.py'))
> ...
> return locals()
>
> The execfile can be outside.
>
> I do not think it is a good idea because it would not take advantage
> of pyc caching, bytecode compilation would break and because it is
> better to define code to be executed on demand in modules (not
> models), import them and call functions that do what you need
> conditionally.
>
>
> On May 1, 7:04 pm, Bruno Rocha  wrote:
>> great improvement, I am testing right now.
>>
>> A question that will raise soon is: How do I execute a model on demand?
if I
>> am in /default/foo and want an object defined in /default/bar, how do I
>> force this model file to run?
>>
>> --
>> Bruno Rocha
>> [ About me:http://zerp.ly/rochacbruno]
>>
>> On Sun, May 1, 2011 at 7:30 PM, Massimo Di Pierro <
>>
>>
>>
>>
>>
>>
>>
>> massimo.dipie...@gmail.com> wrote:
>> > In trunk we have - experimentally - conditional web2py models
>>
>> > 1) models/anything.py (for all controllers)
>> > 2) models//anything.py (only forfunction in controller )
>> > 3) models///anything.py (only for function f in controller )
>>
>> > when you canhttp:////
>> > all models 1 are executed alphabetically, the 2 alphabetically then 3
>> > alphabetically.
>>
>> > Please help us test that:
>> > 1) it works
>> > 2) it works if you bytecode compile the app
>> > 3) it does not apps that were bytecode compiled with a previous web2py
>> > version
>>
>> > This should provide a major speedup for those apps with lots of tables
>> > like ShanaEden.
>>
>> > Massimo


[web2py] rss feed escaping html

2011-05-01 Thread Plumo
How can I include HTML in an RSS feed? By default HTML tags are escaped, 
even though generic.rss has escape=False.

[web2py] Re: more layout plugins

2011-05-01 Thread Plumo
Nice work.

"You can try it by clicking the [zengarden] button on the top-right corner 
of the page"

Top-left


[web2py] Re: rss feed escaping html

2011-05-01 Thread Anthony
On Sunday, May 1, 2011 9:28:13 PM UTC-4, Plumo wrote: 
>
> How can I include HTML in an RSS feed? By default HTML tags are escaped, 
> even though generic.rss has escape=False.

 
Does it work if you wrap the HTML in XML() (see 
http://web2py.com/book/default/chapter/05#XML)?


Re: [web2py] Re: help testing

2011-05-01 Thread Bruno Rocha
Thadeus, this is an improvement for code organization and less use of
memory, I dont think it breaks compatibility. because there are no place in
actual documentation where you can find info about using subfolders. Massimo
said sometime ago that subfolders was "reserved" for future implementation.
This future is now!

I think code organization with memory usage improvement is better than
simply subfolders with models that will be always executed, even if they are
not needed.

May be we can have some king of compatibility check
"run_in_model_compatibility = True" at some place, but. One thing we can
always have in mind: Changes in undocumented features or bug fixing cannot
be considered break of compatibility this is just the wrong usage, we ran in
to this same issue when URL was changed.

The way web2py imports all the models to memory is bad to performance, the
new style is very good and enough. I am testing it now and I think it will
be very productive.

How can we manage this kind of interest conflict?

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


[web2py] Re: Cookie help

2011-05-01 Thread Massimo Di Pierro
web2py cookies never expire (unless the client deleted cookies) but
authentication does in two ways:

1) it check last acces datetime so you can change the expiration time
in seconds

auth.settings.expiration = 100

2) admin deletes session files that have been unused in a while, so
delete

applications/admin/cron/expire_sessions.py


On May 1, 8:02 pm, Pystar  wrote:
> Ok, thanks
> Example:
> How do I allow a user to stay logged in to my site for as long as
> possible? Or have the site remeber the user? without allowing the user
> log in again and again
>
> On May 2, 1:56 am, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > it does.
>
> > if 'counter' in request.cookies:
> >   # retrieve cookie
> >   counter = request.cookies['counter'].value +1
> > else:
> >   counter=1
>
> > # set cookie
> > response.cookies['counter'] = counter
>
> > request.cookies[name] is a Morsel 
> > Objecthttp://docs.python.org/library/cookie.html
>
> > Massimo
>
> > On May 1, 7:36 pm, Pystar  wrote:
>
> > > In dealing with authentication and session do I need to deal with raw
> > > cookies? or does web2py handle that for me?


[web2py] Re: help testing

2011-05-01 Thread Massimo Di Pierro
How about we provide a script that fixes that automatically?

models//.py -> models/_/py

is anybody else using model subfolder?

Massimo

On May 1, 8:09 pm, Thadeus Burgess  wrote:
> Nononononononono
>
> This breaks the way it currently works. I have multile web2py apps that take
> advantage of subfolders for models to group them in the way they should
> execute.
>
> This feature means i could NEVER upgrade my apps again.
> On May 1, 2011 7:44 PM, "Massimo Di Pierro" 
> wrote:
>
>
>
>
>
>
>
> > not that I recommend this but you can do
>
> > def index():
> > execfile(os.path.join(request.folder,'models','mymodel.py'))
> > ...
> > return locals()
>
> > The execfile can be outside.
>
> > I do not think it is a good idea because it would not take advantage
> > of pyc caching, bytecode compilation would break and because it is
> > better to define code to be executed on demand in modules (not
> > models), import them and call functions that do what you need
> > conditionally.
>
> > On May 1, 7:04 pm, Bruno Rocha  wrote:
> >> great improvement, I am testing right now.
>
> >> A question that will raise soon is: How do I execute a model on demand?
> if I
> >> am in /default/foo and want an object defined in /default/bar, how do I
> >> force this model file to run?
>
> >> --
> >> Bruno Rocha
> >> [ About me:http://zerp.ly/rochacbruno]
>
> >> On Sun, May 1, 2011 at 7:30 PM, Massimo Di Pierro <
>
> >> massimo.dipie...@gmail.com> wrote:
> >> > In trunk we have - experimentally - conditional web2py models
>
> >> > 1) models/anything.py (for all controllers)
> >> > 2) models//anything.py (only forfunction in controller )
> >> > 3) models///anything.py (only for function f in controller )
>
> >> > when you canhttp:////
> >> > all models 1 are executed alphabetically, the 2 alphabetically then 3
> >> > alphabetically.
>
> >> > Please help us test that:
> >> > 1) it works
> >> > 2) it works if you bytecode compile the app
> >> > 3) it does not apps that were bytecode compiled with a previous web2py
> >> > version
>
> >> > This should provide a major speedup for those apps with lots of tables
> >> > like ShanaEden.
>
> >> > Massimo


Re: [web2py] Re: help testing

2011-05-01 Thread pbreit
Am I understanding correctly that we could save memory by not loading all 
models on all page views? That seems like a reasonable objective.

[web2py] Re: help testing

2011-05-01 Thread Massimo Di Pierro
yes. You would not be saving memory as much as you would be saving
time.

On May 1, 9:50 pm, pbreit  wrote:
> Am I understanding correctly that we could save memory by not loading all
> models on all page views? That seems like a reasonable objective.


[web2py] Re: help testing

2011-05-01 Thread pbreit
Would there be an approach to this using some sort of loading scheme? The 
directory approach seems like it could get cumbersome as well as be 
problematic for models that are used in multiple controllers.

[web2py] Re: Confusion using experts4solutions

2011-05-01 Thread Steve
I too would like to know what is the best way to interact with the
experts4solutions list.  Do we just spam the list with the work I
have?

On Apr 27, 2:25 pm, Jim Karsten  wrote:
> We are working on a new web2py project. We are making progress and web2py
> has certainly improved our production but we could use some help. The
> experts4solutions site looks very promising but currently it doesn't provide
> details for handling various issues.
>
> We posted a couple of small jobs on elance, oDesk and vWorker, then sent the
> links each member of experts4solutions.
>
> Some of the issues the freelancing sites handle that we have a concern about
> include: job posting tools, contractor filtering tools, payment processing,
> commitment guarantees (for example, payment held in escrow), dispute
> settlements and arbitration, legal terms and software licences.
>
> Is our approach acceptable? What have others done in the past?
>
> Regards,
> Jim Karsten


Re: [web2py] Re: help testing

2011-05-01 Thread Gilson Filho
I tested here, I created designs seen around the controller and also in
specific actions,and everything is quiet, working perfectly.
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/5/2 pbreit 

> Would there be an approach to this using some sort of loading scheme? The
> directory approach seems like it could get cumbersome as well as be
> problematic for models that are used in multiple controllers.


Re: [web2py] Re: help testing

2011-05-01 Thread Bruno Rocha
Yes, lets say we have this app:

models/general.py # this model and all models in root folder is always
executed

models/default/something.py # this model and all on the same folder is only
executed when http:///app/default/* is requested

models/default/index/something.py # this model and all on the same fodler is
only executes when http:///app/default/index is requested

models/default/contact/something.py # this model and all on the same fodler
is only executes when http:///app/default/contact is requested

Imagine a bigger app with too many tables, too many validators etc. there
are no need to always load models of 'contact' page.


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



On Sun, May 1, 2011 at 11:50 PM, pbreit  wrote:

> Am I understanding correctly that we could save memory by not loading all
> models on all page views? That seems like a reasonable objective.


Re: [web2py] Re: help testing

2011-05-01 Thread Gilson Filho
Will need more tests or already is scheduled to play for production?
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/5/2 Bruno Rocha 

> Yes, lets say we have this app:
>
> models/general.py # this model and all models in root folder is always
> executed
>
> models/default/something.py # this model and all on the same folder is only
> executed when http:///app/default/* is requested
>
> models/default/index/something.py # this model and all on the same fodler
> is only executes when http:///app/default/index is requested
>
> models/default/contact/something.py # this model and all on the same fodler
> is only executes when http:///app/default/contact is requested
>
> Imagine a bigger app with too many tables, too many validators etc. there
> are no need to always load models of 'contact' page.
>
>
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
>
>
>
> On Sun, May 1, 2011 at 11:50 PM, pbreit  wrote:
>
>> Am I understanding correctly that we could save memory by not loading all
>> models on all page views? That seems like a reasonable objective.
>
>
>


Re: [web2py] Re: help testing

2011-05-01 Thread Bruno Rocha
Also, I think it is a benefit when working with 'web2py_components' that
today on every ajax call executes all models again on a separate request, in
a modular page built with  5 components we are going to have all models
loaded for 5 different requests.

This new approach is a memory saver if you put specific code on to
models/component folder..


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



On Mon, May 2, 2011 at 12:08 AM, Bruno Rocha  wrote:

> Yes, lets say we have this app:
>
> models/general.py # this model and all models in root folder is always
> executed
>
> models/default/something.py # this model and all on the same folder is only
> executed when http:///app/default/* is requested
>
> models/default/index/something.py # this model and all on the same fodler
> is only executes when http:///app/default/index is requested
>
> models/default/contact/something.py # this model and all on the same fodler
> is only executes when http:///app/default/contact is requested
>
> Imagine a bigger app with too many tables, too many validators etc. there
> are no need to always load models of 'contact' page.
>
>
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
>
>
>
> On Sun, May 1, 2011 at 11:50 PM, pbreit  wrote:
>
>> Am I understanding correctly that we could save memory by not loading all
>> models on all page views? That seems like a reasonable objective.
>
>
>


[web2py] Re: Confusion using experts4solutions

2011-05-01 Thread Massimo Di Pierro
experts4solutions should be considered an association of web2py
experts.

experts4solutions does not take programming jobs. The members and/or
the companies of members take the jobs and write the contracts.

As an association we do not open the doors to everybody but only to
those programmers who have proven themselves with web2py. The
acceptance rules currently require my approval or 5 endorsements. They
will be made even more strict as time goes by. By restricting
membership the association guarantees the professionally of its
members.

You can read more about the services provided by the association
directly on the web site.

It is my experience that members have no interest in competing for the
jobs which are usually posted on oDesk, rent-a-coder which tipically
range $100-$1000. I know members who have contracted jobs for $5000
and above. At least three members have engaged in long term contracts.
Two members been switched career as a result.

The goal of experts4solution is not to provide cheap workforce but to
provide highly skilled workforce.

If you email the association, the emails get forwarded to
http://groups.google.com/group/experts4solutions (*)
and we all (should) get them.
I strongly recommend that you contact individual members that are
close to you geographically.
In general, interaction in person works better.

Massimo

(*) If you are an approved member of experts4solution but not member
of the google group, this is a mistake and please email me to let me
know. the two are sync-ed manually and errors may occur.



On May 1, 9:17 pm, Steve  wrote:
> I too would like to know what is the best way to interact with the
> experts4solutions list.  Do we just spam the list with the work I
> have?
>


Re: [web2py] Re: help testing

2011-05-01 Thread Bruno Rocha
On Mon, May 2, 2011 at 12:04 AM, pbreit  wrote:

> Would there be an approach to this using some sort of loading scheme? The
> directory approach seems like it could get cumbersome as well as be
> problematic for models that are used in multiple controllers.


I agree that some kind of router is a better approach, but this folder
approach is just the start, i see no problem for having both ways in the
future, the folder way is the default, the routed way can be optional.


[web2py] Re: help testing

2011-05-01 Thread Massimo Di Pierro
It works for me but under the hood there were a few changes.

We need to make sure that indeed we did not break anything and in
particular we did not break backward compatibility.

Some people, like Thadeus, have been using subfolders already. I do
not think that should be considered a backward compatibility issue but
I would like to know if other people have been doing that.

Massimo

On May 1, 10:13 pm, Gilson Filho  wrote:
> Will need more tests or already is scheduled to play for production?
> _
> *Gilson Filho*
> *Web Developerhttp://gilsondev.com*
>
> 2011/5/2 Bruno Rocha 
>
>
>
>
>
>
>
> > Yes, lets say we have this app:
>
> > models/general.py # this model and all models in root folder is always
> > executed
>
> > models/default/something.py # this model and all on the same folder is only
> > executed whenhttp:///app/default/*is requested
>
> > models/default/index/something.py # this model and all on the same fodler
> > is only executes whenhttp:///app/default/indexis requested
>
> > models/default/contact/something.py # this model and all on the same fodler
> > is only executes whenhttp:///app/default/contactis requested
>
> > Imagine a bigger app with too many tables, too many validators etc. there
> > are no need to always load models of 'contact' page.
>
> > --
> > Bruno Rocha
> > [ About me:http://zerp.ly/rochacbruno]
>
> > On Sun, May 1, 2011 at 11:50 PM, pbreit  wrote:
>
> >> Am I understanding correctly that we could save memory by not loading all
> >> models on all page views? That seems like a reasonable objective.


Re: [web2py] Re: help testing

2011-05-01 Thread Gilson Filho
Breaking with other versions will be difficult, because they will be using
templates tothe application level. With that would not cause any bugs.
Perhaps what needs to betested is the automatic update of the framework.
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/5/2 Massimo Di Pierro 

> It works for me but under the hood there were a few changes.
>
> We need to make sure that indeed we did not break anything and in
> particular we did not break backward compatibility.
>
> Some people, like Thadeus, have been using subfolders already. I do
> not think that should be considered a backward compatibility issue but
> I would like to know if other people have been doing that.
>
> Massimo
>
> On May 1, 10:13 pm, Gilson Filho  wrote:
> > Will need more tests or already is scheduled to play for production?
> > _
> > *Gilson Filho*
> > *Web Developerhttp://gilsondev.com*
> >
> > 2011/5/2 Bruno Rocha 
> >
> >
> >
> >
> >
> >
> >
> > > Yes, lets say we have this app:
> >
> > > models/general.py # this model and all models in root folder is always
> > > executed
> >
> > > models/default/something.py # this model and all on the same folder is
> only
> > > executed whenhttp:///app/default/*is requested
> >
> > > models/default/index/something.py # this model and all on the same
> fodler
> > > is only executes whenhttp:///app/default/indexis requested
> >
> > > models/default/contact/something.py # this model and all on the same
> fodler
> > > is only executes whenhttp:///app/default/contactis requested
> >
> > > Imagine a bigger app with too many tables, too many validators etc.
> there
> > > are no need to always load models of 'contact' page.
> >
> > > --
> > > Bruno Rocha
> > > [ About me:http://zerp.ly/rochacbruno]
> >
> > > On Sun, May 1, 2011 at 11:50 PM, pbreit 
> wrote:
> >
> > >> Am I understanding correctly that we could save memory by not loading
> all
> > >> models on all page views? That seems like a reasonable objective.
>


[web2py] How do you manage/version you applications and web2py core?

2011-05-01 Thread luckysmack
Im somewhat new to web2py, having tried out django first. I like this
much more. But one thing im still wondering is how others manage their
web2py installations vs the applications in them. Especially when
needing to push an application to your server/live site. Normally
(like iwth django, or even coming from php using other frameworks)
your application is in a ocmpletely different directory than the
framework itself. This means that you only really edit in your
applications directory, whereas with web2py you generally have your
IDE's document root as the base of web2py. When editing/working on a
project do you point your ide to just your applications root? Do you
keep the entire web2py directory versioned and push to the server when
needed. Or do you keep web2py and the applicaiton dir in seperate
repos (like with git submodules).

Basically im curious on two things. How do you guys manage versioning
for your web2py installs vs the apps themselves. And how to you manage
taking your apps from development to production.


Re: [web2py] Re: help testing

2011-05-01 Thread Bruno Rocha
On Mon, May 2, 2011 at 12:25 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> It works for me but under the hood there were a few changes.
>
> We need to make sure that indeed we did not break anything and in
> particular we did not break backward compatibility.


For me this does not breaks compatibility unless there are people using
subfolders for order execution arrangement. (which is not a documented
feature, and not a recommended practice)

Developers will need to think twice when modeling applications for choosing
what to put in specific folder or not, but this matters only for bigger or
componentized apps, small apps and prototypes or legacy apps would have just
to work on the old way (all models on root folder).

In the future, a routed approach will be a better way to define which model
needs to be executed for each controller request.

The automatic update will not breaks because it does not update user
applications.


[web2py] expression question

2011-05-01 Thread niknok
I'm wondering why this doesn't work:

delta=datetime.timedelta(seconds=15*60)
db(request.now>(db.qa.time_start+delta)).count()

TypeError: can't compare datetime.datetime to Expression


while this one does:

delta=datetime.timedelta(seconds=15*60)
db(db.qa.time_start<(request.now-delta)).count()


Struggled with that line all afternoon, and out of frustration decided
to transpose the values, and suddenly it worked.

/r
Nik


Re: [web2py] How do you manage/version you applications and web2py core?

2011-05-01 Thread Bruno Rocha
I do that with mercurial (HG)

I have web2py folder as an hg repo, when a new version of web2py is released
I pull my web2py folder to the current release, in development I always work
with trunk.

Inside applications folder I have one HG repo for each application, on
development I push that to bitbucket, then on my production server I just
pull the specific application.

Note that web2py can work with applications on different folder, you can
have apps in /home/myapplications and web2py in /var/web2py.
--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]


[web2py] joins in crud select

2011-05-01 Thread niknok
Can I do joins in CRUD?

I'm getting a 404 Not Found error with this: 


rows=crud.select(db((db.qa.candidate==user_id)&(db.quiz.id==db.qa.quiz)))


But the following works alright: 

rows=db((db.qa.candidate==user_id)&(db.qa.quiz==db.quiz.id)).select()



/r
Nik 


[web2py] button action

2011-05-01 Thread niknok
I have this button that redirects to a URL:

form[0][-1][1].append(INPUT(_type='button',_value=T('Previous')
,_onclick='document.location="%s"' 
%URL("question")))

what do I add to _onclick to do the following:
1) session.current_item -=1
2) redirect(URL('question'))

/r
Nik


[web2py] Re: jquery for triggering change in dropdown list values

2011-05-01 Thread niknok
Thanks Anthony.

I've actually tried that, but it was a tad too slow for me. :(

On May 1, 12:32 pm, Anthony  wrote:
> This may help:http://www.web2pyslices.com/main/slices/take_slice/85
>
>
>
>
>
>
>
> On Saturday, April 30, 2011 10:53:16 PM UTC-4, niknok wrote:
> > I am clueless about jQuery, but I'm wondering if there's any script I can
> > use to trigger a change the values in one dropdown list after selecting a
> > value from another dropdown list in a CRUD form?
>
> > Right now, I used a jquery script I picked up in the list that initiates a
> > submit action. The consequence of that, however, is that it submits the
> > whole form while there are other fields yet to be filled up.
>
> > Thanks.
>
> > /r Nik


[web2py] Re: How do you manage/version you applications and web2py core?

2011-05-01 Thread luckysmack
How would i use applications in a different directory? would there be
any pros/cons to doing it like this? After getting an application
setup i find (so far, more advanced stuff might be different) i dont
edit the core web2py stuff very often. I can see the application in a
different dir could be easier for managing with git/hg. Does this have
any effect with the admin app? Would the admin app even be able to see
the apps if they are outside of the web2py/applications dir?

On May 1, 8:49 pm, Bruno Rocha  wrote:
> I do that with mercurial (HG)
>
> I have web2py folder as an hg repo, when a new version of web2py is released
> I pull my web2py folder to the current release, in development I always work
> with trunk.
>
> Inside applications folder I have one HG repo for each application, on
> development I push that to bitbucket, then on my production server I just
> pull the specific application.
>
> Note that web2py can work with applications on different folder, you can
> have apps in /home/myapplications and web2py in /var/web2py.
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]


Re: [web2py] Re: help testing

2011-05-01 Thread pbreit
Except that I don't have any models that are specific to components. Will I 
need to duplicate model files into each folder corresponding to the 
controllers that use them? My models seem to be fairly cross-controller so 
I'm not sure how I will use this approach.

Re: [web2py] Re: help testing

2011-05-01 Thread pbreit
This screams "import" to me.

=== default.py ===
from myapp.models import db

def index()
...


[web2py] Re: How do you manage/version you applications and web2py core?

2011-05-01 Thread pbreit
I do exactly the same as Bruno, including pushing to BitBucket.

I assume a symbolic link should work but it's not really necessary. If you 
create your HG repos at the app level, it all works fine.


[web2py] Re: How do you manage/version you applications and web2py core?

2011-05-01 Thread luckysmack
Cool, i just added my app to the .hgignore file to keep web2py core
updated. I have my app setup with git and will be posting it on github
when its ready. I think for the time being ill just keep the apps in
the web2py directory and just point the domain to look at the app.
Thanks guys.

On May 1, 10:49 pm, pbreit  wrote:
> I do exactly the same as Bruno, including pushing to BitBucket.
>
> I assume a symbolic link should work but it's not really necessary. If you
> create your HG repos at the app level, it all works fine.


Re: [web2py] Re: help testing

2011-05-01 Thread Bruno Rocha
On Mon, May 2, 2011 at 2:38 AM, pbreit  wrote:

> Except that I don't have any models that are specific to components. Will I
> need to duplicate model files into each folder corresponding to the
> controllers that use them?


No, just leave all your models on root folder and everything will run as is,
if you have a component with a specific need for a model, put that on
specific folder.