[web2py] Re: plugin_wiki - Ajax to save pages?

2010-07-29 Thread mdipierro
Good idea. I'll take the patch.

On Jul 29, 7:44 pm, Bruno Rocha  wrote:
>  to save a page in plugin_wiki page editor, we have to submit the page or
> focus in page title then hit enter.
>
> As I am writing large pages, I have 2 displays when editing a page, first to
> edit the code, and the other to frequently refresh and view the result.
>
> It is so annoying to submit the page every time I need to have a preview, is
> there any way to save the page code via Ajax, just like appadmin edit_area ?
>
> or may be, to have a preview panel, as you can see when editing a slice on <
> web2pyslices.com> or the one used to edit markdown in 
>
> Tks
>
> --
>
> http://rochacbruno.com.br


Re: [web2py] What's the best way to get code completion / tooltip information ?

2010-07-29 Thread Thadeus Burgess
gluon.

Look in gluon/compileapp.py in build_environment. You could use that
as a template for the autocomplete.

--
Thadeus





On Thu, Jul 29, 2010 at 3:22 PM, Stef Mientki  wrote:
>  hello,
>
> my viewer has changed into an quit handy editor,
> and now I want more: autocompletion and tooltip information.
>
> The autocompletion and tooltip generator,
> searches for classes and methods,
> looks up the documentation and analyses the method arguments.
>
> Now as web2py is (at least I think) a strange package in the pure Python 
> sense,
> it's not obvious to me
> - which paths should I add to the Python system path ?
> - which modules should I import, to get the most common objects into the 
> completion / tooltip
> information ?
>
> (If it succeeds, the program will be free available under BSD license)
>
> thanks,
> Stef Mientki
>


[web2py] plugin_wiki - how to define the target to an external link?

