[web2py] Possible addition to IS_IN_DB

2010-07-09 Thread Alastair Medford

As it stands, when one places the IS_IN_DB validator on a field, you
get a select list with options of all the rows in the given table.
This is great, but now I'm looking for a little more functionality.
For my application I'm looking to filter the selection down to a given
db requirement. For example, instead of a list of all the students in
a table, I want all students who is in class x (so the relationship
could be something like db.student.class=5A). I know I could easily
accomplish this manually, but my project dictates that these forms
will always be generated.

I've looked into the code of the IS_IN_DB validator, and it looks like
to achieve this I could add an argument to it that takes a query (None
by default), and simply change the line:

records = self.dbset.select(*self.fields, **dd)
to
records = self.dbset(query).select(*self.fields, **dd)

Is this all it would take? Would this be useful to anyone else? Should
this feature be somewhere else?
I've yet to contribute to an open source project, and I don't really
know how the process works.
Thanks.


[web2py] Re: Possible addition to IS_IN_DB

2010-07-09 Thread David Marko
You can use full DAL query in IS_IN_DB validator e.g.
IS_IN_DB(db(db.children.sex=='M'),'children.id','%(name)s' )

David

On 9 čnc, 08:08, Alastair Medford alastairmedf...@gmail.com wrote:
 As it stands, when one places the IS_IN_DB validator on a field, you
 get a select list with options of all the rows in the given table.
 This is great, but now I'm looking for a little more functionality.
 For my application I'm looking to filter the selection down to a given
 db requirement. For example, instead of a list of all the students in
 a table, I want all students who is in class x (so the relationship
 could be something like db.student.class=5A). I know I could easily
 accomplish this manually, but my project dictates that these forms
 will always be generated.

 I've looked into the code of the IS_IN_DB validator, and it looks like
 to achieve this I could add an argument to it that takes a query (None
 by default), and simply change the line:

 records = self.dbset.select(*self.fields, **dd)
 to
 records = self.dbset(query).select(*self.fields, **dd)

 Is this all it would take? Would this be useful to anyone else? Should
 this feature be somewhere else?
 I've yet to contribute to an open source project, and I don't really
 know how the process works.
 Thanks.


[web2py] Re: markmin, t2, t3, cube9 etc. (important update)

2010-07-09 Thread aure
Great news! Thanks for the work Massimo!

Being new to both, I myself still hesitate for my project between
choosing a CMS and struggle with the programming vs. choosing web2by
and struggle with all the things which come for free in a CMS... And
Cube2py starts to bridge the gap in some ways :-)

I am sure that having these new features will bring more people to
web2py.

Aurelien

