[web2py] Re: The web2py grid/crud plugin you've always dreamed about!

2011-07-23 Thread Massimo Di Pierro
+1

should this be included in web2py/contrib?

On Jul 22, 5:35 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Hi,

 I present you PowerGrid Plugin (now in beta 0.1) 
 [http://labs.blouweb.com/PowerGrid/]

 What is it?

 A plugin to show, manage and paginate data
 It works with paginated JSON callbacks, you can use web2py DAL's Query or
 Table, or you can create your own callback returning the desired JSON or
 JSONP

 What is has in special?
 - Based on Jquery templates
 - Server side pagination loads records on demand
 - Ajax Caching option
 - Programable in pure Python  web2py
 - You can pass JS callbacks to the event handlers
 - Can show images with Virtual Fields
 - has button system
 - totally integrated with CRUD
 - Easy to integrate with Auth
 - Can be used to manage a site content (a CMS admin page)
 - can be used to create any kind of paginated data view

 Changelog:
 - Some issues solved
 - Tested in Windows, Linux, I.E, Opera, Chrome, FF
 - Better default layout

 Beta:
 - Needs tests with different datasources
 - Need to be tested on GAE
 - Need to test multiple on the same page
 - Need to test wotking with another UI libs

 EXAMPLES:
 images -http://labs.blouweb.com/PowerGrid/default/withimages
 dataGRid -http://labs.blouweb.com/PowerGrid/default/onlydata
 Buttons -http://labs.blouweb.com/PowerGrid/default/buttons
 Scrolling -http://labs.blouweb.com/PowerGrid/default/scroll
 Customization:http://labs.blouweb.com/PowerGrid/default/nocontrol/http://labs.blouweb.com/PowerGrid/default/noadd/http://labs.blouweb.com/PowerGrid/default/nosearch
 Default search 
 system:http://labs.blouweb.com/PowerGrid/default/defaultsearch?what=Ferrari;...
 SubGrids:http://labs.blouweb.com/PowerGrid/default/gridinpopup
 JavaScript callbacks:http://labs.blouweb.com/PowerGrid/default/jscallbacks
 Custom templates:http://labs.blouweb.com/PowerGrid/default/blog(a blog
 created with it)

 DOCUMENTATION:
 Is being writen in home pagehttp://labs.blouweb.com/PowerGrid/default/index(in
 the grid)
 source example app is well commented with options.

 IT USES:http://labs.blouweb.com/PowerGrid/default/about

 Comments:http://labs.blouweb.com/PowerGrid/default/support

 Get it:http://labs.blouweb.com/PowerGrid/default/get

 !!! BETA VERSION, SOME THINGS CAN CRASH, THE SERVER IS A BIT SLOW, IT WILL
 BE VERY MORE QUICKLY IN A GOOD SERVER OR GAE !!!

 Thanks if you can test and report on BitBucker or omments page.

 Bruno Rocha
 [ About me:http://zerp.ly/rochacbruno]
 [ Aprenda a programar:http://CursoDePython.com.br]
 [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
 [ Consultoria em desenvolvimento web:http://www.blouweb.com]


[web2py] Re: how to iterate efficiently (memory-wise) through a huge DAL query

2011-07-23 Thread Massimo Di Pierro
You never want to do this:
n = q.count()
s = db(q)
for i in range(1,n):
   r = s.select( limitby=(i,1)).first()
   # do something with r

instead you consider something like this:

i, m = 0, 1000
while True:
   rows = db(q).select(limitby=(i*m,(i+1)*m))
   for r in rows:
  # do something with r
   if len(rows)m: break
   i+=1


On Jul 22, 10:00 pm, Luis Goncalves lgoncal...@gmail.com wrote:
 I am trying to use web2py's DAL for a project that is not a webapp.

 I have a database with about 8M entries, and I want to process the data.

 Suppose I create a query that returns a lot of results:
 extreme case example:

 q = db.table.id0

 How do I iterate through all the results of  a  large query, q, 
 *without*having to retrieve all the data to memory?

 Is there something better than:

 # q = a db query that returns a huge number of results
 n = q.count()
 s = db(q)

 for i in range(1,n):
 r = s.select( limitby=(i,1)).first()
 # do something with r
 ...

 I've tried this out (interactively, to see what is happening),
 and when I get to i=2,

 s.select( limitby=(2,1)).first()

 the computer starts to swap and hangs for minutes.

 So my question, again, is:

 Is there an efficient way to iterate through a large query (or set =
 db(query) )
 that avoids overloading the system memory?

 Thanks,
 Luis.


[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Luis Goncalves
Yes ... too many  :(

Here's a 'simple' one:

The database table definition, which I use as a form for input:

 

  db.define_table('scorecard',
  Field('offense1', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),
  Field('defense1', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),

 

  Field('offense2', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),
  Field('defense2', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),

 

  Field('fifth', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),

 

  Field('score1', 'integer', requires=IS_IN_SET([1, 2, 3, 4, 
5],zero=None)),
  Field('score2', 'integer', requires=IS_IN_SET([1, 2, 3, 4, 
5],zero=None)),

 

  Field('start', 'datetime', readable=False, writable=False),
  Field('finish', 'datetime', readable=False, writable=False),
  Field('single', 'boolean', readable=False, writable=False)) # single 
game during round-robin rotate play, or part of a game-set-match

 I would like this to display something like: 


https://lh3.googleusercontent.com/-043w1FYNTj8/Tipod6h9_zI/HFk/0eX4V6S0Uf0/scorecard.png

The input is a scorecard for a game.  Two teams with two players each,  and 
a fifth person that will  play the next game.

The user defines who is playing the current game, and who is sitting out. 
 When the game is over, they select the scores.

On 'submit', the teams and scores are recorded, and the form is shown again, 
with a suggested line-up for the next game

(but the user can alter the line-up if he wants). 

 

 


In the controller:


def rotate_5_man(): 


form = SQLFORM( db.scorecard )

# retrieve previous player positions.

# pre-fill form with some suggestions 

 

 

if form.accepts( .. )


# record score,  

# figure out how to rotate players for next game


return dict(form=form)


In the view,  rotate_5_man.html :


{{extend 'layout.html'}}

{{=form}}



So right now, the display of the form is quite rudimentary 
(each item gets shown in order, listed vertically).

Is there a simple way to get the above layout instead? 

Preferably done with minimal additional python/web2py/html, 
but via CSS instead!

 

Thanks!!!
Luis. 

 

 


 

 

 

 

 

 

 

 

 



[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Anthony
What's wrong with this method - 
http://web2py.com/book/default/chapter/07#Custom-forms - you can put the 
form widgets wherever you want? Or specifically, how would 
better/smarter/proper use of the #id table-field entries help? What would 
you like to see in the rendered form HTML that would enable you to do what 
you want with just CSS?
 
Anthony

On Saturday, July 23, 2011 2:33:54 AM UTC-4, Luis Goncalves wrote:

 Yes ... too many  :( 

 Here's a 'simple' one:

  The database table definition, which I use as a form for input:

  

db.define_table('scorecard',
   Field('offense1', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),
   Field('defense1', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),

  

Field('offense2', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),
   Field('defense2', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),

  

Field('fifth', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),

  

Field('score1', 'integer', requires=IS_IN_SET([1, 2, 3, 4, 
 5],zero=None)),
   Field('score2', 'integer', requires=IS_IN_SET([1, 2, 3, 4, 
 5],zero=None)),

  

Field('start', 'datetime', readable=False, writable=False),
   Field('finish', 'datetime', readable=False, writable=False),
   Field('single', 'boolean', readable=False, writable=False)) # single 
 game during round-robin rotate play, or part of a game-set-match

   I would like this to display something like: 


  
 https://lh3.googleusercontent.com/-043w1FYNTj8/Tipod6h9_zI/HFk/0eX4V6S0Uf0/scorecard.png

 The input is a scorecard for a game.  Two teams with two players each,  and 
 a fifth person that will  play the next game.

  The user defines who is playing the current game, and who is sitting out. 
  When the game is over, they select the scores.

  On 'submit', the teams and scores are recorded, and the form is shown 
 again, with a suggested line-up for the next game

  (but the user can alter the line-up if he wants). 

   

   


  In the controller:


  def rotate_5_man(): 


  form = SQLFORM( db.scorecard )

  # retrieve previous player positions.

  # pre-fill form with some suggestions 

   

   

  if form.accepts( .. )


   # record score,  

   # figure out how to rotate players for next game


  return dict(form=form)


  In the view,  rotate_5_man.html :


  {{extend 'layout.html'}}

  {{=form}}



 So right now, the display of the form is quite rudimentary 
 (each item gets shown in order, listed vertically).

 Is there a simple way to get the above layout instead? 

 Preferably done with minimal additional python/web2py/html, 
 but via CSS instead!

  

 Thanks!!!
 Luis. 

  

   


  

  

   



   

   

   

   

   



[web2py] Re: how to iterate efficiently (memory-wise) through a huge DAL query

2011-07-23 Thread Luis Goncalves
Thanks, Massimo!

Even if I grab 1000 at a time (which is definitely better to do!!), 
I still have to wait for minutes before I get rows back!

However, I have found that this is 'fast' :

n = db.table.count() # not sure if that's the syntax, but somehow find out 
how many records in table


for i in range(1,n):

row = db.table(i)

# do something with r


This works fine if I want to iterate through every single entry in the 
database (and I assume there are no breaks in the record.id values). 

I don't know how to do something equivalent when the query/set represents an 
arbitrary (large) number of table records.

I even tried just extracting the record.id values, 

id_index = db(q).select( db.table.id, limitby=(1000,1) )


to then access them through db.table(i),  

row = db.table( id_index[i].id )


but just getting the id_index list of record.id's was slow!

I'm using sqlite3, on linux, with 4GB of RAM, and the DB is about 700MB in 
size (830MB with some index tables built).

Thanks!!!
Luis.

 

 

 



[web2py] Re: how to iterate efficiently (memory-wise) through a huge DAL query

2011-07-23 Thread Luis Goncalves

Thanks, Vineet!  Lot's of good info there!

I don't have actual code yet, because I couldn't even get the db queries to 
work in a reasonable amount of time.

The little code I showed in my initial post already runs slow  ( my DB 
records are db.itemEntry, not db.table ...).

The slowness (so far) is due to doing a query/select on a very large DB.
I need to figure out how to query/select more efficiently.

I wonder if the problem is with sqlite3 itself, since it stores the entire 
DB in a single file.

I have constructed index tables for the fields I am searching on, but it is 
still incredibly slow.
(see post below in reply to Massimo too!).

Thanks!
Luis.


Re: [web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Luis Goncalves
I am just a beginner with CSS/HTML,  and so maybe I have a misconceived idea
of what CSS can/should do and the right way to use it.

Naively, I thought that I could use the #id=table-field entries in CSS to
control placement/shape of the form elements, and not need to change much
more in the controller or the view?

It seems that if I have to use custom forms, then I might as well not even
bother with using SQLFORM --  it's pretty much like building the form piece
by piece in the view?

thanks,
Luis.

On Fri, Jul 22, 2011 at 11:42 PM, Anthony abasta...@gmail.com wrote:

 What's wrong with this method -
 http://web2py.com/book/default/chapter/07#Custom-forms - you can put the
 form widgets wherever you want? Or specifically, how would
 better/smarter/proper use of the #id table-field entries help? What would
 you like to see in the rendered form HTML that would enable you to do what
 you want with just CSS?

 Anthony

 On Saturday, July 23, 2011 2:33:54 AM UTC-4, Luis Goncalves wrote:

 Yes ... too many  :(

 Here's a 'simple' one:

  The database table definition, which I use as a form for input:



db.define_table('scorecard',
   Field('offense1', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),
   Field('defense1', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('offense2', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),
   Field('defense2', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('fifth', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('score1', 'integer', requires=IS_IN_SET([1, 2, 3, 4,
 5],zero=None)),
   Field('score2', 'integer', requires=IS_IN_SET([1, 2, 3, 4,
 5],zero=None)),



Field('start', 'datetime', readable=False, writable=False),
   Field('finish', 'datetime', readable=False, writable=False),
   Field('single', 'boolean', readable=False, writable=False)) # single
 game during round-robin rotate play, or part of a game-set-match

   I would like this to display something like:



 https://lh3.googleusercontent.com/-043w1FYNTj8/Tipod6h9_zI/HFk/0eX4V6S0Uf0/scorecard.png

 The input is a scorecard for a game.  Two teams with two players each,
  and a fifth person that will  play the next game.

  The user defines who is playing the current game, and who is sitting
 out.  When the game is over, they select the scores.

  On 'submit', the teams and scores are recorded, and the form is shown
 again, with a suggested line-up for the next game

  (but the user can alter the line-up if he wants).






  In the controller:


  def rotate_5_man():


  form = SQLFORM( db.scorecard )

  # retrieve previous player positions.

  # pre-fill form with some suggestions





  if form.accepts( .. )


   # record score,

   # figure out how to rotate players for next game


  return dict(form=form)


  In the view,  rotate_5_man.html :


  {{extend 'layout.html'}}

  {{=form}}



 So right now, the display of the form is quite rudimentary
 (each item gets shown in order, listed vertically).

 Is there a simple way to get the above layout instead?

 Preferably done with minimal additional python/web2py/html,
 but via CSS instead!



 Thanks!!!
 Luis.



























[web2py] How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread Saurabh Sawant
I am having a hard time migrating data from sqlite to postgres

This is the command that I use

./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
sqlite://applications/testapp/databases/storage.sqlite -y 'sqlite://
applications/testapp/databases/storage.sqlite'  -Y 'postgres://
puser:ppass@localhost/testdb'

It says

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.97.1 (2011-06-26 19:25:44)
Database drivers available: SQLite3, pymysql, PostgreSQL
EXCEPTION: could not make a copy of the database
Failure to connect, tried 5 times:
unable to open database file

Any idea how to make this work?


Re: [web2py] How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread Kenneth Lundström
It sounds like web2py is not able to open either the sqlite file or 
postgres database. Have you tried to use both connection strings in a 
model file to test that both works?



Kenneth


I am having a hard time migrating data from sqlite to postgres

This is the command that I use

./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
sqlite://applications/testapp/databases/storage.sqlite -y 'sqlite://
applications/testapp/databases/storage.sqlite'  -Y 'postgres://
puser:ppass@localhost/testdb'

It says

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.97.1 (2011-06-26 19:25:44)
Database drivers available: SQLite3, pymysql, PostgreSQL
EXCEPTION: could not make a copy of the database
Failure to connect, tried 5 times:
unable to open database file

Any idea how to make this work?




[web2py] Re: How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread Saurabh Sawant
Hi Kenneth,

Yes both the connection strings work in db.py which I too find
very puzzling.

On Jul 23, 12:24 pm, Kenneth Lundström kenneth.t.lundst...@gmail.com
wrote:
 It sounds like web2py is not able to open either the sqlite file or
 postgres database. Have you tried to use both connection strings in a
 model file to test that both works?

 Kenneth







  I am having a hard time migrating data from sqlite to postgres

  This is the command that I use

  ./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
  sqlite://applications/testapp/databases/storage.sqlite -y 'sqlite://
  applications/testapp/databases/storage.sqlite'  -Y 'postgres://
  puser:ppass@localhost/testdb'

  It says

  web2py Web Framework
  Created by Massimo Di Pierro, Copyright 2007-2011
  Version 1.97.1 (2011-06-26 19:25:44)
  Database drivers available: SQLite3, pymysql, PostgreSQL
  EXCEPTION: could not make a copy of the database
  Failure to connect, tried 5 times:
  unable to open database file

  Any idea how to make this work?


[web2py] SSL Email Support patch

2011-07-23 Thread Eric Vicenti
Hey, all

I was having difficulties sending from web2py, when I realized there
is no SSL encryption support. Since this is already built into
smtplib, it was a simple addition. I should mention this wont work on
GAE, and I have not comprehensively tested it.

diff -r 800e086037d9 gluon/tools.py
--- a/gluon/tools.pySat Jul 23 01:47:05 2011 -0500
+++ b/gluon/tools.pySat Jul 23 00:17:49 2011 -0700
@@ -206,6 +206,7 @@
 settings.sender = sender
 settings.login = login
 settings.tls = tls
+settings.ssl = False
 settings.cipher_type = None
 settings.sign = True
 settings.sign_passphrase = None
@@ -569,8 +570,11 @@
 result =
mail.send_mail(sender=self.settings.sender, to=origTo,
 subject=subject,
body=text, **xcc)
 else:
-server =
smtplib.SMTP(*self.settings.server.split(':'))
-if self.settings.tls:
+if self.settings.ssl:
+server =
smtplib.SMTP_SSL(*self.settings.server.split(':'))
+else:
+server =
smtplib.SMTP(*self.settings.server.split(':'))
+if self.settings.tls and not self.settings.ssl:
 server.ehlo()
 server.starttls()
 server.ehlo()

To use, simply set mail.settings.ssl = True

Enjoy!


[web2py] Re: Simultaneous multi-language system.

2011-07-23 Thread Massimo Di Pierro
There is a solution in trunk. Please check it:
http://code.google.com/p/web2py/issues/detail?id=342


print T(hello) #defualt
print T(hello, language=it-it) #etc etc


On Jul 22, 4:52 am, jamarcer jamar...@gmail.com wrote:
 Hello:

 I have added a comment to the ticket:

 http://code.google.com/p/web2py/issues/detail?id=342

 It is an approach to the issue, based in Anthony's proposal: a class
 that stores multiple T objects.

 I am demetrio's companion. We develop the same application, but we
 have different roles :), so I will test this approach, and other
 possible solutions.

 Regards.

 On 21 jul, 10:16, Daniel Gonzalez Zaballos dgzabal...@gmail.com
 wrote:







  i'll start with the Anthony suggestion.
  I've opened the ticket:http://code.google.com/p/web2py/issues/detail?id=342

  Thank you to everybody

  2011/7/21 Massimo Di Pierro massimo.dipie...@gmail.com

   I think for now Anthony's proposal is the way to go. Open a ticket in
   google code and we can think of other options.

   On Jul 20, 5:53 pm, Anthony abasta...@gmail.com wrote:
I think there are a few possibilities. First, your MultiT function could
work, but you'd have to use str(T(text)) instead of T(text). The reason
   is
that T() returns a lazyT object, not the translated string (it isn't
translated until rendering). You can force the translation by calling 
the
lazyT.__str__ method via str(T(text)).

Another option is to define your own T() objects for each language and
   force
them to use the specific language. For example:

In a model file:
from gluon.languages import translator
enT=translator(request)
enT.force('en-en')
esT=translator(request)
esT.force('es-es')

In a view:
{{=esT('House')}} / {{=enT('House')}}

It would probably be easy to abstract the above by defining a class that
stores multiple T objects and lets you easily add additional ones.

A third option might be to create a special multi-language translation
   file.
For example, you could create a file called es-en.py, which could 
include
translations such as:

'House': 'Casa / House'

Hope that helps.

Anthony

On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote:
 Hi everyone, i don't know if Simultaneous multi-language system is
 the correct way to say what i need... i'll explain myself.

 I'm developing an application that by request of our customer, needs
 to have 2 languages at the same time. For example, if this app were in
 spanish and english, in the navigator should appear something like:

 Casa / House

 In the view we want to do something like this

 {{=T(House, es-es)}} / {{=T(House, en-en)}}

 But i don't know if web2py can permit to do this or something like
 that.

 I was thinking of writing a function like this:

 def MultiT(text,separator= / ):
     T.force(es-es)
     ret_text = T(text)
     T.force(en-en)
     ret_text += separator + T(text)
     return ret_text

 But it does not work. Also, do not know how this affects the system
 when updating the language files with the strings to translate (now
 the files are updated automatically when pressing the update
 languages button in admin, and I guess that it would make it on run
 time.

 Any sugestions?

 Best regards
 Daniel


[web2py] Re: SSL Email Support patch

2011-07-23 Thread Massimo Di Pierro
+1

in trunk ... now.

Massimo

On Jul 23, 2:30 am, Eric Vicenti ericvice...@gmail.com wrote:
 Hey, all

 I was having difficulties sending from web2py, when I realized there
 is no SSL encryption support. Since this is already built into
 smtplib, it was a simple addition. I should mention this wont work on
 GAE, and I have not comprehensively tested it.

 diff -r 800e086037d9 gluon/tools.py
 --- a/gluon/tools.py    Sat Jul 23 01:47:05 2011 -0500
 +++ b/gluon/tools.py    Sat Jul 23 00:17:49 2011 -0700
 @@ -206,6 +206,7 @@
          settings.sender = sender
          settings.login = login
          settings.tls = tls
 +        settings.ssl = False
          settings.cipher_type = None
          settings.sign = True
          settings.sign_passphrase = None
 @@ -569,8 +570,11 @@
                      result =
 mail.send_mail(sender=self.settings.sender, to=origTo,
                                              subject=subject,
 body=text, **xcc)
              else:
 -                server =
 smtplib.SMTP(*self.settings.server.split(':'))
 -                if self.settings.tls:
 +                if self.settings.ssl:
 +                    server =
 smtplib.SMTP_SSL(*self.settings.server.split(':'))
 +                else:
 +                    server =
 smtplib.SMTP(*self.settings.server.split(':'))
 +                if self.settings.tls and not self.settings.ssl:
                      server.ehlo()
                      server.starttls()
                      server.ehlo()

 To use, simply set mail.settings.ssl = True

 Enjoy!


[web2py] How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-23 Thread Iceberg
Hi Massimo,

How to add a IS_NOT_EMPTY constrait to list:reference field? This
seems a simple task but I ends up opening a can of worms. :-/  Here is
what I did.

1. Firstly, setup the sandbox.

db.define_table('tag',
Field('name', requires=IS_NOT_EMPTY()), format='%(name)s')
db.define_table('product',
Field('name', requires=IS_NOT_EMPTY()),
Field('tags', 'list:reference tag'),)

def product():
return {
1: crud.update(db.product, request.args(0)),
2: crud.select(db.product),
}

Now we can add new product with or without tags. Fine.


2. What if we need new product to have at least one tag?

I tried changing the tags field definition into (I thought it was
intuitive):

Field('tags', 'list:reference tag', required=True)

But nothing different. I can't force a tag.


3. Then I tried to change tags into:

Field('tags','list:reference tag',
requires =
IS_IN_DB(db,'tag.id',db.tag._format,multiple=True),),

This is the so-called default constraint, according to the book,
chapter 6.
But situation gets worse. Now I get error ticket whenever submitting
new product.


4. I even tried:

requires = [IS_NOT_EMPTY(), IS_IN_DB(...)]

still tickets.


Problem persists in both web2py 1.95.1 and 1.97.1, on Windows.

Did I miss something really obvious? Thanks in advance.


Regards,
Ray (a.k.a. Iceberg)


[web2py] Re: How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-23 Thread Massimo Di Pierro
Try IS_LIST_OF(IS_IN_DB(.))

On Jul 23, 2:52 am, Iceberg iceb...@21cn.com wrote:
 Hi Massimo,

 How to add a IS_NOT_EMPTY constrait to list:reference field? This
 seems a simple task but I ends up opening a can of worms. :-/  Here is
 what I did.

 1. Firstly, setup the sandbox.

     db.define_table('tag',
         Field('name', requires=IS_NOT_EMPTY()), format='%(name)s')
     db.define_table('product',
         Field('name', requires=IS_NOT_EMPTY()),
         Field('tags', 'list:reference tag'),)

     def product():
         return {
             1: crud.update(db.product, request.args(0)),
             2: crud.select(db.product),
             }

 Now we can add new product with or without tags. Fine.

 2. What if we need new product to have at least one tag?

 I tried changing the tags field definition into (I thought it was
 intuitive):

     Field('tags', 'list:reference tag', required=True)

 But nothing different. I can't force a tag.

 3. Then I tried to change tags into:

     Field('tags','list:reference tag',
         requires =
 IS_IN_DB(db,'tag.id',db.tag._format,multiple=True),),

 This is the so-called default constraint, according to the book,
 chapter 6.
 But situation gets worse. Now I get error ticket whenever submitting
 new product.

 4. I even tried:

     requires = [IS_NOT_EMPTY(), IS_IN_DB(...)]

 still tickets.

 Problem persists in both web2py 1.95.1 and 1.97.1, on Windows.

 Did I miss something really obvious? Thanks in advance.

 Regards,
 Ray (a.k.a. Iceberg)


[web2py] How to use Web2py with Postgres SQL or MySQL installed through XAMPP (Windows) ?

2011-07-23 Thread ArrC
I somehow manged to install to install Postgres into Xampp directory ( by 
following a tutorial i found on web ) to use it under xampp environment 
which is working perfectly fine.
But now i think that python dosnt know where is Postgres located on my 
machine.

I have instlled Psycopg2 using 
http://www.stickpeople.com/projects/python/win-psycopg/  and MinGW GCC.

Will web2py will work with this kind of postgres installation or i have to 
install it the normal way i.e outside of xampp directory?

Thanks.


Re: [web2py] How to use Web2py with Postgres SQL or MySQL installed through XAMPP (Windows) ?

2011-07-23 Thread Kenneth Lundström
web2py doesn´t care where your Postgres is installed. If you can get 
Psycopg2 to work with your Postgres then web2py should work too.



Kenneth

I somehow manged to install to install Postgres into Xampp directory ( 
by following a tutorial i found on web ) to use it under xampp 
environment which is working perfectly fine.
But now i think that python dosnt know where is Postgres located on my 
machine.


I have instlled Psycopg2 using 
http://www.stickpeople.com/projects/python/win-psycopg/  and MinGW GCC.


Will web2py will work with this kind of postgres installation or i 
have to install it the normal way i.e outside of xampp directory?


Thanks.




Re: [web2py] Re: How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread Kenneth Lundström

I guess we have to wait for maybe Massimo to look into this.


Kenneth

Hi Kenneth, Yes both the connection strings work in db.py which I too 
find very puzzling. On Jul 23, 12:24 pm, Kenneth Lundström 
kenneth.t.lundst...@gmail.com wrote:

It sounds like web2py is not able to open either the sqlite file or
postgres database. Have you tried to use both connection strings in a
model file to test that both works?

Kenneth








I am having a hard time migrating data from sqlite to postgres
This is the command that I use
./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
sqlite://applications/testapp/databases/storage.sqlite -y 'sqlite://
applications/testapp/databases/storage.sqlite'  -Y 'postgres://
puser:ppass@localhost/testdb'
It says
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.97.1 (2011-06-26 19:25:44)
Database drivers available: SQLite3, pymysql, PostgreSQL
EXCEPTION: could not make a copy of the database
Failure to connect, tried 5 times:
unable to open database file
Any idea how to make this work?




[web2py] Re: How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread Massimo Di Pierro
Mart wrote it.Let's wait for his opinion first. ;-)

On Jul 23, 3:26 am, Kenneth Lundström kenneth.t.lundst...@gmail.com
wrote:
 I guess we have to wait for maybe Massimo to look into this.

 Kenneth

 Hi Kenneth, Yes both the connection strings work in db.py which I too
 find very puzzling. On Jul 23, 12:24 pm, Kenneth Lundstr m







 kenneth.t.lundst...@gmail.com wrote:
  It sounds like web2py is not able to open either the sqlite file or
  postgres database. Have you tried to use both connection strings in a
  model file to test that both works?

  Kenneth

  I am having a hard time migrating data from sqlite to postgres
  This is the command that I use
  ./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
  sqlite://applications/testapp/databases/storage.sqlite -y 'sqlite://
  applications/testapp/databases/storage.sqlite'  -Y 'postgres://
  puser:ppass@localhost/testdb'
  It says
  web2py Web Framework
  Created by Massimo Di Pierro, Copyright 2007-2011
  Version 1.97.1 (2011-06-26 19:25:44)
  Database drivers available: SQLite3, pymysql, PostgreSQL
  EXCEPTION: could not make a copy of the database
  Failure to connect, tried 5 times:
  unable to open database file
  Any idea how to make this work?


Re: [web2py] Re: Simultaneous multi-language system.

2011-07-23 Thread Jesús Martínez
It works.

Thanks Massimo.

2011/7/23 Massimo Di Pierro massimo.dipie...@gmail.com

 There is a solution in trunk. Please check it:
 http://code.google.com/p/web2py/issues/detail?id=342


 print T(hello) #defualt
 print T(hello, language=it-it) #etc etc


 On Jul 22, 4:52 am, jamarcer jamar...@gmail.com wrote:
  Hello:
 
  I have added a comment to the ticket:
 
  http://code.google.com/p/web2py/issues/detail?id=342
 
  It is an approach to the issue, based in Anthony's proposal: a class
  that stores multiple T objects.
 
  I am demetrio's companion. We develop the same application, but we
  have different roles :), so I will test this approach, and other
  possible solutions.
 
  Regards.
 
  On 21 jul, 10:16, Daniel Gonzalez Zaballos dgzabal...@gmail.com
  wrote:
 
 
 
 
 
 
 
   i'll start with the Anthony suggestion.
   I've opened the ticket:
 http://code.google.com/p/web2py/issues/detail?id=342
 
   Thank you to everybody
 
   2011/7/21 Massimo Di Pierro massimo.dipie...@gmail.com
 
I think for now Anthony's proposal is the way to go. Open a ticket in
google code and we can think of other options.
 
On Jul 20, 5:53 pm, Anthony abasta...@gmail.com wrote:
 I think there are a few possibilities. First, your MultiT function
 could
 work, but you'd have to use str(T(text)) instead of T(text). The
 reason
is
 that T() returns a lazyT object, not the translated string (it
 isn't
 translated until rendering). You can force the translation by
 calling the
 lazyT.__str__ method via str(T(text)).
 
 Another option is to define your own T() objects for each language
 and
force
 them to use the specific language. For example:
 
 In a model file:
 from gluon.languages import translator
 enT=translator(request)
 enT.force('en-en')
 esT=translator(request)
 esT.force('es-es')
 
 In a view:
 {{=esT('House')}} / {{=enT('House')}}
 
 It would probably be easy to abstract the above by defining a class
 that
 stores multiple T objects and lets you easily add additional ones.
 
 A third option might be to create a special multi-language
 translation
file.
 For example, you could create a file called es-en.py, which could
 include
 translations such as:
 
 'House': 'Casa / House'
 
 Hope that helps.
 
 Anthony
 
 On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote:
  Hi everyone, i don't know if Simultaneous multi-language system
 is
  the correct way to say what i need... i'll explain myself.
 
  I'm developing an application that by request of our customer,
 needs
  to have 2 languages at the same time. For example, if this app
 were in
  spanish and english, in the navigator should appear something
 like:
 
  Casa / House
 
  In the view we want to do something like this
 
  {{=T(House, es-es)}} / {{=T(House, en-en)}}
 
  But i don't know if web2py can permit to do this or something
 like
  that.
 
  I was thinking of writing a function like this:
 
  def MultiT(text,separator= / ):
  T.force(es-es)
  ret_text = T(text)
  T.force(en-en)
  ret_text += separator + T(text)
  return ret_text
 
  But it does not work. Also, do not know how this affects the
 system
  when updating the language files with the strings to translate
 (now
  the files are updated automatically when pressing the update
  languages button in admin, and I guess that it would make it on
 run
  time.
 
  Any sugestions?
 
  Best regards
  Daniel



[web2py] Re: Web2py talk proposal - Codebits 2011

2011-07-23 Thread Francisco Costa
I was also going to do it.. but if you submitted first I'm going to
watch it :)

On Jul 23, 2:10 am, blackthorne francisco@gmail.com wrote:
 Hi,
 just submitted a talk proposal on web2py for the Codebits 2011 event
 yield in Lisbon, Portugal (November). I invite you to support me with
 your votes at and join me if you're close 
 by:http://codebits.eu/intra/s/proposal/152

 So, don't forget to put your thumbs up to my talk proposal and hope to
 see you there!


Re: [web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Martín Mulone
Take a look to this:

http://martin.tecnodoc.com.ar/default/post/2011/04/13/2_hacking-web2py-sqlform-part-1

I have to make the part 2, to show more complex css form with sqlforms.

2011/7/23 Luis Goncalves l...@vision.caltech.edu

 I am just a beginner with CSS/HTML,  and so maybe I have a misconceived
 idea of what CSS can/should do and the right way to use it.

 Naively, I thought that I could use the #id=table-field entries in CSS to
 control placement/shape of the form elements, and not need to change much
 more in the controller or the view?

 It seems that if I have to use custom forms, then I might as well not even
 bother with using SQLFORM --  it's pretty much like building the form piece
 by piece in the view?

 thanks,
 Luis.


 On Fri, Jul 22, 2011 at 11:42 PM, Anthony abasta...@gmail.com wrote:

 What's wrong with this method -
 http://web2py.com/book/default/chapter/07#Custom-forms - you can put the
 form widgets wherever you want? Or specifically, how would
 better/smarter/proper use of the #id table-field entries help? What would
 you like to see in the rendered form HTML that would enable you to do what
 you want with just CSS?

 Anthony

 On Saturday, July 23, 2011 2:33:54 AM UTC-4, Luis Goncalves wrote:

 Yes ... too many  :(

 Here's a 'simple' one:

  The database table definition, which I use as a form for input:



db.define_table('scorecard',
   Field('offense1', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),
   Field('defense1', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('offense2', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),
   Field('defense2', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('fifth', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('score1', 'integer', requires=IS_IN_SET([1, 2, 3, 4,
 5],zero=None)),
   Field('score2', 'integer', requires=IS_IN_SET([1, 2, 3, 4,
 5],zero=None)),



Field('start', 'datetime', readable=False, writable=False),
   Field('finish', 'datetime', readable=False, writable=False),
   Field('single', 'boolean', readable=False, writable=False)) #
 single game during round-robin rotate play, or part of a game-set-match

   I would like this to display something like:



 https://lh3.googleusercontent.com/-043w1FYNTj8/Tipod6h9_zI/HFk/0eX4V6S0Uf0/scorecard.png

 The input is a scorecard for a game.  Two teams with two players each,
  and a fifth person that will  play the next game.

  The user defines who is playing the current game, and who is sitting
 out.  When the game is over, they select the scores.

  On 'submit', the teams and scores are recorded, and the form is shown
 again, with a suggested line-up for the next game

  (but the user can alter the line-up if he wants).






  In the controller:


  def rotate_5_man():


  form = SQLFORM( db.scorecard )

  # retrieve previous player positions.

  # pre-fill form with some suggestions





  if form.accepts( .. )


   # record score,

   # figure out how to rotate players for next game


  return dict(form=form)


  In the view,  rotate_5_man.html :


  {{extend 'layout.html'}}

  {{=form}}



 So right now, the display of the form is quite rudimentary
 (each item gets shown in order, listed vertically).

 Is there a simple way to get the above layout instead?

 Preferably done with minimal additional python/web2py/html,
 but via CSS instead!



 Thanks!!!
 Luis.




























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


Re: [web2py] Re: The web2py grid/crud plugin you've always dreamed about!

2011-07-23 Thread Martín Mulone
Very nice and have a lot of examples. I'm rewriting powerpack, to come in a
few weeks in version 2.0. Do you want to include in it also as an example?

2011/7/23 Massimo Di Pierro massimo.dipie...@gmail.com

 +1

 should this be included in web2py/contrib?

 On Jul 22, 5:35 pm, Bruno Rocha rochacbr...@gmail.com wrote:
  Hi,
 
  I present you PowerGrid Plugin (now in beta 0.1) [
 http://labs.blouweb.com/PowerGrid/]
 
  What is it?
 
  A plugin to show, manage and paginate data
  It works with paginated JSON callbacks, you can use web2py DAL's Query or
  Table, or you can create your own callback returning the desired JSON or
  JSONP
 
  What is has in special?
  - Based on Jquery templates
  - Server side pagination loads records on demand
  - Ajax Caching option
  - Programable in pure Python  web2py
  - You can pass JS callbacks to the event handlers
  - Can show images with Virtual Fields
  - has button system
  - totally integrated with CRUD
  - Easy to integrate with Auth
  - Can be used to manage a site content (a CMS admin page)
  - can be used to create any kind of paginated data view
 
  Changelog:
  - Some issues solved
  - Tested in Windows, Linux, I.E, Opera, Chrome, FF
  - Better default layout
 
  Beta:
  - Needs tests with different datasources
  - Need to be tested on GAE
  - Need to test multiple on the same page
  - Need to test wotking with another UI libs
 
  EXAMPLES:
  images -http://labs.blouweb.com/PowerGrid/default/withimages
  dataGRid -http://labs.blouweb.com/PowerGrid/default/onlydata
  Buttons -http://labs.blouweb.com/PowerGrid/default/buttons
  Scrolling -http://labs.blouweb.com/PowerGrid/default/scroll
  Customization:
 http://labs.blouweb.com/PowerGrid/default/nocontrol/http://labs.blouweb.com/PowerGrid/default/noadd/http://labs.blouweb.com/PowerGrid/default/nosearch
  Default search system:
 http://labs.blouweb.com/PowerGrid/default/defaultsearch?what=Ferrari;...
  SubGrids:http://labs.blouweb.com/PowerGrid/default/gridinpopup
  JavaScript callbacks:
 http://labs.blouweb.com/PowerGrid/default/jscallbacks
  Custom templates:http://labs.blouweb.com/PowerGrid/default/blog(a blog
  created with it)
 
  DOCUMENTATION:
  Is being writen in home pagehttp://
 labs.blouweb.com/PowerGrid/default/index(in
  the grid)
  source example app is well commented with options.
 
  IT USES:http://labs.blouweb.com/PowerGrid/default/about
 
  Comments:http://labs.blouweb.com/PowerGrid/default/support
 
  Get it:http://labs.blouweb.com/PowerGrid/default/get
 
  !!! BETA VERSION, SOME THINGS CAN CRASH, THE SERVER IS A BIT SLOW, IT
 WILL
  BE VERY MORE QUICKLY IN A GOOD SERVER OR GAE !!!
 
  Thanks if you can test and report on BitBucker or omments page.
 
  Bruno Rocha
  [ About me:http://zerp.ly/rochacbruno]
  [ Aprenda a programar:http://CursoDePython.com.br]
  [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
  [ Consultoria em desenvolvimento web:http://www.blouweb.com]




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


Re: [web2py] New to programming question

2011-07-23 Thread Martín Mulone
I'm rewriting it, but it's a different story. It's called powerpack. Instant
press is blog/ cms application solution oriented to visual. But in powerpack
I want to achieve that  could make an cms or blog but this don't mix with
the rest of the application, because powerpack is boilerplate app like
welcome, you can do your application an add pages you can administer, or add
comments to some of your controllers. I'm rewriting powerpack that are
comming in the nexts weeks in version 2.0.

The develop version of 2.0 is in
https://bitbucket.org/mulonemartin/web2pyboilerplate/overview but when are
ready is going to replace powerpack.

Some example

=Controllers===

from plugins.comments.main import PluginCommentsdef plugin_comments():
 Example plugin PluginComments 

_ = PluginComments(boilerplate)
_.install()
comments = _.render()

return dict(comments=comments)


This example in controllers, not required nothing in models (only
boilerplate that is central class) so does not interfered with others
controllers, it's loaded when it's need it and give comments when you do
/mycontroller/plugin_comments


def plugin_markitup():
 Example plugin Markitup 

 Move to your models if you want to use in all controllers.
_ = PluginMarkitup(boilerplate)
_.render('#mytextarea')

mytextarea = TEXTAREA(_id='mytextarea')

return dict(textarea=mytextarea)
def plugin_sunlight():
 Example plugin Sunlight 

 Move to your models if you want to use in all controllers.
_ = PluginSunlight(boilerplate)
content = _.render(``def test():   return this is
Python code``:python)

return dict(content=content)
def plugin_simplecontact():
 Example plugin Simplecontact 

_ = PluginSimpleContact(boilerplate)
form = _.render()

return dict(form=form)



2011/7/22 DanB dran...@heximperia.com

 Martin,

 Thanks so much for the quick response! That makes a few things a lot more
 clear, thank you.

 I really like a lot of the things the InstantPress does, and as I'm a
 rather novice programmer, I thought I would work through your example to
 learn more, and maybe build some things I've got in mind.

 If I may, let me ask this: with the changes to web2py, from a high-level
 design perspective, how would you change the code and/or structure of
 Instant Press if you wrote it now? It seems to work well, and is farily
 modular in its own way.




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


[web2py] Re: how to iterate efficiently (memory-wise) through a huge DAL query

2011-07-23 Thread Vineet
Ah !
The database-tier did not flash into my mind.
I have not used sqlite anytime.
I am using MySQL; the table structure is partially normalised,
suitable indexed.
Because of these optimizations, whenever I query a huge table (1
million rows), I get very fast response.
I don't know whether any shell is available for sqlite.
If available, run your query from the shell  see whether the speed is
OK or not.
If OK there, then the problem lies in your python code.
Otherwise, you need to optimize the table-structure at the database-
level.

My advise is to use a production database server like MySQL /
MariaDB / PostgreSQL.

If you have any questions regarding using MySQL through Python, pl.
feel free to ask.

Cheers!
:-)

On Jul 23, 11:56 am, Luis Goncalves lgoncal...@gmail.com wrote:
 Thanks, Vineet!  Lot's of good info there!

 I don't have actual code yet, because I couldn't even get the db queries to
 work in a reasonable amount of time.

 The little code I showed in my initial post already runs slow  ( my DB
 records are db.itemEntry, not db.table ...).

 The slowness (so far) is due to doing a query/select on a very large DB.
 I need to figure out how to query/select more efficiently.

 I wonder if the problem is with sqlite3 itself, since it stores the entire
 DB in a single file.

 I have constructed index tables for the fields I am searching on, but it is
 still incredibly slow.
 (see post below in reply to Massimo too!).

 Thanks!
 Luis.


[web2py] Re: how to iterate efficiently (memory-wise) through a huge DAL query

2011-07-23 Thread Cliff
You have exposed two relatively advanced programming topics: code
profiling and database performance tuning.

Because I am a relative noobie to both Python and Sqlite, I cannot
unfortunately give you specific directions.

But I can offer an approach you might try.  Maybe you should first
learn where the bottleneck lies through code profiling.  Generally a
code profiler will trace the code as it runs and timestamp the steps.
It should be relatively easy to spot long waits after database calls,
for example.

Python does have built in code profiling as described here:
http://docs.python.org/library/profile.html

As a short cut, you might try indexing your table(s).  In general, you
want an index on any column that appears in a where clause or an order
by clause.

Is the data normalized at all, or is it all in one huge table like a
spreadsheet would produce?  If the data is not normalized, you will
need to find a way to normalize it.






Re: [web2py] The web2py grid/crud plugin you've always dreamed about!

2011-07-23 Thread Sebastian E. Ovide
very nice work Bruno !

On Fri, Jul 22, 2011 at 11:35 PM, Bruno Rocha rochacbr...@gmail.com wrote:

 Hi,

 I present you PowerGrid Plugin (now in beta 0.1) [
 http://labs.blouweb.com/PowerGrid/]

 What is it?

 A plugin to show, manage and paginate data
 It works with paginated JSON callbacks, you can use web2py DAL's Query or
 Table, or you can create your own callback returning the desired JSON or
 JSONP

 What is has in special?
 - Based on Jquery templates
 - Server side pagination loads records on demand
 - Ajax Caching option
 - Programable in pure Python  web2py
 - You can pass JS callbacks to the event handlers
 - Can show images with Virtual Fields
 - has button system
 - totally integrated with CRUD
 - Easy to integrate with Auth
 - Can be used to manage a site content (a CMS admin page)
 - can be used to create any kind of paginated data view

 Changelog:
 - Some issues solved
 - Tested in Windows, Linux, I.E, Opera, Chrome, FF
 - Better default layout

 Beta:
 - Needs tests with different datasources
 - Need to be tested on GAE
 - Need to test multiple on the same page
 - Need to test wotking with another UI libs

 EXAMPLES:
 images - http://labs.blouweb.com/PowerGrid/default/withimages
 dataGRid - http://labs.blouweb.com/PowerGrid/default/onlydata
 Buttons - http://labs.blouweb.com/PowerGrid/default/buttons
 Scrolling - http://labs.blouweb.com/PowerGrid/default/scroll
 Customization: http://labs.blouweb.com/PowerGrid/default/nocontrol /
 http://labs.blouweb.com/PowerGrid/default/noadd /
 http://labs.blouweb.com/PowerGrid/default/nosearch
 Default search system:
 http://labs.blouweb.com/PowerGrid/default/defaultsearch?what=Ferrariwhere=manufacturer
 SubGrids: http://labs.blouweb.com/PowerGrid/default/gridinpopup
 JavaScript callbacks:
 http://labs.blouweb.com/PowerGrid/default/jscallbacks
 Custom templates: http://labs.blouweb.com/PowerGrid/default/blog (a blog
 created with it)


 DOCUMENTATION:
 Is being writen in home page
 http://labs.blouweb.com/PowerGrid/default/index (in the grid)
 source example app is well commented with options.

 IT USES:
 http://labs.blouweb.com/PowerGrid/default/about


 Comments:
 http://labs.blouweb.com/PowerGrid/default/support


 Get it:
 http://labs.blouweb.com/PowerGrid/default/get


 !!! BETA VERSION, SOME THINGS CAN CRASH, THE SERVER IS A BIT SLOW, IT WILL
 BE VERY MORE QUICKLY IN A GOOD SERVER OR GAE !!!

 Thanks if you can test and report on BitBucker or omments page.


 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]
 [ Aprenda a programar: http://CursoDePython.com.br ]
 [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
 [ Consultoria em desenvolvimento web: http://www.blouweb.com ]




-- 
Sebastian E. Ovide


[web2py] Re: How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-23 Thread Iceberg
Thanks but, it doesn't work either. Still tickets. Do you have another
suggestion?

On Jul 23, 3:54 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Try IS_LIST_OF(IS_IN_DB(.))

 On Jul 23, 2:52 am, Iceberg iceb...@21cn.com wrote:







  Hi Massimo,

  How to add a IS_NOT_EMPTY constrait to list:reference field? This
  seems a simple task but I ends up opening a can of worms. :-/  Here is
  what I did.

  1. Firstly, setup the sandbox.

      db.define_table('tag',
          Field('name', requires=IS_NOT_EMPTY()), format='%(name)s')
      db.define_table('product',
          Field('name', requires=IS_NOT_EMPTY()),
          Field('tags', 'list:reference tag'),)

      def product():
          return {
              1: crud.update(db.product, request.args(0)),
              2: crud.select(db.product),
              }

  Now we can add new product with or without tags. Fine.

  2. What if we need new product to have at least one tag?

  I tried changing the tags field definition into (I thought it was
  intuitive):

      Field('tags', 'list:reference tag', required=True)

  But nothing different. I can't force a tag.

  3. Then I tried to change tags into:

      Field('tags','list:reference tag',
          requires =
  IS_IN_DB(db,'tag.id',db.tag._format,multiple=True),),

  This is the so-called default constraint, according to the book,
  chapter 6.
  But situation gets worse. Now I get error ticket whenever submitting
  new product.

  4. I even tried:

      requires = [IS_NOT_EMPTY(), IS_IN_DB(...)]

  still tickets.

  Problem persists in both web2py 1.95.1 and 1.97.1, on Windows.

  Did I miss something really obvious? Thanks in advance.

  Regards,
  Ray (a.k.a. Iceberg)


[web2py] Re: How to use Web2py with Postgres SQL or MySQL installed through XAMPP (Windows) ?

2011-07-23 Thread Jay
ArrC, the proper way is to start the database using xampp (using
control panel, or script) then use web2py. Actually web2py will come
up even when the database it not up, but to actually interact with it
the db needs to be up.

So if yo get something like, failed to ... after 5 tries, just start
the db via xampp. db is accessed by network location that is host and
port, if those are correct you are good to go.

On Jul 23, 4:03 am, ArrC justmailnav...@gmail.com wrote:
 I somehow manged to install to install Postgres into Xampp directory ( by
 following a tutorial i found on web ) to use it under xampp environment
 which is working perfectly fine.
 But now i think that python dosnt know where is Postgres located on my
 machine.

 I have instlled Psycopg2 
 usinghttp://www.stickpeople.com/projects/python/win-psycopg/ and MinGW GCC.

 Will web2py will work with this kind of postgres installation or i have to
 install it the normal way i.e outside of xampp directory?

 Thanks.


Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Jonathan Lundell
On Jul 22, 2011, at 7:35 PM, Ross Peoples wrote:

 After some hacking on the welcome application, I have finally got this 
 working! I attached a screenshot of a /default/test function I created. 
 That URL uses the test.html view when viewed on the desktop browser, and 
 the same URL uses the test.mobile.html view when viewed using the iPhone 
 Simulator. I chose to go with .mobile.html instead of just .mobile for 
 the extension because it still gives you the syntax highlighting in text 
 editors when it still ends in .html.
 
 I hope Massimo accepts my mobile browser detection patch so that I can attach 
 the new welcome application that supports this new desktop/mobile dual mode. 
 I'd certainly like a few testers before I submit a formal patch with the new 
 dual site support.
 

I haven't been following this thread in detail, so excuse the repetition.

Now that it's working, could you summarize the logic? I'm curious how the 
.mobile string is being used; it seems like it'd be better, if possible, not to 
clutter up the path with a fairly long extra element if that could be avoided. 

Re: [web2py] SSL Email Support patch

2011-07-23 Thread Jonathan Lundell
On Jul 23, 2011, at 12:30 AM, Eric Vicenti wrote:

 I was having difficulties sending from web2py, when I realized there
 is no SSL encryption support. Since this is already built into
 smtplib, it was a simple addition. I should mention this wont work on
 GAE, and I have not comprehensively tested it.

Under what circumstances would you use ssl vs tis?

 
 diff -r 800e086037d9 gluon/tools.py
 --- a/gluon/tools.py  Sat Jul 23 01:47:05 2011 -0500
 +++ b/gluon/tools.py  Sat Jul 23 00:17:49 2011 -0700
 @@ -206,6 +206,7 @@
 settings.sender = sender
 settings.login = login
 settings.tls = tls
 +settings.ssl = False
 settings.cipher_type = None
 settings.sign = True
 settings.sign_passphrase = None
 @@ -569,8 +570,11 @@
 result =
 mail.send_mail(sender=self.settings.sender, to=origTo,
 subject=subject,
 body=text, **xcc)
 else:
 -server =
 smtplib.SMTP(*self.settings.server.split(':'))
 -if self.settings.tls:
 +if self.settings.ssl:
 +server =
 smtplib.SMTP_SSL(*self.settings.server.split(':'))
 +else:
 +server =
 smtplib.SMTP(*self.settings.server.split(':'))
 +if self.settings.tls and not self.settings.ssl:
 server.ehlo()
 server.starttls()
 server.ehlo()
 
 To use, simply set mail.settings.ssl = True
 



Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Ross Peoples
I had given that some thought, but went with '.mobile.html' for clarity. I 
suppose I could make it just '.m.html', but that might be hard to see in a 
list of files. I could have just made it '.mobile', or something, but then 
code editors won't pick up on it. It's actually kind of annoying manually 
telling code editors which syntax highlighting to use all the time. If you 
use '.load' extensions a lot, then you know what I'm talking about.

[web2py] FORM questions

2011-07-23 Thread Kenneth Lundström

I´m creating a form with SQLFORM that includes 6 fields.

One field is f_customer with requires IS_IN_DB()

Now I'd like to add a new field not taken directly from database. Lets 
call it f_extra.


f_customer is a drop-down and f_extra would also be a drop-down. Now I 
have a list of questions.


1) Is it possible to get the form.accepts to validate that either 
f_customer or f_extra is selected. Both can´t be selected and both can´t 
be empty? I remember seeing this discussed on the list not long ago, but 
could not find it.


2) If 1) is not possible then I guess I have to put dbio=False and do 
the validation manually. How do I show the error message the same way 
web2py does?


3) Instead of creating a custom layout for this form I´d like to add the 
field in the controller with something like:
form.element('table').insert(2,TR('label',INPUT(_name='name'))), but how 
do I add a SELECT with many OPTIONS? The f_extra field drop-down is 
created from two different tables auth_user and t_extra_fields. I guess 
I should use query auth_user and t_extra_fields and then create a list. 
That list is used to create the drop-down.


4) When using the OPTION helper is it possible to have a different value 
of the option then what is shown?


Thank you for all ideas.


Kenneth



Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Jonathan Lundell
On Jul 23, 2011, at 8:11 AM, Ross Peoples wrote:

 I had given that some thought, but went with '.mobile.html' for clarity. I 
 suppose I could make it just '.m.html', but that might be hard to see in a 
 list of files. I could have just made it '.mobile', or something, but then 
 code editors won't pick up on it. It's actually kind of annoying manually 
 telling code editors which syntax highlighting to use all the time. If you 
 use '.load' extensions a lot, then you know what I'm talking about.

I agree that .html is desirable. 

.m.html would be an improvement; people are (to some extent) already trained to 
know what that means because of how some sites (Google comes to mind) use 'm' 
as a mobile subdomain: m.google.com.

But what I'm asking is how the name gets used, and whether it couldn't be a 
flag in the session (say) or something else less visible.

[web2py] Re: how to iterate efficiently (memory-wise) through a huge DAL query

2011-07-23 Thread Vineet
Pl. beware of indexing.
It is a double-edged sword.
Indexing too many columns would increase the data-size.
One can first run a query with explain extended clause (in MySQL
database).
That can tell which column(s) would need an index.


On Jul 23, 6:29 pm, Cliff cjk...@gmail.com wrote:
 You have exposed two relatively advanced programming topics: code
 profiling and database performance tuning.

 Because I am a relative noobie to both Python and Sqlite, I cannot
 unfortunately give you specific directions.

 But I can offer an approach you might try.  Maybe you should first
 learn where the bottleneck lies through code profiling.  Generally a
 code profiler will trace the code as it runs and timestamp the steps.
 It should be relatively easy to spot long waits after database calls,
 for example.

 Python does have built in code profiling as described 
 here:http://docs.python.org/library/profile.html

 As a short cut, you might try indexing your table(s).  In general, you
 want an index on any column that appears in a where clause or an order
 by clause.

 Is the data normalized at all, or is it all in one huge table like a
 spreadsheet would produce?  If the data is not normalized, you will
 need to find a way to normalize it.


Re: [web2py] How to use Web2py with Postgres SQL or MySQL installed through XAMPP (Windows) ?

2011-07-23 Thread Ovidio Marinho
install web2py.src, not web2py for windows.ok.



   Ovidio Marinho Falcao Neto
 ovidio...@gmail.com
 88269088
   Paraiba-Brasil



2011/7/23 ArrC justmailnav...@gmail.com

 I somehow manged to install to install Postgres into Xampp directory ( by
 following a tutorial i found on web ) to use it under xampp environment
 which is working perfectly fine.
 But now i think that python dosnt know where is Postgres located on my
 machine.

 I have instlled Psycopg2 using
 http://www.stickpeople.com/projects/python/win-psycopg/  and MinGW GCC.

 Will web2py will work with this kind of postgres installation or i have to
 install it the normal way i.e outside of xampp directory?

 Thanks.



Re: [web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Anthony
On Saturday, July 23, 2011 3:06:13 AM UTC-4, Luis Goncalves wrote: 

 I am just a beginner with CSS/HTML,  and so maybe I have a misconceived 
 idea of what CSS can/should do and the right way to use it. 

 Naively, I thought that I could use the #id=table-field entries in CSS to 
 control placement/shape of the form elements, and not need to change much 
 more in the controller or the view?

 
Yes, you should be able to (to some extent, depending on exactly what you 
want to do). If you use formstyle='divs', you'll get a set of divs with a 
consistent scheme of CSS classes and ids to identify the different form 
elements. Beyond that, is there something additional you think web2py could 
be doing to facilitate the kind of CSS-based customization you want to do. 
What output should web2py be generating that would enable you to achieve the 
form formatting you want purely via CSS?
 

 It seems that if I have to use custom forms, then I might as well not even 
 bother with using SQLFORM --  it's pretty much like building the form piece 
 by piece in the view?

 
SQLFORM (and FORM, to a lesser extent) does a lot more than just build the 
form HTML for you. It also handles validation, error message display, CSRF 
and double submission protection (via a _formkey hidden field), form 
pre-population for updates, database insertion, etc. Using the 
form.custom.widgets is also easier than manually building all the HTML for 
each field widget.
 
Anthony
 


Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Ross Peoples
In my welcome app's db.py file, this is what I use to switch to the mobile 
view:

if request.is_mobile and request.extension == 'html':
mobile_view = os.path.join(
request.controller, request.function + '.mobile.html'
)

if os.path.exists(os.path.join(request.folder, 'views', mobile_view)):
response.view = mobile_view

So really, to use a different name for the mobile files, you would just 
change the one line in the db.py. I didn't really know where to put this in 
web2py's code, so I just put it in db.py for now. Do you think there is a 
better way to do this?


Re: [web2py] How to use Web2py with Postgres SQL or MySQL installed through XAMPP (Windows) ?

2011-07-23 Thread Vasile Ermicioi
I have experience with mysql:

if mysql is started that will work just fine

db = DAL('mysql://root:@localhost/mydb')


python shouldn't know where is mysql - it runs a on a port 3306, and python
mysql drivers know that :)


[web2py] Re: The web2py grid/crud plugin you've always dreamed about!

2011-07-23 Thread mr.freeze
Fantastic! I modified the WebGrid slice to recommend using this
instead. Great work.

On Jul 22, 5:35 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Hi,

 I present you PowerGrid Plugin (now in beta 0.1) 
 [http://labs.blouweb.com/PowerGrid/]

 What is it?

 A plugin to show, manage and paginate data
 It works with paginated JSON callbacks, you can use web2py DAL's Query or
 Table, or you can create your own callback returning the desired JSON or
 JSONP

 What is has in special?
 - Based on Jquery templates
 - Server side pagination loads records on demand
 - Ajax Caching option
 - Programable in pure Python  web2py
 - You can pass JS callbacks to the event handlers
 - Can show images with Virtual Fields
 - has button system
 - totally integrated with CRUD
 - Easy to integrate with Auth
 - Can be used to manage a site content (a CMS admin page)
 - can be used to create any kind of paginated data view

 Changelog:
 - Some issues solved
 - Tested in Windows, Linux, I.E, Opera, Chrome, FF
 - Better default layout

 Beta:
 - Needs tests with different datasources
 - Need to be tested on GAE
 - Need to test multiple on the same page
 - Need to test wotking with another UI libs

 EXAMPLES:
 images -http://labs.blouweb.com/PowerGrid/default/withimages
 dataGRid -http://labs.blouweb.com/PowerGrid/default/onlydata
 Buttons -http://labs.blouweb.com/PowerGrid/default/buttons
 Scrolling -http://labs.blouweb.com/PowerGrid/default/scroll
 Customization:http://labs.blouweb.com/PowerGrid/default/nocontrol/http://labs.blouweb.com/PowerGrid/default/noadd/http://labs.blouweb.com/PowerGrid/default/nosearch
 Default search 
 system:http://labs.blouweb.com/PowerGrid/default/defaultsearch?what=Ferrari;...
 SubGrids:http://labs.blouweb.com/PowerGrid/default/gridinpopup
 JavaScript callbacks:http://labs.blouweb.com/PowerGrid/default/jscallbacks
 Custom templates:http://labs.blouweb.com/PowerGrid/default/blog(a blog
 created with it)

 DOCUMENTATION:
 Is being writen in home pagehttp://labs.blouweb.com/PowerGrid/default/index(in
 the grid)
 source example app is well commented with options.

 IT USES:http://labs.blouweb.com/PowerGrid/default/about

 Comments:http://labs.blouweb.com/PowerGrid/default/support

 Get it:http://labs.blouweb.com/PowerGrid/default/get

 !!! BETA VERSION, SOME THINGS CAN CRASH, THE SERVER IS A BIT SLOW, IT WILL
 BE VERY MORE QUICKLY IN A GOOD SERVER OR GAE !!!

 Thanks if you can test and report on BitBucker or omments page.

 Bruno Rocha
 [ About me:http://zerp.ly/rochacbruno]
 [ Aprenda a programar:http://CursoDePython.com.br]
 [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
 [ Consultoria em desenvolvimento web:http://www.blouweb.com]


[web2py] Re: how to iterate efficiently (memory-wise) through a huge DAL query

2011-07-23 Thread pbreit
If processing one row at a time works, then go for it. If you want to try 
more at a time, use Massimo's approach and just make the number smaller than 
1000.

Re: [web2py] New to programming question

2011-07-23 Thread pbreit
I'm newish to programming and found the Instant Press code very hard to 
follow. I'm sure it's well designed but can be challenging since it's a 
departure from other projects. I found the best approach is to follow the 
patterns as presented in the Book as much as possible.

[web2py] Re: The web2py grid/crud plugin you've always dreamed about!

2011-07-23 Thread David Marko
+1 to be part of web2py contrib ...

[web2py] Re: How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-23 Thread Massimo Di Pierro
I see what the problem is. The default widget overrides the validator.
Before we look for a solution let me undertand what you need.

The way you phrased looks like you want users to input the IDs of the
tags. I suspect you want instead the user to insert tag names, perhaps
comma separated, and you want the system to parse them and store the
corresponding ids in the product.tags field. Is this correct?

massimo

On Jul 23, 2:52 am, Iceberg iceb...@21cn.com wrote:
 Hi Massimo,

 How to add a IS_NOT_EMPTY constrait to list:reference field? This
 seems a simple task but I ends up opening a can of worms. :-/  Here is
 what I did.

 1. Firstly, setup the sandbox.

     db.define_table('tag',
         Field('name', requires=IS_NOT_EMPTY()), format='%(name)s')
     db.define_table('product',
         Field('name', requires=IS_NOT_EMPTY()),
         Field('tags', 'list:reference tag'),)

     def product():
         return {
             1: crud.update(db.product, request.args(0)),
             2: crud.select(db.product),
             }

 Now we can add new product with or without tags. Fine.

 2. What if we need new product to have at least one tag?

 I tried changing the tags field definition into (I thought it was
 intuitive):

     Field('tags', 'list:reference tag', required=True)

 But nothing different. I can't force a tag.

 3. Then I tried to change tags into:

     Field('tags','list:reference tag',
         requires =
 IS_IN_DB(db,'tag.id',db.tag._format,multiple=True),),

 This is the so-called default constraint, according to the book,
 chapter 6.
 But situation gets worse. Now I get error ticket whenever submitting
 new product.

 4. I even tried:

     requires = [IS_NOT_EMPTY(), IS_IN_DB(...)]

 still tickets.

 Problem persists in both web2py 1.95.1 and 1.97.1, on Windows.

 Did I miss something really obvious? Thanks in advance.

 Regards,
 Ray (a.k.a. Iceberg)


[web2py] Re: New to programming question

2011-07-23 Thread DanB
@Martin,

Sounds really interesting! I'll check it out, and definitely keep an
eye on the project! Thanks!

@pbreit

I agree that, at first, it was a little confusing, but once I saw the
pattern it became a lot easier to trace. (get the configurations and
superclass through the model files, and db.py just starts it all up -
at least, that's how I read it...)

I particularly like the relatively modular nature of the application -
models and functions for each component are contained in their own
module, and, in theory, could be drop-in/drop-out. I'm coming from the
world of Wordpress, so...there are some things I'd do differently (and
am working on just that!), but I think it's a good place to start!
Honestly, I'll probably end up somewhere in between Instant Press and
what the book describes!

On Jul 23, 12:28 pm, pbreit pbreitenb...@gmail.com wrote:
 I'm newish to programming and found the Instant Press code very hard to
 follow. I'm sure it's well designed but can be challenging since it's a
 departure from other projects. I found the best approach is to follow the
 patterns as presented in the Book as much as possible.


Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Jonathan Lundell
On Jul 23, 2011, at 9:19 AM, Ross Peoples wrote:

 In my welcome app's db.py file, this is what I use to switch to the mobile 
 view:
 
 if request.is_mobile and request.extension == 'html':
 mobile_view = os.path.join(
 request.controller, request.function + '.mobile.html'
 )
 
 if os.path.exists(os.path.join(request.folder, 'views', mobile_view)):
 response.view = mobile_view
 
 So really, to use a different name for the mobile files, you would just 
 change the one line in the db.py. I didn't really know where to put this in 
 web2py's code, so I just put it in db.py for now. Do you think there is a 
 better way to do this?

I think it could be more general, perhaps. Some thoughts.

1. Might it be possible to use a views subdirectory, perhaps? So more like 
os.path.join('mobile', controller, function + whatever)?

2. is_mobile should perhaps have better resolution. It's already not too 
unusual to have separate iPhone and iPad pages, for example. So rather than 
yes/no, an indication of the kind of device? Not sure how it would make sense 
to do that; perhaps with a collection of properties. Apps that didn't care to 
discriminate could simply test for generic mobile, but apps that cared could 
look at the details.

3. Related to (2), the ability to choose whether a pad got the mobile or main 
view, or its own view.



[web2py] Re: how to iterate efficiently (memory-wise) through a huge DAL query

2011-07-23 Thread Cliff
That's a fair statement.

Indices not only increase the size of the data, they also slow down db
writes, because the index tables need to be written as well as the
data tables.

Still, you want to avoid a full table scan on a table with millions of
records.

Sqlite also has an explain command, just Google 'sqlite explain
select.'

As we think about this, I am becoming persuaded that the best approach
would be to try the queries from a command-line client, no matter
which db engine is used.  I also guess I'm assuming that the db is at
least partly responsible for the bottleneck.

On Jul 23, 11:34 am, Vineet vineet.deod...@gmail.com wrote:
 Pl. beware of indexing.
 It is a double-edged sword.
 Indexing too many columns would increase the data-size.
 One can first run a query with explain extended clause (in MySQL
 database).
 That can tell which column(s) would need an index.

 On Jul 23, 6:29 pm, Cliff cjk...@gmail.com wrote:







  You have exposed two relatively advanced programming topics: code
  profiling and database performance tuning.

  Because I am a relative noobie to both Python and Sqlite, I cannot
  unfortunately give you specific directions.

  But I can offer an approach you might try.  Maybe you should first
  learn where the bottleneck lies through code profiling.  Generally a
  code profiler will trace the code as it runs and timestamp the steps.
  It should be relatively easy to spot long waits after database calls,
  for example.

  Python does have built in code profiling as described 
  here:http://docs.python.org/library/profile.html

  As a short cut, you might try indexing your table(s).  In general, you
  want an index on any column that appears in a where clause or an order
  by clause.

  Is the data normalized at all, or is it all in one huge table like a
  spreadsheet would produce?  If the data is not normalized, you will
  need to find a way to normalize it.


[web2py] Re: FORM questions

2011-07-23 Thread Kenneth Lundström
As I guess Massimo wanted to post these answers to the list and not only 
to me, I´ll forward his answers here.


On Jul 23, 10:19 am, Kenneth Lundströmkenneth.t.lundst...@gmail.com
wrote:


I m creating a form with SQLFORM that includes 6 fields.

One field is f_customer with requires IS_IN_DB()

Now I'd like to add a new field not taken directly from database. Lets
call it f_extra.

f_customer is a drop-down and f_extra would also be a drop-down. Now I
have a list of questions.

1) Is it possible to get the form.accepts to validate that either
f_customer or f_extra is selected. Both can t be selected and both can t
be empty? I remember seeing this discussed on the list not long ago, but
could not find it.

2) If 1) is not possible then I guess I have to put dbio=False and do
the validation manually. How do I show the error message the same way
web2py does?

yes

def check(form):
if (form.vars.a and form.vars.b) or (not form.vars.a and not
form.vars.b):
form.errors.b = a and b cannot be both empty or selected
form.accepts(...,onvalidation=lambda form: check(form))



3) Instead of creating a custom layout for this form I d like to add the
field in the controller with something like:
form.element('table').insert(2,TR('label',INPUT(_name='name'))), but how
do I add a SELECT with many OPTIONS? The f_extra field drop-down is
created from two different tables auth_user and t_extra_fields. I guess
I should use query auth_user and t_extra_fields and then create a list.
That list is used to create the drop-down.

Is this a FORM or  SQLFORM. In the latter case you need a custom
widget. In the former case you can do

SELECT(*[OPTION(value) for value in ],**dict(value='default'))



4) When using the OPTION helper is it possible to have a different value
of the option then what is shown?

OPTION('shown value',_value='hidden value')






[web2py] Re: How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-23 Thread Iceberg
From the user-interface aspect, of course we expect end user to input
real names, rather than IDs. Actually web2py already provides a nice-
looking multi-selection widget by default, in scenario 1 of my first
post.

The only and real problem right now, is that end user can add/edit a
record with its list:reference field being empty. I hope to add an
IS_NOT_EMPTY() constraint on it.

Hope I explain it clear. If not, feel free to ask me again. Thanks!

Regards,
Ray


On Jul 24, 1:07 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I see what the problem is. The default widget overrides the validator.
 Before we look for a solution let me undertand what you need.

 The way you phrased looks like you want users to input the IDs of the
 tags. I suspect you want instead the user to insert tag names, perhaps
 comma separated, and you want the system to parse them and store the
 corresponding ids in the product.tags field. Is this correct?

 massimo

 On Jul 23, 2:52 am, Iceberg iceb...@21cn.com wrote:







  Hi Massimo,

  How to add a IS_NOT_EMPTY constrait to list:reference field? This
  seems a simple task but I ends up opening a can of worms. :-/  Here is
  what I did.

  1. Firstly, setup the sandbox.

      db.define_table('tag',
          Field('name', requires=IS_NOT_EMPTY()), format='%(name)s')
      db.define_table('product',
          Field('name', requires=IS_NOT_EMPTY()),
          Field('tags', 'list:reference tag'),)

      def product():
          return {
              1: crud.update(db.product, request.args(0)),
              2: crud.select(db.product),
              }

  Now we can add new product with or without tags. Fine.

  2. What if we need new product to have at least one tag?

  I tried changing the tags field definition into (I thought it was
  intuitive):

      Field('tags', 'list:reference tag', required=True)

  But nothing different. I can't force a tag.

  3. Then I tried to change tags into:

      Field('tags','list:reference tag',
          requires =
  IS_IN_DB(db,'tag.id',db.tag._format,multiple=True),),

  This is the so-called default constraint, according to the book,
  chapter 6.
  But situation gets worse. Now I get error ticket whenever submitting
  new product.

  4. I even tried:

      requires = [IS_NOT_EMPTY(), IS_IN_DB(...)]

  still tickets.

  Problem persists in both web2py 1.95.1 and 1.97.1, on Windows.

  Did I miss something really obvious? Thanks in advance.

  Regards,
  Ray (a.k.a. Iceberg)


[web2py] Re: FORM questions

2011-07-23 Thread Anthony
On Saturday, July 23, 2011 1:33:09 PM UTC-4, Kenneth wrote: 

  3) Instead of creating a custom layout for this form I d like to add the
  field in the controller with something like:
  form.element('table').insert(2,TR('label',INPUT(_name='name'))), but how
  do I add a SELECT with many OPTIONS? The f_extra field drop-down is
  created from two different tables auth_user and t_extra_fields. I guess
  I should use query auth_user and t_extra_fields and then create a list.
  That list is used to create the drop-down.
 Is this a FORM or  SQLFORM. In the latter case you need a custom
 widget. In the former case you can do 

 SELECT(*[OPTION(value) for value in ],**dict(value='default'))

Note, since the additional field being added is _not_ associated with the 
database table (if I understand correctly), then I think this method should 
work even for a SQLFORM, as per 
http://web2py.com/book/default/chapter/07#Adding-extra-form-elements-to-SQLFORM
.
 
Anthony
 



[web2py] Re: export data to OOO and Excel

2011-07-23 Thread cyber
Say Dave, is xlwt included into current w2p version? Or I need to add
the library by myself?



On 22 июл, 05:05, Dave davidramsayreinh...@gmail.com wrote:
 I added these two lines and its working now!

     response.headers['Content-Disposition']='attachment;
 filename=test.xls'
     response.headers['Content-Title']='test.xls'

 Dave

 On Jul 21, 4:48 pm, Dave davidramsayreinh...@gmail.com wrote:







  I added it to default.py controller, so it is working as an action
  there.

  When i go to that URL  (.../default/excel_report), the file downloads
  as excel_report with no extension.  I am testing using Mac OS, so
  not sure if that matters.  The file is fine.  When i rename it with
  the .xls extension it opens in my spreadsheet application.

  Thanks,
  Dave

  On Jul 21, 1:51 pm, Joaquin Orbe joaquino...@gmail.com wrote:

   On Thu, Jul 21, 2011 at 3:40 PM, Dave davidramsayreinh...@gmail.com 
   wrote:
This works great, but when i download the file it is missing the 
extension.
Is there an easy way to add '.xls' to the file name?

Thanks,
Dave

   Hi Dave,
   how do you download the file? This method is an action in one controller, 
   ie:

  http://127.0.0.1:8000/myapp/printer/excel_report

   and the file is downloaded as XLS.

   Joaco.


[web2py] Search Form Help

2011-07-23 Thread Ismael Serratos
Hi everybody!! How could I make a google like in web2py, I mean I have:


db.define_table('article',
Field('site', db.site),
Field('section',db.section),
Field('date,'datetime'),
Field('author','string'),
Field('header','string'),
Field('body','text'))

and I like to have a google like form (I need it to be customizable via
CSS), so the user can search any word that is in article.header and
article.body.


Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Ross Peoples
That thought had occurred to me about mobile phones vs tablets, but I didn't 
want to get too complex with this right away. However, you are correct that 
many sites have an iPhone/mobile site, and iPad site, and a desktop site. I 
think I'll try to expand my patch to replace request.is_mobile with 
request.browser_class, which could equal 'desktop', 'mobile', or 'tablet'. A 
request from an iPad would first check for 'tablet' views, then 'mobile' 
views, and finally 'desktop' views. How does that sound?

As for the directory structure, I suppose we could do something like this:

views/
_mobile/
default/
other_controller/
_tablet/
default/
other_controller/
default/
other_controller/

Or even put the devices into an main '_devices' folder:

views/
_devices/
_mobile/
...
_tablet/
...
default/
other_controller/

The only issue I'm having with this is with the layouts. In order for this 
to work with byte compile, I actually had to turn the layout.html file into 
this:

{{if is_mobile:}}
!-- All mobile HTML --
{{else:}}
!-- rest of original layout.html file --
{{pass}}

I tried breaking it into desktop.html and mobile.html, then in layout.html:
{{if is_mobile:}}
{{include 'mobile.html'}}
{{else:}}
{{include 'desktop.html'}}
{{pass}}

Unfortunately, in the desktop.html or mobile.html, the {{include}} line that 
includes the view content is ignored, so I had to put everything into a 
single layout.html file.


[web2py] Re: SSL Email Support patch

2011-07-23 Thread Eric Vicenti
The SMTP protocol can be encrypted at a low level with either TLS or
SSL. It depends on the SMTP server. Most hosts will offer one or both,
and they should tell you, as well as the corresponding port (typically
465 or 587 for secured connections). If you are configured with TLS or
no security when you should be using SSL, web2py requests will take a
few minutes and eventually the server will report a message send
failure.

Further reading:
http://en.wikipedia.org/wiki/SMTPS

-Eric

On Jul 23, 7:59 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Jul 23, 2011, at 12:30 AM, Eric Vicenti wrote:

  I was having difficulties sending from web2py, when I realized there
  is no SSL encryption support. Since this is already built into
  smtplib, it was a simple addition. I should mention this wont work on
  GAE, and I have not comprehensively tested it.

 Under what circumstances would you use ssl vs tis?









  diff -r 800e086037d9 gluon/tools.py
  --- a/gluon/tools.py       Sat Jul 23 01:47:05 2011 -0500
  +++ b/gluon/tools.py       Sat Jul 23 00:17:49 2011 -0700
  @@ -206,6 +206,7 @@
          settings.sender = sender
          settings.login = login
          settings.tls = tls
  +        settings.ssl = False
          settings.cipher_type = None
          settings.sign = True
          settings.sign_passphrase = None
  @@ -569,8 +570,11 @@
                      result =
  mail.send_mail(sender=self.settings.sender, to=origTo,
                                              subject=subject,
  body=text, **xcc)
              else:
  -                server =
  smtplib.SMTP(*self.settings.server.split(':'))
  -                if self.settings.tls:
  +                if self.settings.ssl:
  +                    server =
  smtplib.SMTP_SSL(*self.settings.server.split(':'))
  +                else:
  +                    server =
  smtplib.SMTP(*self.settings.server.split(':'))
  +                if self.settings.tls and not self.settings.ssl:
                      server.ehlo()
                      server.starttls()
                      server.ehlo()

  To use, simply set mail.settings.ssl = True


Re: [web2py] Re: SSL Email Support patch

2011-07-23 Thread David Ford
STARTTLS is the negotiated protocol of SSL.  it's a method of establishing the 
connection using plain text, becoming aware that the server supports an 
encrypted layer and then initiating an SSL session.  plain SSL is the dumb, 
or blind, approach to smtps.  failure to negotiate SSL via protocol means a 
possibly lengthy session timeout with no clear explanation why the session 
failed.

why to use SSL rather than TLS?  generally any server that supports plain SSL 
should also support TLS.  there are corner cases.  while rare, it's nice to be 
able to say yep, we got that covered too.

-david

On 07/23/11 16:02, Eric Vicenti wrote:
 The SMTP protocol can be encrypted at a low level with either TLS or
 SSL. It depends on the SMTP server. Most hosts will offer one or both,
 and they should tell you, as well as the corresponding port (typically
 465 or 587 for secured connections). If you are configured with TLS or
 no security when you should be using SSL, web2py requests will take a
 few minutes and eventually the server will report a message send
 failure.

 Further reading:
 http://en.wikipedia.org/wiki/SMTPS

 -Eric

 On Jul 23, 7:59 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Jul 23, 2011, at 12:30 AM, Eric Vicenti wrote:

 I was having difficulties sending from web2py, when I realized there
 is no SSL encryption support. Since this is already built into
 smtplib, it was a simple addition. I should mention this wont work on
 GAE, and I have not comprehensively tested it.
 Under what circumstances would you use ssl vs tis?



[web2py] Re: Search Form Help

2011-07-23 Thread Web2Py Beginner :S
 Hey there ,

 You can use it like this but you need to build the Css for the
textbox of the search :

def search():
 ajax search
 return
dict(form=FORM(INPUT(_id='keyword',_class=textbox,_name='keyword',
  _onkeyup=ajax('bg_find', ['keyword'], 'target');)),
  target_div=DIV(_id='target'))


default/show.html :

{{extend 'layout.html'}}
h1Search wiki pages/h1
[ {{=A('listall', _href=URL('index'))}}]br /
{{=form}}br /{{=target_div}}

...

 /*CSS FOR THE ELEMENT WITH THE TEXTBOX CLASS*/
.textbox
{
width:50px;
highet:20px;
color:red;
.
.
.
.
}





[web2py] Re: Search Form Help

2011-07-23 Thread Web2Py Freak
OR if You Want YOU can Check this search plugin
http://www.web2pyslices.com/slices/take_slice/115


[web2py] Re: How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread mart
so, cpdb.py runs on its own (no need to invoque with web2py.py).

this is the short version of its usage:

usage: cpdb.py [-h] -f SOURCEFOLDER -F TARGETFOLDER -y
  SOURCECONNECTIONSTRING -Y TARGETCONNECTIONSTRING
  [-a AUTOIMPORT] -d DAL [-t {True,False}] [-b TABLES]
  [-c CLEAN]



you can something like:

$ python cpdb.py -f ./blueLite/db_storage -F ./blueLite/blueP4 -y
sqlite://storage.sqlite -Y sqlite://storage2.sqlite -d ./blueLite/
pyUtils/sql/blueSQL


-f points to the folder of the source DB
-F points t0 the folder of the target DB (which doen't exist yet)
-y the source connection string
-Y the target connection string
-d points to the folder where dal.py lives (like .../gluon

-a is set to True by default

warning:
-c will delete the source db  tables!
-t will truncate all tables

i use this within scripts pn a daily basis and all works for me.
Please try it this way and let me know if you still have issues (i
have not tested from sqLite to postgres, but if the connection string
is correct and everything to connect to postgres is on the system then
all should work well)

Mart :)

On Jul 23, 4:43 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Mart wrote it.Let's wait for his opinion first. ;-)

 On Jul 23, 3:26 am, Kenneth Lundström kenneth.t.lundst...@gmail.com
 wrote:







  I guess we have to wait for maybe Massimo to look into this.

  Kenneth

  Hi Kenneth, Yes both the connection strings work in db.py which I too
  find very puzzling. On Jul 23, 12:24 pm, Kenneth Lundstr m

  kenneth.t.lundst...@gmail.com wrote:
   It sounds like web2py is not able to open either the sqlite file or
   postgres database. Have you tried to use both connection strings in a
   model file to test that both works?

   Kenneth

   I am having a hard time migrating data from sqlite to postgres
   This is the command that I use
   ./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
   sqlite://applications/testapp/databases/storage.sqlite -y 'sqlite://
   applications/testapp/databases/storage.sqlite'  -Y 'postgres://
   puser:ppass@localhost/testdb'
   It says
   web2py Web Framework
   Created by Massimo Di Pierro, Copyright 2007-2011
   Version 1.97.1 (2011-06-26 19:25:44)
   Database drivers available: SQLite3, pymysql, PostgreSQL
   EXCEPTION: could not make a copy of the database
   Failure to connect, tried 5 times:
   unable to open database file
   Any idea how to make this work?


[web2py] Re: SSL Email Support patch

2011-07-23 Thread Eric Vicenti
I would prefer TLS as well, but for some reason GoDaddy Email doesn't
support it. For all technical purposes, though, it shouldn't matter.

On Jul 23, 1:14 pm, David Ford da...@blue-labs.org wrote:
 STARTTLS is the negotiated protocol of SSL.  it's a method of establishing 
 the connection using plain text, becoming aware that the server supports an 
 encrypted layer and then initiating an SSL session.  plain SSL is the dumb, 
 or blind, approach to smtps.  failure to negotiate SSL via protocol means a 
 possibly lengthy session timeout with no clear explanation why the session 
 failed.

 why to use SSL rather than TLS?  generally any server that supports plain SSL 
 should also support TLS.  there are corner cases.  while rare, it's nice to 
 be able to say yep, we got that covered too.

 -david

 On 07/23/11 16:02, Eric Vicenti wrote:







  The SMTP protocol can be encrypted at a low level with either TLS or
  SSL. It depends on the SMTP server. Most hosts will offer one or both,
  and they should tell you, as well as the corresponding port (typically
  465 or 587 for secured connections). If you are configured with TLS or
  no security when you should be using SSL, web2py requests will take a
  few minutes and eventually the server will report a message send
  failure.

  Further reading:
 http://en.wikipedia.org/wiki/SMTPS

  -Eric

  On Jul 23, 7:59 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Jul 23, 2011, at 12:30 AM, Eric Vicenti wrote:

  I was having difficulties sending from web2py, when I realized there
  is no SSL encryption support. Since this is already built into
  smtplib, it was a simple addition. I should mention this wont work on
  GAE, and I have not comprehensively tested it.
  Under what circumstances would you use ssl vs tis?


[web2py] Re: How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread mart
addendum:

when it has run successfully, you should see an output similar to this
in you shell:

dalPath: /Users/mart/aptanaApps/src/blueLite/pyUtils/sql/blueSQL
db.tables: ['affectedFile', 'archive', 'auth_cas', 'auth_event',
'auth_group', 'auth_membership', 'auth_permission', 'auth_user',
'buildData', 'buildLogger', 'buildProperties', 'changes', 'clean',
'cmdObjects', 'commonTags', 'compile', 'createdArchive',
'cumulativeProperties', 'data', 'deliver', 'deliveryFileset',
'environment', 'ether', 'exceptionLogger', 'ftp', 'ftpGet',
'issuekeys', 'jiraIssue', 'local_history', 'local_user', 'mail',
'p4Properties', 'p4Views', 'package', 'plugin_wiki_attachment',
'plugin_wiki_comment', 'plugin_wiki_link', 'plugin_wiki_page',
'plugin_wiki_page_archive', 'plugin_wiki_tag', 'Q', 'scriptCompiler',
'searchAndReplace', 'sjsCompile', 'status', 'sync']
folder exists: /Users/mart/aptanaApps/src/blueLite/db_storage
creating tables...
exporting data...
importing data...
done!
Attention: do not run this program again or you end up with duplicate
records

On Jul 23, 4:58 pm, mart msenecal...@gmail.com wrote:
 so, cpdb.py runs on its own (no need to invoque with web2py.py).

 this is the short version of its usage:

 usage: cpdb.py [-h] -f SOURCEFOLDER -F TARGETFOLDER -y
                   SOURCECONNECTIONSTRING -Y TARGETCONNECTIONSTRING
                   [-a AUTOIMPORT] -d DAL [-t {True,False}] [-b TABLES]
                   [-c CLEAN]

 you can something like:

 $ python cpdb.py -f ./blueLite/db_storage -F ./blueLite/blueP4 -y
 sqlite://storage.sqlite -Y sqlite://storage2.sqlite -d ./blueLite/
 pyUtils/sql/blueSQL

 -f points to the folder of the source DB
 -F points t0 the folder of the target DB (which doen't exist yet)
 -y the source connection string
 -Y the target connection string
 -d points to the folder where dal.py lives (like .../gluon

 -a is set to True by default

 warning:
 -c will delete the source db  tables!
 -t will truncate all tables

 i use this within scripts pn a daily basis and all works for me.
 Please try it this way and let me know if you still have issues (i
 have not tested from sqLite to postgres, but if the connection string
 is correct and everything to connect to postgres is on the system then
 all should work well)

 Mart :)

 On Jul 23, 4:43 am, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  Mart wrote it.Let's wait for his opinion first. ;-)

  On Jul 23, 3:26 am, Kenneth Lundström kenneth.t.lundst...@gmail.com
  wrote:

   I guess we have to wait for maybe Massimo to look into this.

   Kenneth

   Hi Kenneth, Yes both the connection strings work in db.py which I too
   find very puzzling. On Jul 23, 12:24 pm, Kenneth Lundstr m

   kenneth.t.lundst...@gmail.com wrote:
It sounds like web2py is not able to open either the sqlite file or
postgres database. Have you tried to use both connection strings in a
model file to test that both works?

Kenneth

I am having a hard time migrating data from sqlite to postgres
This is the command that I use
./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
sqlite://applications/testapp/databases/storage.sqlite -y 'sqlite://
applications/testapp/databases/storage.sqlite'  -Y 'postgres://
puser:ppass@localhost/testdb'
It says
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.97.1 (2011-06-26 19:25:44)
Database drivers available: SQLite3, pymysql, PostgreSQL
EXCEPTION: could not make a copy of the database
Failure to connect, tried 5 times:
unable to open database file
Any idea how to make this work?


Re: [web2py] Re: SSL Email Support patch

2011-07-23 Thread Jonathan Lundell
On Jul 23, 2011, at 1:59 PM, Eric Vicenti wrote:

 I would prefer TLS as well, but for some reason GoDaddy Email doesn't
 support it. For all technical purposes, though, it shouldn't matter.

That works for me, as long as there's a reason for it being there.

 
 On Jul 23, 1:14 pm, David Ford da...@blue-labs.org wrote:
 STARTTLS is the negotiated protocol of SSL.  it's a method of establishing 
 the connection using plain text, becoming aware that the server supports an 
 encrypted layer and then initiating an SSL session.  plain SSL is the 
 dumb, or blind, approach to smtps.  failure to negotiate SSL via protocol 
 means a possibly lengthy session timeout with no clear explanation why the 
 session failed.
 
 why to use SSL rather than TLS?  generally any server that supports plain 
 SSL should also support TLS.  there are corner cases.  while rare, it's nice 
 to be able to say yep, we got that covered too.
 
 -david
 
 On 07/23/11 16:02, Eric Vicenti wrote:
 
 
 
 
 
 
 
 The SMTP protocol can be encrypted at a low level with either TLS or
 SSL. It depends on the SMTP server. Most hosts will offer one or both,
 and they should tell you, as well as the corresponding port (typically
 465 or 587 for secured connections). If you are configured with TLS or
 no security when you should be using SSL, web2py requests will take a
 few minutes and eventually the server will report a message send
 failure.
 
 Further reading:
 http://en.wikipedia.org/wiki/SMTPS
 
 -Eric
 
 On Jul 23, 7:59 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Jul 23, 2011, at 12:30 AM, Eric Vicenti wrote:
 
 I was having difficulties sending from web2py, when I realized there
 is no SSL encryption support. Since this is already built into
 smtplib, it was a simple addition. I should mention this wont work on
 GAE, and I have not comprehensively tested it.
 Under what circumstances would you use ssl vs tis?



[web2py] Re: Running web2py on Jython

2011-07-23 Thread Richard
Hi Chris,

I for one am glad that you reanimated this thread :-)

Your findings probably led to hg commit #2119 which has the commit
comment possible __builtin__ fix for jython, thanks Chris Clark.
This raised some hopes, but the current hg tip still doesn't work on
Jython yet (at least for me). It needs more love still. Hopefully the
situation will improve soon.

Regards,
Richard


On 20 Jul., 01:12, Chris Clark chris.cl...@ingres.com wrote:
 Apologies for reanimating this old thread but I too just triedJython
 with the current web2py version too :-)



[web2py] Re: How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread mart
yet another addendum:

to me cpdb.py is just a skeleton, it will copy a DB and all that good
stuff, but you can add to it for quick access to tables @ from
something like a bash shell...

as an example, i have a variation on this that uses urllib2 to
download full DB's, connects to it and a python console is started in
my bash shell that can make use of the 'db' object. So, i can
immediately start using the object db.

i.e. $ print db(db.myTable.name=='a_name').select().last().value
 myField_value

or, i added some helpers to quickly display entire tables in a nice
and readable format (i can do: -table tableName fields=id,name,value
file=./myFile.txt

dal @ the cmd line is a wonderful thing! :)
Mart :)


On Jul 23, 5:03 pm, mart msenecal...@gmail.com wrote:
 addendum:

 when it has run successfully, you should see an output similar to this
 in you shell:

 dalPath: /Users/mart/aptanaApps/src/blueLite/pyUtils/sql/blueSQL
 db.tables: ['affectedFile', 'archive', 'auth_cas', 'auth_event',
 'auth_group', 'auth_membership', 'auth_permission', 'auth_user',
 'buildData', 'buildLogger', 'buildProperties', 'changes', 'clean',
 'cmdObjects', 'commonTags', 'compile', 'createdArchive',
 'cumulativeProperties', 'data', 'deliver', 'deliveryFileset',
 'environment', 'ether', 'exceptionLogger', 'ftp', 'ftpGet',
 'issuekeys', 'jiraIssue', 'local_history', 'local_user', 'mail',
 'p4Properties', 'p4Views', 'package', 'plugin_wiki_attachment',
 'plugin_wiki_comment', 'plugin_wiki_link', 'plugin_wiki_page',
 'plugin_wiki_page_archive', 'plugin_wiki_tag', 'Q', 'scriptCompiler',
 'searchAndReplace', 'sjsCompile', 'status', 'sync']
 folder exists: /Users/mart/aptanaApps/src/blueLite/db_storage
 creating tables...
 exporting data...
 importing data...
 done!
 Attention: do not run this program again or you end up with duplicate
 records

 On Jul 23, 4:58 pm, mart msenecal...@gmail.com wrote:







  so, cpdb.py runs on its own (no need to invoque with web2py.py).

  this is the short version of its usage:

  usage: cpdb.py [-h] -f SOURCEFOLDER -F TARGETFOLDER -y
                    SOURCECONNECTIONSTRING -Y TARGETCONNECTIONSTRING
                    [-a AUTOIMPORT] -d DAL [-t {True,False}] [-b TABLES]
                    [-c CLEAN]

  you can something like:

  $ python cpdb.py -f ./blueLite/db_storage -F ./blueLite/blueP4 -y
  sqlite://storage.sqlite -Y sqlite://storage2.sqlite -d ./blueLite/
  pyUtils/sql/blueSQL

  -f points to the folder of the source DB
  -F points t0 the folder of the target DB (which doen't exist yet)
  -y the source connection string
  -Y the target connection string
  -d points to the folder where dal.py lives (like .../gluon

  -a is set to True by default

  warning:
  -c will delete the source db  tables!
  -t will truncate all tables

  i use this within scripts pn a daily basis and all works for me.
  Please try it this way and let me know if you still have issues (i
  have not tested from sqLite to postgres, but if the connection string
  is correct and everything to connect to postgres is on the system then
  all should work well)

  Mart :)

  On Jul 23, 4:43 am, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:

   Mart wrote it.Let's wait for his opinion first. ;-)

   On Jul 23, 3:26 am, Kenneth Lundström kenneth.t.lundst...@gmail.com
   wrote:

I guess we have to wait for maybe Massimo to look into this.

Kenneth

Hi Kenneth, Yes both the connection strings work in db.py which I too
find very puzzling. On Jul 23, 12:24 pm, Kenneth Lundstr m

kenneth.t.lundst...@gmail.com wrote:
 It sounds like web2py is not able to open either the sqlite file or
 postgres database. Have you tried to use both connection strings in a
 model file to test that both works?

 Kenneth

 I am having a hard time migrating data from sqlite to postgres
 This is the command that I use
 ./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
 sqlite://applications/testapp/databases/storage.sqlite -y 'sqlite://
 applications/testapp/databases/storage.sqlite'  -Y 'postgres://
 puser:ppass@localhost/testdb'
 It says
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2011
 Version 1.97.1 (2011-06-26 19:25:44)
 Database drivers available: SQLite3, pymysql, PostgreSQL
 EXCEPTION: could not make a copy of the database
 Failure to connect, tried 5 times:
 unable to open database file
 Any idea how to make this work?


Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Jonathan Lundell
On Jul 23, 2011, at 12:36 PM, Ross Peoples wrote:

 That thought had occurred to me about mobile phones vs tablets, but I didn't 
 want to get too complex with this right away. However, you are correct that 
 many sites have an iPhone/mobile site, and iPad site, and a desktop site. I 
 think I'll try to expand my patch to replace request.is_mobile with 
 request.browser_class, which could equal 'desktop', 'mobile', or 'tablet'. A 
 request from an iPad would first check for 'tablet' views, then 'mobile' 
 views, and finally 'desktop' views. How does that sound?
 
 As for the directory structure, I suppose we could do something like this:

At this stage I don't have enough of a sense of what structure makes the most 
sense, so my comments aren't that well informed. 

Might it make sense for the mobile/ c subdirectories to live inside each 
controller directory instead? Probably not, but I'm not sure of the reasons. 

I also wonder if it might make sense to default to the appropriate top-level 
view if a particular mobile view isn't available. 

 
 views/
 _mobile/
 default/
 other_controller/
 _tablet/
 default/
 other_controller/
 default/
 other_controller/
 
 Or even put the devices into an main '_devices' folder:
 
 views/
 _devices/
 _mobile/
 ...
 _tablet/
 ...
 default/
 other_controller/
 
 The only issue I'm having with this is with the layouts. In order for this to 
 work with byte compile, I actually had to turn the layout.html file into this:
 
 {{if is_mobile:}}
 !-- All mobile HTML --
 {{else:}}
 !-- rest of original layout.html file --
 {{pass}}
 
 I tried breaking it into desktop.html and mobile.html, then in layout.html:
 {{if is_mobile:}}
 {{include 'mobile.html'}}
 {{else:}}
 {{include 'desktop.html'}}
 {{pass}}
 
 Unfortunately, in the desktop.html or mobile.html, the {{include}} line that 
 includes the view content is ignored, so I had to put everything into a 
 single layout.html file.

I'm out of my depth here. Perhaps Massimo or someone else could comment on what 
makes most sense here.

Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Kenneth Lundström

When I first read about subdirectories I saw this structure:

views/default/index.html
views/default/mobile/index.html
views/default/tablet/index.html

If no mobile/tablet directory or index.html is found it defaults to 
/views/default/index.html



Kenneth


On Jul 23, 2011, at 12:36 PM, Ross Peoples wrote:


That thought had occurred to me about mobile phones vs tablets, but I didn't 
want to get too complex with this right away. However, you are correct that 
many sites have an iPhone/mobile site, and iPad site, and a desktop site. I 
think I'll try to expand my patch to replace request.is_mobile with 
request.browser_class, which could equal 'desktop', 'mobile', or 'tablet'. A 
request from an iPad would first check for 'tablet' views, then 'mobile' views, 
and finally 'desktop' views. How does that sound?

As for the directory structure, I suppose we could do something like this:

At this stage I don't have enough of a sense of what structure makes the most 
sense, so my comments aren't that well informed.

Might it make sense for the mobile/c subdirectories to live inside each 
controller directory instead? Probably not, but I'm not sure of the reasons.

I also wonder if it might make sense to default to the appropriate top-level 
view if a particular mobile view isn't available.


views/
 _mobile/
 default/
 other_controller/
 _tablet/
 default/
 other_controller/
 default/
 other_controller/

Or even put the devices into an main '_devices' folder:

views/
 _devices/
 _mobile/
 ...
 _tablet/
 ...
 default/
 other_controller/

The only issue I'm having with this is with the layouts. In order for this to 
work with byte compile, I actually had to turn the layout.html file into this:

{{if is_mobile:}}
 !-- All mobile HTML --
{{else:}}
 !-- rest of original layout.html file --
{{pass}}

I tried breaking it into desktop.html and mobile.html, then in layout.html:
{{if is_mobile:}}
 {{include 'mobile.html'}}
{{else:}}
 {{include 'desktop.html'}}
{{pass}}

Unfortunately, in the desktop.html or mobile.html, the {{include}} line that 
includes the view content is ignored, so I had to put everything into a single 
layout.html file.

I'm out of my depth here. Perhaps Massimo or someone else could comment on what 
makes most sense here.




Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Ross Peoples
Not sure about which directory structure works best, but as for falling 
back, it tries to go to the most specific device first, then will fallback 
to the desktop html if not found. So an iPad will go to the tablet, if 
there's no view for that, should it fall back to mobile, or to desktop?

That and figuring out the best directory structure for this would be a good 
idea. I guess we'd have to get more opinions on the matter. Maybe Massimo 
has a preference? :)


Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Anthony
Developers will probably want to take a variety of approaches to handling 
mobile vs. desktop, so we should probably be careful about being too 
opinionated here and only offering one inflexible approach. For some of this 
stuff, it might make more sense to offer some recipes and/or a plug-in 
rather than, for example, hard-coding directory structures or mobile browser 
lists into the framework. Perhaps we should only make changes to the 
framework to handle things that cannot be handled at the application level 
(e.g., bytecode compilation issues with conditional layouts) or that are 
likely to be useful under a variety of approaches to multi-layout sites.
 
Anthony

On Saturday, July 23, 2011 5:43:30 PM UTC-4, Ross Peoples wrote:

 Not sure about which directory structure works best, but as for falling 
 back, it tries to go to the most specific device first, then will fallback 
 to the desktop html if not found. So an iPad will go to the tablet, if 
 there's no view for that, should it fall back to mobile, or to desktop? 

 That and figuring out the best directory structure for this would be a good 
 idea. I guess we'd have to get more opinions on the matter. Maybe Massimo 
 has a preference? :)



Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread Jonathan Lundell
On Jul 23, 2011, at 3:20 PM, Anthony wrote:

 Developers will probably want to take a variety of approaches to handling 
 mobile vs. desktop, so we should probably be careful about being too 
 opinionated here and only offering one inflexible approach. For some of this 
 stuff, it might make more sense to offer some recipes and/or a plug-in rather 
 than, for example, hard-coding directory structures or mobile browser lists 
 into the framework. Perhaps we should only make changes to the framework to 
 handle things that cannot be handled at the application level (e.g., bytecode 
 compilation issues with conditional layouts) or that are likely to be useful 
 under a variety of approaches to multi-layout sites.

That makes sense. I could see some hooks for implementing a local policy, in a 
very general way.

This general approach could be useful for other stuff as well. I might have a 
kiosk view, for example. And while I might have generic phone and tablet views, 
I might also have specialized iPhone and iPad views, just because they're 
dominant and perhaps worth the extra effort. The point is that these are 
individual decisions.

  
 Anthony
 
 On Saturday, July 23, 2011 5:43:30 PM UTC-4, Ross Peoples wrote:
 Not sure about which directory structure works best, but as for falling back, 
 it tries to go to the most specific device first, then will fallback to the 
 desktop html if not found. So an iPad will go to the tablet, if there's no 
 view for that, should it fall back to mobile, or to desktop?
 
 That and figuring out the best directory structure for this would be a good 
 idea. I guess we'd have to get more opinions on the matter. Maybe Massimo has 
 a preference? :)



[web2py] Re: export data to OOO and Excel

2011-07-23 Thread Alexandre Augusto
cyber,

You can download it from here:
http://www.python-excel.org/

If you are using ubuntu linux distribution you can install it like this:

sudo apt-get install python-xlwt


[web2py] Re: FORM questions

2011-07-23 Thread Kenneth Lundström

Thank you Massimo for your answers.

I can´t get the onvalidation to work.

My code looks like this:

def check(form):
if ((form.vars.f_internal != 0 and form.vars.f_customer != None) or 
(form.vars.f_internal == 0 and form.vars.f_customer == None)):

form.errors.f_customer = a and b cannot be both empty or selected

@auth.requires_login()
def create_receipt():

from decimal import *
..

if form_item.accepts(request.vars, session, onvalidation=lambda 
form_item: check(form_item), formname='receipt_item'):


this results in an error ticket:

Traceback (most recent call last):
  File /web2py/gluon/restricted.py, line 191, in restricted
ccode = compile2(code,layer)
  File /web2py/gluon/restricted.py, line 178, in compile2
return compile(code.rstrip().replace('\r\n','\n')+'\n', layer, 'exec')
SyntaxError: import * is not allowed in function 'create_receipt' 
because it is contains a nested function with free variables 
(receipt.py, line 8)


This line 8 is the from decimal import * line shown in the example.


Kenneth

As I guess Massimo wanted to post these answers to the list and not 
only to me, I´ll forward his answers here.


On Jul 23, 10:19 am, Kenneth Lundströmkenneth.t.lundst...@gmail.com
wrote:


I m creating a form with SQLFORM that includes 6 fields.

One field is f_customer with requires IS_IN_DB()

Now I'd like to add a new field not taken directly from database. Lets
call it f_extra.

f_customer is a drop-down and f_extra would also be a drop-down. Now I
have a list of questions.

1) Is it possible to get the form.accepts to validate that either
f_customer or f_extra is selected. Both can t be selected and both can t
be empty? I remember seeing this discussed on the list not long ago, but
could not find it.

2) If 1) is not possible then I guess I have to put dbio=False and do
the validation manually. How do I show the error message the same way
web2py does?

yes

def check(form):
if (form.vars.a and form.vars.b) or (not form.vars.a and not
form.vars.b):
form.errors.b = a and b cannot be both empty or selected
form.accepts(...,onvalidation=lambda form: check(form))



3) Instead of creating a custom layout for this form I d like to add the
field in the controller with something like:
form.element('table').insert(2,TR('label',INPUT(_name='name'))), but how
do I add a SELECT with many OPTIONS? The f_extra field drop-down is
created from two different tables auth_user and t_extra_fields. I guess
I should use query auth_user and t_extra_fields and then create a list.
That list is used to create the drop-down.

Is this a FORM or  SQLFORM. In the latter case you need a custom
widget. In the former case you can do

SELECT(*[OPTION(value) for value in ],**dict(value='default'))



4) When using the OPTION helper is it possible to have a different value
of the option then what is shown?

OPTION('shown value',_value='hidden value')








[web2py] Re: How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread mart
oh... i just remembered, we can also use it from the web2py/scripts
dir and use the 'default' paths (i think)... let me get back with
this...

On Jul 23, 5:15 pm, mart msenecal...@gmail.com wrote:
 yet another addendum:

 to me cpdb.py is just a skeleton, it will copy a DB and all that good
 stuff, but you can add to it for quick access to tables @ from
 something like a bash shell...

 as an example, i have a variation on this that uses urllib2 to
 download full DB's, connects to it and a python console is started in
 my bash shell that can make use of the 'db' object. So, i can
 immediately start using the object db.

 i.e. $ print db(db.myTable.name=='a_name').select().last().value

  myField_value

 or, i added some helpers to quickly display entire tables in a nice
 and readable format (i can do: -table tableName fields=id,name,value
 file=./myFile.txt

 dal @ the cmd line is a wonderful thing! :)
 Mart :)

 On Jul 23, 5:03 pm, mart msenecal...@gmail.com wrote:







  addendum:

  when it has run successfully, you should see an output similar to this
  in you shell:

  dalPath: /Users/mart/aptanaApps/src/blueLite/pyUtils/sql/blueSQL
  db.tables: ['affectedFile', 'archive', 'auth_cas', 'auth_event',
  'auth_group', 'auth_membership', 'auth_permission', 'auth_user',
  'buildData', 'buildLogger', 'buildProperties', 'changes', 'clean',
  'cmdObjects', 'commonTags', 'compile', 'createdArchive',
  'cumulativeProperties', 'data', 'deliver', 'deliveryFileset',
  'environment', 'ether', 'exceptionLogger', 'ftp', 'ftpGet',
  'issuekeys', 'jiraIssue', 'local_history', 'local_user', 'mail',
  'p4Properties', 'p4Views', 'package', 'plugin_wiki_attachment',
  'plugin_wiki_comment', 'plugin_wiki_link', 'plugin_wiki_page',
  'plugin_wiki_page_archive', 'plugin_wiki_tag', 'Q', 'scriptCompiler',
  'searchAndReplace', 'sjsCompile', 'status', 'sync']
  folder exists: /Users/mart/aptanaApps/src/blueLite/db_storage
  creating tables...
  exporting data...
  importing data...
  done!
  Attention: do not run this program again or you end up with duplicate
  records

  On Jul 23, 4:58 pm, mart msenecal...@gmail.com wrote:

   so, cpdb.py runs on its own (no need to invoque with web2py.py).

   this is the short version of its usage:

   usage: cpdb.py [-h] -f SOURCEFOLDER -F TARGETFOLDER -y
                     SOURCECONNECTIONSTRING -Y TARGETCONNECTIONSTRING
                     [-a AUTOIMPORT] -d DAL [-t {True,False}] [-b TABLES]
                     [-c CLEAN]

   you can something like:

   $ python cpdb.py -f ./blueLite/db_storage -F ./blueLite/blueP4 -y
   sqlite://storage.sqlite -Y sqlite://storage2.sqlite -d ./blueLite/
   pyUtils/sql/blueSQL

   -f points to the folder of the source DB
   -F points t0 the folder of the target DB (which doen't exist yet)
   -y the source connection string
   -Y the target connection string
   -d points to the folder where dal.py lives (like .../gluon

   -a is set to True by default

   warning:
   -c will delete the source db  tables!
   -t will truncate all tables

   i use this within scripts pn a daily basis and all works for me.
   Please try it this way and let me know if you still have issues (i
   have not tested from sqLite to postgres, but if the connection string
   is correct and everything to connect to postgres is on the system then
   all should work well)

   Mart :)

   On Jul 23, 4:43 am, Massimo Di Pierro massimo.dipie...@gmail.com
   wrote:

Mart wrote it.Let's wait for his opinion first. ;-)

On Jul 23, 3:26 am, Kenneth Lundström kenneth.t.lundst...@gmail.com
wrote:

 I guess we have to wait for maybe Massimo to look into this.

 Kenneth

 Hi Kenneth, Yes both the connection strings work in db.py which I too
 find very puzzling. On Jul 23, 12:24 pm, Kenneth Lundstr m

 kenneth.t.lundst...@gmail.com wrote:
  It sounds like web2py is not able to open either the sqlite file or
  postgres database. Have you tried to use both connection strings 
  in a
  model file to test that both works?

  Kenneth

  I am having a hard time migrating data from sqlite to postgres
  This is the command that I use
  ./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
  sqlite://applications/testapp/databases/storage.sqlite -y 
  'sqlite://
  applications/testapp/databases/storage.sqlite'  -Y 'postgres://
  puser:ppass@localhost/testdb'
  It says
  web2py Web Framework
  Created by Massimo Di Pierro, Copyright 2007-2011
  Version 1.97.1 (2011-06-26 19:25:44)
  Database drivers available: SQLite3, pymysql, PostgreSQL
  EXCEPTION: could not make a copy of the database
  Failure to connect, tried 5 times:
  unable to open database file
  Any idea how to make this work?


[web2py] Re: FORM questions

2011-07-23 Thread Anthony
That's an issue with your Python code. You should either move the import 
outside the function or only import specific objects from the Decimal module 
(which is probably a better idea -- from module import * is usually not 
recommended).
 
Anthony

On Saturday, July 23, 2011 6:57:54 PM UTC-4, Kenneth wrote:

 Thank you Massimo for your answers. 

 I can�t get the onvalidation to work. 

 My code looks like this: 

 def check(form):
  if ((form.vars.f_internal != 0 and form.vars.f_customer != None) or 
 (form.vars.f_internal == 0 and form.vars.f_customer == None)):
  form.errors.f_customer = a and b cannot be both empty or 
 selected 

 @auth.requires_login()
 def create_receipt(): 

  from decimal import *
 .. 

  if form_item.accepts(request.vars, session, onvalidation=lambda 
 form_item: check(form_item), formname='receipt_item'): 

 this results in an error ticket: 

 Traceback (most recent call last):
File /web2py/gluon/restricted.py, line 191, in restricted
  ccode = compile2(code,layer)
File /web2py/gluon/restricted.py, line 178, in compile2
  return compile(code.rstrip().replace('\r\n','\n')+'\n', layer, 'exec')
 SyntaxError: import * is not allowed in function 'create_receipt' 
 because it is contains a nested function with free variables 
 (receipt.py, line 8) 

 This line 8 is the from decimal import * line shown in the example. 


 Kenneth 

  As I guess Massimo wanted to post these answers to the list and not 
  only to me, I�ll forward his answers here.
 
  On Jul 23, 10:19 am, Kenneth Lundstr�mkenneth.t...@gmail.com
  wrote:
 
  I m creating a form with SQLFORM that includes 6 fields.
 
  One field is f_customer with requires IS_IN_DB()
 
  Now I'd like to add a new field not taken directly from database. Lets
  call it f_extra.
 
  f_customer is a drop-down and f_extra would also be a drop-down. Now I
  have a list of questions.
 
  1) Is it possible to get the form.accepts to validate that either
  f_customer or f_extra is selected. Both can t be selected and both can t
  be empty? I remember seeing this discussed on the list not long ago, but
  could not find it.
 
  2) If 1) is not possible then I guess I have to put dbio=False and do
  the validation manually. How do I show the error message the same way
  web2py does?
  yes
 
  def check(form):
  if (form.vars.a and form.vars.b) or (not form.vars.a and not
  form.vars.b):
  form.errors.b = a and b cannot be both empty or selected
  form.accepts(...,onvalidation=lambda form: check(form))
 
 
  3) Instead of creating a custom layout for this form I d like to add the
  field in the controller with something like:
  form.element('table').insert(2,TR('label',INPUT(_name='name'))), but how
  do I add a SELECT with many OPTIONS? The f_extra field drop-down is
  created from two different tables auth_user and t_extra_fields. I guess
  I should use query auth_user and t_extra_fields and then create a list.
  That list is used to create the drop-down.
  Is this a FORM or  SQLFORM. In the latter case you need a custom
  widget. In the former case you can do
 
  SELECT(*[OPTION(value) for value in ],**dict(value='default'))
 
 
  4) When using the OPTION helper is it possible to have a different value
  of the option then what is shown?
  OPTION('shown value',_value='hidden value')
 
 
 
  

 

Re: [web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-23 Thread pbreit
I'm a bit with Anthony. I don't yet see a big role for the framework. I 
don't think selectively creating mobile versions of certain views is that 
common a pattern and is easily accomplished with an if-then in the view.

[web2py] Re: How to use the new cpdb.py introduced in 1.97.1?

2011-07-23 Thread mart
if you cd to your web2py/scripts directory and run something like:

python cpdb.py -f ./applications/welcome/databases -F ./dbTest -y
sqlite://storage.sqlite -Y sqlite://storage2.sqlite -d ../gluon, it
should work...

my source db has migrate=False, i think that is a must, but Massimo
can confirm that.

Mart :)

On Jul 23, 6:59 pm, mart msenecal...@gmail.com wrote:
 oh... i just remembered, we can also use it from the web2py/scripts
 dir and use the 'default' paths (i think)... let me get back with
 this...

 On Jul 23, 5:15 pm, mart msenecal...@gmail.com wrote:







  yet another addendum:

  to me cpdb.py is just a skeleton, it will copy a DB and all that good
  stuff, but you can add to it for quick access to tables @ from
  something like a bash shell...

  as an example, i have a variation on this that uses urllib2 to
  download full DB's, connects to it and a python console is started in
  my bash shell that can make use of the 'db' object. So, i can
  immediately start using the object db.

  i.e. $ print db(db.myTable.name=='a_name').select().last().value

   myField_value

  or, i added some helpers to quickly display entire tables in a nice
  and readable format (i can do: -table tableName fields=id,name,value
  file=./myFile.txt

  dal @ the cmd line is a wonderful thing! :)
  Mart :)

  On Jul 23, 5:03 pm, mart msenecal...@gmail.com wrote:

   addendum:

   when it has run successfully, you should see an output similar to this
   in you shell:

   dalPath: /Users/mart/aptanaApps/src/blueLite/pyUtils/sql/blueSQL
   db.tables: ['affectedFile', 'archive', 'auth_cas', 'auth_event',
   'auth_group', 'auth_membership', 'auth_permission', 'auth_user',
   'buildData', 'buildLogger', 'buildProperties', 'changes', 'clean',
   'cmdObjects', 'commonTags', 'compile', 'createdArchive',
   'cumulativeProperties', 'data', 'deliver', 'deliveryFileset',
   'environment', 'ether', 'exceptionLogger', 'ftp', 'ftpGet',
   'issuekeys', 'jiraIssue', 'local_history', 'local_user', 'mail',
   'p4Properties', 'p4Views', 'package', 'plugin_wiki_attachment',
   'plugin_wiki_comment', 'plugin_wiki_link', 'plugin_wiki_page',
   'plugin_wiki_page_archive', 'plugin_wiki_tag', 'Q', 'scriptCompiler',
   'searchAndReplace', 'sjsCompile', 'status', 'sync']
   folder exists: /Users/mart/aptanaApps/src/blueLite/db_storage
   creating tables...
   exporting data...
   importing data...
   done!
   Attention: do not run this program again or you end up with duplicate
   records

   On Jul 23, 4:58 pm, mart msenecal...@gmail.com wrote:

so, cpdb.py runs on its own (no need to invoque with web2py.py).

this is the short version of its usage:

usage: cpdb.py [-h] -f SOURCEFOLDER -F TARGETFOLDER -y
                  SOURCECONNECTIONSTRING -Y TARGETCONNECTIONSTRING
                  [-a AUTOIMPORT] -d DAL [-t {True,False}] [-b TABLES]
                  [-c CLEAN]

you can something like:

$ python cpdb.py -f ./blueLite/db_storage -F ./blueLite/blueP4 -y
sqlite://storage.sqlite -Y sqlite://storage2.sqlite -d ./blueLite/
pyUtils/sql/blueSQL

-f points to the folder of the source DB
-F points t0 the folder of the target DB (which doen't exist yet)
-y the source connection string
-Y the target connection string
-d points to the folder where dal.py lives (like .../gluon

-a is set to True by default

warning:
-c will delete the source db  tables!
-t will truncate all tables

i use this within scripts pn a daily basis and all works for me.
Please try it this way and let me know if you still have issues (i
have not tested from sqLite to postgres, but if the connection string
is correct and everything to connect to postgres is on the system then
all should work well)

Mart :)

On Jul 23, 4:43 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:

 Mart wrote it.Let's wait for his opinion first. ;-)

 On Jul 23, 3:26 am, Kenneth Lundström kenneth.t.lundst...@gmail.com
 wrote:

  I guess we have to wait for maybe Massimo to look into this.

  Kenneth

  Hi Kenneth, Yes both the connection strings work in db.py which I 
  too
  find very puzzling. On Jul 23, 12:24 pm, Kenneth Lundstr m

  kenneth.t.lundst...@gmail.com wrote:
   It sounds like web2py is not able to open either the sqlite file 
   or
   postgres database. Have you tried to use both connection strings 
   in a
   model file to test that both works?

   Kenneth

   I am having a hard time migrating data from sqlite to postgres
   This is the command that I use
   ./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
   sqlite://applications/testapp/databases/storage.sqlite -y 
   'sqlite://
   applications/testapp/databases/storage.sqlite'  -Y 'postgres://
   puser:ppass@localhost/testdb'
   It says
   web2py Web Framework
   Created by Massimo Di Pierro, Copyright 2007-2011

Re: [web2py] web2py videos on the internet

2011-07-23 Thread Miguel Lopes
Cool!

On Fri, Jul 22, 2011 at 3:24 PM, Bruno Rocha rochacbr...@gmail.com wrote:

 I have some (in portuguese)

 web2py + Ipython ( IDE for what?)
 http://vimeo.com/26387038

 Comet
 http://vimeo.com/18399381

 PowerTable
 http://vimeo.com/18447603

 Uploadify
 http://vimeo.com/20107460

 I am also recording new videos(which will be subtitled)

 There are more videos from brazilian people

 This is the web2oy channel on VIMEO - http://vimeo.com/channels/139244 the
 same content as listed in http://web2py.com/examples/default/videos



 2011/7/22 António Ramos ramstei...@gmail.com

 Sorry all post lately but its pertinent ( i think... :)


 all videos that i found in the internet are made by massimo(99,99%).

 Great videos but i think that with a lot of people using and loving web2py
 there shoud be videos from other users experience.


 Maximo could stimulate his students to post videos of web2py in the
 internet.



 It seems that only Massimo cares about videos...

 As a brilliant guy that he is he should be woking on more important
 things.


 IMO


 Best regards

 António




 --



 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]
 [ Aprenda a programar: http://CursoDePython.com.br ]
 [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
 [ Consultoria em desenvolvimento web: http://www.blouweb.com ]




Re: [web2py] Re: CRON or Background script?

2011-07-23 Thread Ismael Serratos
Thank you ron_m!!! That worked more than fine!


On Wed, Jul 20, 2011 at 11:16 AM, ron_m ron.mco...@gmail.com wrote:

 Run 2 copies of web2py, one for the script and the other for the web site.
 If the database is SQLite you will end up with blocking problems if the
 background task takes too long.



Re: [web2py] Re: Search Form Help

2011-07-23 Thread Ismael Serratos
I´m working with the wiki example like this

return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
_onkeyup=ajax('bg_find', ['keyword'], 'target');)),
target_div=DIV(_id='target'))

def bg_find():

pattern = '%' + request.vars.keyword.lower() + '%'

pages = db(db.articulo.body.lower().like(pattern)
).select(orderby=db.article.date)

items = [A(row.header, _href=URL('show', args=row.id)) for row in pages]

return UL(*items).xml()

And is working fine, but could I mix two queries in pages I mean, like this:

pages = db((db.article.body.lower().like(pattern)) |
(db.article.header.lower.like(pattern)) ).select(orderby=db.article.date)

??

I've tried but the example just stops workin (no error)


On Sat, Jul 23, 2011 at 3:37 PM, Web2Py Freak halna...@gardeniatelco.comwrote:

 OR if You Want YOU can Check this search plugin
 http://www.web2pyslices.com/slices/take_slice/115


Re: [web2py] Re: Search Form Help

2011-07-23 Thread Ismael Serratos
Solved, wrong syntax xD

Another doubt is there a way to generate the results like google, I mean UL
of headers and for each header a short preview of the article?

On Sat, Jul 23, 2011 at 8:38 PM, Ismael Serratos ialejandr...@gmail.comwrote:

 I´m working with the wiki example like this

 return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
 _onkeyup=ajax('bg_find', ['keyword'], 'target');)),
 target_div=DIV(_id='target'))

 def bg_find():

 pattern = '%' + request.vars.keyword.lower() + '%'

 pages = db(db.articulo.body.lower().like(pattern)
 ).select(orderby=db.article.date)

 items = [A(row.header, _href=URL('show', args=row.id)) for row in
 pages]

 return UL(*items).xml()

 And is working fine, but could I mix two queries in pages I mean, like
 this:

 pages = db((db.article.body.lower().like(pattern)) |
 (db.article.header.lower.like(pattern)) ).select(orderby=db.article.date)

 ??

 I've tried but the example just stops workin (no error)



 On Sat, Jul 23, 2011 at 3:37 PM, Web2Py Freak 
 halna...@gardeniatelco.comwrote:

 OR if You Want YOU can Check this search plugin
 http://www.web2pyslices.com/slices/take_slice/115