2010-07-29 Thread Bruno Rocha
Any way to define the target="_blank" for  [["a link" http://someurl.com]]

any way like this: [["a link" http://someurl.com "_blank"]] ???

-- 

http://rochacbruno.com.br


Re: [web2py] Re: question/suggestion about URL, controller

2010-07-29 Thread Thadeus Burgess
Massimo, you cannot

I am sorry but that would break backwards compatibility.

Say if in certain apps you have this (in alot of the earlier apps on
web2py.com do this too)

URL(request.application, 'static', 'logo.png')

Or

URL(request.application, 'default', 'index')

Unfortunately, we cannot re-arrange the variables defined in URL from this order

def URL(
a=None,
c=None,
f=None,
r=None,
args=[],
vars={},
anchor='',
extension=None,
env=None
):

--
Thadeus





On Thu, Jul 29, 2010 at 8:23 PM, Michele Comitini
 wrote:
> thumbs up!
>
> 2010/7/30 mdipierro 
>>
>> I took it one step further...
>>
>> >>> URL()
>> /app/default/index
>> >>> URL('test')
>> /app/default/test
>> >>> def test(): return 'test'
>> >>> URL(test)
>> /app/default/test
>> >>> URL('static','filename')
>> /app/static/filename
>> >>> URL('other','static','filename')
>> /other/static/filename
>>
>> No more r=, c=, f= needed but all optional.
>>
>>
>> On Jul 28, 6:28 pm, Thadeus Burgess  wrote:
>> > SORRY! =D
>> >
>> > --
>> > Thadeus
>> >
>> > On Wed, Jul 28, 2010 at 6:22 PM, mdipierro 
>> > wrote:
>> > > WOW. Uploading to trunk. Now I need to revise the book again. :-(
>> >
>> > > On Jul 28, 5:51 pm, Thadeus Burgess  wrote:
>> > >> >>> URL(r=request, c='hello', f='world', args=['hi'],
>> > >> >>> vars={'q':'greetings'}, anchor='the_world')
>> >
>> > >> '/welcome/hello/world/hi#the_world?q=greetings'>>> URL(c='hello',
>> > >> f='world', args=['hi'], vars={'q':'greetings'}, anchor='the_world')
>> >
>> > >> '/welcome/hello/world/hi#the_world?q=greetings'
>> >
>> > >> Attached is the diff
>> >
>> > >> This should not effect any current usages of URL, but from this point
>> > >> forward we shouldn't have to specify r=request!
>> >
>> > >> --
>> > >> Thadeus
>> >
>> > >> On Wed, Jul 28, 2010 at 5:21 PM, mdipierro 
>> > >> wrote:
>> > >> > ok
>> >
>> > >> > On Jul 28, 4:52 pm, Thadeus Burgess  wrote:
>> > >> >> For a little more advanced version of what Massimo just posted:
>> >
>> > >> >> This allows you to use both.
>> >
>> > >> >> URL(r=request, c=, f=.)
>> > >> >> and
>> > >> >> URL(c=, f=.)
>> >
>> > >>
>> > >> >> >>http://packages.python.org/web2py_utils/init.html#gurlhttp://hg.thade..
>> >
>> > >> >> The reason we have to pass the request to URL each time is because
>> > >> >> it
>> > >> >> is just imported into the context. Since it is just a python
>> > >> >> function,
>> > >> >> it has no knowledge of request.
>> >
>> > >> >> Why can't we do something like gURL from within web2py? When
>> > >> >> building
>> > >> >> the context, why can't we make URL a loaded function that will get
>> > >> >> request passed to it, exactly how gURL works.
>> >
>> > >> >> Effectively, we won't have to pass request into URL function
>> > >> >> anymore... ever.
>> >
>> > >> >> If your interested, I can work on the patch.
>> >
>> > >> >> --
>> > >> >> Thadeus
>> >
>> > >> >> On Wed, Jul 28, 2010 at 3:56 PM, mdipierro
>> > >> >>  wrote:
>> > >> >> > 1) It is a bit more complex because of static, appadmin, and
>> > >> >> > admin.
>> > >> >> > You can map
>> >
>> > >> >> > /function/var1/var2
>> >
>> > >> >> > into
>> >
>> > >> >> > /app/controller/function/var1/var2
>> >
>> > >> >> > using a file routes.py
>> > >> >> >  --- begin file
>> > >> >> > routes_in=[
>> > >> >> >  ('/admin/$anything','/admin/$anything'),
>> > >> >> >  ('/static/$anything','/app/static/$anything'),
>> > >> >> >  ('/appadmin/$anything','/app/appadmin/$anything'),
>> > >> >> >  ('/$anything','/app/default/$anything'),
>> > >> >> > ]
>> > >> >> > routes_out=[(y,x) for (x,y) in routes_in]
>> > >> >> > - end file
>> >
>> > >> >> > 2) in db.py define
>> >
>> > >> >> > def url(f,args={},vars={}):
>> > >> >> >      return URL(r=request,f=f,args=args,vars=vars)
>> > >> >> > def go(f,args={},vars={},flash=''):
>> > >> >> >      session.flash=flash
>> > >> >> >      return go(url(f=f,args=args,vars=vars))
>> >
>> > >> >> > and use
>> >
>> > >> >> >    url('index')
>> >
>> > >> >> > or
>> >
>> > >> >> >   go('index',flash='you are being redirected')
>> >
>> > >> >> > I do it all the time
>> >
>> > >> >> > On Jul 28, 3:29 pm, VP  wrote:
>> > >> >> >> I'm a newbie, so my questions probably have easy answers, but
>> > >> >> >> anyway.
>> > >> >> >> Among a few things, there are two I don't understand and think
>> > >> >> >> can be
>> > >> >> >> simplified.
>> >
>> > >> >> >> 1. this url:   app/controller/function/var1/var2
>> >
>> > >> >> >> For me at least, most of the time I probably have only one
>> > >> >> >> controller.   If there is one controller, may be we should get
>> > >> >> >> rid of
>> > >> >> >> "controller" in the url?    This will be sufficient:
>> > >> >> >> app/f/a/b/c
>> >
>> > >> >> >> 2.  Similarly, most of the time I have only one app (current
>> > >> >> >> app).
>> > >> >> >> But I use URL() a lot and every time I have to pass in request
>> > >> >> >> like
>> > >> >> >> this URL(r=request, f='foo').
>> >
>> > >> >> >> 

Re: [web2py] Re: question/suggestion about URL, controller

2010-07-29 Thread Michele Comitini
thumbs up!

2010/7/30 mdipierro 

> I took it one step further...
>
> >>> URL()
> /app/default/index
> >>> URL('test')
> /app/default/test
> >>> def test(): return 'test'
> >>> URL(test)
> /app/default/test
> >>> URL('static','filename')
> /app/static/filename
> >>> URL('other','static','filename')
> /other/static/filename
>
> No more r=, c=, f= needed but all optional.
>
>
> On Jul 28, 6:28 pm, Thadeus Burgess  wrote:
> > SORRY! =D
> >
> > --
> > Thadeus
> >
> > On Wed, Jul 28, 2010 at 6:22 PM, mdipierro 
> wrote:
> > > WOW. Uploading to trunk. Now I need to revise the book again. :-(
> >
> > > On Jul 28, 5:51 pm, Thadeus Burgess  wrote:
> > >> >>> URL(r=request, c='hello', f='world', args=['hi'],
> vars={'q':'greetings'}, anchor='the_world')
> >
> > >> '/welcome/hello/world/hi#the_world?q=greetings'>>> URL(c='hello',
> f='world', args=['hi'], vars={'q':'greetings'}, anchor='the_world')
> >
> > >> '/welcome/hello/world/hi#the_world?q=greetings'
> >
> > >> Attached is the diff
> >
> > >> This should not effect any current usages of URL, but from this point
> > >> forward we shouldn't have to specify r=request!
> >
> > >> --
> > >> Thadeus
> >
> > >> On Wed, Jul 28, 2010 at 5:21 PM, mdipierro 
> wrote:
> > >> > ok
> >
> > >> > On Jul 28, 4:52 pm, Thadeus Burgess  wrote:
> > >> >> For a little more advanced version of what Massimo just posted:
> >
> > >> >> This allows you to use both.
> >
> > >> >> URL(r=request, c=, f=.)
> > >> >> and
> > >> >> URL(c=, f=.)
> >
> > >> >>
> http://packages.python.org/web2py_utils/init.html#gurlhttp://hg.thade
> ..
> >
> > >> >> The reason we have to pass the request to URL each time is because
> it
> > >> >> is just imported into the context. Since it is just a python
> function,
> > >> >> it has no knowledge of request.
> >
> > >> >> Why can't we do something like gURL from within web2py? When
> building
> > >> >> the context, why can't we make URL a loaded function that will get
> > >> >> request passed to it, exactly how gURL works.
> >
> > >> >> Effectively, we won't have to pass request into URL function
> anymore... ever.
> >
> > >> >> If your interested, I can work on the patch.
> >
> > >> >> --
> > >> >> Thadeus
> >
> > >> >> On Wed, Jul 28, 2010 at 3:56 PM, mdipierro <
> mdipie...@cs.depaul.edu> wrote:
> > >> >> > 1) It is a bit more complex because of static, appadmin, and
> admin.
> > >> >> > You can map
> >
> > >> >> > /function/var1/var2
> >
> > >> >> > into
> >
> > >> >> > /app/controller/function/var1/var2
> >
> > >> >> > using a file routes.py
> > >> >> >  --- begin file
> > >> >> > routes_in=[
> > >> >> >  ('/admin/$anything','/admin/$anything'),
> > >> >> >  ('/static/$anything','/app/static/$anything'),
> > >> >> >  ('/appadmin/$anything','/app/appadmin/$anything'),
> > >> >> >  ('/$anything','/app/default/$anything'),
> > >> >> > ]
> > >> >> > routes_out=[(y,x) for (x,y) in routes_in]
> > >> >> > - end file
> >
> > >> >> > 2) in db.py define
> >
> > >> >> > def url(f,args={},vars={}):
> > >> >> >  return URL(r=request,f=f,args=args,vars=vars)
> > >> >> > def go(f,args={},vars={},flash=''):
> > >> >> >  session.flash=flash
> > >> >> >  return go(url(f=f,args=args,vars=vars))
> >
> > >> >> > and use
> >
> > >> >> >url('index')
> >
> > >> >> > or
> >
> > >> >> >   go('index',flash='you are being redirected')
> >
> > >> >> > I do it all the time
> >
> > >> >> > On Jul 28, 3:29 pm, VP  wrote:
> > >> >> >> I'm a newbie, so my questions probably have easy answers, but
> anyway.
> > >> >> >> Among a few things, there are two I don't understand and think
> can be
> > >> >> >> simplified.
> >
> > >> >> >> 1. this url:   app/controller/function/var1/var2
> >
> > >> >> >> For me at least, most of the time I probably have only one
> > >> >> >> controller.   If there is one controller, may be we should get
> rid of
> > >> >> >> "controller" in the url?This will be sufficient: app/f/a/b/c
> >
> > >> >> >> 2.  Similarly, most of the time I have only one app (current
> app).
> > >> >> >> But I use URL() a lot and every time I have to pass in request
> like
> > >> >> >> this URL(r=request, f='foo').
> >
> > >> >> >> Why do I have to pass in request if I have only one app, one
> > >> >> >> controller?
> >
> > >> >> >> Furthermore, isn't request supposed to be global?  If so, do we
> have
> > >> >> >> to pass it in?
> >
> > >>  url_proxy.diff
> > >> 1KViewDownload
>


[web2py] plugin_wiki - Ajax to save pages?

2010-07-29 Thread Bruno Rocha
 to save a page in plugin_wiki page editor, we have to submit the page or
focus in page title then hit enter.

As I am writing large pages, I have 2 displays when editing a page, first to
edit the code, and the other to frequently refresh and view the result.

It is so annoying to submit the page every time I need to have a preview, is
there any way to save the page code via Ajax, just like appadmin edit_area ?

or may be, to have a preview panel, as you can see when editing a slice on <
web2pyslices.com> or the one used to edit markdown in 

Tks

-- 

http://rochacbruno.com.br


[web2py] Re: question/suggestion about URL, controller

2010-07-29 Thread mdipierro
I took it one step further...

>>> URL()
/app/default/index
>>> URL('test')
/app/default/test
>>> def test(): return 'test'
>>> URL(test)
/app/default/test
>>> URL('static','filename')
/app/static/filename
>>> URL('other','static','filename')
/other/static/filename

No more r=, c=, f= needed but all optional.


On Jul 28, 6:28 pm, Thadeus Burgess  wrote:
> SORRY! =D
>
> --
> Thadeus
>
> On Wed, Jul 28, 2010 at 6:22 PM, mdipierro  wrote:
> > WOW. Uploading to trunk. Now I need to revise the book again. :-(
>
> > On Jul 28, 5:51 pm, Thadeus Burgess  wrote:
> >> >>> URL(r=request, c='hello', f='world', args=['hi'], 
> >> >>> vars={'q':'greetings'}, anchor='the_world')
>
> >> '/welcome/hello/world/hi#the_world?q=greetings'>>> URL(c='hello', 
> >> f='world', args=['hi'], vars={'q':'greetings'}, anchor='the_world')
>
> >> '/welcome/hello/world/hi#the_world?q=greetings'
>
> >> Attached is the diff
>
> >> This should not effect any current usages of URL, but from this point
> >> forward we shouldn't have to specify r=request!
>
> >> --
> >> Thadeus
>
> >> On Wed, Jul 28, 2010 at 5:21 PM, mdipierro  wrote:
> >> > ok
>
> >> > On Jul 28, 4:52 pm, Thadeus Burgess  wrote:
> >> >> For a little more advanced version of what Massimo just posted:
>
> >> >> This allows you to use both.
>
> >> >> URL(r=request, c=, f=.)
> >> >> and
> >> >> URL(c=, f=.)
>
> >> >>http://packages.python.org/web2py_utils/init.html#gurlhttp://hg.thade..
>
> >> >> The reason we have to pass the request to URL each time is because it
> >> >> is just imported into the context. Since it is just a python function,
> >> >> it has no knowledge of request.
>
> >> >> Why can't we do something like gURL from within web2py? When building
> >> >> the context, why can't we make URL a loaded function that will get
> >> >> request passed to it, exactly how gURL works.
>
> >> >> Effectively, we won't have to pass request into URL function anymore... 
> >> >> ever.
>
> >> >> If your interested, I can work on the patch.
>
> >> >> --
> >> >> Thadeus
>
> >> >> On Wed, Jul 28, 2010 at 3:56 PM, mdipierro  
> >> >> wrote:
> >> >> > 1) It is a bit more complex because of static, appadmin, and admin.
> >> >> > You can map
>
> >> >> > /function/var1/var2
>
> >> >> > into
>
> >> >> > /app/controller/function/var1/var2
>
> >> >> > using a file routes.py
> >> >> >  --- begin file
> >> >> > routes_in=[
> >> >> >  ('/admin/$anything','/admin/$anything'),
> >> >> >  ('/static/$anything','/app/static/$anything'),
> >> >> >  ('/appadmin/$anything','/app/appadmin/$anything'),
> >> >> >  ('/$anything','/app/default/$anything'),
> >> >> > ]
> >> >> > routes_out=[(y,x) for (x,y) in routes_in]
> >> >> > - end file
>
> >> >> > 2) in db.py define
>
> >> >> > def url(f,args={},vars={}):
> >> >> >      return URL(r=request,f=f,args=args,vars=vars)
> >> >> > def go(f,args={},vars={},flash=''):
> >> >> >      session.flash=flash
> >> >> >      return go(url(f=f,args=args,vars=vars))
>
> >> >> > and use
>
> >> >> >    url('index')
>
> >> >> > or
>
> >> >> >   go('index',flash='you are being redirected')
>
> >> >> > I do it all the time
>
> >> >> > On Jul 28, 3:29 pm, VP  wrote:
> >> >> >> I'm a newbie, so my questions probably have easy answers, but anyway.
> >> >> >> Among a few things, there are two I don't understand and think can be
> >> >> >> simplified.
>
> >> >> >> 1. this url:   app/controller/function/var1/var2
>
> >> >> >> For me at least, most of the time I probably have only one
> >> >> >> controller.   If there is one controller, may be we should get rid of
> >> >> >> "controller" in the url?    This will be sufficient: app/f/a/b/c
>
> >> >> >> 2.  Similarly, most of the time I have only one app (current app).
> >> >> >> But I use URL() a lot and every time I have to pass in request like
> >> >> >> this URL(r=request, f='foo').
>
> >> >> >> Why do I have to pass in request if I have only one app, one
> >> >> >> controller?
>
> >> >> >> Furthermore, isn't request supposed to be global?  If so, do we have
> >> >> >> to pass it in?
>
> >>  url_proxy.diff
> >> 1KViewDownload


Re: [web2py] Re: id field representation (.represent) pb on unnormalized table crud.read

2010-07-29 Thread Jean-Guy

Thanks!

I got it like this :

db.atable.othertablefield_id.represent=\
 lambda value: "%(num)s" % (db.v_othertable_num[value] or {'num':'unkown'})


;-)

