[web2py] Database fieldname convention

2011-03-07 Thread StUStD
I experience inserting and updating problems (only explicit SQL
statements in de dbadmin work, forms don't) with fieldnames like B1x,
B1y, B2x, B2y, etc, only to find out that fieldnames with numbers
don't work... Is this default behaviour, convention, or caused by a
bug? Thanks.


[web2py] Re: Database fieldname convention

2011-03-07 Thread StUStD
I found out, the problem is not in the numeric part of the names,
rather, names containing uppercase letters cause the problem. Again,
is it convention that database field names should be lowercase?

On Mar 7, 9:46 am, StUStD hjansen...@gmail.com wrote:
 I experience inserting and updating problems (only explicit SQL
 statements in de dbadmin work, forms don't) with fieldnames like B1x,
 B1y, B2x, B2y, etc, only to find out that fieldnames with numbers
 don't work... Is this default behaviour, convention, or caused by a
 bug? Thanks.


[web2py] Update_record and validator conflict.

2011-03-07 Thread annet
In db.py I defined the following table:

db.define_table('company',
Field('name',length=54,default='',notnull=True),
Field('CoC_number',length=8),
Field('subdossiernumber',length=4,default=''),
...
Field(...),
migrate=False)

db.company.CoC_number.requires=IS_NOT_IN_DB(db(db.company.subdossiernumber==request.vars.subdossiernumber),db.company.CoC_number,error_message='combination
of CoC-number and subdossiernumber already in database')


In a controller I defined one form to update multiple tables. Here are
the parts related to the company table:

def update():
id= request.args(0)
### retrieve company data
company=db(db.company.id==id).select(db.company.ALL)
### create form
form=SQLFORM.factory(db.bedrijf,...,...)
### pre-populate form
if company:
form.vars.name=company[0].name
form.vars.CoC_number=company[0].CoC_number
form.vars.subdossiernumber=company[0].subdossiernumber
...
if form.accepts(request.vars,session):
 
company.update_record(**db.bedrijf._filter_fields(form.vars))
   ...
session.flash='Records updated'
redirect(URL(r=request,f='retrieve',args=id))
elif form.errors:
response.flash=response.flash_formerror
return dict(form=form)

When I execute the function the data is retrieved, the form is created
and pre-populated, however, when I click the submit button, the
validator on the Coc_number and subdossiernumber field prevents the
record from being updated and displays the error_message: 'combination
of CoC-number and subdossiernumber already in database'

I didn't expect this to happen when updating a record without changing
the CoC-number and subdossiernumber, I'd expect this to happen when I
change the CoC-number and subdossiernumber of one company to that of
another company. Is there a solution to solve this problem?


Kind regards,

Annet.


[web2py] Re: IS_NOT_IN_DB () Bypass the capital letters during validation

2011-03-07 Thread Bernd Rothert
Hi Yannick,

On 6 Mrz., 20:07, Yannick ytchatch...@gmail.com wrote:
 Hello mate,

 A value is saved in the DB as lower case and we put this validation
 IS_NOT_IN_DB(). If for that field the user enter a Capital letter of
 the same value saved the application will validate the entry.

 This is not really good. Is there a way to avoid this in Web2py
 without a need to build a customize validation method ?


not exactly - but you can chain validators and use something as simple
as:

db.person.name.requires= [
lambda s: (s and s.lower(), None),
IS_NOT_IN_DB(db, db.person.name),
]


 Please let me know if you have an idea.

 Cheers,

Cheers
Bernd


[web2py] redirection to /default/user/profile

2011-03-07 Thread pk
hi together,

i have a problem with a redirection. i will not redirected to this
link!
in my view i have this: li class=bluea href={{=URL(r=request,
c='default', f='user/logout')}}spanlogout/span/a/li

my main-controller:
@auth.requires_login()
def index():
return dict(message=main/index)

default-controller:
def index():
if auth.is_logged_in():
redirect(URL(r=request, c='main', f='index'))
return dict(message=index)

def user():
loginform=auth.login()
registerform=auth.register()
return dict(loginform=loginform, registerform=registerform)

but always after clicking the link i get this redirection!
hope somebody of you can help me?!?

thanks peter


[web2py] Re: Database fieldname convention

2011-03-07 Thread villas
I think it depends on the DB.  If you always make your fields lower
case in web2py,  there is a much better chance they will always work
consistently across all DBs. Perhaps not so much a convention,  but
more 'good practice'.


On Mar 7, 9:15 am, StUStD hjansen...@gmail.com wrote:
 I found out, the problem is not in the numeric part of the names,
 rather, names containing uppercase letters cause the problem. Again,
 is it convention that database field names should be lowercase?

 On Mar 7, 9:46 am, StUStD hjansen...@gmail.com wrote:

  I experience inserting and updating problems (only explicit SQL
  statements in de dbadmin work, forms don't) with fieldnames like B1x,
  B1y, B2x, B2y, etc, only to find out that fieldnames with numbers
  don't work... Is this default behaviour, convention, or caused by a
  bug? Thanks.




[web2py] Re: redirection to /default/user/profile

2011-03-07 Thread pk
i need very badly help...
thanks

On 7 Mrz., 11:59, pk peter.kirch...@youngdesigners.de wrote:
 hi together,

 i have a problem with a redirection. i will not redirected to this
 link!
 in my view i have this: li class=bluea href={{=URL(r=request,
 c='default', f='user/logout')}}spanlogout/span/a/li

 my main-controller:
 @auth.requires_login()
 def index():
     return dict(message=main/index)

 default-controller:
 def index():
     if auth.is_logged_in():
         redirect(URL(r=request, c='main', f='index'))
     return dict(message=index)

 def user():
     loginform=auth.login()
     registerform=auth.register()
     return dict(loginform=loginform, registerform=registerform)

 but always after clicking the link i get this redirection!
 hope somebody of you can help me?!?

 thanks peter


[web2py] Re: Update_record and validator conflict.

2011-03-07 Thread villas
Hi Annet

Seems strange that you are creating a form for a real table by using
SQLFORM.factory.  Why do that, rather than create a normal form?  If
you created a normal form,  I suspect the issue would be resolved.

You don't show the model or validators,  so can't comment on those.

Regards, D

On Mar 7, 9:17 am, annet annet.verm...@gmail.com wrote:
 In db.py I defined the following table:

 db.define_table('company',
     Field('name',length=54,default='',notnull=True),
     Field('CoC_number',length=8),
     Field('subdossiernumber',length=4,default=''),
     ...
     Field(...),
     migrate=False)

 db.company.CoC_number.requires=IS_NOT_IN_DB(db(db.company.subdossiernumber==request.vars.subdossiernumber),db.company.CoC_number,error_message='combination
 of CoC-number and subdossiernumber already in database')

 In a controller I defined one form to update multiple tables. Here are
 the parts related to the company table:

 def update():
     id= request.args(0)
     ### retrieve company data
     company=db(db.company.id==id).select(db.company.ALL)
     ### create form
     form=SQLFORM.factory(db.bedrijf,...,...)
     ### pre-populate form
     if company:
         form.vars.name=company[0].name
         form.vars.CoC_number=company[0].CoC_number
         form.vars.subdossiernumber=company[0].subdossiernumber
         ...
         if form.accepts(request.vars,session):

 company.update_record(**db.bedrijf._filter_fields(form.vars))
            ...
             session.flash='Records updated'
             redirect(URL(r=request,f='retrieve',args=id))
         elif form.errors:
             response.flash=response.flash_formerror
         return dict(form=form)

 When I execute the function the data is retrieved, the form is created
 and pre-populated, however, when I click the submit button, the
 validator on the Coc_number and subdossiernumber field prevents the
 record from being updated and displays the error_message: 'combination
 of CoC-number and subdossiernumber already in database'

 I didn't expect this to happen when updating a record without changing
 the CoC-number and subdossiernumber, I'd expect this to happen when I
 change the CoC-number and subdossiernumber of one company to that of
 another company. Is there a solution to solve this problem?

 Kind regards,

 Annet.


[web2py] Re: How to make a simple counter

2011-03-07 Thread minux
Thanks a log pbreit. Your suggested perfectly solved my problem. I
fiddled a bit with update_record but had difficulty who to grab the
field in database, in order to update it. Since this seem to be a
pretty common task (and difficulty for noobs), perhaps It would be
good if this example somehow be incorporated into the web2py chapter
about DAL or example codes.

Cheers



On Mar 6, 1:53 am, pbreit pbreitenb...@gmail.com wrote:
 Wow, hard to say but you definitely have some problems. For example, the
 typo in visits.viist(+=1). Are you getting error messages or is it just
 not doing what you want?

 Something like this perhaps? This code only adds one line to what is shown
 in the Book: image.update_record(visits=image.visits + 1). One thing to do
 is only make one db.table call per controller. You usually only need to
 access the database once per table. And in this case, you only need to do an
 image.update_record to increment the visits.

 def show():
     image = db.image(request.args(0)) or redirect(URL('index'))

     db.comment.image_id.default = image.id
     form = crud.create(db.comment,
                        message='your comment is posted',
             next=URL(args=image.id))
     comments = db(db.comment.image_id==image.id).select()
     image.update_record(visits=image.visits + 1)
     return dict(image=image, comments=comments, form=form)

 === show.html ===
 ...
 pVisits:  {{=image.visits}}/p
 ...


[web2py] Re: web2py applications and apache vhosts

2011-03-07 Thread Haros
Thank you for the quick reply Jonathan.

It's true that syntax for domain mapping has become very easy and also
can be used with different webservers, but I find this way a bit
unefficient when it comes to many domains / applications.

I would be glad though if anyone could provide some help about the
apache config file. I can't believe that everyone using web2py on
apache uses routes to handle domains :P

Oh, one more question. The routes method does it affect somehow the
SEO process? I mean, is it better / worse / same as handling domains
using apache for search engines?


[web2py] web2py recommended web hosting

2011-03-07 Thread Alejandro
Hello everyone,

I am new in web2py and I am very impressed by their simplicity and
capabilities.
I would like to know which is the best/recommended web hosting to run
web2py.

Thanks,

Alejandro


[web2py] Re: DAL new syntax RFC

2011-03-07 Thread kenji4569
Other alternatives might be:

Field('name', **Field.readonly)?
Field('name').readonly()?

though I appreciate explicit is better than implicit.

On 3月6日, 午前9:49, Michele Comitini michele.comit...@gmail.com wrote:
 +1

 2011/3/6 Thadeus Burgess thade...@thadeusb.com:







  Explicit is better than implicit. Typing is cheap. Design is the hardest
  part of development.

  --
  Thadeus

  On Sat, Mar 5, 2011 at 2:52 PM, Vidul Petrov vidul.r...@gmail.com wrote:

  I agree with Stefaan.

  However the ':' before a variable name notation looks like the Ruby
  symbols whose only purpose was improved performance (lightweight
  strings) but lead inevitably to confusion (IMHO).

  On Mar 4, 5:55 pm, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:
   There are some new features in trunk:

   1)

   I got tired of writing default='value',readable=False,writable=False
   etc.

   So:

   Field(':name') is the same as
   Field('name',readable=False,writable=False)
   Field('.name') is the same as
   Field('name',readable=True,writable=False)
   Field('name=value') is the same as Field('name',default='value')

   and combinations:

   Field(':name=value') is the same as
   Field('name',default='value',readable=True,writable=False)

   notice

   Field('name=') is the same as Field('name',default='')

   2)

   db(db.table).select((db.table.field.length()+5).sum())

   note operators length(), +5, sum() can be combined in more ways than
   before.


[web2py] Re: Database fieldname convention

2011-03-07 Thread Kevin Ivarsen
Hello,

I recently ran into this problem as well - field names with uppercase
characters were ignored in SQLFORM inserts/updates. Luckily, I found
that the behavior is fixed in the latest 1.93.2 release of web2py. Try
upgrading and see if that solves the problem.

Kevin

On Mar 7, 4:15 am, StUStD hjansen...@gmail.com wrote:
 I found out, the problem is not in the numeric part of the names,
 rather, names containing uppercase letters cause the problem. Again,
 is it convention that database field names should be lowercase?

 On Mar 7, 9:46 am, StUStD hjansen...@gmail.com wrote:







  I experience inserting and updating problems (only explicit SQL
  statements in de dbadmin work, forms don't) with fieldnames like B1x,
  B1y, B2x, B2y, etc, only to find out that fieldnames with numbers
  don't work... Is this default behaviour, convention, or caused by a
  bug? Thanks.


[web2py] Re: web2py recommended web hosting

2011-03-07 Thread Anthony
You should be able to host web2py apps just about anywhere you can run 
Python, including many shared hosts. For VPS/dedicated hosting, I think a 
common setup is Ubuntu and Apache. See the book for deployment instructions 
(http://web2py.com/book/default/chapter/11), including pointers to some 
one-step deployment scripts (
http://web2py.com/book/default/chapter/11#One-Step-Production-Deployment). 
 
For shared hosting, I've seen strong recommendations for WebFaction (and 
some for DreamHost as well). For VPS/cloud hosting, I've seen 
recommendations for VPS.net (I think that's where web2py.com is hosted), 
Slicehost, DreamHost, Rackspace, Amazon EC2, and a few others. There's also 
a new cloud service in beta called DotCloud (www.dotcloud.com) -- they have 
a tutorial for setting up web2py (
http://docs.dotcloud.com/static/tutorials/web2py/). There are also several 
new Python-specific cloud hosts in beta: www.pydra.com, www.apphosted.com, 
www.ep.io, www.stable.io.
 
Of course, there's also Google App Engine, which web2py can handle very well 
(http://web2py.com/book/default/chapter/11#Google-App-Engine), though it's 
got some limitations, which may affect your application design.
 
Anthony
 

On Monday, March 7, 2011 4:12:48 AM UTC-5, Alejandro wrote:

 Hello everyone, 

 I am new in web2py and I am very impressed by their simplicity and 
 capabilities. 
 I would like to know which is the best/recommended web hosting to run 
 web2py. 

 Thanks, 

 Alejandro



[web2py] NameError: global name 'db' is not defined

2011-03-07 Thread Johann Spies
I want to run a script in the commandline shell to insert records into the
database, but have a problem handling the namespace.

When I try to run it with the '%run' option or do a 'from script  import
*' makes no difference: I get the namespace error in the subject line:

/home/js/web2py/lees_isi_xml6.py in plaas_artikel(rekord)
352 categories = rekord['categories']
353 ut = item['ut'][0]
-- 354 print db.tables()
355 if db(db.isi_articles.ut == ut).count() == 0:
356 titel = item['item_title'][0]

NameError: global name 'db' is not defined

But when I do a 'db.tables()' in the same shell, there is no problem.

I have started the shell with

python web2py.py -M -S kb

How do I get web2py to run this script?

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: redirection to /default/user/profile

2011-03-07 Thread pk
nobody?

On 7 Mrz., 13:22, pk peter.kirch...@youngdesigners.de wrote:
 i need very badly help...
 thanks

 On 7 Mrz., 11:59, pk peter.kirch...@youngdesigners.de wrote:







  hi together,

  i have a problem with a redirection. i will not redirected to this
  link!
  in my view i have this: li class=bluea href={{=URL(r=request,
  c='default', f='user/logout')}}spanlogout/span/a/li

  my main-controller:
  @auth.requires_login()
  def index():
      return dict(message=main/index)

  default-controller:
  def index():
      if auth.is_logged_in():
          redirect(URL(r=request, c='main', f='index'))
      return dict(message=index)

  def user():
      loginform=auth.login()
      registerform=auth.register()
      return dict(loginform=loginform, registerform=registerform)

  but always after clicking the link i get this redirection!
  hope somebody of you can help me?!?

  thanks peter


[web2py] Re: NameError: global name 'db' is not defined

2011-03-07 Thread Anthony
When you import a module, I don't think it's functions see the web2py 
globals. You probably have to explicitly pass db as an argument to the 
function you're calling in your module.

On Monday, March 7, 2011 8:53:37 AM UTC-5, spyker wrote:

 I want to run a script in the commandline shell to insert records into the 
 database, but have a problem handling the namespace.

 When I try to run it with the '%run' option or do a 'from script  import 
 *' makes no difference: I get the namespace error in the subject line:

 /home/js/web2py/lees_isi_xml6.py in plaas_artikel(rekord)
 352 categories = rekord['categories']
 353 ut = item['ut'][0]
 -- 354 print db.tables()
 355 if db(db.isi_articles.ut == ut).count() == 0:
 356 titel = item['item_title'][0]

 NameError: global name 'db' is not defined

 But when I do a 'db.tables()' in the same shell, there is no problem.

 I have started the shell with 

 python web2py.py -M -S kb

 How do I get web2py to run this script?

 Regards
 Johann

 -- 
  May grace and peace be yours in abundance through the full knowledge of 
 God and of Jesus our Lord!  His divine power has given us everything we need 
 for life and godliness through the full knowledge of the one who called us 
 by his own glory and excellence. 
 2 Pet. 1:2b,3a



[web2py] Re: Update_record and validator conflict.

2011-03-07 Thread annet
Hi David,

This is the relevant part of the model file, table definition:

db.define_table('company',
Field('name',length=54,default='',notnull=True),
Field('CoC_number',length=8),
Field('subdossiernumber',length=4,default=''),
...
Field(...),
migrate=False)

... and the validator that's causing the problem:

db.company.CoC_number.requires=IS_NOT_IN_DB(db(db.company.subdossiernumber==request.vars.subdossiernumber),db.company.CoC_number,error_message='combination
of CoC-number and subdossiernumber already in database')


 Seems strange that you are creating a form for a real table by using
 SQLFORM.factory. Why do that, rather than create a normal form?

Because I want to use one form to update multiple tables, and from the
web2py manual: 
http://www.web2py.com/book/default/chapter/07#One-form-for-multiple-tables
I learned to use form=SQLFORM.formfactory(...) for that purpose.

If there's another solution for having one form to update multiple
tables, please let me know.


Kind regards,

Annet.


Re: [web2py] web2py recommended web hosting

2011-03-07 Thread rochacbruno
For shared hosts. The best, easiest and with a nice cost is webfaction.com 


Em 07/03/2011, às 06:12, Alejandro alek...@gmail.com escreveu:

 Hello everyone,
 
 I am new in web2py and I am very impressed by their simplicity and
 capabilities.
 I would like to know which is the best/recommended web hosting to run
 web2py.
 
 Thanks,
 
 Alejandro


[web2py] Re: how to check if form is submitted?

2011-03-07 Thread Iceberg
On Mar 7, 1:33 am, LightOfMooN vladsale...@yandex.ru wrote:
 I try to process checkbox onClick=submit(), but can't check, if
 form with that checkbox is submitted.

 How to check if form is submitted?

As long as your form is submitted into your own web server, a new line
of log appears in the log file or console. Isn't that your case?


Re: [web2py] Re: web2py applications and apache vhosts

2011-03-07 Thread Jonathan Lundell
On Mar 6, 2011, at 3:57 PM, Haros wrote:
 
 Thank you for the quick reply Jonathan.
 
 It's true that syntax for domain mapping has become very easy and also
 can be used with different webservers, but I find this way a bit
 unefficient when it comes to many domains / applications.
 
 I would be glad though if anyone could provide some help about the
 apache config file. I can't believe that everyone using web2py on
 apache uses routes to handle domains :P

I think that configuring apache vhosts ought to be straightforward (and 
independent of web2py); I just don't know how to do it. 

My point, though, is that I don't see why you couldn't get equivalent 
performance with wsgi directly, if Apache and wsgi and configured correctly (in 
particular, with enough processes). But I'm no expert on the subject.

 
 Oh, one more question. The routes method does it affect somehow the
 SEO process? I mean, is it better / worse / same as handling domains
 using apache for search engines?

I don't think a search engine could tell the difference, if the two 
configurations use the same URL scheme.

[web2py] Basic authentication user id

2011-03-07 Thread Alexei Vinidiktov
Hello,

When I do basic authentication to a web2py app from a *desktop* app (tried
two test apps I wrote in Python and REALbasic) I can get the user's first
name and last name from the web app, but I can't get his/her id.

@service.xmlrpc
@service.jsonrpc
def getUserName():
return str(auth.user_id) +   + auth.user.first_name +   +
auth.user.last_name

The above function returns None for the user id and the correct first name
and last name.

The same function called from a *web based* user interface (written with
qooxdoo and authenticated via the standard login form) works fine returning
both the user id and his first and last names.

What am I doing wrong?

I'm on web2py 1.89.5

Thanks.

-- 
Alexei Vinidiktov


Re: [web2py] Basic authentication user id

2011-03-07 Thread Jonathan Lundell
On Mar 7, 2011, at 7:51 AM, Alexei Vinidiktov wrote:
 When I do basic authentication to a web2py app from a *desktop* app (tried 
 two test apps I wrote in Python and REALbasic) I can get the user's first 
 name and last name from the web app, but I can't get his/her id.
 
 @service.xmlrpc 
 @service.jsonrpc
 def getUserName():
 return str(auth.user_id) +   + auth.user.first_name +   + 
 auth.user.last_name
 
 The above function returns None for the user id and the correct first name 
 and last name.
 
 The same function called from a *web based* user interface (written with 
 qooxdoo and authenticated via the standard login form) works fine returning 
 both the user id and his first and last names. 
 
 What am I doing wrong?
 
 I'm on web2py 1.89.5
 

Just a shot in the dark: try auth.user.id instead.

Re: [web2py] Basic authentication user id

2011-03-07 Thread Alexei Vinidiktov
On Mon, Mar 7, 2011 at 10:16 PM, Jonathan Lundell jlund...@pobox.comwrote:

 On Mar 7, 2011, at 7:51 AM, Alexei Vinidiktov wrote:
  When I do basic authentication to a web2py app from a *desktop* app
 (tried two test apps I wrote in Python and REALbasic) I can get the user's
 first name and last name from the web app, but I can't get his/her id.
 
  @service.xmlrpc
  @service.jsonrpc
  def getUserName():
  return str(auth.user_id) +   + auth.user.first_name +   +
 auth.user.last_name
 
  The above function returns None for the user id and the correct first
 name and last name.
 
  The same function called from a *web based* user interface (written with
 qooxdoo and authenticated via the standard login form) works fine returning
 both the user id and his first and last names.
 
  What am I doing wrong?
 
  I'm on web2py 1.89.5
 

 Just a shot in the dark: try auth.user.id instead.


Thanks, Jonathan! Your suggestion worked.

What's odd is that for RIA apps with web based GUI both user.id and user_id
work! I triple checked.

-- 
Alexei Vinidiktov


Re: [web2py] Basic authentication user id

2011-03-07 Thread ron_m
In the file gluon/tools.py line 808 in trunk the Auth class __init__ method 
you will find these lines

if auth and auth.last_visit and auth.last_visit\
 + datetime.timedelta(days=0, seconds=auth.expiration)\
  request.now:
self.user = auth.user
self.user_id = self.user.id
auth.last_visit = request.now

I am guessing this branch does not run when used in a standalone environment 
and the else branch not shown above runs instead which sets the 3 values to 
None.


Re: [web2py] Basic authentication user id

2011-03-07 Thread Jonathan Lundell
On Mar 7, 2011, at 8:54 AM, ron_m wrote:
 In the file gluon/tools.py line 808 in trunk the Auth class __init__ method 
 you will find these lines
 
 if auth and auth.last_visit and auth.last_visit\
  + datetime.timedelta(days=0, seconds=auth.expiration)\
   request.now:
 self.user = auth.user
 self.user_id = self.user.id
 auth.last_visit = request.now
 
 I am guessing this branch does not run when used in a standalone environment 
 and the else branch not shown above runs instead which sets the 3 values to 
 None.

I was wondering about that, but it doesn't appear that auth.user is set to 
None; otherwise auth.user.id wouldn't work either.



Re: [web2py] Basic authentication user id

2011-03-07 Thread ron_m
I am guessing some more because I didn't trace the code but I think 
auth.user eventually gets set in login_bare without setting auth.user_id but 
then do standalone apps actually login?
I could only find 3 places where self.user_id is used in the class, the 2 
places in the if else and as a test to see which of the nav bars (login or 
logout) should be placed at the top of the page. I could not see anywhere 
else that auth.user_id is set outside the class.

I guess bottom line is Alexei has a solution. :-)


[web2py] Re: bug? - boolean field automatically toggles in forms when validation fails

2011-03-07 Thread Carlos
Hi Massimo,

This has been fixed in latest stable 1.93.2.

Thanks!,

   Carlos



Re: [web2py] Basic authentication user id

2011-03-07 Thread Jonathan Lundell
On Mar 7, 2011, at 9:23 AM, ron_m wrote:
 I am guessing some more because I didn't trace the code but I think auth.user 
 eventually gets set in login_bare without setting auth.user_id but then do 
 standalone apps actually login?
 I could only find 3 places where self.user_id is used in the class, the 2 
 places in the if else and as a test to see which of the nav bars (login or 
 logout) should be placed at the top of the page. I could not see anywhere 
 else that auth.user_id is set outside the class.

Good point.

I was wondering if auth.user_id ought to be set wherever auth.user is set, for 
consistency; I see about six places where that doesn't happen.

But how about this: make Auth.user_id a read-only property instead of a plain 
attribute? (Read-only just as a precaution; there's no good reason for someone 
to write it.)

Something like:

def _get_user_id(self):
accessor for user_id
return self.user and self.user.id or None
user_id = property(_get_user_id, doc=user.id or None)


This would be backward-compatible with the current logic, and make auth.user_id 
always identical to auth.user.id (whenever auth.user is defined) without having 
to catch every assignment of auth.user.

Work for you, Massimo?

[web2py] Re: redirection to /default/user/profile

2011-03-07 Thread pbreit
I think the URL tag should be: URL(c='default', f='user', args=['logout'])

It's not really clear to me what you are trying to do. I would strongly 
suggest just using Web2py's built-in register/login/logout functionality.

If you are just starting out, I would advise creating a new application in 
admin and starting fresh. At least use web2py's user functionality in the 
beginning and then if you really want to change it later you can. But it 
works pretty well. And then you can focus on your application which is hard 
enough without re-creating the user functions.


Re: [web2py] web2py recommended web hosting

2011-03-07 Thread contatogilson...@gmail.com
I recommend webfaction.
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/3/7 rochacbruno rochacbr...@gmail.com

 For shared hosts. The best, easiest and with a nice cost is webfaction.com


 Em 07/03/2011, às 06:12, Alejandro alek...@gmail.com escreveu:

  Hello everyone,
 
  I am new in web2py and I am very impressed by their simplicity and
  capabilities.
  I would like to know which is the best/recommended web hosting to run
  web2py.
 
  Thanks,
 
  Alejandro



[web2py] Re: Update_record and validator conflict.

2011-03-07 Thread DenesL
Hi Annet,

when you use SQLFORM to update a record you supply the record or the
record id, so web2py can retrieve it for you. The IS_NOT_IN_DB
validator checks against the record id so updates don't get a
validation error.

Since SQLFORM.factory does not allow you to supply the record or
record id it can not be used as is. But you can modify the validator
before the accepts to skip the error for the particular record you are
using, as shown below. Note: AFAIK this is undocumented, so it may
change in the future.

On Mar 7, 4:17 am, annet annet.verm...@gmail.com wrote:
 In db.py I defined the following table:

 db.define_table('company',
 Field('name',length=54,default='',notnull=True),
 Field('CoC_number',length=8),
 Field('subdossiernumber',length=4,default=''),
 ...
 Field(...),
 migrate=False)

 db.company.CoC_number.requires=IS_NOT_IN_DB(db(db.company.subdossiernumber==request.vars.subdossiernumber),db.company.CoC_number,error_message='combination
 of CoC-number and subdossiernumber already in database')

 In a controller I defined one form to update multiple tables. Here are
 the parts related to the company table:

 def update():
 id= request.args(0)
 ### retrieve company data
 company=db(db.company.id==id).select(db.company.ALL)
 ### create form
 form=SQLFORM.factory(db.bedrijf,...,...)
 ### pre-populate form
 if company:

  # this is undocumented
  db.company.CoC_number.requires.set_self_id(company[0].id)

 form.vars.name=company[0].name
 form.vars.CoC_number=company[0].CoC_number
 form.vars.subdossiernumber=company[0].subdossiernumber
 ...
 if form.accepts(request.vars,session):

 company.update_record(**db.bedrijf._filter_fields(form.vars))

  # this should be:
  company[0].update_record(**db.company._filter_fields(form.vars))

...
 session.flash='Records updated'
 redirect(URL(r=request,f='retrieve',args=id))
 elif form.errors:
 response.flash=response.flash_formerror
 return dict(form=form)

 When I execute the function the data is retrieved, the form is created
 and pre-populated, however, when I click the submit button, the
 validator on the Coc_number and subdossiernumber field prevents the
 record from being updated and displays the error_message: 'combination
 of CoC-number and subdossiernumber already in database'

 I didn't expect this to happen when updating a record without changing
 the CoC-number and subdossiernumber, I'd expect this to happen when I
 change the CoC-number and subdossiernumber of one company to that of
 another company. Is there a solution to solve this problem?

 Kind regards,

 Annet.


[web2py] Re: how to check if form is submitted?

2011-03-07 Thread LightOfMooN
No. I need to know when the form is submitted to make some process.

For example if i have form with input type=submit name=mysubmit
and some inputs for data, I can process it in controller with checking
form submitting like that:

mycontroller_function():
if request.vars.mysubmit:
do something

but if I want to submit form without! button, for example using
onClick event on input type=checkbox
How can I check, if form is submitted?

On 7 мар, 19:56, Iceberg iceb...@21cn.com wrote:
 On Mar 7, 1:33 am, LightOfMooN vladsale...@yandex.ru wrote:

  I try to process checkbox onClick=submit(), but can't check, if
  form with that checkbox is submitted.

  How to check if form is submitted?

 As long as your form is submitted into your own web server, a new line
 of log appears in the log file or console. Isn't that your case?


[web2py] Re: web2py recommended web hosting

2011-03-07 Thread Kevin Ivarsen
I recently had a good experience deploying a web2py website with a VPS
on hostgator.com. During peak periods we had several dozen
simultaneous users hitting the site, and everything remained speedy
and responsive. We used MySQL and Apache with mod_wsgi to deploy.

Kevin

On Mar 7, 4:12 am, Alejandro alek...@gmail.com wrote:
 Hello everyone,

 I am new in web2py and I am very impressed by their simplicity and
 capabilities.
 I would like to know which is the best/recommended web hosting to run
 web2py.

 Thanks,

 Alejandro


[web2py] Image serving performance

2011-03-07 Thread pbreit
I saw over on web2py-developers that Bruno raised a question about image 
serving performance through the download function. I was curious about 
this myself as my app will be serving an excessive amount of imagery. I was 
surprised that images weren't just served statically. What exactly would I 
be giving up by not using the download function? One thing I am guessing is 
authentication which I don't really need.

I suspect I will probably do what Bruno suggested and switch to statically 
served images. I think at some point I will move images over to Amazon S3 or 
RackSpace Files anyhow so this will be a good first step.


[web2py] Re: web2py recommended web hosting

2011-03-07 Thread pbreit
My only advice is that if you are struggling to get web2py running on your 
host, don't fight it, switch.

Webfaction comes up a lot as a great provider. If you are at all thinking 
about cloud, I say go for it. Amazon, RackSpace and Linode are great 
options.


Re: [web2py] Image serving performance

2011-03-07 Thread rochacbruno
I know there is a way to config apache for serve static/* but I did not find 
how to do it in webfaction yet. 

But certainly putting images under static is much faster than download 
function. 

Em 07/03/2011, às 16:36, pbreit pbreitenb...@gmail.com escreveu:

 I saw over on web2py-developers that Bruno raised a question about image 
 serving performance through the download function. I was curious about this 
 myself as my app will be serving an excessive amount of imagery. I was 
 surprised that images weren't just served statically. What exactly would I be 
 giving up by not using the download function? One thing I am guessing is 
 authentication which I don't really need.
 
 I suspect I will probably do what Bruno suggested and switch to statically 
 served images. I think at some point I will move images over to Amazon S3 or 
 RackSpace Files anyhow so this will be a good first step.


[web2py] web2py and ispcp (or any other contol panel)

2011-03-07 Thread Haros
Hello,

I am trying to make web2py work with ispcp but I fail. Google doesn't
provide any tutorial or hint and I guess it's beyond my knowledge to
make it work without help...

So, is there anyone that made web2py work with ispcp? I could also
accept web2py with webmin but there is not much info for that too :P

I would be glad if anyone could help.

Thanks.


Re: [web2py] Image serving performance

2011-03-07 Thread pbreit
Do you know what functionality the download function provides beyond serving 
and authentication?

[web2py] ProgrammingError: Cannot operate on a closed database

2011-03-07 Thread Ross Peoples
Updated to R-1.32.2 from trunk this morning. Ran into this error a few times 
today: ProgrammingError: Cannot operate on a closed database. I don't know 
if it's because of a bug introduced in the release or if my ajax is killing 
it. I just start playing with submitting ajax forms and right after doing 
that a few times, the next page request produces this error. It is easily 
solved by restarting the rocket server, but I wouldn't want this happening 
in production.

[web2py] 1.93.2 broken update_record!

2011-03-07 Thread Clayton
sess.update_record(lockedby=request.vars.client) used to set the field
lockedby in the database to the value of request.vars.client

As of 1.93.2, it sets the field lockedby to the value
lockedby (the string!). This is with sqlite.

Crashes my app. Was I using it wrong to begin with?

Clayton


[web2py] Re: 1.93.2 broken update_record!

2011-03-07 Thread Clayton
Issue 210:  Typo in gluon.dal.update_record

Patched it manually to get my app up and running.

This breaks a lot of apps; how soon can a new release get out?

Clayton

On Mar 7, 4:11 pm, Clayton clayton.grass...@gmail.com wrote:
 sess.update_record(lockedby=request.vars.client) used to set the field
 lockedby in the database to the value of request.vars.client

 As of 1.93.2, it sets the field lockedby to the value
 lockedby (the string!). This is with sqlite.

 Crashes my app. Was I using it wrong to begin with?

 Clayton


[web2py] Re: how to check if form is submitted?

2011-03-07 Thread DenesL

Any submit sends the form to the controller.
Can you post the exact code?.


On Mar 7, 2:12 pm, LightOfMooN vladsale...@yandex.ru wrote:
 No. I need to know when the form is submitted to make some process.

 For example if i have form with input type=submit name=mysubmit
 and some inputs for data, I can process it in controller with checking
 form submitting like that:

 mycontroller_function():
     if request.vars.mysubmit:
         do something

 but if I want to submit form without! button, for example using
 onClick event on input type=checkbox
 How can I check, if form is submitted?

 On 7 ÍÁÒ, 19:56, Iceberg iceb...@21cn.com wrote:

  On Mar 7, 1:33šam, LightOfMooN vladsale...@yandex.ru wrote:

   I try to process checkbox onClick=submit(), but can't check, if
   form with that checkbox is submitted.

   How to check if form is submitted?

  As long as your form is submitted into your own web server, a new line
  of log appears in the log file or console. Isn't that your case?




[web2py] some functionality to mix html and {{python expression}} is broken since 1.92.3, even back to 1.91.6

2011-03-07 Thread dlypka
The following worked in  1.77.3 but not in 1.91.6 and not in 1.92.3

ul id=dhtmlgoodies_tree class=dhtmlgoodies_tree
{{level0result = DIV()}}
{{for row in sortedfolderlist:}}
{{  myrow = row[1]}}
{{  myli = LI(A(myrow['strRegionNameRendered'], _href=#) }}
{{  level0result.append(myli)}}
{{pass}}
{{=level0result}}
/ul

This gets an error:
Traceback (most recent call last):
  File c:\Google\AppEngine\esentrnet\gluon\main.py, line 449, in
wsgibase
serve_controller(request, response, session)
  File c:\Google\AppEngine\esentrnet\gluon\main.py, line 194, in
serve_controller
run_view_in(response._view_environment)
  File c:\Google\AppEngine\esentrnet\gluon\compileapp.py, line 464,
in run_view_in
lambda: compile2(parse_template(response.view,
  File c:\Google\AppEngine\esentrnet\gluon\cfs.py, line 47, in
getcfs
data = filter()
  File c:\Google\AppEngine\esentrnet\gluon\compileapp.py, line 466,
in lambda
context=environment),layer))
  File c:\Google\AppEngine\esentrnet\gluon\restricted.py, line 173,
in compile2
return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
'exec')
  File c:\Google\AppEngine\esentrnet\applications\init/views\default/
m.html, line 102
ul id=dhtmlgoodies_tree class=dhtmlgoodies_tree
^
SyntaxError: invalid syntax


[web2py] Re: how to check if form is submitted?

2011-03-07 Thread LightOfMooN
form method=POST
input type=checkbox name=helloworld
onClick=this.form.submit()
/form

I need to check value of this checkbox in controller only when user
click on it and do smth (for example, session.helloworld=True if it's
checked and False if not)
But I can't check if form is submitted, because if it is and checkbox
isn't checked, if request.vars.helloworld returns False

On 8 мар, 02:31, DenesL denes1...@yahoo.ca wrote:
 Any submit sends the form to the controller.
 Can you post the exact code?.

 On Mar 7, 2:12 pm, LightOfMooN vladsale...@yandex.ru wrote:







  No. I need to know when the form is submitted to make some process.

  For example if i have form with input type=submit name=mysubmit
  and some inputs for data, I can process it in controller with checking
  form submitting like that:

  mycontroller_function():
      if request.vars.mysubmit:
          do something

  but if I want to submit form without! button, for example using
  onClick event on input type=checkbox
  How can I check, if form is submitted?

  On 7 ÍÁÒ, 19:56, Iceberg iceb...@21cn.com wrote:

   On Mar 7, 1:33šam, LightOfMooN vladsale...@yandex.ru wrote:

I try to process checkbox onClick=submit(), but can't check, if
form with that checkbox is submitted.

How to check if form is submitted?

   As long as your form is submitted into your own web server, a new line
   of log appears in the log file or console. Isn't that your case?


[web2py] XML() object in html.py breaks ajax callback which needs HTML returned.

2011-03-07 Thread dlypka
Ever since web2py 1.91.6 I have had to patch html.py to avoid this
exception when my code
tries to do an ajax callback to get some HTML:

Traceback (most recent call last):
  File c:\Google\AppEngine\esentrnet\gluon\restricted.py, line 188,
in restricted
exec ccode in environment
  File c:\Google\AppEngine\esentrnet\applications\init/controllers/
default.py:upbm2gig, line 238, in module
  File c:\Google\AppEngine\esentrnet\gluon\globals.py, line 95, in
lambda
self._caller = lambda f: f()
  File c:\Google\AppEngine\esentrnet\applications\init/controllers/
default.py:upbm2gig, line 93, in upbm2gig
  File applications\init\modules\controllers\default_module.py, line
1766, in upbm2gig
upload_url =
blobstore.create_upload_url(URL(r=request,c='default',f='upbm2gig_gaehandler',args=None))
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\blobstore\blobstore.py, line 192, in create_upload_url
_make_sync_call('blobstore', 'CreateUploadURL', request, response)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\apiproxy_stub_map.py, line 86, in MakeSyncCall
return stubmap.MakeSyncCall(service, call, request, response)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\apiproxy_stub_map.py, line 286, in MakeSyncCall
rpc.CheckSuccess()
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\apiproxy_rpc.py, line 149, in _WaitImpl
self.request, self.response)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\apiproxy_stub.py, line 80, in MakeSyncCall
method(request, response)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\blobstore\blobstore_stub.py, line 218, in
_Dynamic_CreateUploadURL
users.get_current_user())
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\blobstore\blobstore_stub.py, line 204, in _CreateSession
user)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\blobstore\blobstore_stub.py, line 79, in CreateUploadSession
'state': 'init'})
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\datastore.py, line 638, in update
self.__setitem__(name, value)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\datastore.py, line 617, in __setitem__
datastore_types.ValidateProperty(name, value)
  File C:\Program Files (x86)\Google\google_appengine\google\appengine
\api\datastore_types.py, line 1323, in ValidateProperty
'Unsupported type for property %s: %s' % (name, v.__class__))
BadValueError: Unsupported type for property success_path: class
'gluon.html.XML'

CAUSED BY a change in html.py line 265  in 1.92.3 where it does
return XML(rewrite.filter_out(url, env,

the old web2py code in 1.77.3.does not do this.

1.77.3 does
return rewrite.filter_out(url, env) which works for me.

My patch is to delete the enclosing XML() expression.


[web2py] maintaining references while importing records from multiple tables

2011-03-07 Thread Philip
I am importing data into an existing web2py application.  The tables
are connected - I'll pretend for the moment that they are the owners
and dogs tables from the web2py book.  I used the shell and typed in
the following commands (based on an example previously posted by
Massimo):

map = {}
db.owners.import_from_csv_file(open('path/owners.csv','r'),map)
db.dogs.import_from_csv_file(open('path/dogs.csv','r'),map)

The owners appeared correctly in the table, but when I tried to view
the dogs (through the admin database interface), I got an error that
the references were broken.  I had manually ensured that all dogs in
the dogs table had references to owners that were in the owners table
(i.e. no broken references in the data I uploaded), so the failure
occurred on the translation of ids on the upload.

Any ideas what I am doing wrong?  Has anyone successfully used the
this feature of the import_from_csv_file?

Thanks in advance for any ideas.




[web2py] Re: DAL new syntax RFC

2011-03-07 Thread Massimo Di Pierro
I am leaning towards

r=False,w=False,d='default' as alises for readable, writable and
default.

On Mar 7, 7:36 am, kenji4569 hos...@s-cubism.jp wrote:
 Other alternatives might be:

 Field('name', **Field.readonly)?
 Field('name').readonly()?

 though I appreciate explicit is better than implicit.

 On 3月6日, 午前9:49, Michele Comitini michele.comit...@gmail.com wrote:







  +1

  2011/3/6 Thadeus Burgess thade...@thadeusb.com:

   Explicit is better than implicit. Typing is cheap. Design is the hardest
   part of development.

   --
   Thadeus

   On Sat, Mar 5, 2011 at 2:52 PM, Vidul Petrov vidul.r...@gmail.com wrote:

   I agree with Stefaan.

   However the ':' before a variable name notation looks like the Ruby
   symbols whose only purpose was improved performance (lightweight
   strings) but lead inevitably to confusion (IMHO).

   On Mar 4, 5:55 pm, Massimo Di Pierro massimo.dipie...@gmail.com
   wrote:
There are some new features in trunk:

1)

I got tired of writing default='value',readable=False,writable=False
etc.

So:

Field(':name') is the same as
Field('name',readable=False,writable=False)
Field('.name') is the same as
Field('name',readable=True,writable=False)
Field('name=value') is the same as Field('name',default='value')

and combinations:

Field(':name=value') is the same as
Field('name',default='value',readable=True,writable=False)

notice

Field('name=') is the same as Field('name',default='')

2)

db(db.table).select((db.table.field.length()+5).sum())

note operators length(), +5, sum() can be combined in more ways than
before.


[web2py] Re: NameError: global name 'db' is not defined

2011-03-07 Thread Massimo Di Pierro


python web2py.py -M -N -S kb -R script.py

On Mar 7, 7:53 am, Johann Spies johann.sp...@gmail.com wrote:
 I want to run a script in the commandline shell to insert records into the
 database, but have a problem handling the namespace.

 When I try to run it with the '%run' option or do a 'from script  import
 *' makes no difference: I get the namespace error in the subject line:

 /home/js/web2py/lees_isi_xml6.py in plaas_artikel(rekord)
     352     categories = rekord['categories']
     353     ut = item['ut'][0]
 -- 354     print db.tables()
     355     if db(db.isi_articles.ut == ut).count() == 0:
     356         titel = item['item_title'][0]

 NameError: global name 'db' is not defined

 But when I do a 'db.tables()' in the same shell, there is no problem.

 I have started the shell with

 python web2py.py -M -S kb

 How do I get web2py to run this script?

 Regards
 Johann

 --
  May grace and peace be yours in abundance through the full knowledge of God
 and of Jesus our Lord!  His divine power has given us everything we need for
 life and godliness through the full knowledge of the one who called us by
 his own glory and excellence.
                                                     2 Pet. 1:2b,3a


[web2py] Re: DAL new syntax RFC

2011-03-07 Thread ron_m
+1


[web2py] Re: redirection to /default/user/profile

2011-03-07 Thread Massimo Di Pierro
Hello pk,

I do not fully understand the problem. I understand the code but not
your workflow. Can you exaplain what you click on and what you expect
and what you get?

On Mar 7, 4:59 am, pk peter.kirch...@youngdesigners.de wrote:
 hi together,

 i have a problem with a redirection. i will not redirected to this
 link!
 in my view i have this: li class=bluea href={{=URL(r=request,
 c='default', f='user/logout')}}spanlogout/span/a/li

 my main-controller:
 @auth.requires_login()
 def index():
     return dict(message=main/index)

 default-controller:
 def index():
     if auth.is_logged_in():
         redirect(URL(r=request, c='main', f='index'))
     return dict(message=index)

 def user():
     loginform=auth.login()
     registerform=auth.register()
     return dict(loginform=loginform, registerform=registerform)

 but always after clicking the link i get this redirection!
 hope somebody of you can help me?!?

 thanks peter


[web2py] Re: web2py and ispcp (or any other contol panel)

2011-03-07 Thread Massimo Di Pierro
I have never used this. Is there a python module for ispcp?

On Mar 7, 1:59 pm, Haros koimiti...@hotmail.com wrote:
 Hello,

 I am trying to make web2py work with ispcp but I fail. Google doesn't
 provide any tutorial or hint and I guess it's beyond my knowledge to
 make it work without help...

 So, is there anyone that made web2py work with ispcp? I could also
 accept web2py with webmin but there is not much info for that too :P

 I would be glad if anyone could help.

 Thanks.


Re: [web2py] Re: DAL new syntax RFC

2011-03-07 Thread Luis Díaz
in my humble opinion
I think abbreviations are unnecessary.
this is ruby on rails

remember everyone:
the code is read more times than is written.

Díaz Luis
http://www.facebook.com/diazluis2007
TSU Analisis de Sistemas
Universidad de Carabobo
Facultad de 
Odontologíahttp://www.odontologia.uc.edu.ve/index.php?option=com_contentview=articleid=102Itemid=85





2011/3/7 ron_m ron.mco...@gmail.com

 +1



[web2py] Re: web2py recommended web hosting

2011-03-07 Thread Christopher Steel
I like Webfaction a lot. Once you get a handle on the Webfaction
vocabulary and setup it is great, before that happens you may find
yourself learning how it all works. In the end this is a good thing
because you will really understand how things are setup if you ever
have an issue, but it the beginning it can be frustrating if you new
to webfaction or developing with web2py or both.


Chris

On Mar 7, 4:12 am, Alejandro alek...@gmail.com wrote:
 Hello everyone,

 I am new in web2py and I am very impressed by their simplicity and
 capabilities.
 I would like to know which is the best/recommended web hosting to run
 web2py.

 Thanks,

 Alejandro


[web2py] Re: web2py recommended web hosting

2011-03-07 Thread Plumo
Unless you need special features I recommend Google App Engine because there 
is no upfront costs and easy to deploy.

[web2py] How to catch values from CRUD.CREATE and validate?

2011-03-07 Thread Ialejandro
Hi again! Playing again with my hotel booking sys I have a new
doubt...

I have this model:


db.define_table('room',
   Field('name','string),
   Field('ubication','string'))

db.define_table('booking',
Field('room',db.room),
Field('host','string'))

So I have this controller:

def index():
 form = crud.create(db.booking, next = URL('validate'))
return dict(form=form)

def validate():

   return dict()

def view():

#here I have all the code to show the made bookings in powertable

   return dict(table=table)


And this is what I'd like to do:

- A user gets into ~/index and can make a book of MULTIPLE rooms
(currently with the above code I can only book one room at a time).

- When a user clicks on the submit button, I need to sent an email to
a room manager, so he can validate  the booking.  If it proceeds it
will be saved and shown in powertable, if not, nothing is saved. How
could I do it?? Do I need to catch the data before saving it?


(I think I need something like this
auth.settings.registration_requires_approval = True, in fact how could
I do this???)


Thanks!!!

(sorry if there are too many questions)


[web2py] Re: some functionality to mix html and {{python expression}} is broken since 1.92.3, even back to 1.91.6

2011-03-07 Thread Brian M
Well you're missing a closing ) in this line - the A() is closed but the LI( 
is not:
{{  myli = LI(A(myrow['strRegionNameRendered'], _href=#) }} 

Why not simplify your template down a bit - Having your LI's inside a DIV 
seems a bit odd.

{{myUL = UL(_id=dhtmlgoodies_tree, _class=dhtmlgoodies_tree)}}
{{for row in sortedfolderlist:}} 
{{myrow = row[1]}} 
{{myUL.append(A(myrow['strRegionNameRendered'], _href=#)) }} 
{{pass}} 
{{=myUL}}



[web2py] Re: Update_record and validator conflict.

2011-03-07 Thread villas
           # this is undocumented
           db.company.CoC_number.requires.set_self_id(company[0].id)

Denes, Thanks for showing us this!  We should have an 'official'
method to do this,  it is an important feature.


[web2py] DAL shortcuts

2011-03-07 Thread pbreit
Are these three equivalent?

db(db.mytable.id==id).select().first()

db.mytable[id]

db.mytable*(*id*)*



[web2py] Re: DAL shortcuts

2011-03-07 Thread Massimo Di Pierro


On Mar 7, 7:06 pm, pbreit pbreitenb...@gmail.com wrote:
 Are these three equivalent?


these two are equivalent:

db(db.mytable.id==id).select().first()
db.mytable(id)

This is equivalent

db.mytable[id]

only if the id exists. The former two return None if id does not
exist, the third raises an exception.





Re: [web2py] Re: DAL new syntax RFC

2011-03-07 Thread Michael Barrow
Yeah -- I agree with that! Macros in your editor keep you from typing as
much. This is akin to technical folks incessant desire to create new
acronyms. Ugh!

On Mon, Mar 7, 2011 at 3:30 PM, Luis Díaz diazluis2...@gmail.com wrote:

 in my humble opinion
 I think abbreviations are unnecessary.
 this is ruby on rails

 remember everyone:
 the code is read more times than is written.

 Díaz Luis
 http://www.facebook.com/diazluis2007
 TSU Analisis de Sistemas
 Universidad de Carabobo
 Facultad de 
 Odontologíahttp://www.odontologia.uc.edu.ve/index.php?option=com_contentview=articleid=102Itemid=85





 2011/3/7 ron_m ron.mco...@gmail.com

 +1





-- 
Michael Barrow
michael at barrow dot me
+1 (408) 782-4249


[web2py] Re: DAL new syntax RFC

2011-03-07 Thread pbreit
If we are evaluating enhancements that save a few keystrokes AND increase 
clarity, I'd consider this. :-)

 URL('default/home') for URL(c='default', f='home') or URL('default', 
'home')


Re: [web2py] Re: DAL new syntax RFC

2011-03-07 Thread Thadeus Burgess
You can already do

URL('default', 'home')

It has been in web2py for some months now.

--
Thadeus




On Mon, Mar 7, 2011 at 9:20 PM, pbreit pbreitenb...@gmail.com wrote:

 If we are evaluating enhancements that save a few keystrokes AND increase
 clarity, I'd consider this. :-)

  URL('default/home') for URL(c='default', f='home') or URL('default',
 'home')



[web2py] Re: DAL tutorial video

2011-03-07 Thread mart
Massimo, this is great! context is everything and nothing like audio
to accompany the visual!

Thanks for that! :)

if possible, would you to see the output of those 200 and some lines
to a text file or something? There were a few parts (well, maybe more
than a few) in there that I really found interesting and that
triggered an idea or 2 which I would love to look at closer but I can
hardly see the code being printed to the screen... yeah, my eyes
aren't very good. i would just like to blow up the font size to
something familiar (like 24 + :( ) and read that while listening (if
its ok to ask).

Anyways, really enjoyed it, thanks :)


On Mar 7, 8:02 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 http://vimeo.com/20760298


[web2py] DAL issue with w2p 1.91.6

2011-03-07 Thread Michael Barrow
I'm running v1.91.6 and I try out a simple db.*table*.insert in the shell
from the admin application and it works just fine. However, when the exact
same code is in one of my controllers, an exception is generated because
web2py is trying to cram some hunk of data into a column that's only 512
bytes.

Thoughts?

-- 
Michael Barrow
michael at barrow dot me
+1 (408) 782-4249


Re: [web2py] Re: DAL new syntax RFC

2011-03-07 Thread Luis Díaz
premature optimization is the root of all evil

otherwise I still use:
URL (f = 'default ', c = 'home')

these characters f =, c =
I may write more readable code


[web2py] Re: DAL issue with w2p 1.91.6

2011-03-07 Thread Michael Barrow
To follow up, I turned on query logging in the database and it looks like
when the code runs in the controller, it's trying to do an insert for all of
the columns in the table and not just the ones I specified in the
db.table.insert(). Any suggestions as to where I can track down what's going
on here?

On Mon, Mar 7, 2011 at 8:27 PM, Michael Barrow mich...@barrow.me wrote:

 I'm running v1.91.6 and I try out a simple db.*table*.insert in the shell
 from the admin application and it works just fine. However, when the exact
 same code is in one of my controllers, an exception is generated because
 web2py is trying to cram some hunk of data into a column that's only 512
 bytes.

 Thoughts?

 --
 Michael Barrow
 michael at barrow dot me
 +1 (408) 782-4249




-- 
Michael Barrow
michael at barrow dot me
+1 (408) 782-4249


[web2py] Re: DAL issue with w2p 1.91.6

2011-03-07 Thread pbreit
Can you provide some code for us to look at?

Re: [web2py] Re: DAL new syntax RFC

2011-03-07 Thread pbreit
Yeah, I did also note URL('default', 'home')

Sure it's only 3 or 4 chars but I also like the readability of
 'default/index' when working on web projects.

This is not a big deal, of course.


Re: [web2py] Re: NameError: global name 'db' is not defined

2011-03-07 Thread Johann Spies
On 8 March 2011 01:12, Massimo Di Pierro massimo.dipie...@gmail.com wrote:



 python web2py.py -M -N -S kb -R script.py


Thanks!

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


Re: [web2py] Re: DAL issue with w2p 1.91.6

2011-03-07 Thread Michael Barrow
Yeah -- I'm a loser. Sorry about that. I tracked it down to something I had
been attempting to use to automatically stamp record creation and
modifications. Hindsight being 20/20, I realized that I'd not fully vetted
the syntax and was attempting to cram a printed object where it didn't
belong. Mea culpa for the interruption to your normal programming. :)

On Mon, Mar 7, 2011 at 10:07 PM, pbreit pbreitenb...@gmail.com wrote:

 Can you provide some code for us to look at?




-- 
Michael Barrow
michael at barrow dot me
+1 (408) 782-4249


[web2py] routes on GAE

2011-03-07 Thread Plumo
I have the following listing in routes:
('/robots.txt', '/cms/static/robots.txt')

This lets me access /robots.txt on my local computer, but returns invalid 
request when I upload this to GAE. Are there meant to be any differences 
when using routes on GAE?

I can access /cms/static/robots.txt on both local and GAE.