[web2py] Re: Multiple instances of same application

2010-06-04 Thread Iceberg
IMHO, flask and my lightweight proposal try to solve same problem.
Both can load configuration for sure. My proposal's loading ability
relies only on python's built-in import (via web2py's model
mechanism), therefore no need to introducing extra module. Isn't it
clean?

The basic challenge is how to separate and manage local setting from
default setting, and how to prevent the local setting being
distributed via app.w2p or Mercurial. Flask uses environment variable
YOURAPPLICATION_SETTINGS=/path/to/settings.cfg, to specify a local
setting. I like that too, but it can not be done via pure web2py admin
interface, so administrator need to ssh into their production machine
and make adjustments, and perhaps a kill-and-restart is needed. On the
contrary, in my proposal, although I did not emphasis this in earlier
post, administrator only need to visit standard web2py admin interface
and setup a new 0_local_setting.py. No ssh nor restart is needed,
again I rely on web2py's native behavior. Isn't it lightweight?

Of course, I don't like the
0_local_config_pls_dont_pack_dont_commit.py naming convention neither,
but I just did not come up with another descriptive name. The point
here, is we need a config file which can be used by a web2py app, but
not packed with the app.

Well, if we really just don't like the long and clumsy name
convention, then we can do it in a decent way:
1. introduce a applications/myapp/local_config directory, local
settings go into there.
2. adjust web2py to NOT pack, and NOT commit local_config directory
3. but we need more work for web2py's admin UI, to support add/edit/
view/delete setting file.

We can choose.


On Jun4, 3:26am, Thadeus Burgess thade...@thadeusb.com wrote:
 Or... we can copy flask and integrate a configuration module..

 God I pray we never use something like
 `0_local_config_pls_dont_pack_dont_commit.py` INTO web2py. web2py and
 its naming conventions .

 --
 Thadeus



 On Thu, Jun 3, 2010 at 10:22 AM, Iceberg iceb...@21cn.com wrote:
  I think Doug's puzzle deserves a more general solution. The
  requirement and challenge is:
  R1. The app's central source code should contain default setting.
  R2. The app's multiple deployment instances should be allowed to
  contain its local setting.
  R3. And after the next hg update, the default setting in (R1) should
  not override the local setting in (R2).

  My solution contains two steps:
  Step1: Use myapp/models/0_config.py to store default setting, such as:
     MY_HOST = 'http://localhost'
     MY_EMAIL = '@bar.com'
     MY_PASSWORD = 'blah'
     MY_DB = 'sqlite://storage.sqlite'

  Step2: Use myapp/models/0_local_config_pls_dont_pack_dont_commit.py to
  store instance-wide local setting, such as:
     MY_HOST = 'http://myaccount.my_vps_provider.com'
     MY_EMAIL = 'my_real_acco...@for_example_hotmail.com'
     MY_PASSWORD = 'i_will_never_share_it'
     MY_DB = 'mysql://10.1.1.1.'

  To reach this goal, two things need to be adjusted in web2py source
  code:

  Thing1: add 0_local_config_pls_dont_pack_dont_commit.py into /
  web2py/.hgignore

  Thing2: adjust the admin's pack code, to NOT pack the new
  0_local_config_pls_dont_pack_dont_commit.py

  On Jun3, 10:23pm, mdipierro mdipie...@cs.depaul.edu wrote:
  they can see request.env.host_name and you can use hostnames like bla
  bla bla.yourdomain.com

  you can symlink different apps to the same one so you have one but it
  will see different request.application depending on the request

  On Jun 3, 8:50 am, Doug Warren doug.war...@gmail.com wrote:

   Is there a preferred way to handle multiple instances of the same
   application installed on the same machine?  Say for instance is
   there's 3 dev environments and 2 staging environments on one server
   pointing at different databases?  Is there a preferred way of getting
   the configuration to each unique app?  IE: Can a view/db/controller
   see a parameter placed in either options_std or parameters_PORTNO?  I
   guess what I'm really after is a way to specify at a minimum the
   database that an application can point at but have it contained
   outside the application itself.

   IE:
   foo.w2p is uploaded
   foo.w2p is installed as foo
   foo.w2p is installed as foo-dev
   foo.w2p is installed as foo-dev2
   foo.w2p is installed as foo-stag

   Without having to edit db.py in each of those environments I'd like to
   have a way of saying foo-stag should use this connect string, and have
   it survive the next time I upload a new foo.w2p and overwrite the one
   that's there.


[web2py] Re: Multiple instances of same application

2010-06-04 Thread mdipierro
I normally use

#in models/0.py
from gluon.storage import Storage
settings=Storage()
settings.development=True
settings.email_sender='m...@example.com'
...

Anyway, this does not address Iceberg's problem of packing some config
files and not others. I am not convinced this scenario should be
handled at the web2py level. This is better handled using .hgignore
and mercurial or other version control system.

I am thinking anyway, to allow a flag when packaging that does not
package the database/ folder. So in principle one could create
function that updates parameters from a DAL('sqlite://settings.db')

On Jun 4, 1:10 am, Iceberg iceb...@21cn.com wrote:
 IMHO, flask and my lightweight proposal try to solve same problem.
 Both can load configuration for sure. My proposal's loading ability
 relies only on python's built-in import (via web2py's model
 mechanism), therefore no need to introducing extra module. Isn't it
 clean?

 The basic challenge is how to separate and manage local setting from
 default setting, and how to prevent the local setting being
 distributed via app.w2p or Mercurial. Flask uses environment variable
 YOURAPPLICATION_SETTINGS=/path/to/settings.cfg, to specify a local
 setting. I like that too, but it can not be done via pure web2py admin
 interface, so administrator need to ssh into their production machine
 and make adjustments, and perhaps a kill-and-restart is needed. On the
 contrary, in my proposal, although I did not emphasis this in earlier
 post, administrator only need to visit standard web2py admin interface
 and setup a new 0_local_setting.py. No ssh nor restart is needed,
 again I rely on web2py's native behavior. Isn't it lightweight?

 Of course, I don't like the
 0_local_config_pls_dont_pack_dont_commit.py naming convention neither,
 but I just did not come up with another descriptive name. The point
 here, is we need a config file which can be used by a web2py app, but
 not packed with the app.

 Well, if we really just don't like the long and clumsy name
 convention, then we can do it in a decent way:
 1. introduce a applications/myapp/local_config directory, local
 settings go into there.
 2. adjust web2py to NOT pack, and NOT commit local_config directory
 3. but we need more work for web2py's admin UI, to support add/edit/
 view/delete setting file.

 We can choose.

 On Jun4, 3:26am, Thadeus Burgess thade...@thadeusb.com wrote:

  Or... we can copy flask and integrate a configuration module..

  God I pray we never use something like
  `0_local_config_pls_dont_pack_dont_commit.py` INTO web2py. web2py and
  its naming conventions .

  --
  Thadeus

  On Thu, Jun 3, 2010 at 10:22 AM, Iceberg iceb...@21cn.com wrote:
   I think Doug's puzzle deserves a more general solution. The
   requirement and challenge is:
   R1. The app's central source code should contain default setting.
   R2. The app's multiple deployment instances should be allowed to
   contain its local setting.
   R3. And after the next hg update, the default setting in (R1) should
   not override the local setting in (R2).

   My solution contains two steps:
   Step1: Use myapp/models/0_config.py to store default setting, such as:
      MY_HOST = 'http://localhost'
      MY_EMAIL = '@bar.com'
      MY_PASSWORD = 'blah'
      MY_DB = 'sqlite://storage.sqlite'

   Step2: Use myapp/models/0_local_config_pls_dont_pack_dont_commit.py to
   store instance-wide local setting, such as:
      MY_HOST = 'http://myaccount.my_vps_provider.com'
      MY_EMAIL = 'my_real_acco...@for_example_hotmail.com'
      MY_PASSWORD = 'i_will_never_share_it'
      MY_DB = 'mysql://10.1.1.1.'

   To reach this goal, two things need to be adjusted in web2py source
   code:

   Thing1: add 0_local_config_pls_dont_pack_dont_commit.py into /
   web2py/.hgignore

   Thing2: adjust the admin's pack code, to NOT pack the new
   0_local_config_pls_dont_pack_dont_commit.py

   On Jun3, 10:23pm, mdipierro mdipie...@cs.depaul.edu wrote:
   they can see request.env.host_name and you can use hostnames like bla
   bla bla.yourdomain.com

   you can symlink different apps to the same one so you have one but it
   will see different request.application depending on the request

   On Jun 3, 8:50 am, Doug Warren doug.war...@gmail.com wrote:

Is there a preferred way to handle multiple instances of the same
application installed on the same machine?  Say for instance is
there's 3 dev environments and 2 staging environments on one server
pointing at different databases?  Is there a preferred way of getting
the configuration to each unique app?  IE: Can a view/db/controller
see a parameter placed in either options_std or parameters_PORTNO?  I
guess what I'm really after is a way to specify at a minimum the
database that an application can point at but have it contained
outside the application itself.

IE:
foo.w2p is uploaded
foo.w2p is installed as foo
foo.w2p is installed as foo-dev

Re: [web2py] LIKE is slow on RDBS; true for GAE also?

2010-06-04 Thread Álvaro Justen
On Fri, Jun 4, 2010 at 02:36, Vasile Ermicioi elff...@gmail.com wrote:
 I think GAE doesn't support like

Ouch, I forgot this. Excuse me for that.

-- 
Álvaro Justen - Turicas
 http://blog.justen.eng.br/
 21 9898-0141


[web2py] call javascript function from within controller

2010-06-04 Thread annet
I have the following code in a view:

td
  {{=A(club.companyname,_onmouseover=this.style.cursor='pointer';,\

_onclick=javascript:clublocatordetails('%s')%URL(r=request,f='details',args=[club.id]))}}
/td

The javascript clublocatordetails function (in web2py_ajax.html)
re sizes the window. I extended the details function:

def details():

if not club:
redirect(URL(r=request,c='default',f='error'))
elif club[0].status=='2':
redirect(URL(r=request,f='homepage',args=id))

return dict(...)

When a club has status 2 there is a redirect to a different function,
since this function's view is larger I would like to resize the
browser window.

Would it be possible to define a second javascript function that re-
sizes the window to the desired height and width and call that
function in the redirect somehow?


Kind regards,

Annet.


[web2py] Re: unique entry or null validation

2010-06-04 Thread dlin
Thanks, It works.

I've searched it on http://web2py.com/book/default/section/7/4

On 6月4日, 下午1時47分, Yarko Tymciurak resultsinsoftw...@gmail.com wrote:
 On Jun 3, 11:31 pm, dlin dlin...@gmail.com wrote:

  There is a field which I want user to enter different answer, or just
  keep in empty.

 empty, or unique answer:

 db.table.answer.requires=IS_NULL_OR( IS_NOT_IN_DB( db,
 'table.answer' ) )





  I've tried by:

  db.table.field.requires=IS_NOT_IN_DB(db, 'table.field')

  But, it will failed, if the second empty field entered.

  How could I do the validation for this case?
  Is there any method?


[web2py] Re: How to set multiple primary key?

2010-06-04 Thread dlin
I still not understand the answer.

How could I build primary key on two fields by default sqlite?
Or, is there any better method to build 'unique key' on multiple
fields?


On 5月20日, 上午12時30分, drayco antrod...@gmail.com wrote:
 Thank's a lot Nico de Groot.

 It worked for me too even with mysql.

 On 18 mayo, 07:24, Nico de Groot ndegr...@chello.nl wrote:



  Hi Denes,

  I got the same syntax error (SyntaxError: invalid table account
  attribute: sequence_name ) when using a legacy database (by specifying
  the primarykey in 'define_table'). I tracked it down to the init
  method of KeyedTable in sql.py and made an adjustment that worked -
  for me at least - see below.

  Nico de Groot

  class KeyedTable(Table):
  ...
      def __init__(
          self,
          db,
          tablename,
          *fields,
          **args
          ):
  ...
          self._trigger_name = args.get('trigger_name', None)
          self._sequence_name = args.get('sequence_name', None)

          for k,v in args.iteritems():
              #patch NCdG
              if k in ['trigger_name','sequence_name']:
                  continue
              #/patch NCdG
              if k != 'primarykey':

  ...

  On 9 mei, 18:57, DenesL denes1...@yahoo.ca wrote: On May 9, 9:08 am, 
  Iceberg iceb...@21cn.com wrote:

Thanks for the info. Would you please comment on my following
understanding and further questions?

1. Keyed tables are only designed for dealing with legacy tables. Is
that true? And how do we definemultipleprimary keys in a brand new
db? Consider the address book scenario in my previous post.

   Keyed tables support is primarily for legacy tables that do not have a
   field that can be used as id field. It can also be used in newly
   created tables since all operations work (except update_record). Note
   that references are specified as tablename.fieldname and can only
   reference other keyed tables.

2. Keyed tables are yet to be supported in some other DB engines, but
NOT the handy SQLite. Is there any special reason for that? AFAIK
SQLite contains native support formultipleprimary key.

   I might be wrong but I think SQLite does not have FK (field level
   foreign key) and TFK (table level foreign key) required for the keyed
   table support in web2py.

3. Neither keyword KeyedTable nor primarykey can be found 
inhttp://www.web2py.com/bookrightnow. Why? Denes' good work deserves
being mentioned as a dedicated section.

   It was added after the book was made available and it would be my
   fault, I either had no time or forgot about it.

Thanks in advance.

Sincerely,
Iceberg- Tekst uit oorspronkelijk bericht niet weergeven -

   - Tekst uit oorspronkelijk bericht weergeven -


[web2py] Re: Multiple instances of same application

2010-06-04 Thread Iceberg
Aside from the config issue, a flag when packaging that does not
package the database/ folder, would be the long missing piece. And
when this flag is available, I think I can have my own databases/
my_config.py to solve the local config problem in my style. :-)

So +1 for the flag when packaging that does not package the database/
folder.

On Jun4, 2:20pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I normally use

 #in models/0.py
 from gluon.storage import Storage
 settings=Storage()
 settings.development=True
 settings.email_sender=...@example.com'
 ...

 Anyway, this does not address Iceberg's problem of packing some config
 files and not others. I am not convinced this scenario should be
 handled at the web2py level. This is better handled using .hgignore
 and mercurial or other version control system.

 I am thinking anyway, to allow a flag when packaging that does not
 package the database/ folder. So in principle one could create
 function that updates parameters from a DAL('sqlite://settings.db')

 On Jun 4, 1:10 am, Iceberg iceb...@21cn.com wrote:



  IMHO, flask and my lightweight proposal try to solve same problem.
  Both can load configuration for sure. My proposal's loading ability
  relies only on python's built-in import (via web2py's model
  mechanism), therefore no need to introducing extra module. Isn't it
  clean?

  The basic challenge is how to separate and manage local setting from
  default setting, and how to prevent the local setting being
  distributed via app.w2p or Mercurial. Flask uses environment variable
  YOURAPPLICATION_SETTINGS=/path/to/settings.cfg, to specify a local
  setting. I like that too, but it can not be done via pure web2py admin
  interface, so administrator need to ssh into their production machine
  and make adjustments, and perhaps a kill-and-restart is needed. On the
  contrary, in my proposal, although I did not emphasis this in earlier
  post, administrator only need to visit standard web2py admin interface
  and setup a new 0_local_setting.py. No ssh nor restart is needed,
  again I rely on web2py's native behavior. Isn't it lightweight?

  Of course, I don't like the
  0_local_config_pls_dont_pack_dont_commit.py naming convention neither,
  but I just did not come up with another descriptive name. The point
  here, is we need a config file which can be used by a web2py app, but
  not packed with the app.

  Well, if we really just don't like the long and clumsy name
  convention, then we can do it in a decent way:
  1. introduce a applications/myapp/local_config directory, local
  settings go into there.
  2. adjust web2py to NOT pack, and NOT commit local_config directory
  3. but we need more work for web2py's admin UI, to support add/edit/
  view/delete setting file.

  We can choose.

  On Jun4, 3:26am, Thadeus Burgess thade...@thadeusb.com wrote:

   Or... we can copy flask and integrate a configuration module..

   God I pray we never use something like
   `0_local_config_pls_dont_pack_dont_commit.py` INTO web2py. web2py and
   its naming conventions .

   --
   Thadeus

   On Thu, Jun 3, 2010 at 10:22 AM, Iceberg iceb...@21cn.com wrote:
I think Doug's puzzle deserves a more general solution. The
requirement and challenge is:
R1. The app's central source code should contain default setting.
R2. The app's multiple deployment instances should be allowed to
contain its local setting.
R3. And after the next hg update, the default setting in (R1) should
not override the local setting in (R2).

My solution contains two steps:
Step1: Use myapp/models/0_config.py to store default setting, such as:
   MY_HOST = 'http://localhost'
   MY_EMAIL = '@bar.com'
   MY_PASSWORD = 'blah'
   MY_DB = 'sqlite://storage.sqlite'

Step2: Use myapp/models/0_local_config_pls_dont_pack_dont_commit.py to
store instance-wide local setting, such as:
   MY_HOST = 'http://myaccount.my_vps_provider.com'
   MY_EMAIL = 'my_real_acco...@for_example_hotmail.com'
   MY_PASSWORD = 'i_will_never_share_it'
   MY_DB = 'mysql://10.1.1.1.'

To reach this goal, two things need to be adjusted in web2py source
code:

Thing1: add 0_local_config_pls_dont_pack_dont_commit.py into /
web2py/.hgignore

Thing2: adjust the admin's pack code, to NOT pack the new
0_local_config_pls_dont_pack_dont_commit.py

On Jun3, 10:23pm, mdipierro mdipie...@cs.depaul.edu wrote:
they can see request.env.host_name and you can use hostnames like bla
bla bla.yourdomain.com

you can symlink different apps to the same one so you have one but it
will see different request.application depending on the request

On Jun 3, 8:50 am, Doug Warren doug.war...@gmail.com wrote:

 Is there a preferred way to handle multiple instances of the same
 application installed on the same machine?  Say for instance is
 there's 3 dev environments and 2 staging environments on one server
 pointing 

[web2py] Re: unique entry or null validation

2010-06-04 Thread dlin
By the way,
I found http://127.0.0.1:8000/examples/static/epydoc/index.html also
have such document.
But, I missed it.  I should click on the left upper corner to choose
validator at first to narrow the display results.


On 6月4日, 下午4時15分, dlin dlin...@gmail.com wrote:
 Thanks, It works.

 I've searched it onhttp://web2py.com/book/default/section/7/4

 On 6月4日, 下午1時47分, Yarko Tymciurak resultsinsoftw...@gmail.com wrote:



  On Jun 3, 11:31 pm, dlin dlin...@gmail.com wrote:

   There is a field which I want user to enter different answer, or just
   keep in empty.

  empty, or unique answer:

  db.table.answer.requires=IS_NULL_OR( IS_NOT_IN_DB( db,
  'table.answer' ) )

   I've tried by:

   db.table.field.requires=IS_NOT_IN_DB(db, 'table.field')

   But, it will failed, if the second empty field entered.

   How could I do the validation for this case?
   Is there any method?


Re: [web2py] Re: checkboxes and radio widget failed with multiple validators

2010-06-04 Thread Mathieu Clabaut
Good point ! My example was not so good. But anyway I have another specific
validator to add...

-Mathieu

On Fri, Jun 4, 2010 at 06:42, Iceberg iceb...@21cn.com wrote:

 Maybe your patch is ok. But wouldn't it be not necessary to use
 requires=[IS_IN_SET(...), IS_NOT_EMPTY()]? Because you must already
 mention all the allowed values in the IS_IN_SET() and usually empty
 value in not inside.

 On Jun4, 1:36am, Mathieu Clabaut mathieu.clab...@gmail.com wrote:
  Hello,
 
  Is there any interest in this problem ? Is there any chance a correction
 may
  be integrated into trunk ?
 
  -Mathieu
 
  On Thu, May 27, 2010 at 20:20, Mathieu Clabaut 
 mathieu.clab...@gmail.com
 
 
 
 
 
   wrote:
   Reported ashttp://code.google.com/p/web2py/issues/detail?id=80
 
   Hello,
 
   I've met a problem with checkboxes and rzdio widgets:
 
   The following works:
   Field('status', 'string', requires=IS_IN_SET(STATUS_TYPE,
 multiple=True),
   widget=SQLFORM.widgets.checkboxes.widget)
 
   However if I add another validator, it doesn't work anymore :
   Field('status', 'string', requires=[IS_IN_SET(STATUS_TYPE,
 multiple=True),
   IS_NOT_EMPTY()],
   widget=SQLFORM.widgets.checkboxes.widget)
 
   Any suggestion ?
 
   -Mathieu
 
  On Thu, May 27, 2010 at 20:38, Mathieu Clabaut 
 mathieu.clab...@gmail.comwrote:
 
 
 
   Patch :
 
   diff -r 9802a87428fa gluon/sqlhtml.py
   --- a/gluon/sqlhtml.py Wed May 26 17:17:46 2010 +0200
   +++ b/gluon/sqlhtml.py Thu May 27 20:37:56 2010 +0200
   @@ -223,10 +223,15 @@
 
attr = OptionsWidget._attributes(field, {}, **attributes)
 
   -if hasattr(field.requires, 'options'):
   -options = field.requires.options()
   -else:
   -raise SyntaxError, 'widget cannot determine options of %s'
 %
   field
   +requires = field.requires
   +if not isinstance(requires, (list, tuple)):
   +requires = [requires]
   +if requires:
   +if hasattr(requires[0], 'options'):
   +options = requires[0].options()
   +else:
   +raise SyntaxError, 'widget cannot determine options of
 %s'
   \
   +% field