Jonhy


On 2010-07-29 18:18, mdipierro wrote:

please try:

db.atable.othertablefield_id.represent=\
  lambda value: "%(num)s" % (db.v_othertable_num[value] or
{'num','unkown'}

(this will fix if the problem is that record is None)
and/or

db.atable.othertablefield_id.represent=\
  lambda value: str(db.v_othertable_num[value].num)

(this will fix it if it is a type conversion problem)


On Jul 29, 4:55 pm, Jean-Guy  wrote:
   

>  Hello,
>
>  I define the way to show the id field in crud.read like this :
>
>  db.atable.othertablefield_id.represent=\
>lambda value: "%(num)s" %db.v_othertable_num[value]
>
>  Placed in model.
>
>  v_othertable_num is a database view of the related table because the
>  number are formed of many fields so I concatenated them into a unique
>  number with the view.
>
>  The problem is I have a unnormalized table in wich differents id fields
>  as to be (represented), but most of the time only one of them are
>  entered. The app break when crud.read return "None" because a field have
>  been let blank at the seizure. Here is the error :
>
>  Traceback(most recent call last):
>  File"/version_181-4/web2py/gluon/restricted.py",line178,inrestricted
>execccodeinenvironment
>  
File"/version_181-4/web2py/applications/app/controllers/default.py",line83,in
>  File"/version_181-4/web2py/gluon/globals.py",line96,in
>self._caller=lambdaf:f()
>  File"/version_181-4/web2py/gluon/tools.py",line2192,inf
>returnaction(*a, **b)
>  
File"/version_181-4/web2py/applications/app/controllers/default.py",line36,inread
>request.args[1])
>  File"/version_181-4/web2py/gluon/tools.py",line2797,inread
>formstyle=self.settings.formstyle
>  File"/version_181-4/web2py/gluon/sqlhtml.py",line687,in__init__
>inp=field.represent(default)
>  
File"/version_181-4/web2py/applications/app/models/default.py",line224,in
>lambdavalue:"%(num)s"%db.v_othertable_num[value]
>  TypeError:format requires a mapping
>
>  I used postgres as dbms backend with postgres sequence formatting style
>  (table_field_id_seq)...
>
>  I am not sure what the origin of the error... I don't know how to verify
>  if field are returning None...
>
>  Jonhy
 




[web2py] Re: Rocket is a good built-in server

2010-07-29 Thread mdipierro
40k/s on a local network on upload is slow. I am not sure if this a
rocket issue. Perhaps other uesrs have other feedback on this topic.
If you make any more tests please let us know.

Massimo

On Jul 29, 8:16 am, BearXu  wrote:
> We build a small file sharing webapp in our intranet. Sometimes we
> need to transfer a big file like 700M. First we use django and its
> built in server and when we upload, the server stops to serve other
> requests.
>
> Then I tried the web2py with rocket and I found it's more robust.
> Plus, at first we also tried Flask. but I found the debug part of it
> is not good to use.
>
> we use http to upload a file and the speed is only 40k/s。What can we
> do to impove the upload speed using http?
> We only use it in our intranet, and I think maybe the speed can be faster.


[web2py] Re: id field representation (.represent) pb on unnormalized table crud.read

2010-07-29 Thread mdipierro
please try:

db.atable.othertablefield_id.represent=\
 lambda value: "%(num)s" % (db.v_othertable_num[value] or
{'num','unkown'}

(this will fix if the problem is that record is None)
and/or

db.atable.othertablefield_id.represent=\
 lambda value: str(db.v_othertable_num[value].num)

(this will fix it if it is a type conversion problem)


On Jul 29, 4:55 pm, Jean-Guy  wrote:
> Hello,
>
> I define the way to show the id field in crud.read like this :
>
> db.atable.othertablefield_id.represent=\
>      lambda value: "%(num)s" %db.v_othertable_num[value]
>
> Placed in model.
>
> v_othertable_num is a database view of the related table because the
> number are formed of many fields so I concatenated them into a unique
> number with the view.
>
> The problem is I have a unnormalized table in wich differents id fields
> as to be (represented), but most of the time only one of them are
> entered. The app break when crud.read return "None" because a field have
> been let blank at the seizure. Here is the error :
>
> Traceback(most recent call last):
>    File"/version_181-4/web2py/gluon/restricted.py",line178,inrestricted
>      execccodeinenvironment
>    File"/version_181-4/web2py/applications/app/controllers/default.py"  
> ,line83,in
>    File"/version_181-4/web2py/gluon/globals.py",line96,in
>      self._caller=lambdaf:f()
>    File"/version_181-4/web2py/gluon/tools.py",line2192,inf
>      returnaction(*a, **b)
>    File"/version_181-4/web2py/applications/app/controllers/default.py"  
> ,line36,inread
>      request.args[1])
>    File"/version_181-4/web2py/gluon/tools.py",line2797,inread
>      formstyle=self.settings.formstyle
>    File"/version_181-4/web2py/gluon/sqlhtml.py",line687,in__init__
>      inp=field.represent(default)
>    File"/version_181-4/web2py/applications/app/models/default.py"  
> ,line224,in
>      lambdavalue:"%(num)s"%db.v_othertable_num[value]
> TypeError:format requires a mapping
>
> I used postgres as dbms backend with postgres sequence formatting style
> (table_field_id_seq)...
>
> I am not sure what the origin of the error... I don't know how to verify
> if field are returning None...
>
> Jonhy