On Jul 9, 12:20 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Jul 7, 2010, at 3:47 PM, mdipierro wrote:

  I do not have a strong opposition and I see the advantages in terms of
  notation but I have two problems:

 I'm tied up today, so just a quick note. I understand and generally agree 
 with your caveats. I have a couple of thoughts on the subject that I'll come 
 back with.



  The page:slug notation is handled by plugin_wiki, not by markmin.
  markmin just treats url, #anchor, url#anchor, page:slug all in the
  same way. plugin_wiki replaces the page:.. with /app/plugin_wiki/
  page/ after markmin has done its job.
  This decoupling was intentional to allow markmin to work without
  web2py and without plugin_wiki conventions.
  Your first suggestion would introduce coupling. Moreover it would
  provide a shortcut that encourage users to display the slug as text of
  the link. I am not convinced this is a good idea.

  Massimo

  On 7 Lug, 17:24, Jonathan Lundell jlund...@pobox.com wrote:
  On Jul 7, 2010, at 3:14 PM, mdipierro wrote:

  Right now you can do links with

  url
  [[name url]]
  [[name #anchor]]
  [[name url#anchor]]
  [[name page:slug]]

  and define an anchor with

  [[anchor]]

  If I understand your suggestions:
  1) also allow
  [[url]]
  [[url#anchor]]
  [[#anchor]]
  [[page:slug]]
  to allow un-named links. Q: how can a link not have a name?

  In your notation, I was thinking:

  [[slug]] would imply [[slug page:slug]]

  'slug' would be used verbatim as the name, and with slug-encoding as the 
  slug.

  A link would always have a name; it would just be implicit. That's the 
  Mediawiki convention, though they use a vertical bar to separate an 
  optional name from the slug.

  2) use [[=anchor]] to define an anchor to avoid conflict with 1.

  if we do 1, we must do 2 but I would prefer [[!anchor]] then.

  Sure.

  Or [name:anchor], which corresponds to the html that it generates.




[web2py] Re: Possible addition to IS_IN_DB

2010-07-09 Thread Alastair Medford
I thought there was an easier way. I didn't think of just passing it
in with db in the first place. Thanks

On Jul 9, 12:35 am, David Marko dma...@tiscali.cz wrote:
 You can use full DAL query in IS_IN_DB validator e.g.
 IS_IN_DB(db(db.children.sex=='M'),'children.id','%(name)s' )

 David

 On 9 čnc, 08:08, Alastair Medford alastairmedf...@gmail.com wrote:

  As it stands, when one places the IS_IN_DB validator on a field, you
  get a select list with options of all the rows in the given table.
  This is great, but now I'm looking for a little more functionality.
  For my application I'm looking to filter the selection down to a given
  db requirement. For example, instead of a list of all the students in
  a table, I want all students who is in class x (so the relationship
  could be something like db.student.class=5A). I know I could easily
  accomplish this manually, but my project dictates that these forms
  will always be generated.

  I've looked into the code of the IS_IN_DB validator, and it looks like
  to achieve this I could add an argument to it that takes a query (None
  by default), and simply change the line:

  records = self.dbset.select(*self.fields, **dd)
  to
  records = self.dbset(query).select(*self.fields, **dd)

  Is this all it would take? Would this be useful to anyone else? Should
  this feature be somewhere else?
  I've yet to contribute to an open source project, and I don't really
  know how the process works.
  Thanks.


[web2py] Re: Remove lost password link from the standard login form

2010-07-09 Thread mdipierro
You need to edit the views/layout.html page.


On 8 Lug, 23:36, Giuseppe Luca Scrofani glsdes...@gmail.com wrote:
 Hi all, how can I remove this function?
 I've tried with

 auth.settings.actions_disabled.append('request_reset_password')

 in the user(): controller, but this remove only the target page, not
 the link in itself from the login form...

 Some ideas?


[web2py] Re: markmin, t2, t3, cube9 etc. (important update)

2010-07-09 Thread mdipierro
Please feel free to propose for new features. That was exactly the
intention.


On 9 Lug, 03:02, aure aureliengir...@googlemail.com wrote:
 Great news! Thanks for the work Massimo!

 Being new to both, I myself still hesitate for my project between
 choosing a CMS and struggle with the programming vs. choosing web2by
 and struggle with all the things which come for free in a CMS... And
 Cube2py starts to bridge the gap in some ways :-)

 I am sure that having these new features will bring more people to
 web2py.

 Aurelien

 On Jul 9, 12:20 am, Jonathan Lundell jlund...@pobox.com wrote:

  On Jul 7, 2010, at 3:47 PM, mdipierro wrote:

   I do not have a strong opposition and I see the advantages in terms of
   notation but I have two problems:

  I'm tied up today, so just a quick note. I understand and generally agree 
  with your caveats. I have a couple of thoughts on the subject that I'll 
  come back with.

   The page:slug notation is handled by plugin_wiki, not by markmin.
   markmin just treats url, #anchor, url#anchor, page:slug all in the
   same way. plugin_wiki replaces the page:.. with /app/plugin_wiki/
   page/ after markmin has done its job.
   This decoupling was intentional to allow markmin to work without
   web2py and without plugin_wiki conventions.
   Your first suggestion would introduce coupling. Moreover it would
   provide a shortcut that encourage users to display the slug as text of
   the link. I am not convinced this is a good idea.

   Massimo

   On 7 Lug, 17:24, Jonathan Lundell jlund...@pobox.com wrote:
   On Jul 7, 2010, at 3:14 PM, mdipierro wrote:

   Right now you can do links with

   url
   [[name url]]
   [[name #anchor]]
   [[name url#anchor]]
   [[name page:slug]]

   and define an anchor with

   [[anchor]]

   If I understand your suggestions:
   1) also allow
   [[url]]
   [[url#anchor]]
   [[#anchor]]
   [[page:slug]]
   to allow un-named links. Q: how can a link not have a name?

   In your notation, I was thinking:

   [[slug]] would imply [[slug page:slug]]

   'slug' would be used verbatim as the name, and with slug-encoding as the 
   slug.

   A link would always have a name; it would just be implicit. That's the 
   Mediawiki convention, though they use a vertical bar to separate an 
   optional name from the slug.

   2) use [[=anchor]] to define an anchor to avoid conflict with 1.

   if we do 1, we must do 2 but I would prefer [[!anchor]] then.

   Sure.

   Or [name:anchor], which corresponds to the html that it generates.


[web2py] multiple checkboxes

2010-07-09 Thread Rob
Hi All,

Sorry for the noob post, but I'm having an issue.  I'm trying to do a
little toy 'shopping list' app - the index page is to have a list of
'items' on the page with a 'need' checkbox and an 'update' button.
When the update button is pressed, the database is to be updated with
the new checked values.

here is the db:

db.define_table('Item',
Field('description'),
Field('need', 'boolean')

here is the controller:
def index():
table = TABLE()
items = db().select(db.Item.ALL)
for item in items:
chk = INPUT(_type='checkbox', _name='need_%s' % item.id,
value=item.need)
table.append(TR(item.id,item.description,chk))
form = FORM(table,INPUT(_type='submit'))
if form.accepts(request.vars,session):
for k,v in request.vars.items():
if k.startswith('need_'):
id = k.split('_')[-1]
item = db(db.Item.id == int(id)).select()[0]
item.update_record(need=(form.vars[k]=='on'))
return dict(form=form)

view: default/index.html
{{extend 'layout.html'}}
{{=form}}

This doesn't quite work right - it's close and it feels like a
kludge.  I need to set the checkbox value to the proper 'request'
variable, but I don't process those until the end of the function...
am I on the right track here?  I found most of this code on a forum
somewhere.

Thanks for the help... it sucks just starting out!

-Rob


[web2py] why do forms get defined in the controller?

2010-07-09 Thread Rob
I'm very new to web2py and MVC.  I see that in a lot of examples,
forms get defined in the controller (ie: 
http://web2py.com/book/default/section/7/1).
My question is - why?  Why do forms get defined in the controller and
not the view in some situations?

I have a friend doing a toy app with me - he's using asp.net MVC and
he didn't understand why I would do this... and I didn't know what to
tell him.

Anyway, just looking for thoughts on the issue - we are both new so
perhaps we're missing something?

Thanks!


[web2py] Re: is_in_set hoirzontal radio widget and is_empty as default

2010-07-09 Thread mr.freeze
This may help:
http://groups.google.com/group/web2py/browse_thread/thread/8b5974af438a436a


On Jul 1, 6:08 am, selecta gr...@delarue-berlin.de wrote:
 *bump*

 could you please at least tell me if I should write the hradio
 (horizontally aligned radio boxes) widget?

 On Jun 25, 12:19 pm, selecta gr...@delarue-berlin.de wrote:

  when I create a form field with the following code

  Field('open_source',            requires =
  IS_EMPTY_OR(IS_IN_SET((True, False), zero = 'unknown')),
  widget=SQLFORM.widgets.radio.widget, default = None),

  I get vertical aligned radio boxes. Is there a build in method for
  showing the radio boxed horizontally aligned or do I have to write my
  own widget class for that?

  And

  The default option should be None but the 'unknown' box is not check
  when the widget is build, how can I change that?


[web2py] customize form in template

2010-07-09 Thread Julius Minka
I am loading the form in the template this way:
{{=LOAD('default','form')}}

Can I somewhow customize it this way?
{{=form.custom.begin}}
Image name: div{{=form.custom.widget.name}}/div
Click here to upload: {{=form.custom.submit}}
{{=form.custom.end}}

What I actually need is to place labels above fields.

Julius




[web2py] Re: [web2py:37631] Re: How to limit get_twits function?

2010-07-09 Thread Julius Minka
Was anybody able to resolve this issue?
Julius

V Pondelok, 21. december 2009 o 20:35 -0300, Tito Garrido napísal(a):
 Looks like it just returns 1 result for:
 http://search.twitter.com/search.atom?q=from%3Aweb2py
 
 strange... but thanks for your answers!
 
 On Mon, Dec 21, 2009 at 12:33 AM, mr.freeze nat...@freezable.com
 wrote:
 You should be able to search by user with from%3Auser (url
 encoded
 'from:user') :
 http://search.twitter.com/search.json?q=from%
 3Auserpage=1rpp=10
 
 On Dec 20, 8:03 pm, Tito Garrido titogarr...@gmail.com
 wrote:
  I've found this link too but it doesn't work :-/
 
 
 
 
  On Sun, Dec 20, 2009 at 5:45 PM, mdipierro
 mdipie...@cs.depaul.edu wrote:
   based on this it is rpp=10
 
  http://apiwiki.twitter.com/Twitter-Search-API-Method%
 3A-search
 
   On Dec 20, 2:28 pm, Tito Garrido titogarr...@gmail.com
 wrote:
def get_twits():
  user='web2py'
  import gluon.tools
  import gluon.contrib.simplejson as sj
 
  page = gluon.tools.fetch('http://twitter.com/%
 s?format=json'%http://twitter.com/%s?format=json%27%user)
 
  tweets=XML(sj.loads(page)['#timeline'])
  return dict(tweets=tweets)
 
I'm wondering how can we limit this query for last 10
 tweets...
 
Anybody has a clue?
 
Thanks!
 
--
 
Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___
 
   --
 
   You received this message because you are subscribed to
 the Google Groups
   web2py-users group.
   To post to this group, send email to
 web...@googlegroups.com.
   To unsubscribe from this group, send email to
 
   web2py+unsubscr...@googlegroups.comweb2py%
 2bunsubscr...@googlegroups.com
 
   .
   For more options, visit this group at
  http://groups.google.com/group/web2py?hl=en.
 
  --
 
  Linux User #387870
  .
   _/_õ|__|
  ..º[ .-.___.-._| . . . .
  .__( o)__( o).:___
 
 --
 
 You received this message because you are subscribed to the
 Google Groups web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to web2py
 +unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/web2py?hl=en.
 
 
 
 
 
 
 -- 
 
 Linux User #387870
 .
  _/_õ|__|
 ..º[ .-.___.-._| . . . .
 .__( o)__( o).:___
 
 
 --
 
 You received this message because you are subscribed to the Google
 Groups web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to web2py
 +unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/web2py?hl=en.




Re: [web2py] Re: markmin, t2, t3, cube9 etc. (important update)

2010-07-09 Thread Albert Abril
I thought about the idea of making a frontend (i.e. in the web admin) to
edit routes.py and make more customizable the urls.
But don't know how implement it.



On Fri, Jul 9, 2010 at 12:48 PM, mdipierro mdipie...@cs.depaul.edu wrote:

 Please feel free to propose for new features. That was exactly the
 intention.


 On 9 Lug, 03:02, aure aureliengir...@googlemail.com wrote:
  Great news! Thanks for the work Massimo!
 
  Being new to both, I myself still hesitate for my project between
  choosing a CMS and struggle with the programming vs. choosing web2by
  and struggle with all the things which come for free in a CMS... And
  Cube2py starts to bridge the gap in some ways :-)
 
  I am sure that having these new features will bring more people to
  web2py.
 
  Aurelien
 
  On Jul 9, 12:20 am, Jonathan Lundell jlund...@pobox.com wrote:
 
   On Jul 7, 2010, at 3:47 PM, mdipierro wrote:
 
I do not have a strong opposition and I see the advantages in terms
 of
notation but I have two problems:
 
   I'm tied up today, so just a quick note. I understand and generally
 agree with your caveats. I have a couple of thoughts on the subject that
 I'll come back with.
 
The page:slug notation is handled by plugin_wiki, not by markmin.
markmin just treats url, #anchor, url#anchor, page:slug all in the
same way. plugin_wiki replaces the page:.. with /app/plugin_wiki/
page/ after markmin has done its job.
This decoupling was intentional to allow markmin to work without
web2py and without plugin_wiki conventions.
Your first suggestion would introduce coupling. Moreover it would
provide a shortcut that encourage users to display the slug as text
 of
the link. I am not convinced this is a good idea.
 
Massimo
 
On 7 Lug, 17:24, Jonathan Lundell jlund...@pobox.com wrote:
On Jul 7, 2010, at 3:14 PM, mdipierro wrote:
 
Right now you can do links with
 
url
[[name url]]
[[name #anchor]]
[[name url#anchor]]
[[name page:slug]]
 
and define an anchor with
 
[[anchor]]
 
If I understand your suggestions:
1) also allow
[[url]]
[[url#anchor]]
[[#anchor]]
[[page:slug]]
to allow un-named links. Q: how can a link not have a name?
 
In your notation, I was thinking:
 
[[slug]] would imply [[slug page:slug]]
 
'slug' would be used verbatim as the name, and with slug-encoding as
 the slug.
 
A link would always have a name; it would just be implicit. That's
 the Mediawiki convention, though they use a vertical bar to separate an
 optional name from the slug.
 
2) use [[=anchor]] to define an anchor to avoid conflict with 1.
 
if we do 1, we must do 2 but I would prefer [[!anchor]] then.
 
Sure.
 
Or [name:anchor], which corresponds to the html that it generates.



[web2py] Re: multiple checkboxes

2010-07-09 Thread mdipierro
This should work:

def index():
items = db().select(db.Item.ALL)
form=SQLFORM.factory(*[Field('need_%s'%item.id, default=item.need)
for item in items])
if form.accepts(request.vars,session):
   for item in items:
  need = not request.vars['need_%s'%item.id]==None
  item.update_record(need=need)
   return dict(form=form)

On 9 Lug, 01:04, Rob r...@rmdashr.com wrote:
 Hi All,

 Sorry for the noob post, but I'm having an issue.  I'm trying to do a
 little toy 'shopping list' app - the index page is to have a list of
 'items' on the page with a 'need' checkbox and an 'update' button.
 When the update button is pressed, the database is to be updated with
 the new checked values.

 here is the db:

 db.define_table('Item',
     Field('description'),
     Field('need', 'boolean')

 here is the controller:
 def index():
     table = TABLE()
     items = db().select(db.Item.ALL)
     for item in items:
         chk = INPUT(_type='checkbox', _name='need_%s' % item.id,
 value=item.need)
         table.append(TR(item.id,item.description,chk))
     form = FORM(table,INPUT(_type='submit'))
     if form.accepts(request.vars,session):
         for k,v in request.vars.items():
             if k.startswith('need_'):
                 id = k.split('_')[-1]
                 item = db(db.Item.id == int(id)).select()[0]
                 item.update_record(need=(form.vars[k]=='on'))
     return dict(form=form)

 view: default/index.html
 {{extend 'layout.html'}}
 {{=form}}

 This doesn't quite work right - it's close and it feels like a
 kludge.  I need to set the checkbox value to the proper 'request'
 variable, but I don't process those until the end of the function...
 am I on the right track here?  I found most of this code on a forum
 somewhere.

 Thanks for the help... it sucks just starting out!

 -Rob


[web2py] Re: why do forms get defined in the controller?

2010-07-09 Thread mdipierro
There are different parts of a form. The logic (structure and
validation) and presentation.

The logic goes in the controller. The presentation goes in the view.
Often you use the default presentation so you only need {{=form}} in
the view.



Massimo

On 9 Lug, 01:10, Rob r...@rmdashr.com wrote:
 I'm very new to web2py and MVC.  I see that in a lot of examples,
 forms get defined in the controller 
 (ie:http://web2py.com/book/default/section/7/1).
 My question is - why?  Why do forms get defined in the controller and
 not the view in some situations?

 I have a friend doing a toy app with me - he's using asp.net MVC and
 he didn't understand why I would do this... and I didn't know what to
 tell him.

 Anyway, just looking for thoughts on the issue - we are both new so
 perhaps we're missing something?

 Thanks!


[web2py] Re: customize form in template

2010-07-09 Thread mdipierro
if you just need to place labels above fields you can just do

SQLFORM(...formstyle='table2cols')

On 9 Lug, 06:25, Julius Minka j...@minka.sk wrote:
 I am loading the form in the template this way:
 {{=LOAD('default','form')}}

 Can I somewhow customize it this way?
 {{=form.custom.begin}}
 Image name: div{{=form.custom.widget.name}}/div
 Click here to upload: {{=form.custom.submit}}
 {{=form.custom.end}}

 What I actually need is to place labels above fields.

 Julius


[web2py] Re: markmin, t2, t3, cube9 etc. (important update)

2010-07-09 Thread mdipierro
That would belong to admin not to cube2py although we could expose it
there. In principle you only need to edit routes.py (look into
applications/admin/controllers/default.py, def edit()) and then call
gluon.rewrite.load(routes='routes.py').

The problem is logical. If you use admin to edit routes and mess up
admin may not work anymore and you lose the ability to fix it.

Massimo

On 9 Lug, 07:10, Albert Abril albert.ab...@gmail.com wrote:
 I thought about the idea of making a frontend (i.e. in the web admin) to
 edit routes.py and make more customizable the urls.
 But don't know how implement it.

 On Fri, Jul 9, 2010 at 12:48 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  Please feel free to propose for new features. That was exactly the
  intention.

  On 9 Lug, 03:02, aure aureliengir...@googlemail.com wrote:
   Great news! Thanks for the work Massimo!

   Being new to both, I myself still hesitate for my project between
   choosing a CMS and struggle with the programming vs. choosing web2by
   and struggle with all the things which come for free in a CMS... And
   Cube2py starts to bridge the gap in some ways :-)

   I am sure that having these new features will bring more people to
   web2py.

   Aurelien

   On Jul 9, 12:20 am, Jonathan Lundell jlund...@pobox.com wrote:

On Jul 7, 2010, at 3:47 PM, mdipierro wrote:

 I do not have a strong opposition and I see the advantages in terms
  of
 notation but I have two problems:

I'm tied up today, so just a quick note. I understand and generally
  agree with your caveats. I have a couple of thoughts on the subject that
  I'll come back with.

 The page:slug notation is handled by plugin_wiki, not by markmin.
 markmin just treats url, #anchor, url#anchor, page:slug all in the
 same way. plugin_wiki replaces the page:.. with /app/plugin_wiki/
 page/ after markmin has done its job.
 This decoupling was intentional to allow markmin to work without
 web2py and without plugin_wiki conventions.
 Your first suggestion would introduce coupling. Moreover it would
 provide a shortcut that encourage users to display the slug as text
  of
 the link. I am not convinced this is a good idea.

 Massimo

 On 7 Lug, 17:24, Jonathan Lundell jlund...@pobox.com wrote:
 On Jul 7, 2010, at 3:14 PM, mdipierro wrote:

 Right now you can do links with

 url
 [[name url]]
 [[name #anchor]]
 [[name url#anchor]]
 [[name page:slug]]

 and define an anchor with

 [[anchor]]

 If I understand your suggestions:
 1) also allow
 [[url]]
 [[url#anchor]]
 [[#anchor]]
 [[page:slug]]
 to allow un-named links. Q: how can a link not have a name?

 In your notation, I was thinking:

 [[slug]] would imply [[slug page:slug]]

 'slug' would be used verbatim as the name, and with slug-encoding as
  the slug.

 A link would always have a name; it would just be implicit. That's
  the Mediawiki convention, though they use a vertical bar to separate an
  optional name from the slug.

 2) use [[=anchor]] to define an anchor to avoid conflict with 1.

 if we do 1, we must do 2 but I would prefer [[!anchor]] then.

 Sure.

 Or [name:anchor], which corresponds to the html that it generates.


[web2py] Changing default value in SELECT

2010-07-09 Thread Serbitar
The following code:

test = SELECT(1,2, value = 2)
test.attributes[value] = 1

still renders as:

select
option value=11/option
option selected=selected value=22/option
/select

I have no idea why . . .


[web2py] Re: Changing default value in SELECT

2010-07-09 Thread mdipierro
test = SELECT(1,2, value = 2)
test.attributes[value] = 1
test._postprocessing() # recursively loops over options and fixes
them.

On 9 Lug, 06:41, Serbitar rserbi...@googlemail.com wrote:
 The following code:

 test = SELECT(1,2, value = 2)
 test.attributes[value] = 1

 still renders as:

 select
 option value=11/option
 option selected=selected value=22/option
 /select

 I have no idea why . . .


[web2py] Subtle data integrity bug with web2py

2010-07-09 Thread John Heenan
This is a report of a subtle data integrity bug that is difficult to
describe in a short manner. However the bug is trivial to fix.

I noticed the bug when I imported data directly into sqlite3 that had
date fields with empty dates. I used the sqlite3 utility .import
command as I needed to preserve the ROWID primary keys. The dates are
termination dates and should only be filled in when a termination
occurs.

If the corresponding web2py db.Field type is 'date' and the imported
value of the date field is empty then the following error message
occurs from the web2py database administrator.
Invalid Query invalid literal for int() with base 10: ''

If web2py is used to enter data then no error arises.

However if the web2py entered record is exported from sqlite and then
reimported the error occurs.

This should be enough to ring bells that there appears to be a data
integrity bug.

The first reaction of experts is likely to be that the error is
related to dynamic typing of sqlite and the requirement that text
entered date follows a strict ISO8601 format for sqlite3 internal date
functions to work correctly. However this is irrelevant as web2py
stores and manipulates date data without using sqlite internal date
functions and web2py does not necessarily use a complete ISO8601
string.

The next paragraph might appear bizarre and wrong to a database
expert, however to anyone familiar with the dynamic typing rules of
sqlite there is nothing wrong.

The key to the problem is examining the type of dynamic data stored by
sqlite3. The typename in the create statement for the date fileld is
'DATE'. Since 'DATE' is not matched by sqlite3's dynmaic typing column
affinity rules, the affinity of the column defaults to 'NUMERIC'. The
actual type of the sqlite imported date with an empty date is 'text'
but the type of the date field when entered through web2py is 'null'
instead!

This means the problem lies with web2py and is easily fixed. All
web2py needs to do when parsing dates is to treat a null and an empty
string the same way!

John Heenan


[web2py] Re: Subtle data integrity bug with web2py

2010-07-09 Thread mdipierro
Thanks for the explanation. It helps clarify a long standing problem.
I have a solution in trunk based on your comment. Please check it and
let us know if this is what you had in mind.

Massimo

On 9 Lug, 07:55, John Heenan johnmhee...@gmail.com wrote:
 This is a report of a subtle data integrity bug that is difficult to
 describe in a short manner. However the bug is trivial to fix.

 I noticed the bug when I imported data directly into sqlite3 that had
 date fields with empty dates. I used the sqlite3 utility .import
 command as I needed to preserve the ROWID primary keys. The dates are
 termination dates and should only be filled in when a termination
 occurs.

 If the corresponding web2py db.Field type is 'date' and the imported
 value of the date field is empty then the following error message
 occurs from the web2py database administrator.
 Invalid Query invalid literal for int() with base 10: ''

 If web2py is used to enter data then no error arises.

 However if the web2py entered record is exported from sqlite and then
 reimported the error occurs.

 This should be enough to ring bells that there appears to be a data
 integrity bug.

 The first reaction of experts is likely to be that the error is
 related to dynamic typing of sqlite and the requirement that text
 entered date follows a strict ISO8601 format for sqlite3 internal date
 functions to work correctly. However this is irrelevant as web2py
 stores and manipulates date data without using sqlite internal date
 functions and web2py does not necessarily use a complete ISO8601
 string.

 The next paragraph might appear bizarre and wrong to a database
 expert, however to anyone familiar with the dynamic typing rules of
 sqlite there is nothing wrong.

 The key to the problem is examining the type of dynamic data stored by
 sqlite3. The typename in the create statement for the date fileld is
 'DATE'. Since 'DATE' is not matched by sqlite3's dynmaic typing column
 affinity rules, the affinity of the column defaults to 'NUMERIC'. The
 actual type of the sqlite imported date with an empty date is 'text'
 but the type of the date field when entered through web2py is 'null'
 instead!

 This means the problem lies with web2py and is easily fixed. All
 web2py needs to do when parsing dates is to treat a null and an empty
 string the same way!

 John Heenan


[web2py] Re: Problem uploading on GAE

2010-07-09 Thread Ravi
no python 3.1
plz. help

On Jul 9, 2:28 am, mdipierro mdipie...@cs.depaul.edu wrote:
 Strange appcfg.py is aGAEfile. Are you using python 2.5?

 On 8 Lug, 11:47, Ravi gr8su...@gmail.com wrote:

  on running appconfig.py it is showing this error-

  Traceback (most recent call last):
    File appcfg.py, line 68, in module
      run_file(__file__, globals())
    File appcfg.py, line 64, in run_file
      execfile(script_path, globals_)
  NameError: global name 'execfile' is not defined

  what shud i do


[web2py] Re: Problem uploading on GAE

2010-07-09 Thread mdipierro
Google only supports python 2.5.

On 9 Lug, 08:10, Ravi gr8su...@gmail.com wrote:
 no python 3.1
 plz. help

 On Jul 9, 2:28 am, mdipierro mdipie...@cs.depaul.edu wrote:

  Strange appcfg.py is aGAEfile. Are you using python 2.5?

  On 8 Lug, 11:47, Ravi gr8su...@gmail.com wrote:

   on running appconfig.py it is showing this error-

   Traceback (most recent call last):
     File appcfg.py, line 68, in module
       run_file(__file__, globals())
     File appcfg.py, line 64, in run_file
       execfile(script_path, globals_)
   NameError: global name 'execfile' is not defined

   what shud i do


[web2py] fedora experts?

2010-07-09 Thread mdipierro
I managed to wrote this script

http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-fedora.sh

It worked for me but I am no fedora expert. Any advice for
imrpovements?


[web2py] new welcome (scaffolding) app

2010-07-09 Thread mdipierro
let's consider a new scaffolding app.

What should be in it?
What should not be in it?

possible suggestions:
[ ] js menu
[ ] new layout (suggestions?)
[ ] more complex views/layout?
[ ] simpler views/layout.html
[ ] example plugins
[ ] plugin_wiki from cube2py?
[ ] jquery.ui

Massimo


[web2py] web2py 1.93?

2010-07-09 Thread Massimo Di Pierro
I am planning to release the nightly build as stable 1.93 on Monday.  
Please check it out if you have not done so. 


[web2py] Re: Subtle data integrity bug with web2py

2010-07-09 Thread John Heenan
Yes, the bug is now fixed.

I checked out the current mercurial trunk for web2py Version 1.79.2
(2010-06-08 16:40:21)

All I had to do to confirm the bug was fixed was change a web2py
db.Field type from a 'char' type to a 'date' type and confirm database
administration worked for the relevant table of an uploaded
application.

Thanks for the quick change.

Seems surreal that such a subtle data integrity bug could be fixed in
this manner!

John Heenan

On Jul 9, 11:04 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Thanks for the explanation. It helps clarify a long standing problem.
 I have a solution in trunk based on your comment. Please check it and
 let us know if this is what you had in mind.

 Massimo

 On 9 Lug, 07:55, John Heenan johnmhee...@gmail.com wrote:

  This is a report of a subtle data integrity bug that is difficult to
  describe in a short manner. However the bug is trivial to fix.

  I noticed the bug when I imported data directly into sqlite3 that had
  date fields with empty dates. I used the sqlite3 utility .import
  command as I needed to preserve the ROWID primary keys. The dates are
  termination dates and should only be filled in when a termination
  occurs.

  If the corresponding web2py db.Field type is 'date' and the imported
  value of the date field is empty then the following error message
  occurs from the web2py database administrator.
  Invalid Query invalid literal for int() with base 10: ''

  If web2py is used to enter data then no error arises.

  However if the web2py entered record is exported from sqlite and then
  reimported the error occurs.

  This should be enough to ring bells that there appears to be a data
  integrity bug.

  The first reaction of experts is likely to be that the error is
  related to dynamic typing of sqlite and the requirement that text
  entered date follows a strict ISO8601 format for sqlite3 internal date
  functions to work correctly. However this is irrelevant as web2py
  stores and manipulates date data without using sqlite internal date
  functions and web2py does not necessarily use a complete ISO8601
  string.

  The next paragraph might appear bizarre and wrong to a database
  expert, however to anyone familiar with the dynamic typing rules of
  sqlite there is nothing wrong.

  The key to the problem is examining the type of dynamic data stored by
  sqlite3. The typename in the create statement for the date fileld is
  'DATE'. Since 'DATE' is not matched by sqlite3's dynmaic typing column
  affinity rules, the affinity of the column defaults to 'NUMERIC'. The
  actual type of the sqlite imported date with an empty date is 'text'
  but the type of the date field when entered through web2py is 'null'
  instead!

  This means the problem lies with web2py and is easily fixed. All
  web2py needs to do when parsing dates is to treat a null and an empty
  string the same way!

  John Heenan


Re: [web2py] Re: Possible addition to IS_IN_DB

2010-07-09 Thread Johann Spies
I have a related query.

 On Jul 9, 12:35 am, David Marko dma...@tiscali.cz wrote:
 You can use full DAL query in IS_IN_DB validator e.g.
 IS_IN_DB(db(db.children.sex=='M'),'children.id','%(name)s' )

I want the result of IS_IN_DB to be part of my access control measures
and dependent on who is logged in and what is typed in another field
in the form.

Example:

X is logged in and has access to say 8 of about 50 options in the database.

In the form the first field should make only  some of the 8 options
available in the second field.

I suspect it can be done with AJAX but I have now experience in using
javascript tools.

Has anyone done that before?

Or should I have two forms where the content of the second is
determined by the submission of the first?

Regards
Johann
-- 
Finally, brethren, whatsoever things are true,  whatsoever things are
honest, whatsoever things are  just, whatsoever things are pure,
whatsoever things are lovely, whatsoever things are of good report; if
there be any virtue, and if there be any praise, think on these
things.    Philippians 4:8


[web2py] Re: Problem uploading on GAE

2010-07-09 Thread Ravi
ok
now its giving me this-
Traceback (most recent call last):
  File appcfg.py, line 68, in module
run_file(__file__, globals())
  File appcfg.py, line 64, in run_file
execfile(script_path, globals_)
  File /home/ravi/Desktop/google_appengine/google/appengine/tools/
appcfg.py, line 59, in module
from google.appengine.tools import appengine_rpc
  File /home/ravi/Desktop/google_appengine/google/appengine/tools/
appengine_rpc.py, line 32, in module
https_handler = urllib2.HTTPSHandler
AttributeError: 'module' object has no attribute 'HTTPSHandler'

plz.help

On Jul 9, 6:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Google only supports python 2.5.

 On 9 Lug, 08:10, Ravi gr8su...@gmail.com wrote:

  no python 3.1
  plz. help

  On Jul 9, 2:28 am, mdipierro mdipie...@cs.depaul.edu wrote:

   Strange appcfg.py is aGAEfile. Are you using python 2.5?

   On 8 Lug, 11:47, Ravi gr8su...@gmail.com wrote:

on running appconfig.py it is showing this error-

Traceback (most recent call last):
  File appcfg.py, line 68, in module
    run_file(__file__, globals())
  File appcfg.py, line 64, in run_file
    execfile(script_path, globals_)
NameError: global name 'execfile' is not defined

what shud i do


[web2py] Re: Possible addition to IS_IN_DB

2010-07-09 Thread mdipierro
You only use ajax if the option of field2 depend o selection for
field1 and you always end up with usability problems when field1 and 2
are in the same form (because of the ajax delay).

If the options depend on the logged in user it can be done without
ajax. How depends on details.


On 9 Lug, 09:06, Johann Spies johann.sp...@gmail.com wrote:
 I have a related query.

  On Jul 9, 12:35 am, David Marko dma...@tiscali.cz wrote:
  You can use full DAL query in IS_IN_DB validator e.g.
  IS_IN_DB(db(db.children.sex=='M'),'children.id','%(name)s' )

 I want the result of IS_IN_DB to be part of my access control measures
 and dependent on who is logged in and what is typed in another field
 in the form.

 Example:

 X is logged in and has access to say 8 of about 50 options in the database.

 In the form the first field should make only  some of the 8 options
 available in the second field.

 I suspect it can be done with AJAX but I have now experience in using
 javascript tools.

 Has anyone done that before?

 Or should I have two forms where the content of the second is
 determined by the submission of the first?

 Regards
 Johann
 --
 Finally, brethren, whatsoever things are true,  whatsoever things are
 honest, whatsoever things are  just, whatsoever things are pure,
 whatsoever things are lovely, whatsoever things are of good report; if
 there be any virtue, and if there be any praise, think on these
 things.    Philippians 4:8


[web2py] Re: Problem uploading on GAE

2010-07-09 Thread mdipierro
Are you sure you are using python 2.5?

On 9 Lug, 09:06, Ravi gr8su...@gmail.com wrote:
 ok
 now its giving me this-
 Traceback (most recent call last):
   File appcfg.py, line 68, in module
     run_file(__file__, globals())
   File appcfg.py, line 64, in run_file
     execfile(script_path, globals_)
   File /home/ravi/Desktop/google_appengine/google/appengine/tools/
 appcfg.py, line 59, in module
     from google.appengine.tools import appengine_rpc
   File /home/ravi/Desktop/google_appengine/google/appengine/tools/
 appengine_rpc.py, line 32, in module
     https_handler = urllib2.HTTPSHandler
 AttributeError: 'module' object has no attribute 'HTTPSHandler'

 plz.help

 On Jul 9, 6:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  Google only supports python 2.5.

  On 9 Lug, 08:10, Ravi gr8su...@gmail.com wrote:

   no python 3.1
   plz. help

   On Jul 9, 2:28 am, mdipierro mdipie...@cs.depaul.edu wrote:

Strange appcfg.py is aGAEfile. Are you using python 2.5?

On 8 Lug, 11:47, Ravi gr8su...@gmail.com wrote:

 on running appconfig.py it is showing this error-

 Traceback (most recent call last):
   File appcfg.py, line 68, in module
     run_file(__file__, globals())
   File appcfg.py, line 64, in run_file
     execfile(script_path, globals_)
 NameError: global name 'execfile' is not defined

 what shud i do


[web2py] label field comment

2010-07-09 Thread Jean-Guy

Hello,

I would like to change the way the grid of SQLForm or crud is presented :


|Field1 Label|Field1|Comment1|
|Field2 Label|Field2|Comment2|

I would prefer it be like this :

|Field1 Label| |
|Field1|Comment1|
|Field2 Label| |
|Field2|Comment2|

How may I change it if it is possible?

Thank you!

Jonhy


Re: [web2py] Re: Possible addition to IS_IN_DB

2010-07-09 Thread Johann Spies
 You only use ajax if the option of field2 depend o selection for
 field1 and you always end up with usability problems when field1 and 2
 are in the same form (because of the ajax delay).

 If the options depend on the logged in user it can be done without
 ajax. How depends on details.



Thanks.

Regards
Johann

-- 
Finally, brethren, whatsoever things are true,  whatsoever things are
honest, whatsoever things are  just, whatsoever things are pure,
whatsoever things are lovely, whatsoever things are of good report; if
there be any virtue, and if there be any praise, think on these
things.    Philippians 4:8


[web2py] Re: label field comment

2010-07-09 Thread mdipierro
If you do SQLFORM(formstyle='table2cols') you get:

|Field1 Label| |Comment1|
|Field1|Comment2|
|Field2 Label| |
|Field2|

else you can use SQLFORM(formstyle='divs')

and align the divs yourself.



On 9 Lug, 09:18, Jean-Guy jean...@gmail.com wrote:
 Hello,

 I would like to change the way the grid of SQLForm or crud is presented :

 |Field1 Label|Field1|Comment1|
 |Field2 Label|Field2|Comment2|

 I would prefer it be like this :

 |Field1 Label| |
 |Field1|Comment1|
 |Field2 Label| |
 |Field2|Comment2|

 How may I change it if it is possible?

 Thank you!

 Jonhy


[web2py] Re: markmin, t2, t3, cube9 etc. (important update)

2010-07-09 Thread mdipierro
I think I forgot to post this:

http://www.slideshare.net/mdipierro/cube2py-4709237

It is a summary of what is available.
To use this in your own app, export plugin_wiki from admin and re-
import it in your app.

On 9 Lug, 07:50, mdipierro mdipie...@cs.depaul.edu wrote:
 That would belong to admin not to cube2py although we could expose it
 there. In principle you only need to edit routes.py (look into
 applications/admin/controllers/default.py, def edit()) and then call
 gluon.rewrite.load(routes='routes.py').

 The problem is logical. If you use admin to edit routes and mess up
 admin may not work anymore and you lose the ability to fix it.

 Massimo

 On 9 Lug, 07:10, Albert Abril albert.ab...@gmail.com wrote:

  I thought about the idea of making a frontend (i.e. in the web admin) to
  edit routes.py and make more customizable the urls.
  But don't know how implement it.

  On Fri, Jul 9, 2010 at 12:48 PM, mdipierro mdipie...@cs.depaul.edu wrote:
   Please feel free to propose for new features. That was exactly the
   intention.

   On 9 Lug, 03:02, aure aureliengir...@googlemail.com wrote:
Great news! Thanks for the work Massimo!

Being new to both, I myself still hesitate for my project between
choosing a CMS and struggle with the programming vs. choosing web2by
and struggle with all the things which come for free in a CMS... And
Cube2py starts to bridge the gap in some ways :-)

I am sure that having these new features will bring more people to
web2py.

Aurelien

On Jul 9, 12:20 am, Jonathan Lundell jlund...@pobox.com wrote:

 On Jul 7, 2010, at 3:47 PM, mdipierro wrote:

  I do not have a strong opposition and I see the advantages in terms
   of
  notation but I have two problems:

 I'm tied up today, so just a quick note. I understand and generally
   agree with your caveats. I have a couple of thoughts on the subject that
   I'll come back with.

  The page:slug notation is handled by plugin_wiki, not by markmin.
  markmin just treats url, #anchor, url#anchor, page:slug all in the
  same way. plugin_wiki replaces the page:.. with /app/plugin_wiki/
  page/ after markmin has done its job.
  This decoupling was intentional to allow markmin to work without
  web2py and without plugin_wiki conventions.
  Your first suggestion would introduce coupling. Moreover it would
  provide a shortcut that encourage users to display the slug as text
   of
  the link. I am not convinced this is a good idea.

  Massimo

  On 7 Lug, 17:24, Jonathan Lundell jlund...@pobox.com wrote:
  On Jul 7, 2010, at 3:14 PM, mdipierro wrote:

  Right now you can do links with

  url
  [[name url]]
  [[name #anchor]]
  [[name url#anchor]]
  [[name page:slug]]

  and define an anchor with

  [[anchor]]

  If I understand your suggestions:
  1) also allow
  [[url]]
  [[url#anchor]]
  [[#anchor]]
  [[page:slug]]
  to allow un-named links. Q: how can a link not have a name?

  In your notation, I was thinking:

  [[slug]] would imply [[slug page:slug]]

  'slug' would be used verbatim as the name, and with slug-encoding 
  as
   the slug.

  A link would always have a name; it would just be implicit. That's
   the Mediawiki convention, though they use a vertical bar to separate an
   optional name from the slug.

  2) use [[=anchor]] to define an anchor to avoid conflict with 1.

  if we do 1, we must do 2 but I would prefer [[!anchor]] then.

  Sure.

  Or [name:anchor], which corresponds to the html that it generates.


Re: [web2py] new welcome (scaffolding) app

2010-07-09 Thread Thadeus Burgess
[x] new layout
[x] less on the views/layout is more, unless you just want to ship a
tutorial with web2py instead, good for newbies, not so good for those
who have done a few apps
[x] id rather a tutorial series written instead of being shipped with web2py
[ ] no plugin_wiki, let me install it if I want to, just make some
documentation on how to use it.
[ ] jquery.ui is nice, but not needed for everyone or everything.

--
Thadeus





On Fri, Jul 9, 2010 at 8:34 AM, mdipierro mdipie...@cs.depaul.edu wrote:
 let's consider a new scaffolding app.

 What should be in it?
 What should not be in it?

 possible suggestions:
 [ ] js menu
 [ ] new layout (suggestions?)
 [ ] more complex views/layout?
 [ ] simpler views/layout.html
 [ ] example plugins
 [ ] plugin_wiki from cube2py?
 [ ] jquery.ui

 Massimo



Re: [web2py] new welcome (scaffolding) app

2010-07-09 Thread Jonathan Lundell
On Jul 9, 2010, at 6:34 AM, mdipierro wrote:

 let's consider a new scaffolding app.
 
 What should be in it?
 What should not be in it?

Either the features should be modular, and easily removable, or IMO there 
should be two scaffolding apps. One would be a minimal framework, suitable for 
starting a new app from as close to a blank-page template as reasonable, and 
the other with all the bells and whistles.

 
 possible suggestions:
 [ ] js menu
 [ ] new layout (suggestions?)
 [ ] more complex views/layout?
 [ ] simpler views/layout.html
 [ ] example plugins
 [ ] plugin_wiki from cube2py?
 [ ] jquery.ui
 
 Massimo




Re: [web2py] Re: label field comment

2010-07-09 Thread Jean-Guy


formstyle=

It's not working with crud??

The solution is ok with SQLFORM.

Jonhy





On 2010-07-09 10:24, mdipierro wrote:

If you do SQLFORM(formstyle='table2cols') you get:

|Field1 Label| |Comment1|
|Field1|Comment2|
|Field2 Label| |
|Field2|

else you can use SQLFORM(formstyle='divs')

and align the divs yourself.



On 9 Lug, 09:18, Jean-Guyjean...@gmail.com  wrote:
   

Hello,

I would like to change the way the grid of SQLForm or crud is presented :

|Field1 Label|Field1|Comment1|
|Field2 Label|Field2|Comment2|

I would prefer it be like this :

|Field1 Label| |
|Field1|Comment1|
|Field2 Label| |
|Field2|Comment2|

How may I change it if it is possible?

Thank you!

Jonhy
 




[web2py] Re: Problem uploading on GAE

2010-07-09 Thread Ravi
yes sir
i am using the command python2.5

On Jul 9, 7:14 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Are you sure you are using python 2.5?

 On 9 Lug, 09:06, Ravi gr8su...@gmail.com wrote:

  ok
  now its giving me this-
  Traceback (most recent call last):
    File appcfg.py, line 68, in module
      run_file(__file__, globals())
    File appcfg.py, line 64, in run_file
      execfile(script_path, globals_)
    File /home/ravi/Desktop/google_appengine/google/appengine/tools/
  appcfg.py, line 59, in module
      from google.appengine.tools import appengine_rpc
    File /home/ravi/Desktop/google_appengine/google/appengine/tools/
  appengine_rpc.py, line 32, in module
      https_handler = urllib2.HTTPSHandler
  AttributeError: 'module' object has no attribute 'HTTPSHandler'

  plz.help

  On Jul 9, 6:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   Google only supports python 2.5.

   On 9 Lug, 08:10, Ravi gr8su...@gmail.com wrote:

no python 3.1
plz. help

On Jul 9, 2:28 am, mdipierro mdipie...@cs.depaul.edu wrote:

 Strange appcfg.py is aGAEfile. Are you using python 2.5?

 On 8 Lug, 11:47, Ravi gr8su...@gmail.com wrote:

  on running appconfig.py it is showing this error-

  Traceback (most recent call last):
    File appcfg.py, line 68, in module
      run_file(__file__, globals())
    File appcfg.py, line 64, in run_file
      execfile(script_path, globals_)
  NameError: global name 'execfile' is not defined

  what shud i do


Re: [web2py] Re: Beginner Question

2010-07-09 Thread Jonathan Lundell
On Jul 8, 2010, at 12:10 AM, mdipierro wrote:

 That is true...
 
 IS_IN_DB(db,'table.id', '%(name)s')
 
 when it build the list of options for
 
 SELECTOPTION value={{=row.id}}{{=name}}OPTION.../SELECT
 
 name is  '%(name)s' % row
 
 since row belongs to a class that extends dict.

IS_IN_DB() has a lot of undocumented options. Perhaps you could add something 
to the source comment, as a start.


 
 
 
 
 On 8 Lug, 01:26, Jonathan Lundell jlund...@pobox.com wrote:
 On Jul 7, 2010, at 7:29 PM, Bruno Rocha wrote:
 
 Open a Python terminal, and try this example
 
 d = {'id':1,'title':'web2py'}
 d
 {'id': 1, 'title': 'web2py'}
 Title for id %(id)s is %(title)s  % d
 'Title for id 1 is web2py '
 
 Unfortunately, none of this explains how the label argument is used in 
 IS_IN_DB(), nor is it explained in the manual. And I find the code pretty 
 opaque.
 
 How does the above relate to IS_IN_DB?
 
 2010/7/7 Bruno Rocha rochacbr...@gmail.com:
 Take a look to the String Formating and String Interpolation in Python
 Documentation
 
 http://docs.python.org/library/stdtypes.html#string-formatting-operat...
 
 2010/7/7 ra3don ra3do...@gmail.com:
 I apologize for a seemingly simple question, but what exactly does '%
 (title)s' do? I ran across it in the book in the wiki section, the
 whole line reads.
 
 db.document.page_id.requires = IS_IN_DB(db, 'page.id', '%(title)s')
 
 Thanks in advance,
 
 ra3don.




[web2py] Fastcgi vs uwsgi

2010-07-09 Thread Jose
I have a server running FreeBSD + Cherokee + web2py.

Cherokee was configured to serve web2py applications through Fastcgi.

For some time, Cherokee supports uwsgi. I changed the configuration to
use web2py with uwsgi. Without any formal test, I see that runs
faster.

Is my assessment correct?
Should I run faster?

Jose


[web2py] Re: label field comment

2010-07-09 Thread mdipierro
crud.settings.formstyle='table2cols' (requires trunk but will be in
stable next week).

On 9 Lug, 10:00, Jean-Guy jean...@gmail.com wrote:
 formstyle=

 It's not working with crud??

 The solution is ok with SQLFORM.

 Jonhy

 On 2010-07-09 10:24, mdipierro wrote:

  If you do SQLFORM(formstyle='table2cols') you get:

  |Field1 Label| |Comment1|
  |Field1|Comment2|
  |Field2 Label| |
  |Field2|

  else you can use SQLFORM(formstyle='divs')

  and align the divs yourself.

  On 9 Lug, 09:18, Jean-Guyjean...@gmail.com  wrote:

  Hello,

  I would like to change the way the grid of SQLForm or crud is presented :

  |Field1 Label|Field1|Comment1|
  |Field2 Label|Field2|Comment2|

  I would prefer it be like this :

  |Field1 Label| |
  |Field1|Comment1|
  |Field2 Label| |
  |Field2|Comment2|

  How may I change it if it is possible?

  Thank you!

  Jonhy


[web2py] Re: Fastcgi vs uwsgi

2010-07-09 Thread mdipierro
Thadeus has had some problem on high traffic with web2py+cherokee
+uwsgi.

could you run ab on it and let us know if you experience or not
dropped requests?

Massimo

On 9 Lug, 11:40, Jose jjac...@gmail.com wrote:
 I have a server running FreeBSD + Cherokee + web2py.

 Cherokee was configured to serve web2py applications through Fastcgi.

 For some time, Cherokee supports uwsgi. I changed the configuration to
 use web2py with uwsgi. Without any formal test, I see that runs
 faster.

 Is my assessment correct?
 Should I run faster?

 Jose


[web2py] multiselect plugin and filtering options

2010-07-09 Thread mgrabau
Good Day,

I'm trying to use a multi select plugin (this code is in the
controller):


view_contents.append(plugin_multiselect(db.vulnerabilities.assets))

Is the line of code to connect (and it does, the plugin works as it is
supposed to), but I was wondering if it is possible to make a WHERE
clause for only certain options to be included.

Looking at the method being called plugin_multiselect, I don't think
that it provides any facility for doing this. Am I mistaken in this
view? Or is it possible to filter the row selection? Thanks!

Mathew Grabau


[web2py] Re: multiselect plugin and filtering options

2010-07-09 Thread mdipierro
This is what I do to use the multiselect plugin...
I put this in my layout.html

  scriptjQuery(document).ready(function()
{jQuery('[multiple]').multiSelect();});/script

so it works for all select multiple/. You can can the set the
options using the validators

  IS_IN_SET(,multiple=True) o IS_IN_DB(db(subset),db.table.id,'%
(...)s',multiple=True).

If you have plugin_wiki from cube2py this is default behavior.

Massimo

On 9 Lug, 10:14, mgrabau g.rab...@gmail.com wrote:
 Good Day,

 I'm trying to use a multi select plugin (this code is in the
 controller):

 view_contents.append(plugin_multiselect(db.vulnerabilities.assets))

 Is the line of code to connect (and it does, the plugin works as it is
 supposed to), but I was wondering if it is possible to make a WHERE
 clause for only certain options to be included.

 Looking at the method being called plugin_multiselect, I don't think
 that it provides any facility for doing this. Am I mistaken in this
 view? Or is it possible to filter the row selection? Thanks!

 Mathew Grabau


[web2py] Re: Fastcgi vs uwsgi

2010-07-09 Thread Jose
I comment if I have a problem. The first impression after the change,
was running faster.

Jose


[web2py] web2py Reference Manual -- a call to arms

2010-07-09 Thread weheh
This is an old request, but I haven't heard anything about it of late
and wanted to keep it alive.

I propose a web2py reference manual where every web2py-native
statement, helper, DAL, auth, settable attribute, ... whatever is in
indexed and every page has sections: description, usage, arguments
list with explanation of each argument, and reference/link to a parent
statement, helper, DAL, etc.

At least, I think a reference should be as good as python's
documentation and possibly better. I imagine this could easily be a
community thing, built by wiki (prefereably a web2py wiki). If we
could all agree to the headings, then we could all choose a couple/few
web2py statements to work on to document. I bet we could have a kick-
ass reference manual built in a matter of weeks without consuming all
of Massimo's time, and preferably as little as possible.

What do you think? Anybody have ideas about how we could do it?


[web2py] Re: Fastcgi vs uwsgi

2010-07-09 Thread mdipierro
Please comment even if you DO NOT have a problem because we need to
get to bottom of why a few people are having problems and what is
causing that. Knowing that some people do not have the problem is
important. we can compare the OS, the python version, the uwsgi
version. etc.

On 9 Lug, 14:13, Jose jjac...@gmail.com wrote:
 I comment if I have a problem. The first impression after the change,
 was running faster.

 Jose


Re: [web2py] Re: label field comment

2010-07-09 Thread Jean-Guy

Great!

Jonhy

On 2010-07-09 14:39, mdipierro wrote:

crud.settings.formstyle='table2cols' (requires trunk but will be in
stable next week).

On 9 Lug, 10:00, Jean-Guyjean...@gmail.com  wrote:
   

formstyle=

It's not working with crud??

The solution is ok with SQLFORM.

Jonhy

On 2010-07-09 10:24, mdipierro wrote:

 

If you do SQLFORM(formstyle='table2cols') you get:
   
 

|Field1 Label| |Comment1|
|Field1|Comment2|
|Field2 Label| |
|Field2|
   
 

else you can use SQLFORM(formstyle='divs')
   
 

and align the divs yourself.
   
 

On 9 Lug, 09:18, Jean-Guyjean...@gmail.comwrote:
   
 

Hello,
 
 

I would like to change the way the grid of SQLForm or crud is presented :
 
 

|Field1 Label|Field1|Comment1|
|Field2 Label|Field2|Comment2|
 
 

I would prefer it be like this :
 
 

|Field1 Label| |
|Field1|Comment1|
|Field2 Label| |
|Field2|Comment2|
 
 

How may I change it if it is possible?
 
 

Thank you!
 
 

Jonhy
 




Re: [web2py] new welcome (scaffolding) app

2010-07-09 Thread Jason Brower
On Fri, 2010-07-09 at 06:34 -0700, mdipierro wrote: 
 let's consider a new scaffolding app.
 
 What should be in it?
Minimal and welcome.  It's nice to have something I can jsut start with
rather than strip down. 
 What should not be in it?

 
 possible suggestions:
 [ ] js menu
 [X] new layout (suggestions?)
Something more like Jquery.com and that has some nice examples of
working with images both from a database and from a a static area. 
 [X] more complex views/layout?
An example of dynamic css? 
 [X] simpler views/layout.html
 [X] example plugins
Instructions on how they are done too. 
 [ ] plugin_wiki from cube2py?
 [ ] jquery.ui
Meh... I can do it myself.  But if your going to use it, you better go
all out.  I wanna see it really shine in the admin tools and other what
not. 
 
 Massimo
Jason (:




[web2py] Re: web2py Reference Manual -- a call to arms

2010-07-09 Thread ra3don
I like this idea alot, it would be a valuable resource for a beginner
(like me). I think its important that it be wiki-style so that we can
all come in and add our example useages to the statements, helpers,
etc. (like weheh mentioned) so we get a feel for how to use it if
we're stuck.

On Jul 9, 2:15 pm, weheh richard_gor...@verizon.net wrote:
 This is an old request, but I haven't heard anything about it of late
 and wanted to keep it alive.

 I propose a web2py reference manual where every web2py-native
 statement, helper, DAL, auth, settable attribute, ... whatever is in
 indexed and every page has sections: description, usage, arguments
 list with explanation of each argument, and reference/link to a parent
 statement, helper, DAL, etc.

 At least, I think a reference should be as good as python's
 documentation and possibly better. I imagine this could easily be a
 community thing, built by wiki (prefereably a web2py wiki). If we
 could all agree to the headings, then we could all choose a couple/few
 web2py statements to work on to document. I bet we could have a kick-
 ass reference manual built in a matter of weeks without consuming all
 of Massimo's time, and preferably as little as possible.

 What do you think? Anybody have ideas about how we could do it?


Re: [web2py] Re: web2py Reference Manual -- a call to arms

2010-07-09 Thread Vasile Ermicioi
I like php manual style, where at the bottom are user contributions


[web2py] Re: new web2py site in Poland!

2010-07-09 Thread Mengu
make it english, make it damn global. it'd just work for every country
and city.

On 7 Temmuz, 23:46, Kuba Kucharski kuba.kuchar...@gmail.com wrote:
 Hi, people,

 I would like to present you WRSZW project

 http://wrszw.pl
 it is about events in Warsaw, capital of Poland, fully non-commercial
 initiative of places in my city.
 polish only but english is coming,
 web2py rocks. it was a pleasure to make it happen :)

 --
 Kuba


[web2py] Re: multiple checkboxes

2010-07-09 Thread Rob
Hi mdipierro,

Thanks for the answer!  I have some questions.

1) using the SQLFORM syntax with list comprehension below, how do I
add additional fields?  I need to add 'hidden' fields that match the
name of the 'checkbox' fields - otherwise, non-checked items don't get
put in request.vars and I don't want to assume they are false (ie:
Pagination)

2) Since we're building the form with values from the DB in the
beginning of the function, then updating the DB, then returning the
form, the view gets a stale copy of the form.  I guess you could solve
this with a redirect if form.accepts() is true?  Seems hackish...

Thanks for the help :)

On Jul 9, 5:44 am, mdipierro mdipie...@cs.depaul.edu wrote:
 This should work:

 def index():
     items = db().select(db.Item.ALL)
     form=SQLFORM.factory(*[Field('need_%s'%item.id, default=item.need)
 for item in items])
     if form.accepts(request.vars,session):
        for item in items:
           need = not request.vars['need_%s'%item.id]==None
           item.update_record(need=need)
    return dict(form=form)

 On 9 Lug, 01:04, Rob r...@rmdashr.com wrote:



  Hi All,

  Sorry for the noob post, but I'm having an issue.  I'm trying to do a
  little toy 'shopping list' app - the index page is to have a list of
  'items' on the page with a 'need' checkbox and an 'update' button.
  When the update button is pressed, the database is to be updated with
  the new checked values.

  here is the db:

  db.define_table('Item',
      Field('description'),
      Field('need', 'boolean')

  here is the controller:
  def index():
      table = TABLE()
      items = db().select(db.Item.ALL)
      for item in items:
          chk = INPUT(_type='checkbox', _name='need_%s' % item.id,
  value=item.need)
          table.append(TR(item.id,item.description,chk))
      form = FORM(table,INPUT(_type='submit'))
      if form.accepts(request.vars,session):
          for k,v in request.vars.items():
              if k.startswith('need_'):
                  id = k.split('_')[-1]
                  item = db(db.Item.id == int(id)).select()[0]
                  item.update_record(need=(form.vars[k]=='on'))
      return dict(form=form)

  view: default/index.html
  {{extend 'layout.html'}}
  {{=form}}

  This doesn't quite work right - it's close and it feels like a
  kludge.  I need to set the checkbox value to the proper 'request'
  variable, but I don't process those until the end of the function...
  am I on the right track here?  I found most of this code on a forum
  somewhere.

  Thanks for the help... it sucks just starting out!

  -Rob


[web2py] Re: fedora experts?

2010-07-09 Thread Scott
Line 28: change 'you' to 'yum'

28c28
 you install python2.5
---
 yum install python2.5

Other than that, I can test the script on a RedHat system tomorrow...
Cheers!

On Jul 9, 9:26 am, mdipierro mdipie...@cs.depaul.edu wrote:
 I managed to wrote this script

 http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-fe...

 It worked for me but I am no fedora expert. Any advice for
 imrpovements?


Re: [web2py] new welcome (scaffolding) app

2010-07-09 Thread Bruno Rocha
Is there any chance to have that options for choose just at the moment
of app creation?

we put the name for the application, then check what do we want to have within.

May be choosing a completely blank new app or a complete one, choosing
the theme, to have or not things like Plugins, Wiki, Jquery UI etc..

and the new app based on scaffold app is created dinamically.

By the way my choice is:

2010/7/9 mdipierro mdipie...@cs.depaul.edu:
 let's consider a new scaffolding app.

 What should be in it?
 What should not be in it?

 possible suggestions:
 [ ] js menu
I prefer a simple CSS menu
 [x] new layout (suggestions?)
I think default scaffold app needs to be clean, minimalist, a blank theme.
Good design is as little design as possible.
 http://52weeksofux.com/tagged/week_8 
 [x] more complex views/layout?
RSS, Json, XML examples too
 [ ] simpler views/layout.html
 [x ] example plugins
GRID plugin, it is usefull for most projects
 [ ] plugin_wiki from cube2py?
 [ ] jquery.ui
 [x] facebook, twitter, Gmail, openID authentication
 [x] webservices example
 [x] Sending mail examples
 Massimo



-- 

http://rochacbruno.com.br


[web2py] Re: web2py 1.93?

2010-07-09 Thread Scott
Massimo,

Is it in the repository hosted on Google Code?  I just checked it out
and it's showing as version 1.79.2 (2010-06-08 16:40:21) in the Admin.

Thanks!

On Jul 9, 9:36 am, Massimo Di Pierro mdipie...@cs.depaul.edu wrote:
 I am planning to release the nightly build as stable 1.93 on Monday.  
 Please check it out if you have not done so.


[web2py] Re: markmin, t2, t3, cube9 etc. (important update)

2010-07-09 Thread Scott
I think this should replace the Welcome application and the
documentation should be integrated into the web2py book.  I'm
impressed with the complete rewrite!  I like the way that you get
web2py-admin-esque functionality without having to use the admin
directly, and it all works through Google App Engine.  It certainly
makes page creation easier.

Out of curiosity, would you need to use a custom routes.py to remove
(rewrite) plugin_wiki from the URL?  I'd probably want to hide that
from casual users.

A few suggestions and questions:
- Consider an internally-hosted chart generator (e.g. jqPlot) in lieu
of Google Charts API; this will allow the charts to generate behind
corporate firewalls
- Can the tag cloud be made hyper-linkable?  That is to say, clicking
on a word in the tag cloud might show a list of relevant tagged pages.
- What is the future direction of cube2py?  It seems that most of the
functionality coded in the View can be replaced with cube2py and
markmin.  It also replaces some of the code normally located in the
Controller such as CRUD and jqGrid functionality.  If this is the
case, is it the intent to replace the admin with cube2py?

Thanks!


[web2py] Customizing Auth to use Username Instead of Email?

2010-07-09 Thread Phyo Arkar
Hello Web2py

I am having trouble with Auth form. As described in Web2py book , i added
this :


in Model db.py:

from gluon.tools import Auth

auth = Auth(globals(),db)  #
authentication/authorization

auth.settings.hmac_key = 'mwpk120409'   # before define_tables()


auth_table = db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default=),
Field('last_name', length=128, default=),
Field('username', length=128, default=,unique=True),
Field('email', length=128, default=, unique=True),
Field('password', 'password', length=128,
  readable=False, label='Password'),
Field('registration_key', length=128, default= ,
  writable=False, readable=False))

auth_table.first_name.requires = \
  IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.last_name.requires = \
  IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.password.requires = [IS_STRONG(), CRYPT()]
auth_table.email.requires = [
  IS_EMAIL(error_message=auth.messages.invalid_email),
  IS_NOT_IN_DB(db, auth_table.email)]
auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)
auth.settings.table_user = auth_table


auth.settings.actions_disabled.append('register')
#auth.settings.actions_disabled.append('change_password')
auth.settings.actions_disabled.append('verify_email')
auth.settings.actions_disabled.append('retrieve_username')
auth.settings.actions_disabled.append('retrieve_password')
auth.settings.actions_disabled.append('impersonate')
auth.settings.actions_disabled.append('groups')


In Controller :

def user():

form = auth()
if form.accepts( request.vars, formname = 'login'):


exposes:
http:///[app]/default/user/login
http:///[app]/default/user/logout
http:///[app]/default/user/register
http:///[app]/default/user/profile
http:///[app]/default/user/retrieve_password
http:///[app]/default/user/change_password
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control

return
return dict( loginform = form )


In View-  layout.html (i did a custom form to fit it in status bar):

  div class=ez-box statusbar-v2
form action= enctype=multipart/form-data method=post
  Username: input id=auth_user_username name=username
type=text value= /
  Password: input id=auth_user_password name=password
type=password value= /
input type=submit value=Login /
div class=hidden
   input name=_next type=hidden
value=/sExtract/default/index /
   input name=_formkey type=hidden
value=4ae3a7ab-73ab-4d2e-8032-ad525bf88e65 /
   input name=_formname type=hidden value=login /
/div
/form
  /div


Then when i tried to Login

Traceback (most recent call last):

  File /home/v3ss/workspace-bbb/web2py-clone/gluon/restricted.py,
line 178, in restricted

exec ccode in environment
  File 
/home/v3ss/workspace-bbb/web2py-clone/applications/sExtract/controllers/default.py
http://localhost:8080/admin/default/edit/sExtract/controllers/default.py,
line 286, in module

  File /home/v3ss/workspace-bbb/web2py-clone/gluon/globals.py, line
96, in lambda

self._caller = lambda f: f()

  File 
/home/v3ss/workspace-bbb/web2py-clone/applications/sExtract/controllers/default.py
http://localhost:8080/admin/default/edit/sExtract/controllers/default.py,
line 185, in user

form = auth()
  File /home/v3ss/workspace-bbb/web2py-clone/gluon/tools.py, line
962, in __call__

return self.login()
  File /home/v3ss/workspace-bbb/web2py-clone/gluon/tools.py, line
1394, in login

self.log_event(log % self.user)

  File /home/v3ss/workspace-bbb/web2py-clone/gluon/tools.py, line
1154, in log_event

self.settings.table_event.insert(description=description,
AttributeError: 'NoneType' object has no attribute 'insert'