opts = [TR(INPUT(_type='radio', _name=field.name,
 requires=attr.get('requires',None),
 hideerror=True, _value=k,
   @@ -250,10 +255,15 @@
 
attr = OptionsWidget._attributes(field, {}, **attributes)
 
   -if hasattr(field.requires, 'options'):
   -options = field.requires.options()
   -else:
   -raise SyntaxError, 'widget cannot determine options of %s'
 %
   field
   +requires = field.requires
   +if not isinstance(requires, (list, tuple)):
   +requires = [requires]
   +if requires:
   +if hasattr(requires[0], 'options'):
   +options = requires[0].options()
   +else:
   +raise SyntaxError, 'widget cannot determine options of
 %s'
   \
   +% field
 
options = [(k, v) for k, v in options if k!='']
opts = []



[web2py] Support for Indian Languages

2010-06-04 Thread Rahul
Hi Massimo, All,
   Wondering how the internationalization for Indian Languages
works. I am using latest web2py (1.78.3) on Firefox with Translate
Plugin installed for translation on Windows XP (SP2). International
languages like Japanese, Chinese, Korean and others work seamlessly
and thats brilliant.
Also, I've successfully translated to Hindi (hi-hi) but Marathi (mr-
mr) , Bengali (bn-bn) and other languages like Punjabi (pa-pa) etc
don't seem to work with my application. I've even tried adding these
languages to Browser (Firefox and IE7) via languages option but no
use.
What am I doing wrong? Do these files need to be created exclusively?
Please advice.

BTW, I am repeatedly viewing your video on http://vimeo.com/7520812
to understand where I am going wrong.

Thanks, Rahul.



[web2py] [proposition] Need date calculations in a query

2010-06-04 Thread Sverre
I need some like

query(startdate+timedelta(days)  endtime)

In PostgreSQL and other databases that not a problem. The alternative
is only filtering on client side.


[web2py] Mustache.js and web2py

2010-06-04 Thread PanosJee
Hello everyone i am trying to use Mustache.js along with web2py
Mustache is a cross language rendering mechanism. We use it both
server side and client side.

What i want to do is to have a hidden div with the mustache template
but i have the following problem. Mustache uses {{ }} as web2py does
so if i place my mustache templates in the html code web2py dies.

Is there anyway to bypass the web2py rendering for a given partial so
i do not have to do any changes to mustache?


[web2py] Re: Outer join problem

2010-06-04 Thread ceriox
correction:

record=db().select(db.Book.ALL, db.Union.ALL,
left=db.Book.on(db.Union.book_iddb.Book.id))

i use 'left=db.Book.on' not 'right=.'

On 4 Giu, 14:17, ceriox cer...@gmail.com wrote:
 hi all
 i have a problem making an outer join
 somebody can write me the correct one?

 db.define_table('Union',
     Field('user_id', db.User, writable=False, readable=False),
     Field('book_id', 'integer', db.Book, writable=False,
 readable=False))

 db.define_table('Book',
    Field('Titolo', 'string'))

 i want to have all book with no User
 i try with
 record=db().select(db.Book.ALL, db.Union.ALL,
 right=db.Book.on(db.Union.book_iddb.Book.id))

 but i have all Book and Book without union

 what is the error?
 thanks for help


[web2py] Re: routes to have userprofile pages

2010-06-04 Thread ChrisM
anyone?

On Jun 3, 2:29 pm, ChrisM cjjmur...@gmail.com wrote:
 Having trouble gettingroutesto work (not used before) for instance
 as a test I did:

 inroutes.py:
 routes_in = (  ('/profile/*', '/init/default/userprofilepage/*'),)
 routes_out = (  ('/init/default/userprofilepage/*', '/profile'),)

 in default controller:
 def userprofilepage():
     userprofile request.args(0)
     return dict(userprofile=userprofile)

 in userprofilepage.html:

 {{extend 'layout.html'}}
 h1{{=userprofile}}/h1

 get invalid request?

 any help appreciated.
 chrism

 On Jun 3, 6:08 am, Adi aditya.sa...@gmail.com wrote:



  You could use an argument.

 www.myapp.com/userprofilecanbe mapped to a controller/method 
 likewww.myapp.com/app/profiles/show/userprofile

  where app = application, profiles = controller, show = function,
  userprofile is an argument accessed by request.args(0) inside show.
  You can use it to query database according to that user.

  In order to hide app/profiles/show from url follow the usualroutes.py 
  mapping  (its given on some other post here) assuming you
  have only one app on the server.

  On Jun 2, 9:31 pm, ChrisM cjjmur...@gmail.com wrote:

   For isntance I have RPX login which creates user profile for each
   logged in user.
   I would like to give each one of these users there own homepage (i.e.
   like twitter) which could be
   dynamically created.
   So I thought the first task was to see how thiscould be mapped,
   perhaps by querying db.profile and then mapping throughroutes.py.

   chrism

   On Jun 2, 3:46 pm, mdipierro mdipie...@cs.depaul.edu wrote:

Can you explain more?

On Jun 2, 8:00 am, ChrisM cjjmur...@gmail.com wrote:

 I searched through the list but couldn't find any discussion on this
 topic.

 Any ideas how the following can be achieved withroutes.py

www.appname.com\userprofilename

 I am guessing that there would need to be a db.auth lookup to match
 the userprofilename
 and then pass that to a generic controller, but how?

 Help Aprreciated

 ChrisM- Hide quoted text -

- Show quoted text -- Hide quoted text -

  - Show quoted text -- Hide quoted text -

 - Show quoted text -


[web2py] Re: Support for Indian Languages

2010-06-04 Thread mdipierro
if you email me your language files I will include them in web2py.

On Jun 4, 5:29 am, Rahul rahul.dhak...@gmail.com wrote:
 Hi Massimo, All,
        Wondering how the internationalization for Indian Languages
 works. I am using latest web2py (1.78.3) on Firefox with Translate
 Plugin installed for translation on Windows XP (SP2). International
 languages like Japanese, Chinese, Korean and others work seamlessly
 and thats brilliant.
 Also, I've successfully translated to Hindi (hi-hi) but Marathi (mr-
 mr) , Bengali (bn-bn) and other languages like Punjabi (pa-pa) etc
 don't seem to work with my application. I've even tried adding these
 languages to Browser (Firefox and IE7) via languages option but no
 use.
 What am I doing wrong? Do these files need to be created exclusively?
 Please advice.

 BTW, I am repeatedly viewing your video onhttp://vimeo.com/7520812
 to understand where I am going wrong.

 Thanks, Rahul.


Re: [web2py] Mustache.js and web2py

2010-06-04 Thread Thadeus Burgess
Unfortunately not at the moment. This is something we have been
discussing for the last week however it does not seem web2py templates
will ever get this.

Just as a note, you would have this problem whether you were using
jinja, or django templates as well.

--
Thadeus





On Fri, Jun 4, 2010 at 6:50 AM, PanosJee panos...@gmail.com wrote:
 Hello everyone i am trying to use Mustache.js along with web2py
 Mustache is a cross language rendering mechanism. We use it both
 server side and client side.

 What i want to do is to have a hidden div with the mustache template
 but i have the following problem. Mustache uses {{ }} as web2py does
 so if i place my mustache templates in the html code web2py dies.

 Is there anyway to bypass the web2py rendering for a given partial so
 i do not have to do any changes to mustache?



[web2py] Re: Mustache.js and web2py

2010-06-04 Thread PanosJee
I just open an html file and spit the code in web2py views now :P
Just for the shake of performance i cache the content so i do not open
the file all the time :)

On 4 Ιούν, 17:12, Thadeus Burgess thade...@thadeusb.com wrote:
 Unfortunately not at the moment. This is something we have been
 discussing for the last week however it does not seem web2py templates
 will ever get this.

 Just as a note, you would have this problem whether you were using
 jinja, or django templates as well.

 --
 Thadeus



 On Fri, Jun 4, 2010 at 6:50 AM, PanosJee panos...@gmail.com wrote:
  Hello everyone i am trying to use Mustache.js along with web2py
  Mustache is a cross language rendering mechanism. We use it both
  server side and client side.

  What i want to do is to have a hidden div with the mustache template
  but i have the following problem. Mustache uses {{ }} as web2py does
  so if i place my mustache templates in the html code web2py dies.

  Is there anyway to bypass the web2py rendering for a given partial so
  i do not have to do any changes to mustache?


Re: [web2py] Re: I can not update

2010-06-04 Thread Marcelo Martinez
thanks, solved my problem


2010/6/4 mdipierro mdipie...@cs.depaul.edu

 In this

  try:
  #1
  except:
  # 2

 if #1 fails because it violates a constraint, than you need to
 rollback before you can access the database again.
 Try this:

  try:
  #1
  db.commit()
  except:
  db.rollback()
  # 2
  db.commit()

 It is not a good idea to use try...except in database operations
 anyway.


 On Jun 3, 5:05 pm, mmartinez alexra...@gmail.com wrote:
  Good afternoon, my question is this, there is a postgres sql query
  that does not work, I am doing the query q is:
 
  for r in rws:
try:
db.ratecltes.insert(id_rutas=r.rutas.id,
  id_clte=r.clientes.id, rate=r.rutaproveedor.valor)
except:
# # # HERE IS THE ERROR # # #
query=((db.ratecltes.id_rutas==r.rutas.id) 
  (db.ratecltes.id_clte==r.clientes.id))
db(query).update(rate=int(r.rutaproveedor.valor))
 
  Web2py The message sent is as follows.
 
   File /home/marcelo/web2py/applications/administrador/controllers/
  default.py, line 1087, in cargar_tarifas
  db(query).update(rate=int(r.rutaproveedor.valor))
File /home/marcelo/web2py/gluon/sql.py, line 3285, in update
  self._db._execute(query)
File /home/marcelo/web2py/gluon/sql.py, line 958, in lambda
  self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
  InternalError: transacción abortada, las órdenes serán ignoradas hasta
  el fin de bloque de transacción
 
  PostgreSQL modify the settings to see the log_statement = all, and
  this is the result:
 
  2010-06-03 16:31:52 CLT ERROR:  transacción abortada, las órdenes
  serán ignoradas hasta el fin de bloque de transacción
  2010-06-03 16:31:52 CLT SENTENCIA:  UPDATE ratecltes SET rate=60.0
  WHERE (ratecltes.id_rutas=1 AND ratecltes.id_clte=3);
  2010-06-03 16:32:51 CLT WARNING:  ya hay una transacción en curso
  2010-06-03 16:32:51 CLT WARNING:  ya hay una transacción en curso
  2010-06-03 16:32:54 CLT WARNING:  ya hay una transacción en curso
  2010-06-03 16:33:00 CLT WARNING:  ya hay una transacción en curso
  2010-06-03 16:33:00 CLT ERROR:  llave duplicada viola restricción de
  unicidad «ratecltes_ndx»
  2010-06-03 16:33:00 CLT SENTENCIA:  INSERT INTO ratecltes(id_rutas,
  id_clte, rate) VALUES (1, 3, 60.0);
  2010-06-03 16:33:00 CLT ERROR:  transacción abortada, las órdenes
  serán ignoradas hasta el fin de bloque de transacción
  2010-06-03 16:33:00 CLT SENTENCIA:  UPDATE ratecltes SET rate=60.0
  WHERE (ratecltes.id_rutas=1 AND ratecltes.id_clte=3);
 
  I hope I can help, not that I'm failing.



[web2py] Inserting data with foreign keys not from a form

2010-06-04 Thread Doug Warren
Hi,

I defined all my tables in my model file and want to have a few
hundred rows of default foreign keys to maintain 3rd normal form.  So
I have things in my code such as:

if db(fk_table.id  0).count() == 0:
db.fk_table.insert(name=The Foreign Key)

if db(table2.id  0).count() == 0:
fk = db(db.fk_table.name == The Foreign Key).select()[0]
db.table2.insert(name = Some name, fk_id = fk.id, field2=some value)

I'm sure there's a better way to get the id of the foreign key than
doing select()[0].id, but I'm not sure what it is...


[web2py] Re: Inserting data with foreign keys not from a form

2010-06-04 Thread mr.freeze
The insert function will return the id.
fk = db.fk_table.insert(name=The Foreign Key)

On Jun 4, 9:48 am, Doug Warren doug.war...@gmail.com wrote:
 Hi,

 I defined all my tables in my model file and want to have a few
 hundred rows of default foreign keys to maintain 3rd normal form.  So
 I have things in my code such as:

 if db(fk_table.id  0).count() == 0:
     db.fk_table.insert(name=The Foreign Key)

 if db(table2.id  0).count() == 0:
     fk = db(db.fk_table.name == The Foreign Key).select()[0]
     db.table2.insert(name = Some name, fk_id = fk.id, field2=some value)

 I'm sure there's a better way to get the id of the foreign key than
 doing select()[0].id, but I'm not sure what it is...


Re: [web2py] Re: Inserting data with foreign keys not from a form

2010-06-04 Thread Doug Warren
Yes, but the foreign key here is many to one, not one to one.  (I
guess I should have been more clear:
 if db(fk_table.id  0).count() == 0:
db.fk_table.insert(name=The Foreign Key)

if db(table2.id  0).count() == 0:
 fk = db(db.fk_table.name == The Foreign Key).select()[0]
 db.table2.insert(name = Some name, fk_id = fk.id, field2=some value)
 db.table2.insert(name = Some name2, fk_id = fk.id, field2=some value2)
 db.table2.insert(name = Some name3, fk_id = fk.id, field2=some value3)
 db.table2.insert(name = Some name4, fk_id = fk.id, field2=some value4)

On Fri, Jun 4, 2010 at 8:00 AM, mr.freeze nat...@freezable.com wrote:
 The insert function will return the id.
 fk = db.fk_table.insert(name=The Foreign Key)

 On Jun 4, 9:48 am, Doug Warren doug.war...@gmail.com wrote:
 Hi,

 I defined all my tables in my model file and want to have a few
 hundred rows of default foreign keys to maintain 3rd normal form.  So
 I have things in my code such as:

 if db(fk_table.id  0).count() == 0:
     db.fk_table.insert(name=The Foreign Key)

 if db(table2.id  0).count() == 0:
     fk = db(db.fk_table.name == The Foreign Key).select()[0]
     db.table2.insert(name = Some name, fk_id = fk.id, field2=some value)

 I'm sure there's a better way to get the id of the foreign key than
 doing select()[0].id, but I'm not sure what it is...


Re: [web2py] Re: Wouldn't it be cool ...

2010-06-04 Thread Doug Warren
Getting way off topic, but the Sprint 4g Evo comes out today...  I've
been waiting for this phone since it was announced to jump from an
iPhone :)  http://sprint.com/evo (Website being hammered by
activations probably.)  Can act as an 802.11 base station, is the
first 4g android phone in the US, and 4g is covered at my home, my
office, and my gym.