[web2py] Re: reset password mail as html mail

2010-07-29 Thread mdipierro
Please try the code in trunk. If the message is '' it
should be sent automatically in html.

On Jul 29, 3:00 am, Rohan  wrote:
> I need to send reset password mail as html, so i created
>
> in db.py
>
> auth.messages.reset_password = [None, "Some html + Click on
> below link to reset your password\n\n
> http://'+request.env.http_host+URL(r=request,c='account',f='user',args=['reset_password'])+'/%(key)s
> "]
>
> in tools.py request_reset_password api, tries to generate key and
> substitute in the message above
>
> self.settings.mailer.send(to=form.vars.email,
>
> subject=self.messages.reset_password_subject,
>
> message=self.messages.reset_password % \
>
> dict(key=reset_password_key))
>
> but in case of reset_password message is tuple or list, the above
> substitution will result in an error.
>
> Any pointers how to send html message?


[web2py] Re: Redirect status of redirects via routes.py

2010-07-29 Thread mdipierro
None of them.

routes_in does not generates a response. The map is done internally
before dispatching. web2py only sees the new url, not the old one.

On Jul 29, 3:58 am, "ma...@rockiger.com" 
wrote:
> If I rewrite an old url to a new one in routes.py:
> What is the response? A 301(permanent) or a 302 (temporary)?
>
> I ask this question, because Google don't like temporary redirects
> and I don't want to mess with my Apache configuration if I can
> do the redirects with web2py.
>
> Thanks,
> Marco


[web2py] id field representation (.represent) pb on unnormalized table crud.read

2010-07-29 Thread Jean-Guy

Hello,

I define the way to show the id field in crud.read like this :

db.atable.othertablefield_id.represent=\
lambda value: "%(num)s" %db.v_othertable_num[value]

Placed in model.


v_othertable_num is a database view of the related table because the 
number are formed of many fields so I concatenated them into a unique 
number with the view.


The problem is I have a unnormalized table in wich differents id fields 
as to be (represented), but most of the time only one of them are 
entered. The app break when crud.read return "None" because a field have 
been let blank at the seizure. Here is the error :



Traceback(most recent call last):
  File"/version_181-4/web2py/gluon/restricted.py",line178,inrestricted
execccodeinenvironment
  File"/version_181-4/web2py/applications/app/controllers/default.py"  
,line83,in
  File"/version_181-4/web2py/gluon/globals.py",line96,in
self._caller=lambdaf:f()
  File"/version_181-4/web2py/gluon/tools.py",line2192,inf
returnaction(*a, **b)
  File"/version_181-4/web2py/applications/app/controllers/default.py"  
,line36,inread
request.args[1])
  File"/version_181-4/web2py/gluon/tools.py",line2797,inread
formstyle=self.settings.formstyle
  File"/version_181-4/web2py/gluon/sqlhtml.py",line687,in__init__
inp=field.represent(default)
  File"/version_181-4/web2py/applications/app/models/default.py"  
,line224,in
lambdavalue:"%(num)s"%db.v_othertable_num[value]
TypeError:format requires a mapping



I used postgres as dbms backend with postgres sequence formatting style 
(table_field_id_seq)...


I am not sure what the origin of the error... I don't know how to verify 
if field are returning None...


Jonhy


[web2py] Re: how to validate duplicity in a many to many table relationship?

2010-07-29 Thread mdipierro
You are dernormalizing in a link table. Not a good idea. Let's go it b
the book:

with crud.create(db.familia_riesgo)

The models are like:

db.define_table('familia',Field('ficha','string'),format='%(ficha)s')

db.define_table('riesgo',Field('nombre','string'),format='%(nombre)s')

db.define_table('familia_riesgo',
Field('familia_id',db.familia),
Field('riesgo_id',db.risiego)
)

# this is not necessary
# db.familia_riesgo.familia_id.requires=IS_IN_DB(db,'familia.ficha')

# this is one way to do it
db.familia_riesgo.riesgo_id.requires=IS_IN_DB(db,'riesgo.id','%
(nobre)s',
 
_and=IS_NOT_IN_DB(db(db.familia_riesgo.familia_id==request.vars.familia_id),'familia_riesgo.riesgo_id'))

On Jul 29, 9:17 am, web2py noob  wrote:
> what can I do for that?
>
> thanks in advance
>
> On 29 jul, 09:37, web2py noob  wrote:
>
> > On 29 jul, 09:20, mdipierro  wrote:
>
> > > It depends on how you insert records in familia_risiego
>
> > with crud.create(db.familia_riesgo)
>
> > The models are like:
>
> > db.define_table('familia',Field('ficha','string'))
>
> > db.define_table('riesgo',Field('nombre','string'))
>
> > db.define_table('familia_riesgo',
> >                 Field('familia_id','string'),
> >                 Field('riesgo_id','string')
> >                 )
>
> > db.familia_riesgo.familia_id.requires=IS_IN_DB(db,'familia.ficha')
>
> > # I'm tryied this, but don't work; just block the insert if riesgo_id
> > repeats even with a different familia_id
> > db.familia_riesgo.riesgo_id.requires=IS_IN_DB(db,'riesgo.nombre')),IS_NOT_IN_DB(db,'familia_riesgo.riesgo_id')
>
> > Regards.


[web2py] Re: How to map multiple 'tags' to a 'blog'

2010-07-29 Thread mdipierro
if you use

db.blog.tags.requires = IS_IN_DB(db, 'tags.id',
'tags.name',multiple=True)

than you are not using many2many but you are denormalizing. that means
db.blogs.tags has to be a string field and tags will be stored as '|3|
6|18|43|'.  So:

db.define_table ('blog',
Field('heading'),
Field('description' ,'text'),
Field('tags') # not Field('tags',db.tag)
  )

Massimo

On Jul 29, 12:24 pm, Abhiteja  wrote:
> Hi Gurus,
>
> I want to map multiple tags to a blog and allow users to select
> predefined tags to a blog header.
> I am able to see form for blogs and no errors shown after submit , but
> nothing is entered to DB.
>
> Am I missing something, please help me out.
>
> Thanks & regards
>
> Abhiteja
>
> PS: My setup info
> - I have following db definition: --
>
> db.define_table('tags',
>    Field('name')
>   )
>
> db.define_table ('blog',
>     Field('heading'),
>     Field('description' ,'text'),
>     Field('tags', db.tags)
>   )
>
> db.blogs.tags.requires = IS_IN_DB(db, 'tags.id', 'tags.name',
> multiple=True)
>
> --- Here is the controller definition for blogs: --
> def blogs():
>
>     form = SQLFORM(db.blogs)
>
> #    if form.accepts(request.vars, session):
> #        response.flash = 'new song addded'
>
>     records = SQLTABLE(db().select(db.blogs.ALL))
>     return dict(form=form, records=records)