[web2py] Re: Search Form Help

2011-07-23 Thread Web2Py Freak
Can you please show it to me  .. i may need it ..


Re: [web2py] Re: The web2py grid/crud plugin you've always dreamed about!

2011-07-23 Thread Bruno Rocha
On Sat, Jul 23, 2011 at 2:34 AM, tomt tom_tren...@yahoo.com wrote:

 DatabaseError: malformed database schema (comments) - near by:


Hi Tom, I just tested it and works normally with latest web2py from download
link, I am using Ubuntu 11.04 and Python 2.7.

It seens to be a problem in auth.requires_membership, try to removeor
comment this line from default.py and see if it works.

Another thing is trying to run the plugin in a fresh new app, just follow
the template code used in the example app.

I am writing the documentation to be online by the end of this week.

Thanks..


Re: [web2py] Re: The web2py grid/crud plugin you've always dreamed about!

2011-07-23 Thread Bruno Rocha
On Sat, Jul 23, 2011 at 3:13 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 should this be included in web2py/contrib?


Would be very nice if it can go to contrib, but wait it to left beta
version, I am doing a lot of tests and writing a better docs.

as it uses model and controller, I will need to create some helper methods,
but it will be easy to implement in contrib.

I am running a test application which uses PowerGrid in place of SQLTABLE in
appadmin.py. works great to admin database records.