On Thu, Jun 3, 2010 at 10:47 PM, mdipierro mdipie...@cs.depaul.edu wrote:
 hmmm. I must get one of these...

 On Jun 3, 7:54 pm, Doug Warren doug.war...@gmail.com wrote:
 http://google-opensource.blogspot.com/2009/06/introducing-android-scr...
 ?

 On Thu, Jun 3, 2010 at 5:34 PM, weheh richard_gor...@verizon.net wrote:
  if web2py could run native on the Droid? Then, give me a foldup
  keyboard and who would need a laptop any more?


[web2py] Re: Support for Indian Languages

2010-06-04 Thread Anand Vaidya
Hi Rahul,

I had contributed a Hindi translation some time ago, which was like
85-90% complete. It works.

I had tested it in two ways:

- set T() in web2py so w2py serves only Hindi ;-)
- I had downloaded the hindi localized build of firefox to test ( I
think I also tested with Arora webkit browser on linux by overwriting
fr-fr with hi-hi and setting the language in Arora as French)

I was hoping to work on Marathi, Kannada when time permits. If there
is enough interest, we can collaborate on this one.

Regards
Anand



On Jun 4, 6:29 pm, Rahul rahul.dhak...@gmail.com wrote:
 Hi Massimo, All,
        Wondering how the internationalization for Indian Languages
 works. I am using latest web2py (1.78.3) on Firefox with Translate
 Plugin installed for translation on Windows XP (SP2). International
 languages like Japanese, Chinese, Korean and others work seamlessly
 and thats brilliant.
 Also, I've successfully translated to Hindi (hi-hi) but Marathi (mr-
 mr) , Bengali (bn-bn) and other languages like Punjabi (pa-pa) etc
 don't seem to work with my application. I've even tried adding these
 languages to Browser (Firefox and IE7) via languages option but no
 use.
 What am I doing wrong? Do these files need to be created exclusively?
 Please advice.

 BTW, I am repeatedly viewing your video onhttp://vimeo.com/7520812
 to understand where I am going wrong.

 Thanks, Rahul.


[web2py] Layout of functions with the MVC environment

2010-06-04 Thread Doug Warren
Traditionally when I've written MVC style applications, the model
would contain not only the data representing the objects but also the
data for manipulating the objects.  I'm not sure how that same
relation applies to web2py.

If I have a model that defines 4-5 tables, 2 of them are just foreign
key lookups, and creating a new object involves inserting data into 3
of the tables, it seems that I would want a create_object method in my
model file.

So I write something like:

def create_object(owner_id=None, template=None):
# Some sanity checking on the above
new_object = db.objects.insert(template_id=template.id, person_id=owner_id)

widgets = db.template_widget(db.template_widget.thingy_template_id
== template.id).select()
for widget in widgets: db.thingy_widget.insert(widget_id =
widget.id, thingy_id = new_object)

whatchymacallits =
db.template_whatchymacallit(db.template_whatchymacallit.thingy_template_id
== template.id).select()
for whatchymacallit in whatchymacallits:
db.thingy_whatchymacallit.insert(whatchymacallit_id =
whatchymacallit.id, thingy_id = new_object)

return new_object