[web2py] Re: Configure Apache to forward http://1.2.3.4/admin/ to https://1.2.3.4/admin/

2010-07-29 Thread mdipierro
If you find out how to force the redirection let me know and I will
update web2py-setup-ubuntu.sh

On Jul 29, 4:20 pm, mwolfe02  wrote:
> When I follow a ticket link it goes to http: instead of https:.  Can I
> configure Apache to recognizehttp://1.2.3.4/admin/and automatically
> redirect tohttps://1.2.3.4?
>
> This is more an annoyance than anything, but it has gotten really
> annoying.  I'm testing my new app in its future production environment
> (a virtual ubuntu server that I have root access to).  I am deploying
> it on Apache with mod_wsgi and SSL.  Whenever an error gets raised and
> I try to follow the link in the ticket, I get a 403 Forbidden error.
> The link in the ticket is a relative link, so it is trying to go 
> tohttp://1.2.3.4/admin/.../.  I have to manually change the url 
> tohttps://1.2.3.4/admin/.../.  Once I do that it works fine.
>
> I don't think it was behaving this way when I first set up the
> production environment, but I have been developing locally for awhile
> now, so I can't remember for sure.  I don't have the issue developing
> locally because web2py allows non-secure http access to the admin site
> for the localhost, 127.0.0.1.
>
> It's annoying for me because I'm trying to troubleshoot something (a
> problem that only shows up in my production environment, of course)
> and it takes an extra 5-10 seconds for me to get to the error stack.
> I'm hoping there is some apache configuration that will fix this
> problem, but I have very little experience configuring apache and
> after hours of trying to google my way to a solution I'm throwing up
> the white flag.


[web2py] Re: rocket performance issues

2010-07-29 Thread mdipierro
It is easy to fix things when problems are clearly reported. ;-)