I guess I can provide an appadmin2.py


Re: [web2py] Re: The web2py grid/crud plugin you've always dreamed about!

2011-07-23 Thread Bruno Rocha
On Sat, Jul 23, 2011 at 1:22 PM, mr.freeze nfre...@gmail.com wrote:

 Fantastic! I modified the WebGrid slice to recommend using this
 instead. Great work.



Nice, thanks!

But, this is in beta, some things can crash, and webgrid works with more
datasources, PowerGrid is working only with Table and Query by default.
Anyone can create a custom json callback but I want to implement other
options very soon.

I think there is a place for all grid plugins.

tks.

Bruno


Re: [web2py] Re: The web2py grid/crud plugin you've always dreamed about!

2011-07-23 Thread Bruno Rocha
On Sat, Jul 23, 2011 at 8:23 AM, Martín Mulone mulone.mar...@gmail.comwrote:

 Very nice and have a lot of examples. I'm rewriting powerpack, to come in a
 few weeks in version 2.0. Do you want to include in it also as an example?


Hi Martin, of course it will be nice to have it included in your app. just
wait me to do more tests and solve some issues.

I am implementing PDF and EXCEL exports feature, and still needs to be
tested in GAE.


Re: [web2py] Re: Search Form Help

2011-07-23 Thread Anthony
On Saturday, July 23, 2011 9:47:26 PM UTC-4, Ialejandro wrote: 

 Solved, wrong syntax xD

 Another doubt is there a way to generate the results like google, I mean UL 
 of headers and for each header a short preview of the article?

 