and place that into my db.py.  Now the controller has a function like:
def create():
form = SQLFORM.factory( Field('template',
requires=IS_IN_SET(__get_templates(
if form.accepts(request.vars, session):
foo = db.create_object(owner_id=auth.auth_id,
template_name=form.vars.template)
response.flash = Created
elif form.errors:
response.flash = Error (hacker)

Well db is referring to the DAL db not the db.py, from db import
create_object gives a name not found error, so I'm at a loss as to how
to define functions that work upon the model and can be invoked from
one or more controllers.  Are there any non-trivial example
applications for web2py?  Most of the ones that I have seen assumes
that all data you need in the database can be supplied from a form and
that's not the case I run into over and over again.


[web2py] Re: new stuff in trunk...

2010-06-04 Thread Anand Vaidya
There is a nice article related to this topic on Smashing Magazine:
http://www.smashingmagazine.com/2010/06/02/getting-started-with-e-commerce-your-options-when-selling-online/comment-page-1/#comment-462851

Regards
Anand

On Jun 3, 10:23 pm, Richard richar...@gmail.com wrote:
 I would also trust someone known like PayPal more than the average
 website.

 Hopefully a good PayPal solution can be implemented like PHP has. But
 it's a lot of work for a hobby programmer.

 What do you think about having some kind of bounty system where people
 interested in a difficult feature like this could contribute money as
 an incentive for someone to implement it. On the uservoice page
 (http://web2py.uservoice.com) a lot of people are interested in DAL
 support for NoSQL databases.
 I have heard of other open source projects doing this, though they
 don't seem to have been overly successful.

 Richard

 On Jun 3, 11:39 am, howesc how...@umich.edu wrote:

  I use paypal Website Payments Standard and the *best* part about
  that is that while the user experience is crappy with the redirection,
  i *never* learn the user's credit card number, and therefore don't
  have to worry about regulations in how that info is handled (which
  extends to your server logs if they log parameters).  So, just for
  legal reasons i'll continue to avoid doing credit card processing on
  my site.

  cfh

  On Jun 1, 8:59 pm, Miguel Goncalves goncalvesmig...@gmail.com wrote:

   Paypal has multiple workflows and products.

   The simplest one is *Website Payments Standard* where you direct the 
   user
   to the paypal website for payment. Not great for the user experience but
   workable and above all there is no monthly fee associated with it.

   Another version is *Website Payment Pro* where your visitors stay on 
   your
   website and your server contacts Paypal servers to validate the payment.

   One of the websites I administer has been using the payment standards and
   now is migrating to the pro version. Of course the software they use 
   (x-cart
   -php cart-) integrates nicely with paypal so I did not have to do much 
   work
   :)

   I think these 2 paypal methods would be the most interesting to have
   integrated in web2py since they both support credit cards processing and 
   are
   a cheap and easy way to support payments.

   -Miguel

   On Tue, Jun 1, 2010 at 7:58 PM, mdipierro mdipie...@cs.depaul.edu wrote:
Both paypal and google require redirection to their sites. The
workflow is more complex that needs to be.

There is this:

   http://www.scribd.com/doc/30661771/Web2py-Paypal-Integration

Massimo

On Jun 1, 8:54 pm, Richard richar...@gmail.com wrote:
 would be great if web2py had a robust Paypal solution, which by
 extension would support credit cards too.

 Though maybe this is more difficult than it sounds - I know Django has
 not yet achieved this.
 Recently I signed up for a conference that used a Django registration
 system and the Paypal support was extremely fragile. To pay it
 redirected you to PayPal and then if you pressed back before
 completing it would list you as paid anyway and wouldn't let you pay
 again!

 On Jun 1, 11:21 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  good point. I was not aware of that.

  On Jun 1, 2:04 am, Richard richar...@gmail.com wrote:

   was looking around the Authorize docs and found:
   The merchant must have a U.S. based merchant bank account
   http://developer.authorize.net/guides/AIM/Introduction_to_AIM/AIM_Min
..

   darn...

   If that does rule out non-US developers perhaps it doesn't belong 
   in
   trunk.

   Richard

   On Jun 1, 4:38 pm, Richard richar...@gmail.com wrote:

paypal is definitely complex, but it is also popular!

On Jun 1, 12:16 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 Turns out that one has dependencies. Some in zope code.
 This one seems a simpler option. Authorize.net is one of the 
 best
 options anyway.

 Paypal and google have more complex workflow.

 On May 31, 8:28 pm, Richard richar...@gmail.com wrote:

  sms handling and credit card payments - neat!

  That onlinepayment API you linked earlier (
   http://pypi.python.org/pypi/
  onlinepayment/1.0.0) offers more payment options, such as
PayPal.
  Would it be worth integrating that instead?

  On May 31, 2:42 pm, mdipierro mdipie...@cs.depaul.edu 
  wrote:

   1)
   mail.settings.server='logging'
   will pretend it is sending emails and just log them 
   instead
with a
   warning.

   2) from gluon.contrib.sms_utils import SMSCODES, sms_email
   sms_email(number,provider)
   will send an sms via an email (free) where provider is in 
   the
list of
   SMSCODES

   

[web2py] Re: Rocket for production sites?

2010-06-04 Thread Anand Vaidya

Hi Massimo,

I am confused by what you say here:

 I trust rocket even more but I do not have data or direct
 experience of its use in production.

How can you trust rocket if you have no direct experience with it? Can
you please elaborate what you meant with that line?

Regards
Anand


 On Jun 3, 5:46 pm, knitatoms minkto...@gmail.com wrote:

  Is it the intention that web2py can be deployed using Rocket for
  production sites?


[web2py] Re: Outer join problem

2010-06-04 Thread ceriox
it don't work
AttributeError: 'Field' object has no attribute 'belngs'

mdipierro i write you an email with the real full db

On 4 Giu, 15:40, mdipierro mdipie...@cs.depaul.edu wrote:
 I think you want this, all Books without a union.

 records=db(~db.Book.book_id.belngs(db()._select(db.Union.id))).select(db.Book.ALL)

 On Jun 4, 7:17 am, ceriox cer...@gmail.com wrote:

  hi all
  i have a problem making an outer join
  somebody can write me the correct one?

  db.define_table('Union',
      Field('user_id', db.User, writable=False, readable=False),
      Field('book_id', 'integer', db.Book, writable=False,
  readable=False))

  db.define_table('Book',
     Field('Titolo', 'string'))

  i want to have all book with no User
  i try with
  record=db().select(db.Book.ALL, db.Union.ALL,
  right=db.Book.on(db.Union.book_iddb.Book.id))

  but i have all Book and Book without union

  what is the error?
  thanks for help


[web2py] Re: Ticket when trying to upload an image

2010-06-04 Thread weheh
auth.user table

On Jun 4, 1:43 am, mdipierro mdipie...@cs.depaul.edu wrote:
 which table?

 On Jun 1, 1:42 am, weheh richard_gor...@verizon.net wrote:



  I got the following ticket when trying to upload an image via the
  appadmin:

  Traceback (most recent call last):
    File C:\web2py\gluon\restricted.py, line 178, in restricted
      exec ccode in environment
    File C:/web2py/applications/myapp/controllers/appadmin.py, line
  410, in module
    File C:\web2py\gluon\globals.py, line 96, in lambda
      self._caller = lambda f: f()
    File C:/web2py/applications/myapp/controllers/appadmin.py, line
  275, in update
      if form.accepts(request.vars, session):
    File C:\web2py\gluon\sqlhtml.py, line 862, in accepts
      if not request_vars.get(key,None) \
    File C:\Program Files\Python25\Lib\cgi.py, line 633, in __len__
      return len(self.keys())
    File C:\Program Files\Python25\Lib\cgi.py, line 609, in keys
      raise TypeError, not indexable
  TypeError: not indexable

  The image field is defined as follows:

    Field('avatar','upload',label=T('Image'),autodelete=True,
      uploadfolder=PATH,

  requires=(IS_NULL_OR(IS_IMAGE()),IS_NULL_OR(IS_LENGTH(10,10,

  Any ideas?- Hide quoted text -

 - Show quoted text -


[web2py] Re: Outer join problem

2010-06-04 Thread Candid
typo: belongs, not belngs

On Jun 4, 11:49 am, ceriox cer...@gmail.com wrote:
 it don't work
 AttributeError: 'Field' object has no attribute 'belngs'

 mdipierro i write you an email with the real full db

 On 4 Giu, 15:40, mdipierro mdipie...@cs.depaul.edu wrote:



  I think you want this, all Books without a union.

  records=db(~db.Book.book_id.belngs(db()._select(db.Union.id))).select(db.Bo 
  ok.ALL)

  On Jun 4, 7:17 am, ceriox cer...@gmail.com wrote:

   hi all
   i have a problem making an outer join
   somebody can write me the correct one?

   db.define_table('Union',
       Field('user_id', db.User, writable=False, readable=False),
       Field('book_id', 'integer', db.Book, writable=False,
   readable=False))

   db.define_table('Book',
      Field('Titolo', 'string'))

   i want to have all book with no User
   i try with
   record=db().select(db.Book.ALL, db.Union.ALL,
   right=db.Book.on(db.Union.book_iddb.Book.id))

   but i have all Book and Book without union

   what is the error?
   thanks for help


[web2py] Re: Layout of functions with the MVC environment

2010-06-04 Thread Yarko Tymciurak


On Jun 4, 10:43 am, Doug Warren doug.war...@gmail.com wrote:
 Traditionally when I've written MVC style applications, the model
 would contain not only the data representing the objects but also the
 data for manipulating the objects.  I'm not sure how that same
 relation applies to web2py.

 If I have a model that defines 4-5 tables, 2 of them are just foreign
 key lookups, and creating a new object involves inserting data into 3
 of the tables, it seems that I would want a create_object method in my
 model file.

 So I write something like:

 def create_object(owner_id=None, template=None):
     # Some sanity checking on the above
     new_object = db.objects.insert(template_id=template.id, 
 person_id=owner_id)

     widgets = db.template_widget(db.template_widget.thingy_template_id
 == template.id).select()
     for widget in widgets: db.thingy_widget.insert(widget_id =
 widget.id, thingy_id = new_object)

     whatchymacallits =
 db.template_whatchymacallit(db.template_whatchymacallit.thingy_template_id
 == template.id).select()
     for whatchymacallit in whatchymacallits:
 db.thingy_whatchymacallit.insert(whatchymacallit_id =
 whatchymacallit.id, thingy_id = new_object)

     return new_object

 and place that into my db.py.  Now the controller has a function like:
 def create():
     form = SQLFORM.factory( Field('template',
 requires=IS_IN_SET(__get_templates(
     if form.accepts(request.vars, session):
         foo = db.create_object(owner_id=auth.auth_id,
 template_name=form.vars.template)
         response.flash = Created
     elif form.errors:
         response.flash = Error (hacker)

 Well db is referring to the DAL db not the db.py, from db import
 create_object gives a name not found error, so I'm at a loss as to how
 to define functions that work upon the model and can be invoked from
 one or more controllers.

I'm not sure what exactly you are saying here - but to import, use
local_import()
(see http://www.web2py.com/book/default/section/4/18?search=local_import)

BUT before you do, here is some background:

When a request comes into web2py,   here's what happens (roughly):

web2py parses the request url, and sets up an environment to call the
appropriate application / controller / function;
Part of that setup involves running all the files in your app's  model
folder (so that db connections, table definitions, etc. are all there
for you);

This means you can put your files in the models folder, and they will
be run (defined) before the call to your controller.

Then, your controller / function is called.

local_import will pull in definitions / modules from your
application's modules folder, but you can (for development certainly)
just put your file in your models folder.
When you really want to reduce what gets run at _each_ request, you
might want to look at what to move to modules, so that you're only
pulling in those files when needed.

As for db - DAL:   db is the global and default  name for the db
connection string (it is so named and setup in the default models/
db.py file).   You can change the name of this variable as you like
(or change your imports).

Hope this at least helps point you out of the forrest.

Regards,
- Yarko
 Are there any non-trivial example
 applications for web2py?  Most of the ones that I have seen assumes
 that all data you need in the database can be supplied from a form and
 that's not the case I run into over and over again.


Re: [web2py] Re: Layout of functions with the MVC environment

2010-06-04 Thread Doug Warren
I don't believe I want to local_import my db.py file as it's already
set up by the environment correct?

What I'm asking for is a way to keep all of the code that relates to
the model in one place and to invoke it from controllers.  That is if
I define 5 tables for the model I'd expect to write helper functions
to manipulate all 5 tables and not to have the controller know the
intimate details of the model.  That's the concept behind Object
Orientated programming isn't it?  Objects are black boxes to other
objects other than their public facing interface.

On Fri, Jun 4, 2010 at 8:56 AM, Yarko Tymciurak
resultsinsoftw...@gmail.com wrote:


 On Jun 4, 10:43 am, Doug Warren doug.war...@gmail.com wrote:
 Traditionally when I've written MVC style applications, the model
 would contain not only the data representing the objects but also the
 data for manipulating the objects.  I'm not sure how that same
 relation applies to web2py.

 If I have a model that defines 4-5 tables, 2 of them are just foreign
 key lookups, and creating a new object involves inserting data into 3
 of the tables, it seems that I would want a create_object method in my
 model file.

 So I write something like:

 def create_object(owner_id=None, template=None):
     # Some sanity checking on the above
     new_object = db.objects.insert(template_id=template.id, 
 person_id=owner_id)

     widgets = db.template_widget(db.template_widget.thingy_template_id
 == template.id).select()
     for widget in widgets: db.thingy_widget.insert(widget_id =
 widget.id, thingy_id = new_object)

     whatchymacallits =
 db.template_whatchymacallit(db.template_whatchymacallit.thingy_template_id
 == template.id).select()
     for whatchymacallit in whatchymacallits:
 db.thingy_whatchymacallit.insert(whatchymacallit_id =
 whatchymacallit.id, thingy_id = new_object)

     return new_object

 and place that into my db.py.  Now the controller has a function like:
 def create():
     form = SQLFORM.factory( Field('template',
 requires=IS_IN_SET(__get_templates(
     if form.accepts(request.vars, session):
         foo = db.create_object(owner_id=auth.auth_id,
 template_name=form.vars.template)
         response.flash = Created
     elif form.errors:
         response.flash = Error (hacker)

 Well db is referring to the DAL db not the db.py, from db import
 create_object gives a name not found error, so I'm at a loss as to how
 to define functions that work upon the model and can be invoked from
 one or more controllers.

 I'm not sure what exactly you are saying here - but to import, use
 local_import()
 (see http://www.web2py.com/book/default/section/4/18?search=local_import)

 BUT before you do, here is some background:

 When a request comes into web2py,   here's what happens (roughly):

 web2py parses the request url, and sets up an environment to call the
 appropriate application / controller / function;
 Part of that setup involves running all the files in your app's  model
 folder (so that db connections, table definitions, etc. are all there
 for you);

 This means you can put your files in the models folder, and they will
 be run (defined) before the call to your controller.

 Then, your controller / function is called.

 local_import will pull in definitions / modules from your
 application's modules folder, but you can (for development certainly)
 just put your file in your models folder.
 When you really want to reduce what gets run at _each_ request, you
 might want to look at what to move to modules, so that you're only
 pulling in those files when needed.

 As for db - DAL:   db is the global and default  name for the db
 connection string (it is so named and setup in the default models/
 db.py file).   You can change the name of this variable as you like
 (or change your imports).

 Hope this at least helps point you out of the forrest.

 Regards,
 - Yarko
 Are there any non-trivial example
 applications for web2py?  Most of the ones that I have seen assumes
 that all data you need in the database can be supplied from a form and
 that's not the case I run into over and over again.


[web2py] Re: Layout of functions with the MVC environment

2010-06-04 Thread Yarko Tymciurak


On Jun 4, 10:58 am, Doug Warren doug.war...@gmail.com wrote:
 I don't believe I want to local_import my db.py file as it's already
 set up by the environment correct?

Correct - you do not want / need to import your db.py.

As long as it is in your models folder (by default it is), it's
already in your request context before your controller is called.


 What I'm asking for is a way to keep all of the code that relates to
 the model in one place and to invoke it from controllers.  That is if
 I define 5 tables for the model I'd expect to write helper functions
 to manipulate all 5 tables and not to have the controller know the
 intimate details of the model.  That's the concept behind Object
 Orientated programming isn't it?  Objects are black boxes to other
 objects other than their public facing interface.

Right - but DAL is just a Data abstraction layer (i.e. an SQL adapter,
if you will), not an ORM (i.e. there's not the level of object-
oriented abstraction that you would expect w/ an orm - it's lower
level)

So in web2py, with DAL you have knowledge of your table layout
(without direct knowledge / need for the specific back ends SQL).

You'll also find that forms, and validators are coupled to table
structure, so if / as you try to abstract away from table definitions,
you will run into this.

I'm sure others will add more comments...


 On Fri, Jun 4, 2010 at 8:56 AM, Yarko Tymciurak

 resultsinsoftw...@gmail.com wrote:

  On Jun 4, 10:43 am, Doug Warren doug.war...@gmail.com wrote:
  Traditionally when I've written MVC style applications, the model
  would contain not only the data representing the objects but also the
  data for manipulating the objects.  I'm not sure how that same
  relation applies to web2py.

  If I have a model that defines 4-5 tables, 2 of them are just foreign
  key lookups, and creating a new object involves inserting data into 3
  of the tables, it seems that I would want a create_object method in my
  model file.

  So I write something like:

  def create_object(owner_id=None, template=None):
      # Some sanity checking on the above
      new_object = db.objects.insert(template_id=template.id, 
  person_id=owner_id)

      widgets = db.template_widget(db.template_widget.thingy_template_id
  == template.id).select()
      for widget in widgets: db.thingy_widget.insert(widget_id =
  widget.id, thingy_id = new_object)

      whatchymacallits =
  db.template_whatchymacallit(db.template_whatchymacallit.thingy_template_id
  == template.id).select()
      for whatchymacallit in whatchymacallits:
  db.thingy_whatchymacallit.insert(whatchymacallit_id =
  whatchymacallit.id, thingy_id = new_object)

      return new_object

  and place that into my db.py.  Now the controller has a function like:
  def create():
      form = SQLFORM.factory( Field('template',
  requires=IS_IN_SET(__get_templates(
      if form.accepts(request.vars, session):
          foo = db.create_object(owner_id=auth.auth_id,
  template_name=form.vars.template)
          response.flash = Created
      elif form.errors:
          response.flash = Error (hacker)

  Well db is referring to the DAL db not the db.py, from db import
  create_object gives a name not found error, so I'm at a loss as to how
  to define functions that work upon the model and can be invoked from
  one or more controllers.

  I'm not sure what exactly you are saying here - but to import, use
  local_import()
  (seehttp://www.web2py.com/book/default/section/4/18?search=local_import)

  BUT before you do, here is some background:

  When a request comes into web2py,   here's what happens (roughly):

  web2py parses the request url, and sets up an environment to call the
  appropriate application / controller / function;
  Part of that setup involves running all the files in your app's  model
  folder (so that db connections, table definitions, etc. are all there
  for you);

  This means you can put your files in the models folder, and they will
  be run (defined) before the call to your controller.

  Then, your controller / function is called.

  local_import will pull in definitions / modules from your
  application's modules folder, but you can (for development certainly)
  just put your file in your models folder.
  When you really want to reduce what gets run at _each_ request, you
  might want to look at what to move to modules, so that you're only
  pulling in those files when needed.

  As for db - DAL:   db is the global and default  name for the db
  connection string (it is so named and setup in the default models/
  db.py file).   You can change the name of this variable as you like
  (or change your imports).

  Hope this at least helps point you out of the forrest.

  Regards,
  - Yarko
  Are there any non-trivial example
  applications for web2py?  Most of the ones that I have seen assumes
  that all data you need in the database can be supplied from a form and
  that's not the case I run into over and over again.


[web2py] convert field to multiple view values?

2010-06-04 Thread Keith
I'm new to web2py and the I did this previously was with javascript
but I was hoping to avoid that this go around.

In my database table I have a single field something like this below:

db.define_table('foo',
   Field('height', 'double'),

In the controller/view I need to be able to translate that so when
viewing a record they see:
Feet, Inches, and Fractions of a Inch.

When adding a record it would need to be a text field for feet and
drop down lists for inches and fractions of a inch.

I know how to do that in javascript, but I don't like relying on
javascript if possible.  I'm hoping there is a way to do this in the
controller or model.

Thanks for any suggestions.


[web2py] Re: routes to have userprofile pages

2010-06-04 Thread Adi
Assuming your application is in init folder - the following might work

routes_in=(
  ('/profile/$args', '/init/default/profile/$args'),
  ('/profile/$args/(?Pany.*$)', '/init/default/profile/$args/
\gany'),
)

routes_out=(
  ('/init/default/profile/$args', '/profile/$args'),
  ('/init/default/profile/$args/\gany', '/profile/$args/(?Pany.*
$)'),
)


On Jun 4, 6:23 pm, ChrisM cjjmur...@gmail.com wrote:
 anyone?

 On Jun 3, 2:29 pm, ChrisM cjjmur...@gmail.com wrote:



  Having trouble gettingroutesto work (not used before) for instance
  as a test I did:

  inroutes.py:
  routes_in = (  ('/profile/*', '/init/default/userprofilepage/*'),)
  routes_out = (  ('/init/default/userprofilepage/*', '/profile'),)

  in default controller:
  def userprofilepage():
      userprofile request.args(0)
      return dict(userprofile=userprofile)

  in userprofilepage.html:

  {{extend 'layout.html'}}
  h1{{=userprofile}}/h1

  get invalid request?

  any help appreciated.
  chrism

  On Jun 3, 6:08 am, Adi aditya.sa...@gmail.com wrote:

   You could use an argument.

  www.myapp.com/userprofilecanbemapped to a controller/method 
  likewww.myapp.com/app/profiles/show/userprofile

   where app = application, profiles = controller, show = function,
   userprofile is an argument accessed by request.args(0) inside show.
   You can use it to query database according to that user.

   In order to hide app/profiles/show from url follow the usualroutes.py 
   mapping  (its given on some other post here) assuming you
   have only one app on the server.

   On Jun 2, 9:31 pm, ChrisM cjjmur...@gmail.com wrote:

For isntance I have RPX login which creates user profile for each
logged in user.
I would like to give each one of these users there own homepage (i.e.
like twitter) which could be
dynamically created.
So I thought the first task was to see how thiscould be mapped,
perhaps by querying db.profile and then mapping throughroutes.py.

chrism

On Jun 2, 3:46 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 Can you explain more?

 On Jun 2, 8:00 am, ChrisM cjjmur...@gmail.com wrote:

  I searched through the list but couldn't find any discussion on this
  topic.

  Any ideas how the following can be achieved withroutes.py

 www.appname.com\userprofilename

  I am guessing that there would need to be a db.auth lookup to match
  the userprofilename
  and then pass that to a generic controller, but how?

  Help Aprreciated

  ChrisM- Hide quoted text -

 - Show quoted text -- Hide quoted text -

   - Show quoted text -- Hide quoted text -

  - Show quoted text -


Re: [web2py] Re: Rocket for production sites?

2010-06-04 Thread Jason Brower
Ananad... if you haven't used it how can _you_ trust it.  You may want
to talk to the people that made Rocket.  I use it for our production
system.  But my setup is very different.  It runs a robot.
BR,
Jason

On Fri, 2010-06-04 at 08:46 -0700, Anand Vaidya wrote: 
 Hi Massimo,
 
 I am confused by what you say here:
 
  I trust rocket even more but I do not have data or direct
  experience of its use in production.
 
 How can you trust rocket if you have no direct experience with it? Can
 you please elaborate what you meant with that line?
 
 Regards
 Anand
 
 
  On Jun 3, 5:46 pm, knitatoms minkto...@gmail.com wrote:
 
   Is it the intention that web2py can be deployed using Rocket for
   production sites?




Re: [web2py] Re: Layout of functions with the MVC environment

2010-06-04 Thread Doug Warren
On Fri, Jun 4, 2010 at 9:11 AM, Yarko Tymciurak
resultsinsoftw...@gmail.com wrote:


 On Jun 4, 10:58 am, Doug Warren doug.war...@gmail.com wrote:
 I don't believe I want to local_import my db.py file as it's already
 set up by the environment correct?

 Correct - you do not want / need to import your db.py.

 As long as it is in your models folder (by default it is), it's
 already in your request context before your controller is called.

Yes but as I mentioned in my original E-Mail, I was unable to get a
function defined in the model file to be visible to the controller
hence the original question. :)

I thought about it a bit during my drive and think I will try (using
the below example) something like:
def create_object...
...

co = create_object

controller.py
  co( template_id ...)



 What I'm asking for is a way to keep all of the code that relates to
 the model in one place and to invoke it from controllers.  That is if
 I define 5 tables for the model I'd expect to write helper functions
 to manipulate all 5 tables and not to have the controller know the
 intimate details of the model.  That's the concept behind Object
 Orientated programming isn't it?  Objects are black boxes to other
 objects other than their public facing interface.

 Right - but DAL is just a Data abstraction layer (i.e. an SQL adapter,
 if you will), not an ORM (i.e. there's not the level of object-
 oriented abstraction that you would expect w/ an orm - it's lower
 level)

 So in web2py, with DAL you have knowledge of your table layout
 (without direct knowledge / need for the specific back ends SQL).

 You'll also find that forms, and validators are coupled to table
 structure, so if / as you try to abstract away from table definitions,
 you will run into this.

 I'm sure others will add more comments...


 On Fri, Jun 4, 2010 at 8:56 AM, Yarko Tymciurak

 resultsinsoftw...@gmail.com wrote:

  On Jun 4, 10:43 am, Doug Warren doug.war...@gmail.com wrote:
  Traditionally when I've written MVC style applications, the model
  would contain not only the data representing the objects but also the
  data for manipulating the objects.  I'm not sure how that same
  relation applies to web2py.

  If I have a model that defines 4-5 tables, 2 of them are just foreign
  key lookups, and creating a new object involves inserting data into 3
  of the tables, it seems that I would want a create_object method in my
  model file.

  So I write something like:

  def create_object(owner_id=None, template=None):
      # Some sanity checking on the above
      new_object = db.objects.insert(template_id=template.id, 
  person_id=owner_id)

      widgets = db.template_widget(db.template_widget.thingy_template_id
  == template.id).select()
      for widget in widgets: db.thingy_widget.insert(widget_id =
  widget.id, thingy_id = new_object)

      whatchymacallits =
  db.template_whatchymacallit(db.template_whatchymacallit.thingy_template_id
  == template.id).select()
      for whatchymacallit in whatchymacallits:
  db.thingy_whatchymacallit.insert(whatchymacallit_id =
  whatchymacallit.id, thingy_id = new_object)

      return new_object

  and place that into my db.py.  Now the controller has a function like:
  def create():
      form = SQLFORM.factory( Field('template',
  requires=IS_IN_SET(__get_templates(
      if form.accepts(request.vars, session):
          foo = db.create_object(owner_id=auth.auth_id,
  template_name=form.vars.template)
          response.flash = Created
      elif form.errors:
          response.flash = Error (hacker)

  Well db is referring to the DAL db not the db.py, from db import
  create_object gives a name not found error, so I'm at a loss as to how
  to define functions that work upon the model and can be invoked from
  one or more controllers.

  I'm not sure what exactly you are saying here - but to import, use
  local_import()
  (seehttp://www.web2py.com/book/default/section/4/18?search=local_import)

  BUT before you do, here is some background:

  When a request comes into web2py,   here's what happens (roughly):

  web2py parses the request url, and sets up an environment to call the
  appropriate application / controller / function;
  Part of that setup involves running all the files in your app's  model
  folder (so that db connections, table definitions, etc. are all there
  for you);

  This means you can put your files in the models folder, and they will
  be run (defined) before the call to your controller.

  Then, your controller / function is called.

  local_import will pull in definitions / modules from your
  application's modules folder, but you can (for development certainly)
  just put your file in your models folder.
  When you really want to reduce what gets run at _each_ request, you
  might want to look at what to move to modules, so that you're only
  pulling in those files when needed.

  As for db - DAL:   db is the global and default  name for the db
  connection string (it is so 

[web2py] Re: Outer join problem

2010-06-04 Thread ceriox
now it work thanks Candid

On 4 Giu, 17:55, Candid roman.bat...@gmail.com wrote:
 typo: belongs, not belngs

 On Jun 4, 11:49 am, ceriox cer...@gmail.com wrote:

  it don't work
  AttributeError: 'Field' object has no attribute 'belngs'

  mdipierro i write you an email with the real full db

  On 4 Giu, 15:40, mdipierro mdipie...@cs.depaul.edu wrote:

   I think you want this, all Books without a union.

   records=db(~db.Book.book_id.belngs(db()._select(db.Union.id))).select(db.Bo
ok.ALL)

   On Jun 4, 7:17 am, ceriox cer...@gmail.com wrote:

hi all
i have a problem making an outer join
somebody can write me the correct one?

db.define_table('Union',
    Field('user_id', db.User, writable=False, readable=False),
    Field('book_id', 'integer', db.Book, writable=False,
readable=False))

db.define_table('Book',
   Field('Titolo', 'string'))

i want to have all book with no User
i try with
record=db().select(db.Book.ALL, db.Union.ALL,
right=db.Book.on(db.Union.book_iddb.Book.id))

but i have all Book and Book without union

what is the error?
thanks for help


Re: [web2py] Re: Layout of functions with the MVC environment

2010-06-04 Thread Thadeus Burgess
All functions defined in models are available to controllers and views
as anything you put in the models becomes part of the global namespace
that the controllers/views are executed in.

This leads to potential problems of namespace collision.

Make sure you do not overwrite the function elsewhere, as this could
be causing issues.

Why are you calling db.create_object? This isn't a class of the DAL,
refer to Yarko's explanation, the DAL is not an ORM.

You probably mean.

  if form.accepts(request.vars, session):
   foo = create_object(owner_id=auth.auth_id, # NOT
db.create_object, just call your function like regular
template_name=form.vars.template)



--
Thadeus





On Fri, Jun 4, 2010 at 11:39 AM, Doug Warren doug.war...@gmail.com wrote:
 On Fri, Jun 4, 2010 at 9:11 AM, Yarko Tymciurak
 resultsinsoftw...@gmail.com wrote:


 On Jun 4, 10:58 am, Doug Warren doug.war...@gmail.com wrote:
 I don't believe I want to local_import my db.py file as it's already
 set up by the environment correct?

 Correct - you do not want / need to import your db.py.

 As long as it is in your models folder (by default it is), it's
 already in your request context before your controller is called.

 Yes but as I mentioned in my original E-Mail, I was unable to get a
 function defined in the model file to be visible to the controller
 hence the original question. :)

 I thought about it a bit during my drive and think I will try (using
 the below example) something like:
 def create_object...
 ...

 co = create_object

 controller.py
  co( template_id ...)



 What I'm asking for is a way to keep all of the code that relates to
 the model in one place and to invoke it from controllers.  That is if
 I define 5 tables for the model I'd expect to write helper functions
 to manipulate all 5 tables and not to have the controller know the
 intimate details of the model.  That's the concept behind Object
 Orientated programming isn't it?  Objects are black boxes to other
 objects other than their public facing interface.

 Right - but DAL is just a Data abstraction layer (i.e. an SQL adapter,
 if you will), not an ORM (i.e. there's not the level of object-
 oriented abstraction that you would expect w/ an orm - it's lower
 level)

 So in web2py, with DAL you have knowledge of your table layout
 (without direct knowledge / need for the specific back ends SQL).

 You'll also find that forms, and validators are coupled to table
 structure, so if / as you try to abstract away from table definitions,
 you will run into this.

 I'm sure others will add more comments...


 On Fri, Jun 4, 2010 at 8:56 AM, Yarko Tymciurak

 resultsinsoftw...@gmail.com wrote:

  On Jun 4, 10:43 am, Doug Warren doug.war...@gmail.com wrote:
  Traditionally when I've written MVC style applications, the model
  would contain not only the data representing the objects but also the
  data for manipulating the objects.  I'm not sure how that same
  relation applies to web2py.

  If I have a model that defines 4-5 tables, 2 of them are just foreign
  key lookups, and creating a new object involves inserting data into 3
  of the tables, it seems that I would want a create_object method in my
  model file.

  So I write something like:

  def create_object(owner_id=None, template=None):
      # Some sanity checking on the above
      new_object = db.objects.insert(template_id=template.id, 
  person_id=owner_id)

      widgets = db.template_widget(db.template_widget.thingy_template_id
  == template.id).select()
      for widget in widgets: db.thingy_widget.insert(widget_id =
  widget.id, thingy_id = new_object)

      whatchymacallits =
  db.template_whatchymacallit(db.template_whatchymacallit.thingy_template_id
  == template.id).select()
      for whatchymacallit in whatchymacallits:
  db.thingy_whatchymacallit.insert(whatchymacallit_id =
  whatchymacallit.id, thingy_id = new_object)

      return new_object

  and place that into my db.py.  Now the controller has a function like:
  def create():
      form = SQLFORM.factory( Field('template',
  requires=IS_IN_SET(__get_templates(
      if form.accepts(request.vars, session):
          foo = db.create_object(owner_id=auth.auth_id,
  template_name=form.vars.template)
          response.flash = Created
      elif form.errors:
          response.flash = Error (hacker)

  Well db is referring to the DAL db not the db.py, from db import
  create_object gives a name not found error, so I'm at a loss as to how
  to define functions that work upon the model and can be invoked from
  one or more controllers.

  I'm not sure what exactly you are saying here - but to import, use
  local_import()
  (seehttp://www.web2py.com/book/default/section/4/18?search=local_import)

  BUT before you do, here is some background:

  When a request comes into web2py,   here's what happens (roughly):

  web2py parses the request url, and sets up an environment to call the
  appropriate application / controller / function;
  Part of that 

Re: [web2py] [proposition] Need date calculations in a query

2010-06-04 Thread Thadeus Burgess
http://thadeusb.com/weblog/archive/2010/1/5/query_between_dates/30
http://thadeusb.com/weblog/archive/2010/3/19/increase_productivity_by_using_parameterized_queries_with_web2py/33

If you have any questions please feel free to ask.

--
Thadeus





On Fri, Jun 4, 2010 at 5:42 AM, Sverre sverreodeg...@gmail.com wrote:
 I need some like

 query(startdate+timedelta(days)  endtime)

 In PostgreSQL and other databases that not a problem. The alternative
 is only filtering on client side.



Re: [web2py] Re: Multiple instances of same application

2010-06-04 Thread Thadeus Burgess
I agree with Massimo, the NOT packing facility could be handled by .hgignore.

As for configuration, I have used 0_config.py in blogitizor so that I
can run two versions, my personal version and the one that is open
source, this way my database and email information doesn't get leaked
out into the internetz.

I use the following,

http://code.google.com/p/blogitizor/source/browse/src/models/A_config.example

And then rename it to A_config.py and it won't get committed since
src/models/A_config.py is placed in my .hgignore file.

However this isn't a web2py mechanism just a personal one, I don't
like the idea of making web2py in charge of this because then I the
developer lose control and can't change the way it works without
forking web2py.



--
Thadeus





On Fri, Jun 4, 2010 at 3:28 AM, Iceberg iceb...@21cn.com wrote:
 Aside from the config issue, a flag when packaging that does not
 package the database/ folder, would be the long missing piece. And
 when this flag is available, I think I can have my own databases/
 my_config.py to solve the local config problem in my style. :-)

 So +1 for the flag when packaging that does not package the database/
 folder.

 On Jun4, 2:20pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I normally use

 #in models/0.py
 from gluon.storage import Storage
 settings=Storage()
 settings.development=True
 settings.email_sender=...@example.com'
 ...

 Anyway, this does not address Iceberg's problem of packing some config
 files and not others. I am not convinced this scenario should be
 handled at the web2py level. This is better handled using .hgignore
 and mercurial or other version control system.

 I am thinking anyway, to allow a flag when packaging that does not
 package the database/ folder. So in principle one could create
 function that updates parameters from a DAL('sqlite://settings.db')

 On Jun 4, 1:10 am, Iceberg iceb...@21cn.com wrote:



  IMHO, flask and my lightweight proposal try to solve same problem.
  Both can load configuration for sure. My proposal's loading ability
  relies only on python's built-in import (via web2py's model
  mechanism), therefore no need to introducing extra module. Isn't it
  clean?

  The basic challenge is how to separate and manage local setting from
  default setting, and how to prevent the local setting being
  distributed via app.w2p or Mercurial. Flask uses environment variable
  YOURAPPLICATION_SETTINGS=/path/to/settings.cfg, to specify a local
  setting. I like that too, but it can not be done via pure web2py admin
  interface, so administrator need to ssh into their production machine
  and make adjustments, and perhaps a kill-and-restart is needed. On the
  contrary, in my proposal, although I did not emphasis this in earlier
  post, administrator only need to visit standard web2py admin interface
  and setup a new 0_local_setting.py. No ssh nor restart is needed,
  again I rely on web2py's native behavior. Isn't it lightweight?

  Of course, I don't like the
  0_local_config_pls_dont_pack_dont_commit.py naming convention neither,
  but I just did not come up with another descriptive name. The point
  here, is we need a config file which can be used by a web2py app, but
  not packed with the app.

  Well, if we really just don't like the long and clumsy name
  convention, then we can do it in a decent way:
  1. introduce a applications/myapp/local_config directory, local
  settings go into there.
  2. adjust web2py to NOT pack, and NOT commit local_config directory
  3. but we need more work for web2py's admin UI, to support add/edit/
  view/delete setting file.

  We can choose.

  On Jun4, 3:26am, Thadeus Burgess thade...@thadeusb.com wrote:

   Or... we can copy flask and integrate a configuration module..

   God I pray we never use something like
   `0_local_config_pls_dont_pack_dont_commit.py` INTO web2py. web2py and
   its naming conventions .

   --
   Thadeus

   On Thu, Jun 3, 2010 at 10:22 AM, Iceberg iceb...@21cn.com wrote:
I think Doug's puzzle deserves a more general solution. The
requirement and challenge is:
R1. The app's central source code should contain default setting.
R2. The app's multiple deployment instances should be allowed to
contain its local setting.
R3. And after the next hg update, the default setting in (R1) should
not override the local setting in (R2).

My solution contains two steps:
Step1: Use myapp/models/0_config.py to store default setting, such as:
   MY_HOST = 'http://localhost'
   MY_EMAIL = '@bar.com'
   MY_PASSWORD = 'blah'
   MY_DB = 'sqlite://storage.sqlite'

Step2: Use myapp/models/0_local_config_pls_dont_pack_dont_commit.py to
store instance-wide local setting, such as:
   MY_HOST = 'http://myaccount.my_vps_provider.com'
   MY_EMAIL = 'my_real_acco...@for_example_hotmail.com'
   MY_PASSWORD = 'i_will_never_share_it'
   MY_DB = 'mysql://10.1.1.1.'

To reach this goal, two things need to 

[web2py] welcome.w2p

2010-06-04 Thread NetAdmin
I just upgraded to web2p version 1.78.3 and there seems to be no
welcome.w2p scaffold app.

Is this a problem or do I need to create my own?

Thanks!



[web2py] Re: welcome.w2p

2010-06-04 Thread NetAdmin

Sorry I found it.  Time for new eye-glasses.



On Jun 4, 2:19 pm, NetAdmin mr.netad...@gmail.com wrote:
 I just upgraded to web2p version 1.78.3 and there seems to be no
 welcome.w2p scaffold app.

 Is this a problem or do I need to create my own?

 Thanks!


[web2py] Cherokee-fastcgi server (error log)

2010-06-04 Thread Jose
Hello,

From the applicative not see any mistake or problem, but I think that
is not normal, but in the error log Cherokee appears thousands of
times the following error:

Unhandled exception in thread started by bound method Connection.run
of gluon.contrib.gateways.fcgi.Connection object at 0x8071515d0
Traceback (most recent call last):
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 664, in
run
self.process_input()
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 700, in
process_input
self._do_params(rec)
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 799, in
_do_params
self._start_request(req)
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 783, in
_start_request
req.run()
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 592, in
run
self._flush()
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 599, in
_flush
self.stdout.close()
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 358, in
close
self._conn.writeRecord(rec)
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 715, in
writeRecord
rec.write(self._sock)
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 552, in
write
self._sendall(sock, header)
  File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 529, in
_sendall
sent = sock.send(data)
socket.error: [Errno 32] Broken pipe


How to solve this?

Jose


[web2py] Re: Rocket for production sites?

2010-06-04 Thread mdipierro
Because I have seen the source code. Even if a problem where to show
up (none recently), I trust we'd be able to deal with it fast.

On Jun 4, 10:46 am, Anand Vaidya anandvaidya...@gmail.com wrote:
 Hi Massimo,

 I am confused by what you say here:

  I trust rocket even more but I do not have data or direct
  experience of its use in production.

 How can you trust rocket if you have no direct experience with it? Can
 you please elaborate what you meant with that line?

 Regards
 Anand



  On Jun 3, 5:46 pm, knitatoms minkto...@gmail.com wrote:

   Is it the intention that web2py can be deployed using Rocket for
   production sites?


[web2py] Re: Where can I download web2py 1.77.3?

2010-06-04 Thread mdipierro
The problem is that the csv export requires the entire data to be
stored in ram. You may want to try exporting using the shell and/or
exporting a some data at the time.

On Jun 4, 2:22 pm, drayco antrod...@gmail.com wrote:
 Today, when I try to download large csv archives, with admin, apache
 crashed

 Well, I added this to httpd.conf

 WSGIDaemonProcess web2py user=drayco group=drayco \
      home=/home/drayco/webapps/seccion36/web2py \
      processes=1 maximum-requests=1000

 But even with that, apache crashed equal. Any advice?

 On Jun 4, 12:20 am, drayco antrod...@gmail.com wrote:

  Well, I followed the advise of Dr. Massimo, thank's a lot.

  I updated all about my applications in web2faction, but a I did all
  manually, because when I used the script for install I can't used
  admin well. (install applications and local_import).
  I am using in my applications mod_wgsi 2.5 and python 2.5
  I configured the httpd.conf with this

  ServerRoot /home/username/webapps/appname/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/username/webapps/appname/htdocs
  KeepAlive Off
  Listen PORTNUMBER
  LogFormat %{X-Forwarded-For}i %l %u %t \%r\ %s %b \%{Referer}i\
  \%{User-Agent}i\ combined
  CustomLog /home/username/logs/user/access_appname.log combined
  ErrorLog /home/username/logs/user/error_appname.log
  ServerLimit 2

  SetEnvIf X-Forwarded-SSL on HTTPS=1

  WSGIScriptAlias / /home/username/webapps/appname/web2py/wsgihandler.py

  I ran web2py manually one time, and them I ran apache, at this moment,
  everything is done with web2py version 1.78.3 even admin with https.

  On Jun 3, 1:48 am, drayco antrod...@gmail.com wrote:

   Very probability, because i very new in web applications and python

   In the past,1 week ago, before we updated version of web2py, we
   created 10589 registers with the same application. And now, the only
   idea that i have, it is this, the new version of web2py.

   This are the controllers involved when we created one register

   #Beneficiarios
   @auth.requires_login()
   def update_benef(form):
       import datetime
       now = datetime.datetime.today()
       beneficiario = db.benefs2[form.vars.id]

   keybenef=db(db.keys2benefs.keybenef==beneficiario.key_Registro).select()

   db(db.keys2benefs.id==keybenef[0].id).update(benefid=beneficiario.id)
       coordinador = db.coordinadores[keybenef[0].coordid]
       fechas =
   db((db.fechas.fechaTramitenow)(db.fechas.regional==coordinador.regional)(db.fechas.fulldb.fechas.cargaMax)).select(db.fechas.ALL,orderby=db.fechas.fechaTramite)

   db(db.benefs2.id==beneficiario.id).update(coordid=keybenef[0].coordid)
       db(db.benefs2.id==beneficiario.id).update(fechasid=fechas[0].id)
       db(db.fechas.id==fechas[0].id).update(full=fechas[0].full+1)

   #Beneficiarios
   @auth.requires_login()
   def update_benef2(form):
       now = request.now
       benef = db.benefs2[form.vars.id]
       keybenef=db(db.keys2benefs.keybenef==benef.key_Registro).select()
   [0]
       db(db.keys2benefs.id==keybenef.id).update(benefs2_id=benef.id)
       coord = db.coordinadores[keybenef.coordinador_id]
       dates2 =
   db((db.dates2.startnow)(db.dates2.regional_id==coord.regional_id)(db.dates2.xdiadb.dates2.cargados)).
   \
           select(db.dates2.ALL,orderby=db.dates2.start)[0]
       benefs =
   db(db.benefs2.dates2_id==dates2.id).select(db.benefs2.id,db.benefs2.tramite,db.benefs2.entrega,db.benefs2.tramite.count(),
   \
           orderby=db.benefs2.tramite,groupby=db.benefs2.tramite)
       if len(benefs)0:
           if
   benefs[len(benefs)-1]._extra[db.benefs2.tramite.count()]dates2.xhora:
               tramite=benefs[len(benefs)-1].benefs2.tramite
               entrega=benefs[len(benefs)-1].benefs2.entrega
           else:
               from datetime import timedelta
               HOUR = timedelta(hours=1)
               tramite=benefs[len(benefs)-1].benefs2.tramite+HOUR
               entrega=benefs[len(benefs)-1].benefs2.entrega+HOUR
       else:
           tramite=dates2.start
           entrega=dates2.inicio

   db(db.benefs2.id==benef.id).update(dates2_id=dates2.id,tramite=tramite,entrega=entrega,coordnador_id=keybenef.coordinador_id)
       db(db.dates2.id==dates2.id).update(cargados=dates2.cargados
   +1,xcargar=dates2.xdia-(dates2.cargados+1))

   @auth.requires_login()
   def crea_benef():
       return dict(form=crud.create(db.benefs2, next=URL(r=request,
   f='benefs2_regist'),onaccept=update_benef2))

   And this when we try to show as a list

   @auth.requires_login()
   def benefs2_regist():
       if len(request.args): page=int(request.args[0])
       else: page=0
     

[web2py] Re: Cherokee-fastcgi server (error log)

2010-06-04 Thread mdipierro
This happens when users drop connections (like close the broser or tab
duing a slow download).

There is not much that we can do. The web server logs it. Probably
web2py logs it too.

Massimo

On Jun 4, 2:54 pm, Jose jjac...@gmail.com wrote:
 Hello,

 From the applicative not see any mistake or problem, but I think that
 is not normal, but in the error log Cherokee appears thousands of
 times the following error:

 Unhandled exception in thread started by bound method Connection.run
 of gluon.contrib.gateways.fcgi.Connection object at 0x8071515d0
 Traceback (most recent call last):
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 664, in
 run
     self.process_input()
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 700, in
 process_input
     self._do_params(rec)
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 799, in
 _do_params
     self._start_request(req)
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 783, in
 _start_request
     req.run()
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 592, in
 run
     self._flush()
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 599, in
 _flush
     self.stdout.close()
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 358, in
 close
     self._conn.writeRecord(rec)
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 715, in
 writeRecord
     rec.write(self._sock)
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 552, in
 write
     self._sendall(sock, header)
   File /usr/home/web2py/gluon/contrib/gateways/fcgi.py, line 529, in
 _sendall
     sent = sock.send(data)
 socket.error: [Errno 32] Broken pipe

 How to solve this?

 Jose


[web2py] Re: routes to have userprofile pages

2010-06-04 Thread ChrisM
Adi, thanks very much, works well.
I will probably want to remove profile from url so user can just
have www.myapp.com\username but I will
need to think how this can be done:)

On Jun 4, 5:16 pm, Adi aditya.sa...@gmail.com wrote:
 Assuming your application is in init folder - the following might work

 routes_in=(
   ('/profile/$args', '/init/default/profile/$args'),
   ('/profile/$args/(?Pany.*$)', '/init/default/profile/$args/
 \gany'),
 )

 routes_out=(
   ('/init/default/profile/$args', '/profile/$args'),
   ('/init/default/profile/$args/\gany', '/profile/$args/(?Pany.*
 $)'),
 )

 On Jun 4, 6:23 pm, ChrisM cjjmur...@gmail.com wrote:

  anyone?

  On Jun 3, 2:29 pm, ChrisM cjjmur...@gmail.com wrote:

   Having trouble gettingroutesto work (not used before) for instance
   as a test I did:

   inroutes.py:
   routes_in = (  ('/profile/*', '/init/default/userprofilepage/*'),)
   routes_out = (  ('/init/default/userprofilepage/*', '/profile'),)

   in default controller:
   def userprofilepage():
       userprofile request.args(0)
       return dict(userprofile=userprofile)

   in userprofilepage.html:

   {{extend 'layout.html'}}
   h1{{=userprofile}}/h1

   get invalid request?

   any help appreciated.
   chrism

   On Jun 3, 6:08 am, Adi aditya.sa...@gmail.com wrote:

You could use an argument.

   www.myapp.com/userprofilecanbemappedto a controller/method 
   likewww.myapp.com/app/profiles/show/userprofile

where app = application, profiles = controller, show = function,
userprofile is an argument accessed by request.args(0) inside show.
You can use it to query database according to that user.

In order to hide app/profiles/show from url follow the usualroutes.py 
mapping  (its given on some other post here) assuming you
have only one app on the server.

On Jun 2, 9:31 pm, ChrisM cjjmur...@gmail.com wrote:

 For isntance I have RPX login which creates user profile for each
 logged in user.
 I would like to give each one of these users there own homepage (i.e.
 like twitter) which could be
 dynamically created.
 So I thought the first task was to see how thiscould be mapped,
 perhaps by querying db.profile and then mapping throughroutes.py.

 chrism

 On Jun 2, 3:46 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  Can you explain more?

  On Jun 2, 8:00 am, ChrisM cjjmur...@gmail.com wrote:

   I searched through the list but couldn't find any discussion on 
   this
   topic.

   Any ideas how the following can be achieved withroutes.py

  www.appname.com\userprofilename

   I am guessing that there would need to be a db.auth lookup to 
   match
   the userprofilename
   and then pass that to a generic controller, but how?

   Help Aprreciated

   ChrisM- Hide quoted text -

  - Show quoted text -- Hide quoted text -

- Show quoted text -- Hide quoted text -

   - Show quoted text -


Re: [web2py] Re: Cherokee-fastcgi server (error log)

2010-06-04 Thread Álvaro Justen
On Fri, Jun 4, 2010 at 20:16, mdipierro mdipie...@cs.depaul.edu wrote:
 This happens when users drop connections (like close the broser or tab
 duing a slow download).

 There is not much that we can do. The web server logs it. Probably
 web2py logs it too.

Maybe adding an except socket.error?

-- 
Álvaro Justen - Turicas
 http://blog.justen.eng.br/
 21 9898-0141


[web2py] Re: Multiple instances of same application

2010-06-04 Thread Iceberg
Let me clarify and then summarize.

First, .hgignore is one thing, packing is another. Ok we can leave
the .hgignore out of web2py level, let each developer controls it by
themselves. But when talking about packing, I mean the pack
feature on http://localhost:8000/admin/default/site for each app. It
is a web2py way to built app.w2p package, especially for non-open-
source project. So far, there is no way to built a w2p without leaking
your current copy's local config content, even when .hgignore already
setup by developer.

So, perhaps we could, at least, agree on a new pack without
databases feature on http://localhost:8000/admin/default/site for
each app? (Then I can put my own local_config.ini inside there)

Regards,
iceberg

On Jun5, 1:55am, Thadeus Burgess thade...@thadeusb.com wrote:
 I agree with Massimo, the NOT packing facility could be handled by .hgignore.

 As for configuration, I have used 0_config.py in blogitizor so that I
 can run two versions, my personal version and the one that is open
 source, this way my database and email information doesn't get leaked
 out into the internetz.

 I use the following,

 http://code.google.com/p/blogitizor/source/browse/src/models/A_config...

 And then rename it to A_config.py and it won't get committed since
 src/models/A_config.py is placed in my .hgignore file.

 However this isn't a web2py mechanism just a personal one, I don't
 like the idea of making web2py in charge of this because then I the
 developer lose control and can't change the way it works without
 forking web2py.

 --
 Thadeus



 On Fri, Jun 4, 2010 at 3:28 AM, Iceberg iceb...@21cn.com wrote:
  Aside from the config issue, a flag when packaging that does not
  package the database/ folder, would be the long missing piece. And
  when this flag is available, I think I can have my own databases/
  my_config.py to solve the local config problem in my style. :-)

  So +1 for the flag when packaging that does not package the database/
  folder.

  On Jun4, 2:20pm, mdipierro mdipie...@cs.depaul.edu wrote:
  I normally use

  #in models/0.py
  from gluon.storage import Storage
  settings=Storage()
  settings.development=True
  settings.email_sender=...@example.com'
  ...

  Anyway, this does not address Iceberg's problem of packing some config
  files and not others. I am not convinced this scenario should be
  handled at the web2py level. This is better handled using .hgignore
  and mercurial or other version control system.

  I am thinking anyway, to allow a flag when packaging that does not
  package the database/ folder. So in principle one could create
  function that updates parameters from a DAL('sqlite://settings.db')

  On Jun 4, 1:10 am, Iceberg iceb...@21cn.com wrote:

   IMHO, flask and my lightweight proposal try to solve same problem.
   Both can load configuration for sure. My proposal's loading ability
   relies only on python's built-in import (via web2py's model
   mechanism), therefore no need to introducing extra module. Isn't it
   clean?

   The basic challenge is how to separate and manage local setting from
   default setting, and how to prevent the local setting being
   distributed via app.w2p or Mercurial. Flask uses environment variable
   YOURAPPLICATION_SETTINGS=/path/to/settings.cfg, to specify a local
   setting. I like that too, but it can not be done via pure web2py admin
   interface, so administrator need to ssh into their production machine
   and make adjustments, and perhaps a kill-and-restart is needed. On the
   contrary, in my proposal, although I did not emphasis this in earlier
   post, administrator only need to visit standard web2py admin interface
   and setup a new 0_local_setting.py. No ssh nor restart is needed,
   again I rely on web2py's native behavior. Isn't it lightweight?

   Of course, I don't like the
   0_local_config_pls_dont_pack_dont_commit.py naming convention neither,
   but I just did not come up with another descriptive name. The point
   here, is we need a config file which can be used by a web2py app, but
   not packed with the app.

   Well, if we really just don't like the long and clumsy name
   convention, then we can do it in a decent way:
   1. introduce a applications/myapp/local_config directory, local
   settings go into there.
   2. adjust web2py to NOT pack, and NOT commit local_config directory
   3. but we need more work for web2py's admin UI, to support add/edit/
   view/delete setting file.

   We can choose.

   On Jun4, 3:26am, Thadeus Burgess thade...@thadeusb.com wrote:

Or... we can copy flask and integrate a configuration module..

God I pray we never use something like
`0_local_config_pls_dont_pack_dont_commit.py` INTO web2py. web2py and
its naming conventions .

--
Thadeus

On Thu, Jun 3, 2010 at 10:22 AM, Iceberg iceb...@21cn.com wrote:
 I think Doug's puzzle deserves a more general solution. The
 requirement and challenge is:
 R1. The app's central source code