On Jul 29, 4:38 pm, Michael Ellis  wrote:
> Seems to be.  I updated, restarted, and restored the colon after the
> comment.  No errors when I load the page.  Thanks for fixing it so quickly!
>
> On Thu, Jul 29, 2010 at 5:21 PM, mdipierro  wrote:
> > Can you check if this issue is solved in trunk?
>
> > Massimo
>
> > On Jul 29, 7:55 am, Michael Ellis  wrote:
> > > Has anything changed at tip in the view parser? Looks like there may
> > > be a problem now with colons at the end of comment lines. I have a
> > > view with the following that was working fine before I updated this
> > > morning.
>
> > > {{
> > > ## On entry, vars returned by controller are:
> > > ## problem, c, s, sc, wsc, problemid, currenthash, nparticipants
> > > bulbicon = URL(r=request, c="static", f="lightbulb32.png")
> > > gaugeicon = URL(r=request, c='static', f="gauge.png")
>
> > > ...
>
> > > *After updating it started issuing tickets about "Missing pass in
> > > view" and the ticket listing showed an unexpected indentation. *
>
> > > *
> > > *
>
> > > ## On entry, vars returned by controller are:
> > >     ## problem, c, s, sc, wsc, problemid, currenthash, nparticipants
> > >     bulbicon = URL (r=request
> > > , c="static", f="lightbulb32.png")
> > >     gaugeicon = URL (r=request
> > > , c='static', f="gauge.png")
>
> > > ...
>
> > > Removing the colon at the end of the comment fixed it.
>
> > > *
> > > *
>
> > > On Thu, Jul 29, 2010 at 8:19 AM, Michael Ellis <
> > michael.f.el...@gmail.com>wrote:
>
> > > > Testing under way...
>
> > > > (Iceberg, I'm running OS X 10.6.4)
>
> > > > Cheers,
> > > > Mike
>
> > > > On Thu, Jul 29, 2010 at 2:57 AM, mdipierro  > >wrote:
>
> > > >> Mike,
>
> > > >> I modified the expire_sessions.py in trunk and added a
> > > >> try:...execept... If the problem was that a file was locked and the
> > > >> cron task got stuck, it may be solved now. Can you test it?
>
> > > >> Massimo
>
> > > >> On Jul 28, 4:10 pm, MikeEllis  wrote:
> > > >> > Update: (Summarizes a couple of emails exchanged with Massimo)
>
> > > >> > Yesterday I found that my instance of web2py appeared be "leaking"
> > > >> > processes at about 1 per hour.  Massimo suggested running with -N to
> > > >> > disable cron.  I started two instances this way -- one under winpdb
> > > >> > and another directly.  They've been running almost 24 hours now and
> > > >> > neither has added any processes.  As noted earlier, my app has
> > nothing
> > > >> > in crontab. The admin and examples apps have the crontabs that are
> > "as
> > > >> > shipped" in v1.85.
>
> > > >> > Cheers,
> > > >> > Mike
>
> > > >> > On Jul 27, 12:17 pm, Jonathan Lundell  wrote:
>
> > > >> > > On Jul 27, 2010, at 9:01 AM, Michael Ellis wrote:
>
> > > >> > > > Thanks for the info about sloth. I may try it later.  It was
> > pretty
> > > >> easy to get what I needed with ipython:
>
> > > >> > > > procs = !ps ax | grep "web2py"
> > > >> > > > pids = [r[0] for r in procs.fields()[0:-2]]
> > > >> > > > for p in pids:
> > > >> > > >      print p
> > > >> > > >      !lsof | grep $p | wc
>
> > > >> > > Also: sudo launchctl limit maxfiles
>
> > > >> > > I see 256 by default. The second limit is the "hard limit", beyond
> > > >> which you can't configure (unlimited in this case).
>
> >http://serverfault.com/questions/15564/where-are-the-default-ulimits-.
> > > >> ..


Re: [web2py] Re: rocket performance issues

2010-07-29 Thread Michael Ellis
Seems to be.  I updated, restarted, and restored the colon after the
comment.  No errors when I load the page.  Thanks for fixing it so quickly!



On Thu, Jul 29, 2010 at 5:21 PM, mdipierro  wrote:

> Can you check if this issue is solved in trunk?
>
> Massimo
>
> On Jul 29, 7:55 am, Michael Ellis  wrote:
> > Has anything changed at tip in the view parser? Looks like there may
> > be a problem now with colons at the end of comment lines. I have a
> > view with the following that was working fine before I updated this
> > morning.
> >
> > {{
> > ## On entry, vars returned by controller are:
> > ## problem, c, s, sc, wsc, problemid, currenthash, nparticipants
> > bulbicon = URL(r=request, c="static", f="lightbulb32.png")
> > gaugeicon = URL(r=request, c='static', f="gauge.png")
> >
> > ...
> >
> > *After updating it started issuing tickets about "Missing pass in
> > view" and the ticket listing showed an unexpected indentation. *
> >
> > *
> > *
> >
> > ## On entry, vars returned by controller are:
> > ## problem, c, s, sc, wsc, problemid, currenthash, nparticipants
> > bulbicon = URL (r=request
> > , c="static", f="lightbulb32.png")
> > gaugeicon = URL (r=request
> > , c='static', f="gauge.png")
> >
> > ...
> >
> > Removing the colon at the end of the comment fixed it.
> >
> > *
> > *
> >
> > On Thu, Jul 29, 2010 at 8:19 AM, Michael Ellis <
> michael.f.el...@gmail.com>wrote:
> >
> > > Testing under way...
> >
> > > (Iceberg, I'm running OS X 10.6.4)
> >
> > > Cheers,
> > > Mike
> >
> > > On Thu, Jul 29, 2010 at 2:57 AM, mdipierro  >wrote:
> >
> > >> Mike,
> >
> > >> I modified the expire_sessions.py in trunk and added a
> > >> try:...execept... If the problem was that a file was locked and the
> > >> cron task got stuck, it may be solved now. Can you test it?
> >
> > >> Massimo
> >
> > >> On Jul 28, 4:10 pm, MikeEllis  wrote:
> > >> > Update: (Summarizes a couple of emails exchanged with Massimo)
> >
> > >> > Yesterday I found that my instance of web2py appeared be "leaking"
> > >> > processes at about 1 per hour.  Massimo suggested running with -N to
> > >> > disable cron.  I started two instances this way -- one under winpdb
> > >> > and another directly.  They've been running almost 24 hours now and
> > >> > neither has added any processes.  As noted earlier, my app has
> nothing
> > >> > in crontab. The admin and examples apps have the crontabs that are
> "as
> > >> > shipped" in v1.85.
> >
> > >> > Cheers,
> > >> > Mike
> >
> > >> > On Jul 27, 12:17 pm, Jonathan Lundell  wrote:
> >
> > >> > > On Jul 27, 2010, at 9:01 AM, Michael Ellis wrote:
> >
> > >> > > > Thanks for the info about sloth. I may try it later.  It was
> pretty
> > >> easy to get what I needed with ipython:
> >
> > >> > > > procs = !ps ax | grep "web2py"
> > >> > > > pids = [r[0] for r in procs.fields()[0:-2]]
> > >> > > > for p in pids:
> > >> > > >  print p
> > >> > > >  !lsof | grep $p | wc
> >
> > >> > > Also: sudo launchctl limit maxfiles
> >
> > >> > > I see 256 by default. The second limit is the "hard limit", beyond
> > >> which you can't configure (unlimited in this case).
> >
> > >> > >
> http://serverfault.com/questions/15564/where-are-the-default-ulimits-.
> > >> ..
>


[web2py] Re: Configure Apache to forward http://1.2.3.4/admin/ to https://1.2.3.4/admin/

2010-07-29 Thread mwolfe02
I just realized I can visit all of my web pages over https.  So the
simple solution for me is to test on the production server by visiting
https://1.2.3.4/ instead of http://1.2.3.4/.  Then when I click on the
relative ticket link it takes me to https://1.2.3.4/admin/.  All is
good.

Seems glaringly obvious now...

On Jul 29, 5:20 pm, mwolfe02  wrote:
> When I follow a ticket link it goes to http: instead of https:.  Can I
> configure Apache to recognizehttp://1.2.3.4/admin/and automatically
> redirect tohttps://1.2.3.4?
>
> This is more an annoyance than anything, but it has gotten really
> annoying.  I'm testing my new app in its future production environment
> (a virtual ubuntu server that I have root access to).  I am deploying
> it on Apache with mod_wsgi and SSL.  Whenever an error gets raised and
> I try to follow the link in the ticket, I get a 403 Forbidden error.
> The link in the ticket is a relative link, so it is trying to go 
> tohttp://1.2.3.4/admin/.../.  I have to manually change the url 
> tohttps://1.2.3.4/admin/.../.  Once I do that it works fine.
>
> I don't think it was behaving this way when I first set up the
> production environment, but I have been developing locally for awhile
> now, so I can't remember for sure.  I don't have the issue developing
> locally because web2py allows non-secure http access to the admin site
> for the localhost, 127.0.0.1.
>
> It's annoying for me because I'm trying to troubleshoot something (a
> problem that only shows up in my production environment, of course)
> and it takes an extra 5-10 seconds for me to get to the error stack.
> I'm hoping there is some apache configuration that will fix this
> problem, but I have very little experience configuring apache and
> after hours of trying to google my way to a solution I'm throwing up
> the white flag.


[web2py] Re: rocket performance issues

2010-07-29 Thread mdipierro
Can you check if this issue is solved in trunk?

Massimo

On Jul 29, 7:55 am, Michael Ellis  wrote:
> Has anything changed at tip in the view parser? Looks like there may
> be a problem now with colons at the end of comment lines. I have a
> view with the following that was working fine before I updated this
> morning.
>
> {{
> ## On entry, vars returned by controller are:
> ## problem, c, s, sc, wsc, problemid, currenthash, nparticipants
> bulbicon = URL(r=request, c="static", f="lightbulb32.png")
> gaugeicon = URL(r=request, c='static', f="gauge.png")
>
> ...
>
> *After updating it started issuing tickets about "Missing pass in
> view" and the ticket listing showed an unexpected indentation. *
>
> *
> *
>
> ## On entry, vars returned by controller are:
>     ## problem, c, s, sc, wsc, problemid, currenthash, nparticipants
>     bulbicon = URL (r=request
> , c="static", f="lightbulb32.png")
>     gaugeicon = URL (r=request
> , c='static', f="gauge.png")
>
> ...
>
> Removing the colon at the end of the comment fixed it.
>
> *
> *
>
> On Thu, Jul 29, 2010 at 8:19 AM, Michael Ellis 
> wrote:
>
> > Testing under way...
>
> > (Iceberg, I'm running OS X 10.6.4)
>
> > Cheers,
> > Mike
>
> > On Thu, Jul 29, 2010 at 2:57 AM, mdipierro wrote:
>
> >> Mike,
>
> >> I modified the expire_sessions.py in trunk and added a
> >> try:...execept... If the problem was that a file was locked and the
> >> cron task got stuck, it may be solved now. Can you test it?
>
> >> Massimo
>
> >> On Jul 28, 4:10 pm, MikeEllis  wrote:
> >> > Update: (Summarizes a couple of emails exchanged with Massimo)
>
> >> > Yesterday I found that my instance of web2py appeared be "leaking"
> >> > processes at about 1 per hour.  Massimo suggested running with -N to
> >> > disable cron.  I started two instances this way -- one under winpdb
> >> > and another directly.  They've been running almost 24 hours now and
> >> > neither has added any processes.  As noted earlier, my app has nothing
> >> > in crontab. The admin and examples apps have the crontabs that are "as
> >> > shipped" in v1.85.
>
> >> > Cheers,
> >> > Mike
>
> >> > On Jul 27, 12:17 pm, Jonathan Lundell  wrote:
>
> >> > > On Jul 27, 2010, at 9:01 AM, Michael Ellis wrote:
>
> >> > > > Thanks for the info about sloth. I may try it later.  It was pretty
> >> easy to get what I needed with ipython:
>
> >> > > > procs = !ps ax | grep "web2py"
> >> > > > pids = [r[0] for r in procs.fields()[0:-2]]
> >> > > > for p in pids:
> >> > > >      print p
> >> > > >      !lsof | grep $p | wc
>
> >> > > Also: sudo launchctl limit maxfiles
>
> >> > > I see 256 by default. The second limit is the "hard limit", beyond
> >> which you can't configure (unlimited in this case).
>
> >> > >http://serverfault.com/questions/15564/where-are-the-default-ulimits-.
> >> ..


[web2py] Configure Apache to forward http://1.2.3.4/admin/ to https://1.2.3.4/admin/

2010-07-29 Thread mwolfe02
When I follow a ticket link it goes to http: instead of https:.  Can I
configure Apache to recognize http://1.2.3.4/admin/ and automatically
redirect to https://1.2.3.4?

This is more an annoyance than anything, but it has gotten really
annoying.  I'm testing my new app in its future production environment
(a virtual ubuntu server that I have root access to).  I am deploying
it on Apache with mod_wsgi and SSL.  Whenever an error gets raised and
I try to follow the link in the ticket, I get a 403 Forbidden error.
The link in the ticket is a relative link, so it is trying to go to
http://1.2.3.4/admin/.../.  I have to manually change the url to
https://1.2.3.4/admin/.../.  Once I do that it works fine.

I don't think it was behaving this way when I first set up the
production environment, but I have been developing locally for awhile
now, so I can't remember for sure.  I don't have the issue developing
locally because web2py allows non-secure http access to the admin site
for the localhost, 127.0.0.1.

It's annoying for me because I'm trying to troubleshoot something (a
problem that only shows up in my production environment, of course)
and it takes an extra 5-10 seconds for me to get to the error stack.
I'm hoping there is some apache configuration that will fix this
problem, but I have very little experience configuring apache and
after hours of trying to google my way to a solution I'm throwing up
the white flag.


[web2py] Re: Getting Eclipse / Pydev running

2010-07-29 Thread pabloest
Thanks, Christopher.

At some point it may make sense for me to contribute my learnings to
the wiki. However, for now I'm just trying to get off the ground so I
can't provide much value.



On Jul 29, 1:58 pm, Christopher Steel  wrote:
> Hi Pabloest,
>
> We have started a Wiki with Web2py Eclipse and Maven Stuff where we
> publish working configurations. It may be helpful. If you want to
> contribute any additional info let me know.
>
> http://code.google.com/p/voa-web2py2eclipse/
>
> Cheer,
>
> Christopher Steel
>
> Voice of Access
>
> http://code.google.com/p/voa-web2py2eclipse/
>
> On 29 juil, 13:26, pabloest  wrote:
>
>
>
> > thanks.
> > normally I do, but I'm not sure where to do so in Eclipse.  Similarly
> > with the port and address (127.0.0.1).  I checked the debug config
> > parameters and variables and tried a bit there, but it didn't lead
> > anywhere.
>
> > On Jul 29, 9:54 am, Bruno Rocha  wrote:
>
> > > did you provide password parameter to run web2py.py?
>
> > > 2010/7/29 pabloest 
>
> > > > Hi,
>
> > > > I'm having some trouble simply getting started with Eclipse and Pydev
> > > > for web2py development.
> > > > I can't get into a debugging mode with web2py.py and the web server
> > > > will not even start. When I right-click and select Debug As > Python
> > > > Run, I get error messages that say:
> > > > -unexpected error setting up the debugger: socket closed
> > > > -pydev debugger: starting
> > > > Could not connect to localhost: 51530
> > > > Traceback (most recent call last):
> > > >  File "/Applications/eclipse/plugins/
> > > > org.python.pydev.debug_1.6.0.2010071813/pysrc/pydevd_comm.py", line
> > > > 341, in StartClient
> > > >    s.connect((host, port))
> > > >  File "", line 1, in connect
> > > > gaierror: (8, 'nodename nor servname provided, or not known')
>
> > > > I haven't modified my db.py files from the default.
> > > > It seems I am missing something quite basic as I haven't found
> > > > anything on this message board or others to indicate this is a normal
> > > > problem.
>
> > > > I'm running Eclipse IDE for Javascript Developers (by the way, does it
> > > > matter which Eclipse? I also tried with Eclipse Classic and got the
> > > > same results).
> > > > Eclipse v1.3.0.2
> > > > Eclipse Platform SDK v3.0.6
> > > > PyDev for Eclipse 1.6.0.2
> > > > PyDev Mylyn Integration 0.3.0
>
> > > > I'm on a Mac 10.5.8 and Python 2.6.5.
> > > > Any hints?
> > > > Thanks much.
>
> > > --
>
> > >http://rochacbruno.com.br


[web2py] Re: What's the best way to get code completion / tooltip information ?

2010-07-29 Thread mdipierro
Edit this file:

applications/admin/models/0.py

and change

TEXT_EDITOR = 'edit_area' or 'amy'

into

TEXT_EDITOR = 'amy'

amy editor provide web2py autocompletion. It is not the default
because does not work with every browser.

On Jul 29, 3:22 pm, Stef Mientki  wrote:
>  hello,
>
> my viewer has changed into an quit handy editor,
> and now I want more: autocompletion and tooltip information.
>
> The autocompletion and tooltip generator,
> searches for classes and methods,
> looks up the documentation and analyses the method arguments.
>
> Now as web2py is (at least I think) a strange package in the pure Python 
> sense,
> it's not obvious to me
> - which paths should I add to the Python system path ?
> - which modules should I import, to get the most common objects into the 
> completion / tooltip
> information ?
>
> (If it succeeds, the program will be free available under BSD license)
>
> thanks,
> Stef Mientki


[web2py] Re: "Why I hate Django" by Cal Henderson

2010-07-29 Thread mdipierro
The speaker raises some good issue with Django and some do apply to
web2py

Aside for the many jokes which are indeed funny he complains about
scalability and make these valid points:

1) session should be stored client side for scalability (web2py and
Django both store them server side, although it it would be trivial to
have a client side option and it is on my todo list, I will take a
patch if somebody does this first)

2) it is important to be able to connect to multiple databases
depending on the request (Django cannot do it, web2py can) I also just
added a modification in trunk that allows to do:

   db=DAL([uri1,uri2,uri3])

and it will try to connect to uri1, then uri2, then uri3. Of course
you can do

   db=DAL(random_permute(uri1,uri2,uri3))

to share the load at random. web2py will also try them all in case of
failure and re-try 5 times.

3) it would be nice if the ORM and DAL were to be smart about de-
normalization and about multiple db connection. There is a lot that
can be done in this direction. web2py allows an easy API to
denormalize many2many:

   # define some shortcuts
   D,F=db.define_table, Field
   # define a table dog, a person, and ownership
   d=D('dog',F('name'))
   p=D('person',F('name'),F('dogs'))
   L=D('ownership',F('person',p),F('dog',d))
   # denormalize p.dogs
   p.dogs.requires=IS_IN_DB(db,d.id,d.name,multiple=True)
   # p.dogs will be used in forms, when it changes update L
   def f(form):
 db(L.person==form.vars.id).delete()
 [L.insert(person=form.var.id,dog=k) for k in
form.request_vars.dogs]
   crud.settings.create_onaccept.person.append(f)
   crud.settings.update_onaccept.person.append(f)

In principle  the job of the last 5 lines could be automated and be
done under the hood (what the user speaks about). It would be too much
magic but it would be convenient. We have been discussing some of
this.

On Jul 29, 2:53 pm, Vidul Petrov  wrote:
> Django (the opposite of RoR) sucks likes RoR (the Denmark salesman vs
> the desparate Kanzas Python programmers ambitions to create everything
> out of nothing).
>
> Probably you know what's the definition of the Nobel winners for
> intellect - adequacy.
>
> And in order to achieve adequacy we need compromises - web2py.
>
> On Jul 29, 7:08 pm, Wobmofo  wrote:
>
> > Cal Henderson delivered a very enterteining keynote at DjangoCon 2008.
> > Go watch the video if you haven't, it's really funny 
> > !http://www.youtube.com/watch?v=i6Fr65PFqfk


[web2py] Re: Getting Eclipse / Pydev running

2010-07-29 Thread Christopher Steel
Hi Pabloest,

We have started a Wiki with Web2py Eclipse and Maven Stuff where we
publish working configurations. It may be helpful. If you want to
contribute any additional info let me know.

http://code.google.com/p/voa-web2py2eclipse/

Cheer,

Christopher Steel

Voice of Access

http://code.google.com/p/voa-web2py2eclipse/

On 29 juil, 13:26, pabloest  wrote:
> thanks.
> normally I do, but I'm not sure where to do so in Eclipse.  Similarly
> with the port and address (127.0.0.1).  I checked the debug config
> parameters and variables and tried a bit there, but it didn't lead
> anywhere.
>
> On Jul 29, 9:54 am, Bruno Rocha  wrote:
>
> > did you provide password parameter to run web2py.py?
>
> > 2010/7/29 pabloest 
>
> > > Hi,
>
> > > I'm having some trouble simply getting started with Eclipse and Pydev
> > > for web2py development.
> > > I can't get into a debugging mode with web2py.py and the web server
> > > will not even start. When I right-click and select Debug As > Python
> > > Run, I get error messages that say:
> > > -unexpected error setting up the debugger: socket closed
> > > -pydev debugger: starting
> > > Could not connect to localhost: 51530
> > > Traceback (most recent call last):
> > >  File "/Applications/eclipse/plugins/
> > > org.python.pydev.debug_1.6.0.2010071813/pysrc/pydevd_comm.py", line
> > > 341, in StartClient
> > >    s.connect((host, port))
> > >  File "", line 1, in connect
> > > gaierror: (8, 'nodename nor servname provided, or not known')
>
> > > I haven't modified my db.py files from the default.
> > > It seems I am missing something quite basic as I haven't found
> > > anything on this message board or others to indicate this is a normal
> > > problem.
>
> > > I'm running Eclipse IDE for Javascript Developers (by the way, does it
> > > matter which Eclipse? I also tried with Eclipse Classic and got the
> > > same results).
> > > Eclipse v1.3.0.2
> > > Eclipse Platform SDK v3.0.6
> > > PyDev for Eclipse 1.6.0.2
> > > PyDev Mylyn Integration 0.3.0
>
> > > I'm on a Mac 10.5.8 and Python 2.6.5.
> > > Any hints?
> > > Thanks much.
>
> > --
>
> >http://rochacbruno.com.br


[web2py] How to map multiple 'tags' to a 'blog'

2010-07-29 Thread Abhiteja
Hi Gurus,

I want to map multiple tags to a blog and allow users to select
predefined tags to a blog header.
I am able to see form for blogs and no errors shown after submit , but
nothing is entered to DB.

Am I missing something, please help me out.

Thanks & regards

Abhiteja

PS: My setup info
- I have following db definition: --

db.define_table('tags',
   Field('name')
  )

db.define_table ('blog',
Field('heading'),
Field('description' ,'text'),
Field('tags', db.tags)
  )

db.blogs.tags.requires = IS_IN_DB(db, 'tags.id', 'tags.name',
multiple=True)

--- Here is the controller definition for blogs: --
def blogs():

form = SQLFORM(db.blogs)

#if form.accepts(request.vars, session):
#response.flash = 'new song addded'


records = SQLTABLE(db().select(db.blogs.ALL))
return dict(form=form, records=records)


[web2py] What's the best way to get code completion / tooltip information ?

2010-07-29 Thread Stef Mientki
 hello,

my viewer has changed into an quit handy editor,
and now I want more: autocompletion and tooltip information.

The autocompletion and tooltip generator,
searches for classes and methods,
looks up the documentation and analyses the method arguments.

Now as web2py is (at least I think) a strange package in the pure Python sense,
it's not obvious to me
- which paths should I add to the Python system path ?
- which modules should I import, to get the most common objects into the 
completion / tooltip
information ?

(If it succeeds, the program will be free available under BSD license)

thanks,
Stef Mientki


[web2py] Re: "Why I hate Django" by Cal Henderson

2010-07-29 Thread Vidul Petrov
Django (the opposite of RoR) sucks likes RoR (the Denmark salesman vs
the desparate Kanzas Python programmers ambitions to create everything
out of nothing).

Probably you know what's the definition of the Nobel winners for
intellect - adequacy.

And in order to achieve adequacy we need compromises - web2py.



On Jul 29, 7:08 pm, Wobmofo  wrote:
> Cal Henderson delivered a very enterteining keynote at DjangoCon 2008.
> Go watch the video if you haven't, it's really funny 
> !http://www.youtube.com/watch?v=i6Fr65PFqfk


[web2py] Re: Webfaction deployment

2010-07-29 Thread Iceberg
On Jul 30, 12:29 am, iceb...@21cn.com wrote:
> Hi pals,
>
> Today I start my day 1 with webfaction. Here come some experience and 
> thoughts to share.
>
> a. web2py installation will be smooth if you use these install script [1] & 
> [2], and follow its docstring instructions. (One bug in [2] is found and 
> fixed today.)
>
> b. If you use the "latest stable source" install script [1], you will be 
> trapped because your web2py admin is unable to upload any app, just giving 
> out a unhelpful message "unable to install application your_app". (To 
> Massimo: It is unhelpful because gluon/admin.py 's most helper functions 
> absorb all exception but give no meaningful feedback -- not a good practice I 
> think.)
>
> Real cause and solution: Use ssh to login and then:
>         mkdir ~/webapps/your_chosen_name/web2py/deposit
>
> Besides, you are unable to import any module until you:
>         touch ~/webapps/your_chosen_name/web2py/applications/__init__.py
>
> (To Massimo: These are easy to be fixed in web2py_src.zip, aren't they?)
>
> c. If you are using the "hg trunk install", pay attention 
> tohttp://groups.google.com/group/web2py/msg/1937fae4b080e4ef
>
> Now the thoughts and questions.
>
> Which wsgi mode is webfaction using to serve web2py according to this setup 
> script [1] and [2]?  Is it "embedded mode" or "daemon mode"? (See more about 
> the two modes athttp://groups.google.com/group/web2py/msg/2ebe817c9bd2b0bb)
>
> How many web2py process are actually running? I saw 3 apache are running. I 
> guess they are one parent for listening and two children for real job?
>
> If there are more than one web2py process, what caveat need to be aware? 
> AFAIK:
>
> 1. cache.ram() still works, but is not that effective because content are not 
> shared by 2 (or more) web2py processes, so need to use cache.disk or 
> cache.memcache instead. More discussion is available 
> here.http://groups.google.com/group/web2py/browse_frm/thread/9993d61782c9b11d
>
> 2. The cron. According to [3], I'd better setup external cron. Fine, but are 
> the 2 wsgi web2py processes already running in soft cron mode by default? And 
> if yes, how to disable them to avoid conflict?
>
> 3. Anything else I missed?
>
> I hope to form some guidelines for new comers who, just like me, are not wsgi 
> expert.
>
> Thanks in advance!
>
> [1]http://wiki.webfaction.com/wiki/Web2py-LatestSource
> [2]http://wiki.webfaction.com/wiki/Web2pyHgTrunkInstall
> [3]http://web2py.com/book/default/section/4/17?search=cron
>
> Sincerely,
>              Iceberg, 2010-Jul-29, 22:04(PM), Thu


One more big problem, my app on webfaction keeps asking me to re-login
within every few minutes.  Why is that?  @_@

Anybody who is using webfaction can share some info?

Thanks


[web2py] Re: Webfaction deployment

2010-07-29 Thread Iceberg
On Jul 30, 1:40 am, Vasile Ermicioi  wrote:
> I think you don't need that a install script for web2py
>
> I would recommend
>
> 1. Create from your panel an application:
>           - category:  mod_wsgi
>           - type:  mod_wsgi 3.2 / python2.6
> 2. Use mod_wsgi deployment 
> recipeshttp://web2py.com/book/default/chapter/11#mod_wsgi
>
> notes:
> - don't forget to use the port of your application (webfaction app that you
> just created) when configuring httpd.conf

I used to think webfaction's one-click installer would be handy for
noob like me. Turns out its apache conf is quite different than the
one suggested in http://web2py.com/book/default/chapter/11#mod_wsgi

The webfaction apache http.conf is as below.

$ cat ../conf/httpd.conf
ServerRoot "/home//webapps/web2py_1_81_5/apache2"

LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule wsgi_module modules/mod_wsgi.so

DirectoryIndex index.py
DocumentRoot /home//webapps/web2py_1_81_5/htdocs
KeepAlive Off
Listen 53400
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\"" combined
CustomLog /home//logs/user/access_web2py_1_81_5.log combined
ErrorLog /home//logs/user/error_web2py_1_81_5.log
ServerLimit 1 # I just change it from 2 to 1
#ServerLimit 2

SetEnvIf X-Forwarded-SSL on HTTPS=1

WSGIScriptAlias / /home//webapps/web2py_1_81_5/web2py/
wsgihandler.py



[web2py] Re: Filling a form with AJAX / contextual JQuery dialog?

2010-07-29 Thread pabloest
Hi,

I believe it should be ok to leave the  and jQuery  in
the header. This will be cached by the browser and you may well find
yourself using it elsewhere too as it is quite useful.

Then for view-specific functions, there's no reason you can't place