If you want to do true full text search, you might consider a dedicated full 
text search server. PostgreSQL (
http://www.postgresql.org/docs/8.3/static/textsearch.html) and SQLite (
http://www.sqlite.org/fts3.html) both include full text search capabilities. 
Whoosh (https://bitbucket.org/mchaput/whoosh/wiki/Home) is a standalone 
Python search engine. Other (non-Python) options are Sphinx, Solr, Xapian, 
and Elastic Search. Another option is a hosted search service like IndexTank 
(http://indextank.com/).
 
Anthony


[web2py] wiki 1st question: problem with an anchor

2011-07-23 Thread Martin Weissenboeck
Hi,

I have written a text page abc with web2py wiki containing a label [[a]].
There are two links in default/index.html:

   - a href=http://127.0.0.1:8000/test/plugin_wiki/page/abc#a;Link 1/a

   - {{=A('Link 2',_href=URL('test','plugin_wiki','page',args=['abc#a']))}}

Link 1 opens http://127.0.0.1:8000/test/plugin_wiki/page/abc*#*a; and works
fine.
Link 2 tries http://127.0.0.1:8000/test/plugin_wiki/page/abc*%23*a; and the
result is *invalid request*.
Web2py does not like %23 instead of # as a part an url?

Any ideas?
Regards, Martin


[web2py] wiki 2nd question: multilingual

2011-07-23 Thread Martin Weissenboeck
Hi,

what is the best way to write multilingual help pages using the wiki?

Regards Martin