[web2py] Best Method to implement a like button

2012-09-11 Thread pbreit
Check out:
http://web2py.com/books/default/chapter/29/11#Voting-and-rating

-- 





[web2py] [OT] Ubuntu 12.10 will no longer ship with Python 2

2012-09-11 Thread pbreit
Well...for starters, web2py, fabric and pil are 2.7. So, yes, I think it is an 
absolutely, insanely user-hostile decision. The python ecosystem is not even 
close to ready to move to 3. And from what I can tell, 3 offers minimal 
benefits.

-- 





[web2py] postgres getting better and better....

2012-09-11 Thread Niphlod
Happy september with the 9.2 release for everybody

http://wiki.postgresql.org/wiki/What%27s_new_in_PostgreSQL_9.2

http://www.postgresql.org/about/news/1415/

-- 





[web2py] Re: How do I incorporate git into my web2py workflow?

2012-09-11 Thread pbreit
I use Mercurial but should be basically the same.

First, hg clone web2py somewhere on your hardrive.

Then in /applications, create a new app (I usually copy welcome).

Then cd into the new app directory and git init.

Now your app will be version controlled.

I host some of my projects on Bitbucket (similar to Github but private 
projects are free). In that case, I might create the project on Bitbucket 
and then hg clone it to my hard drive.

I don't use any of the git/hg features built in to Web2py.


On Saturday, September 8, 2012 11:23:46 AM UTC-7, Pystar wrote:

 I actually meant having a git repository on your local development machine 
 not pushing to github or something similar. How do you use git and web2py? 

 On Friday, September 7, 2012 11:46:13 PM UTC+1, Massimo Di Pierro wrote:

 One of the new features is that in admin you can use a git url to install 
 a web2py directly from github. You can also push 
 an app to github. All of this requires python-git.

 We are working on adding better git/hg features.




 On Friday, 7 September 2012 17:24:42 UTC-5, Pystar wrote:

 I would like to know how coders here incorporate git or any other VCS 
 into their coding workflow with web2py?
 Thanks



-- 





[web2py] bug in 2.0.8

2012-09-11 Thread Matt
Hi there,

First off thanks for all of the fantastic work putting 2.0 together. 
Looking forward to trying the new features.

I've just upgraded from 1.99.7 - 2.0.8 and I've discovered a serious bug 
which has resulted in the loss of my data.

[I'm using both GAE with CloudSQL and dal(migrate_enabled = True)]

The automatically created image_blob references for GAE fields like:

Field('image', 'upload', required = True, length = 100)

Have vanished and with them the data contained in the image_blob fields.

It seems to have happened fairly randomly i.e. some tables are fine but 
others are affected. Out of about 6 tables using uploads only two still 
have the extra blob columns.

I've had some of these table definitions around for a long time and they 
haven't changed. Whereas some others have been edited more recently.

Any help or suggestions would be appreciated. Happy to give mere 
information if possible.

Thanks in advance,
Matt

BTW: Also had this problem occur prior to the above:

 self.db.executesql(CREATE TABLE IF NOT EXISTS web2py_filesystem (path 
VARCHAR(512), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;)
  File /Projects/www/gluon/dal.py, line 7234, in executesql
adapter.execute(query)
  File /Projects/www/gluon/dal.py, line 4002, in execute
return self.log_execute(a.decode('utf8'))
  File /Projects/www/gluon/dal.py, line 1653, in log_execute
ret = self.cursor.execute(*a, **b)
  File /Library/Python/2.7/site-packages/MySQLdb/cursors.py, line 174, in 
execute
  File /Library/Python/2.7/site-packages/MySQLdb/connections.py, line 36, 
in defaulterrorhandler
OperationalError: (1071, 'Specified key was too long; max key length is 767 
bytes')

Temporary fix was to change from True to False.

class DatabaseStoredFile:

web2py_filesystem = True

(I did already have the web2py_filesystem table of course)

-- 





[web2py] Re: Web2py. for a minimalist app, it feels bloated. Do it I need it?

2012-09-11 Thread pbreit
It sounds like you know enough about these things to figure out if Web2py 
is too bloated for you. My sense is that even if you think it might be 
bloated, the extraneous stuff really doesn't get in the way too much. Not 
using DAL means you are missing out on one of the core features. Building a 
REST API should be fine either using what Web2py gives you out of the bos 
or rolling your own. You can either build multiple Web2py apps or build 
some web2py apps and some other apps. DAL doesn't really support NoSQL much 
at this point so you're on your own there. I've used Web2py to build a POS 
system and it works great.



On Saturday, September 8, 2012 12:39:26 AM UTC-7, luckysmack wrote:

 I am somewhat new to python, and * shock * have an idea for a simple app I 
 want to build. To start the app will be relatively light weight, but if it 
 works out in my grand scheme could be far more complex.but the core will be 
 fairly simple. something an experienced python dev could probably whip up 
 in bottle in a few days. 

 The core will a simply be an advanced rest based api. The other half dozen 
 or so apps will all be built of this core. The either apps will likely be 
 built as a cms like system to manage each other. And as different as a POS 
 in store program. 

 So as many cool things as I thing web2py has, do you guys think its the 
 right system? I know w2p can do great APIs easily. But for that simple 
 aspect, I don't need a milti-application admin interface, or a code editor, 
 and I may not even use DAL. (For my project I may actually use something 
 like neo4j/orientdb/titan. Not sure yet. Might use mongodb as instead). So 
 for that simple part, all the other stuff seems a little bloated to me. 
 Stuff that I won't need.

 Sure as a whole, all the apps will be built into somewhat of a cms (which 
 I would like to build anyways), for that I'm not sure I would need the 
 web2py admin part. As a cms I would probably have my own interface, even 
 for the admins. How or would web2py admin ui fit in. I know you guys are 
 biased towards web2py, but does it sound like it would be a right fit? Or 
 would it be too complex? In comparison, I feel django is too bloated as 
 well since I would be doing a similar thing, except it would be done quite 
 a bit differently. The core of how it works doesn't seem to fit my ideas. 

 If I don't use web2py, the next best things I see as a starting point are 
 pyramid, or bottle/flask or even wheezy looks pretty cool. 

 What do you guys think? The core great api would be the crux of the other 
 apps. This core is what talks to the db. And each if the apps with build on 
 it. The rest part will be made so they can all communicate with each other 
 based on the URL. 

 The either individual apps, were they to be on their own, I can totally 
 see as a web2py app. So I'm curious how this idea as a whole, would fit 
 into web2py. If it can. Since there are a handful of web2py featured I 
 won't even use. I don't need them to be auto imported if I'm not using them 
 (since I can't see what's being imported). So in a way it feels like bloat. 
 A reason I don't like django. 

 What do you guys think? Any input is greatly appreciated.


-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread martzi
Thanks for the reply. I have tried it, ondelete=CASCADE worked, but the 
referenced table seems to be accepting multiple entries ... one-to-many 
relation. Are there ways to prevent this from occurring ? 

On Monday, September 10, 2012 2:43:55 PM UTC+2, Massimo Di Pierro wrote:

 Field('','reference other_table',ondelete='CASCADE')

 this is actually the default. Is this what you are asking?

 On Monday, 10 September 2012 05:45:28 UTC-5, martzi wrote:

 Hi,
 I wonder if there a way to enforce a one to one relationship with Cascade 
 via web2py  DAL API. ???



-- 





Re: [web2py] Re: internal error crash with newest 2.0.6 and old 1.99.2

2012-09-11 Thread lucas
ok, maybe some progress.  i removed any instances of psycopg2 from my 
computer and web2py by default was and is not forced to use only the 
contrib/pg8000 driver.  i think i would rather use that one anyway.  when i 
changed the pool_size from the default 0 to 16, the initial 
ticket/exception above stopped being logged.  so i was under the impression 
that all was good again, but then my users have still been having logging 
in, but this time it tells them it is an unrecoverable error and when i try 
to see the ticket on their computer after this message, i can't pull 
anything up.  so now i can not trace the problem and the users still have 
infrequent times the site is crashing unrecoverably.  when i look into the 
ticket logs i only get a bunch of these:

Traceback (most recent call last):
  File /opt/web-apps/web2py/gluon/restricted.py, line 209, in restricted
exec ccode in environment
  File /opt/web-apps/web2py/applications/admin/controllers/default.py 
https://weinstruct.org/admin/default/edit/admin/controllers/default.py, line 
1726, in module
  File /opt/web-apps/web2py/gluon/globals.py, line 185, in lambda
self._caller = lambda f: f()
  File /opt/web-apps/web2py/applications/admin/controllers/default.py 
https://weinstruct.org/admin/default/edit/admin/controllers/default.py, line 
1548, in ticket
e.load(request, app, ticket)
  File /opt/web-apps/web2py/gluon/restricted.py, line 168, in load
d = ticket_storage.load(request, app, ticket_id)
  File /opt/web-apps/web2py/gluon/restricted.py, line 96, in load
return cPickle.load(ef)
EOFError

but i am not sure what this means because it looks internal to web2py.  i have 
upgraded to 2.0.8 a few days ago; so i am up to date.

so i am still having trouble finding if it is the postgresql-9.1, the pg8000 
driver, web2py, the DAL, my code, my views, i just don't know.  pretty 
frustrating.  lucas


-- 





[web2py] BeautifulSoup parsers when in web2py

2012-09-11 Thread lcamara
Hey,

My application is using a module that depends on BeautifulSoup which I have 
in the application modules folders along with my module, I have installed 
html5lib on my system as it's a very permissive parser. When I run the 
module directly from the console I get:

registring HTMLParserTreeBuilder
registring HTML5TreeBuilder

But when I run the module by calling it's functions inside my web2py I get:

registring HTMLParserTreeBuilder

This results in me getting the wanted results when calling from the console 
and wrong results when calling from web2py as it is not using the html5lib 
parser.

html5lib is installed on my ms windows python installation and should be 
available for all python applications.

Is there a reason why web2py fails to import it?

I'm running web2py 2.0.8 from source, in windows 7 and using python 2.7.3

Thanks,
Leo

-- 





[web2py] HTML truncate

2012-09-11 Thread Pepe Araya
Hello,

I need to truncate a field that contains HTML content. 

Now i'm using htmltruncate https://github.com/eentzel/htmltruncate.py in 
a controller that return a SQLFORM.smartgrid and it works perfect:
 
def noticias():

db.noticias.cuerpo.represent = lambda field,row: 
XML(htmltruncate.truncate(field, 100))
grid = SQLFORM.smartgrid(db.noticias, 
linked_tables=['adjuntos_noticia'])

return dict(grid =grid)


But when I try to implement a in a controller in this way:

def index():
db.publicaciones.descripcion.represent = lambda field, row: 
XML(htmltruncate.truncate(field, 10))
tipo_3 = db(db.publicaciones.tipo == 3).select().last()

return dict(tipo_3 = tipo_3)


It doesn't work


The module is inside the modules folder of the app and it's imported via:
import htmltruncate


any help is welcome!

Best!

-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread villas
I may be wrong,  but I do not think Cascade could assist you with enforcing 
a 1-1 relationship. 
Maybe making the foreign key field unique would help?


On Monday, September 10, 2012 11:45:28 AM UTC+1, martzi wrote:

 Hi,
 I wonder if there a way to enforce a one to one relationship with Cascade 
 via web2py  DAL API. ???


-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread martzi
Thanks for the reply. But if you meant Field('','reference 
other_table', unique=True), I have tried that with failure, i am still 
having a one-to-many relation. FYI: Regarding CASCADE, an  ondelete cascade 
causes deletion of all referred data.

On Tuesday, September 11, 2012 1:37:59 PM UTC+2, villas wrote:

 I may be wrong,  but I do not think Cascade could assist you with 
 enforcing a 1-1 relationship. 
 Maybe making the foreign key field unique would help?


 On Monday, September 10, 2012 11:45:28 AM UTC+1, martzi wrote:

 Hi,
 I wonder if there a way to enforce a one to one relationship with Cascade 
 via web2py  DAL API. ???



-- 





[web2py] Re: Best Method to implement a like button

2012-09-11 Thread villas
How about:  in 'likes' make a unique composite index of both fields 
(created at DB level).  Try to insert a record.  If it fails (because of 
the index) then delete instead.


On Monday, September 10, 2012 11:58:03 PM UTC+1, Mark Li wrote:

 I have 3 datatables as follows:


 db.define_table('songs',
 Field('songname'),
 format='%(songname)s')

 db.define_table('likes',
 Field('username', 'reference auth_user'),
 Field('songname', 'reference songs'))

 with the 3rd table being db.auth_user

 I would like to implement a like button, where clicking it adds an entry 
 to the intermediate table 'likes'. For example, if User1 likes Song1, it 
 would perform the following:
 db.likes.insert(username=auth.user.id, songname=1)



 Right now I have the like button as the following in the view: 
 {{=A('like me', callback=URL('add_like'))}}

 and the function as:
 def add_like():
 db.likes.insert(username=auth.user.id, songname=1)

 The problem I'm having is that a user should only be allowed to 'like' a 
 song once; if the user has already liked the song, clicking on 'like' again 
 should remove that like. Basically a toggle functionality for the 'like' 
 button.

 I'm not sure how to implement the last part, as it seems checking the 
 entire database for the existence of that record on every 'like' click is 
 overkill. Is there an eloquent way (minimal database calls) to go about 
 implementing this toggle functionality for a 'like' button?







-- 





[web2py] Re: BeautifulSoup parsers when in web2py

2012-09-11 Thread lcamara
Nevermind I found the solution. I needed to make imports relative in 
beautifulsoup _html5lib.py builder.

for instanc:.
from bs4.element import NamespacedAttribute
changed to:
from ..element import NamespacedAttribute

I guess this is what you get when you simply copy paste modules into the 
folder.

Terça-feira, 11 de Setembro de 2012 12:19:53 UTC+1, lcamara escreveu:

 Hey,

 My application is using a module that depends on BeautifulSoup which I 
 have in the application modules folders along with my module, I have 
 installed html5lib on my system as it's a very permissive parser. When I 
 run the module directly from the console I get:

 registring HTMLParserTreeBuilder
 registring HTML5TreeBuilder

 But when I run the module by calling it's functions inside my web2py I get:
 
 registring HTMLParserTreeBuilder

 This results in me getting the wanted results when calling from the 
 console and wrong results when calling from web2py as it is not using the 
 html5lib parser.

 html5lib is installed on my ms windows python installation and should be 
 available for all python applications.

 Is there a reason why web2py fails to import it?

 I'm running web2py 2.0.8 from source, in windows 7 and using python 2.7.3

 Thanks,
 Leo


-- 





[web2py] Remember to delete examples application or become a spam farm

2012-09-11 Thread Web2py Mostly Newbie
Just a short note to say traffic on one of my websites had gone through the 
roof recently.  It turns out that I hadn't removed the examples directory 
from web2py and spammers were using the example applications to upload 
comment spam. 

Cheers

Brendan 

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Alan Etkin
On Thursday, September 6, 2012 9:34:51 AM UTC-3, Massimo Di Pierro wrote:

 Please open a ticket and this will be easy to fix. 


Opened the ticket:

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

Now it was closed with status fixed, but:

-AFAIK, fileld.writable still has no effect in computed fields. You cannot 
set a computed field as writable with crud so it shows the widget. You can 
with SQLFORM (by using the fields argument), however, entering blank inputs 
don't trigger the compute function server side.
-There's no modification of SQLFORM to process empty form fields as 
computable (in replacement of a previous or new record value)*
-SQLFORM doesn't set computed fields as empty on form creation (I think 
this should be the default behavior)*

* Perhaps it would be necessary to add different checks by field type and a 
standard way of detecting a blank input in each case.

Of course, it's possible to show a given widget and do further record 
processing in the controller without depending on the computed field 
facility, but with this changes, it would save that extra code and give a 
more clean and web2py like interface.

-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread villas
I am quite familiar with cascade;  I just couldn't figure out how it could 
assist you.

In my opinion,  Field('','reference other_table', unique=True)  should 
be supported and work.  Maybe you added the constraint later and the DB 
didn't accept it because you already had duplicated field contents.

In any case,  even if unique=True is not working for the moment,  then a 
work-around would be to make a unique index on the field yourself.  You'll 
have to handle exceptions when the insert/update fails due to duplicate 
keys.




On Tuesday, September 11, 2012 12:48:49 PM UTC+1, martzi wrote:

 Thanks for the reply. But if you meant Field('','reference 
 other_table', unique=True), I have tried that with failure, i am still 
 having a one-to-many relation. FYI: Regarding CASCADE, an  ondelete cascade 
 causes deletion of all referred data.

 On Tuesday, September 11, 2012 1:37:59 PM UTC+2, villas wrote:

 I may be wrong,  but I do not think Cascade could assist you with 
 enforcing a 1-1 relationship. 
 Maybe making the foreign key field unique would help?


 On Monday, September 10, 2012 11:45:28 AM UTC+1, martzi wrote:

 Hi,
 I wonder if there a way to enforce a one to one relationship with 
 Cascade via web2py  DAL API. ???



-- 





[web2py] Re: postgres getting better and better....

2012-09-11 Thread LightDot
Native JSON features look really interesting.

Basically, postgres can return a row or an array as JSON now. And validate 
JSON. Seems quite handy!

Regards,
Ales

On Tuesday, September 11, 2012 10:21:54 AM UTC+2, Niphlod wrote:

 Happy september with the 9.2 release for everybody

 http://wiki.postgresql.org/wiki/What%27s_new_in_PostgreSQL_9.2

 http://www.postgresql.org/about/news/1415/


-- 





[web2py] Re: HTML truncate

2012-09-11 Thread Massimo Di Pierro
What does it mean it does not work? Can you import it? Can you import it 
from python?

On Tuesday, 11 September 2012 00:55:03 UTC-5, Pepe Araya wrote:

 Hello,

 I need to truncate a field that contains HTML content. 

 Now i'm using htmltruncate https://github.com/eentzel/htmltruncate.py in 
 a controller that return a SQLFORM.smartgrid and it works perfect:
  
 def noticias():
 
 db.noticias.cuerpo.represent = lambda field,row: 
 XML(htmltruncate.truncate(field, 100))
 grid = SQLFORM.smartgrid(db.noticias, 
 linked_tables=['adjuntos_noticia'])

 return dict(grid =grid)


 But when I try to implement a in a controller in this way:

 def index():
 db.publicaciones.descripcion.represent = lambda field, row: 
 XML(htmltruncate.truncate(field, 10))
 tipo_3 = db(db.publicaciones.tipo == 3).select().last()

 return dict(tipo_3 = tipo_3)


 It doesn't work


 The module is inside the modules folder of the app and it's imported via:
 import htmltruncate


 any help is welcome!

 Best!


-- 





[web2py] Re: bug in 2.0.8

2012-09-11 Thread Massimo Di Pierro
Please open a ticket about this. You say the problem is on GAE but the 
ticket refers to MySQLdb. I assume these are two different systems.

On Tuesday, 11 September 2012 03:44:46 UTC-5, Matt wrote:

 Hi there,

 First off thanks for all of the fantastic work putting 2.0 together. 
 Looking forward to trying the new features.

 I've just upgraded from 1.99.7 - 2.0.8 and I've discovered a serious bug 
 which has resulted in the loss of my data.

 [I'm using both GAE with CloudSQL and dal(migrate_enabled = True)]

 The automatically created image_blob references for GAE fields like:

 Field('image', 'upload', required = True, length = 100)

 Have vanished and with them the data contained in the image_blob fields.

 It seems to have happened fairly randomly i.e. some tables are fine but 
 others are affected. Out of about 6 tables using uploads only two still 
 have the extra blob columns.

 I've had some of these table definitions around for a long time and they 
 haven't changed. Whereas some others have been edited more recently.

 Any help or suggestions would be appreciated. Happy to give mere 
 information if possible.

 Thanks in advance,
 Matt

 BTW: Also had this problem occur prior to the above:

  self.db.executesql(CREATE TABLE IF NOT EXISTS web2py_filesystem (path 
 VARCHAR(512), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;)
   File /Projects/www/gluon/dal.py, line 7234, in executesql
 adapter.execute(query)
   File /Projects/www/gluon/dal.py, line 4002, in execute
 return self.log_execute(a.decode('utf8'))
   File /Projects/www/gluon/dal.py, line 1653, in log_execute
 ret = self.cursor.execute(*a, **b)
   File /Library/Python/2.7/site-packages/MySQLdb/cursors.py, line 174, 
 in execute
   File /Library/Python/2.7/site-packages/MySQLdb/connections.py, line 
 36, in defaulterrorhandler
 OperationalError: (1071, 'Specified key was too long; max key length is 
 767 bytes')

 Temporary fix was to change from True to False.

 class DatabaseStoredFile:

 web2py_filesystem = True

 (I did already have the web2py_filesystem table of course)


-- 





[web2py] Re: Remember to delete examples application or become a spam farm

2012-09-11 Thread Massimo Di Pierro
The latest examples (2.0.x) should not have any DB at all for this reason.

On Tuesday, 11 September 2012 07:16:28 UTC-5, Web2py Mostly Newbie wrote:

 Just a short note to say traffic on one of my websites had gone through 
 the roof recently.  It turns out that I hadn't removed the examples 
 directory from web2py and spammers were using the example applications to 
 upload comment spam. 

 Cheers

 Brendan 


-- 





[web2py] Re: HTML truncate

2012-09-11 Thread Pepe Araya
Hi Massimo,

Sorry for my poor explanation.

What I don't get is in the view when i call the field value 
{{=tipo_3.descripcion}}  I get the whole text and not the truncated one 
like in the SQLFORM.grid case.




On Tuesday, September 11, 2012 9:32:18 AM UTC-3, Massimo Di Pierro wrote:

 What does it mean it does not work? Can you import it? Can you import it 
 from python?

 On Tuesday, 11 September 2012 00:55:03 UTC-5, Pepe Araya wrote:

 Hello,

 I need to truncate a field that contains HTML content. 

 Now i'm using htmltruncate https://github.com/eentzel/htmltruncate.py in 
 a controller that return a SQLFORM.smartgrid and it works perfect:
  
 def noticias():
 
 db.noticias.cuerpo.represent = lambda field,row: 
 XML(htmltruncate.truncate(field, 100))
 grid = SQLFORM.smartgrid(db.noticias, 
 linked_tables=['adjuntos_noticia'])

 return dict(grid =grid)


 But when I try to implement a in a controller in this way:

 def index():
 db.publicaciones.descripcion.represent = lambda field, row: 
 XML(htmltruncate.truncate(field, 10))
 tipo_3 = db(db.publicaciones.tipo == 3).select().last()

 return dict(tipo_3 = tipo_3)


 It doesn't work


 The module is inside the modules folder of the app and it's imported 
 via:
 import htmltruncate


 any help is welcome!

 Best!



-- 





[web2py] Re: postgres getting better and better....

2012-09-11 Thread Alan Etkin
Aren't dal Row and Rows classes capable of returning json also?

On Tuesday, September 11, 2012 9:28:52 AM UTC-3, LightDot wrote:

 Native JSON features look really interesting.

 Basically, postgres can return a row or an array as JSON now. And validate 
 JSON. Seems quite handy!

 Regards,
 Ales

 On Tuesday, September 11, 2012 10:21:54 AM UTC+2, Niphlod wrote:

 Happy september with the 9.2 release for everybody

 http://wiki.postgresql.org/wiki/What%27s_new_in_PostgreSQL_9.2

 http://www.postgresql.org/about/news/1415/



-- 





Re: [web2py] Re: Web2py. for a minimalist app, it feels bloated. Do it I need it?

2012-09-11 Thread Shawn McElroy
Well its starting to seem like a good fit. But yes I won't be using DAL,
since I'll be using orientdb. I know I lose something with that decision,
but its what I need. I'm also curious how people are using it here as well
with web2py.
On Sep 11, 2012 1:46 AM, pbreit pbreitenb...@gmail.com wrote:

 It sounds like you know enough about these things to figure out if Web2py
 is too bloated for you. My sense is that even if you think it might be
 bloated, the extraneous stuff really doesn't get in the way too much. Not
 using DAL means you are missing out on one of the core features. Building a
 REST API should be fine either using what Web2py gives you out of the bos
 or rolling your own. You can either build multiple Web2py apps or build
 some web2py apps and some other apps. DAL doesn't really support NoSQL much
 at this point so you're on your own there. I've used Web2py to build a POS
 system and it works great.



 On Saturday, September 8, 2012 12:39:26 AM UTC-7, luckysmack wrote:

 I am somewhat new to python, and * shock * have an idea for a simple app
 I want to build. To start the app will be relatively light weight, but if
 it works out in my grand scheme could be far more complex.but the core will
 be fairly simple. something an experienced python dev could probably whip
 up in bottle in a few days.

 The core will a simply be an advanced rest based api. The other half
 dozen or so apps will all be built of this core. The either apps will
 likely be built as a cms like system to manage each other. And as different
 as a POS in store program.

 So as many cool things as I thing web2py has, do you guys think its the
 right system? I know w2p can do great APIs easily. But for that simple
 aspect, I don't need a milti-application admin interface, or a code editor,
 and I may not even use DAL. (For my project I may actually use something
 like neo4j/orientdb/titan. Not sure yet. Might use mongodb as instead). So
 for that simple part, all the other stuff seems a little bloated to me.
 Stuff that I won't need.

 Sure as a whole, all the apps will be built into somewhat of a cms (which
 I would like to build anyways), for that I'm not sure I would need the
 web2py admin part. As a cms I would probably have my own interface, even
 for the admins. How or would web2py admin ui fit in. I know you guys are
 biased towards web2py, but does it sound like it would be a right fit? Or
 would it be too complex? In comparison, I feel django is too bloated as
 well since I would be doing a similar thing, except it would be done quite
 a bit differently. The core of how it works doesn't seem to fit my ideas.

 If I don't use web2py, the next best things I see as a starting point are
 pyramid, or bottle/flask or even wheezy looks pretty cool.

 What do you guys think? The core great api would be the crux of the other
 apps. This core is what talks to the db. And each if the apps with build on
 it. The rest part will be made so they can all communicate with each other
 based on the URL.

 The either individual apps, were they to be on their own, I can totally
 see as a web2py app. So I'm curious how this idea as a whole, would fit
 into web2py. If it can. Since there are a handful of web2py featured I
 won't even use. I don't need them to be auto imported if I'm not using them
 (since I can't see what's being imported). So in a way it feels like bloat.
 A reason I don't like django.

 What do you guys think? Any input is greatly appreciated.

  --





-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread martzi
Unique = True,  has probably no effect. see below.
...
 db = DAL('sqlite://storage.db')
 person = db.define_table('person', Field('name'))
 bodypart = db.define_table('bodypart', Field('name'), Field('owner', 
'reference person', unique=True)) #unique= True seems to have no effect
 pid = person.insert(name='Sid')
 bpid = bodypart.insert(name='arms', owner= pid) #pid = 1
 bodypart(bpid).owner #bpid = 1, first insertion of owner as 1
1
 bpid = bodypart.insert(name='mouth', owner= pid) # multiple entries not 
caught, pid is still 1
 bodypart(bpid).owner #bpid = 2, second insertion of owner as 1 AGAIN
1

On Tuesday, September 11, 2012 2:22:09 PM UTC+2, villas wrote:

 I am quite familiar with cascade;  I just couldn't figure out how it could 
 assist you.

 In my opinion,  Field('','reference other_table', unique=True)  should 
 be supported and work.  Maybe you added the constraint later and the DB 
 didn't accept it because you already had duplicated field contents.

 In any case,  even if unique=True is not working for the moment,  then a 
 work-around would be to make a unique index on the field yourself.  You'll 
 have to handle exceptions when the insert/update fails due to duplicate 
 keys.




 On Tuesday, September 11, 2012 12:48:49 PM UTC+1, martzi wrote:

 Thanks for the reply. But if you meant Field('','reference 
 other_table', unique=True), I have tried that with failure, i am still 
 having a one-to-many relation. FYI: Regarding CASCADE, an  ondelete cascade 
 causes deletion of all referred data.

 On Tuesday, September 11, 2012 1:37:59 PM UTC+2, villas wrote:

 I may be wrong,  but I do not think Cascade could assist you with 
 enforcing a 1-1 relationship. 
 Maybe making the foreign key field unique would help?


 On Monday, September 10, 2012 11:45:28 AM UTC+1, martzi wrote:

 Hi,
 I wonder if there a way to enforce a one to one relationship with 
 Cascade via web2py  DAL API. ???



-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread villas
I think it does have some effect.  
I suspect that your existing data may not be unique.  
See whether the following helps:

   - If using commandline,  try with db.commit() after.
   - Try with a new table.
   - Look in databases/sql.log and see whether the field was created with 
   UNIQUE.
   - Use a DB management tool to inspect your DB.



On Tuesday, September 11, 2012 2:23:16 PM UTC+1, martzi wrote:

 Unique = True,  has probably no effect. see below.
 ...
  db = DAL('sqlite://storage.db')
  person = db.define_table('person', Field('name'))
  bodypart = db.define_table('bodypart', Field('name'), Field('owner', 
 'reference person', unique=True)) #unique= True seems to have no effect
  pid = person.insert(name='Sid')
  bpid = bodypart.insert(name='arms', owner= pid) #pid = 1
  bodypart(bpid).owner #bpid = 1, first insertion of owner as 1
 1
  bpid = bodypart.insert(name='mouth', owner= pid) # multiple entries 
 not caught, pid is still 1
  bodypart(bpid).owner #bpid = 2, second insertion of owner as 1 AGAIN
 1

 On Tuesday, September 11, 2012 2:22:09 PM UTC+2, villas wrote:

 I am quite familiar with cascade;  I just couldn't figure out how it 
 could assist you.

 In my opinion,  Field('','reference other_table', unique=True)  
 should be supported and work.  Maybe you added the constraint later and the 
 DB didn't accept it because you already had duplicated field contents.

 In any case,  even if unique=True is not working for the moment,  then a 
 work-around would be to make a unique index on the field yourself.  You'll 
 have to handle exceptions when the insert/update fails due to duplicate 
 keys.




 On Tuesday, September 11, 2012 12:48:49 PM UTC+1, martzi wrote:

 Thanks for the reply. But if you meant Field('','reference 
 other_table', unique=True), I have tried that with failure, i am still 
 having a one-to-many relation. FYI: Regarding CASCADE, an  ondelete cascade 
 causes deletion of all referred data.

 On Tuesday, September 11, 2012 1:37:59 PM UTC+2, villas wrote:

 I may be wrong,  but I do not think Cascade could assist you with 
 enforcing a 1-1 relationship. 
 Maybe making the foreign key field unique would help?


 On Monday, September 10, 2012 11:45:28 AM UTC+1, martzi wrote:

 Hi,
 I wonder if there a way to enforce a one to one relationship with 
 Cascade via web2py  DAL API. ???



-- 





[web2py] Re: HTML truncate

2012-09-11 Thread villas
I end up doing something like this:

{{=db.publicaciones.descripcion.represent(=tipo_3.descripcion,tipo_3)}}

I hope that helps,  but maybe there is a better way?



On Tuesday, September 11, 2012 1:48:59 PM UTC+1, Pepe Araya wrote:

 Hi Massimo,

 Sorry for my poor explanation.

 What I don't get is in the view when i call the field value 
 {{=tipo_3.descripcion}}  I get the whole text and not the truncated one 
 like in the SQLFORM.grid case.




 On Tuesday, September 11, 2012 9:32:18 AM UTC-3, Massimo Di Pierro wrote:

 What does it mean it does not work? Can you import it? Can you import it 
 from python?

 On Tuesday, 11 September 2012 00:55:03 UTC-5, Pepe Araya wrote:

 Hello,

 I need to truncate a field that contains HTML content. 

 Now i'm using htmltruncate https://github.com/eentzel/htmltruncate.py in 
 a controller that return a SQLFORM.smartgrid and it works perfect:
  
 def noticias():
 
 db.noticias.cuerpo.represent = lambda field,row: 
 XML(htmltruncate.truncate(field, 100))
 grid = SQLFORM.smartgrid(db.noticias, 
 linked_tables=['adjuntos_noticia'])

 return dict(grid =grid)


 But when I try to implement a in a controller in this way:

 def index():
 db.publicaciones.descripcion.represent = lambda field, row: 
 XML(htmltruncate.truncate(field, 10))
 tipo_3 = db(db.publicaciones.tipo == 3).select().last()

 return dict(tipo_3 = tipo_3)


 It doesn't work


 The module is inside the modules folder of the app and it's imported 
 via:
 import htmltruncate


 any help is welcome!

 Best!



-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread martzi
I don't get you, could give an InteractiveConsole example, to illustrate 
your idea.

On Tuesday, September 11, 2012 3:39:53 PM UTC+2, villas wrote:

 I think it does have some effect.  
 I suspect that your existing data may not be unique.  
 See whether the following helps:

- If using commandline,  try with db.commit() after.
- Try with a new table.
- Look in databases/sql.log and see whether the field was created with 
UNIQUE.
- Use a DB management tool to inspect your DB.



 On Tuesday, September 11, 2012 2:23:16 PM UTC+1, martzi wrote:

 Unique = True,  has probably no effect. see below.
 ...
  db = DAL('sqlite://storage.db')
  person = db.define_table('person', Field('name'))
  bodypart = db.define_table('bodypart', Field('name'), Field('owner', 
 'reference person', unique=True)) #unique= True seems to have no effect
  pid = person.insert(name='Sid')
  bpid = bodypart.insert(name='arms', owner= pid) #pid = 1
  bodypart(bpid).owner #bpid = 1, first insertion of owner as 1
 1
  bpid = bodypart.insert(name='mouth', owner= pid) # multiple entries 
 not caught, pid is still 1
  bodypart(bpid).owner #bpid = 2, second insertion of owner as 1 AGAIN
 1

 On Tuesday, September 11, 2012 2:22:09 PM UTC+2, villas wrote:

 I am quite familiar with cascade;  I just couldn't figure out how it 
 could assist you.

 In my opinion,  Field('','reference other_table', unique=True)  
 should be supported and work.  Maybe you added the constraint later and the 
 DB didn't accept it because you already had duplicated field contents.

 In any case,  even if unique=True is not working for the moment,  then a 
 work-around would be to make a unique index on the field yourself.  You'll 
 have to handle exceptions when the insert/update fails due to duplicate 
 keys.




 On Tuesday, September 11, 2012 12:48:49 PM UTC+1, martzi wrote:

 Thanks for the reply. But if you meant Field('','reference 
 other_table', unique=True), I have tried that with failure, i am still 
 having a one-to-many relation. FYI: Regarding CASCADE, an  ondelete 
 cascade 
 causes deletion of all referred data.

 On Tuesday, September 11, 2012 1:37:59 PM UTC+2, villas wrote:

 I may be wrong,  but I do not think Cascade could assist you with 
 enforcing a 1-1 relationship. 
 Maybe making the foreign key field unique would help?


 On Monday, September 10, 2012 11:45:28 AM UTC+1, martzi wrote:

 Hi,
 I wonder if there a way to enforce a one to one relationship with 
 Cascade via web2py  DAL API. ???



-- 





Re: [web2py] Re: internal error crash with newest 2.0.6 and old 1.99.2

2012-09-11 Thread Massimo Di Pierro
This traceback means the ticket file is corrupted/truncated. 

On Tuesday, 11 September 2012 06:18:11 UTC-5, lucas wrote:

 ok, maybe some progress.  i removed any instances of psycopg2 from my 
 computer and web2py by default was and is not forced to use only the 
 contrib/pg8000 driver.  i think i would rather use that one anyway.  when i 
 changed the pool_size from the default 0 to 16, the initial 
 ticket/exception above stopped being logged.  so i was under the impression 
 that all was good again, but then my users have still been having logging 
 in, but this time it tells them it is an unrecoverable error and when i try 
 to see the ticket on their computer after this message, i can't pull 
 anything up.  so now i can not trace the problem and the users still have 
 infrequent times the site is crashing unrecoverably.  when i look into the 
 ticket logs i only get a bunch of these:

 Traceback (most recent call last):
   File /opt/web-apps/web2py/gluon/restricted.py, line 209, in restricted
 exec ccode in environment
   File /opt/web-apps/web2py/applications/admin/controllers/default.py 
 https://weinstruct.org/admin/default/edit/admin/controllers/default.py, 
 line 1726, in module
   File /opt/web-apps/web2py/gluon/globals.py, line 185, in lambda
 self._caller = lambda f: f()
   File /opt/web-apps/web2py/applications/admin/controllers/default.py 
 https://weinstruct.org/admin/default/edit/admin/controllers/default.py, 
 line 1548, in ticket
 e.load(request, app, ticket)
   File /opt/web-apps/web2py/gluon/restricted.py, line 168, in load
 d = ticket_storage.load(request, app, ticket_id)
   File /opt/web-apps/web2py/gluon/restricted.py, line 96, in load
 return cPickle.load(ef)
 EOFError

 but i am not sure what this means because it looks internal to web2py.  i 
 have upgraded to 2.0.8 a few days ago; so i am up to date.

 so i am still having trouble finding if it is the postgresql-9.1, the pg8000 
 driver, web2py, the DAL, my code, my views, i just don't know.  pretty 
 frustrating.  lucas




-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Massimo Di Pierro
Now I see what you are trying to do. I do not consider this a bug. At this 
point this is the intended behavior. You want conditional computed fields 
depending on user input. If a value is provided use it, if one is not 
provided then compute it. That is not what compute fields were designed 
for. What you ask can be done but would break backward compatibility 
because it would require running the compute callback even if there is a 
value provided for the computed field and let the callback decide whether 
to override the provided value. For some an empty value  is an acceptable 
value and for some it should trigger a computation. For me a field has a 
compute attribute the field is NOT editable in forms, it is only readable.



On Tuesday, 11 September 2012 07:17:28 UTC-5, Alan Etkin wrote:

 On Thursday, September 6, 2012 9:34:51 AM UTC-3, Massimo Di Pierro wrote:

 Please open a ticket and this will be easy to fix. 


 Opened the ticket:

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

 Now it was closed with status fixed, but:

 -AFAIK, fileld.writable still has no effect in computed fields. You cannot 
 set a computed field as writable with crud so it shows the widget. You can 
 with SQLFORM (by using the fields argument), however, entering blank inputs 
 don't trigger the compute function server side.
 -There's no modification of SQLFORM to process empty form fields as 
 computable (in replacement of a previous or new record value)*
 -SQLFORM doesn't set computed fields as empty on form creation (I think 
 this should be the default behavior)*

 * Perhaps it would be necessary to add different checks by field type and 
 a standard way of detecting a blank input in each case.

 Of course, it's possible to show a given widget and do further record 
 processing in the controller without depending on the computed field 
 facility, but with this changes, it would save that extra code and give a 
 more clean and web2py like interface.



-- 





Re: [web2py] [OT] Ubuntu 12.10 will no longer ship with Python 2

2012-09-11 Thread Jonathan Lundell
On 10 Sep 2012, at 11:32 PM, pbreit pbreitenb...@gmail.com wrote:
 
 Well...for starters, web2py, fabric and pil are 2.7. So, yes, I think it is 
 an absolutely, insanely user-hostile decision. The python ecosystem is not 
 even close to ready to move to 3. And from what I can tell, 3 offers minimal 
 benefits.

OTOH, it's never going to be ready to move until it gets a push. A first step 
would be to be able to count on its presence.

-- 





[web2py] Re: bug in 2.0.8

2012-09-11 Thread Massimo Di Pierro
Let me add you did not lose your data. If you revert to 1.99.7 you should 
find the data is still there.
Yet we need to understand what is happening

On Tuesday, 11 September 2012 03:44:46 UTC-5, Matt wrote:

 Hi there,

 First off thanks for all of the fantastic work putting 2.0 together. 
 Looking forward to trying the new features.

 I've just upgraded from 1.99.7 - 2.0.8 and I've discovered a serious bug 
 which has resulted in the loss of my data.

 [I'm using both GAE with CloudSQL and dal(migrate_enabled = True)]

 The automatically created image_blob references for GAE fields like:

 Field('image', 'upload', required = True, length = 100)

 Have vanished and with them the data contained in the image_blob fields.

 It seems to have happened fairly randomly i.e. some tables are fine but 
 others are affected. Out of about 6 tables using uploads only two still 
 have the extra blob columns.

 I've had some of these table definitions around for a long time and they 
 haven't changed. Whereas some others have been edited more recently.

 Any help or suggestions would be appreciated. Happy to give mere 
 information if possible.

 Thanks in advance,
 Matt

 BTW: Also had this problem occur prior to the above:

  self.db.executesql(CREATE TABLE IF NOT EXISTS web2py_filesystem (path 
 VARCHAR(512), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;)
   File /Projects/www/gluon/dal.py, line 7234, in executesql
 adapter.execute(query)
   File /Projects/www/gluon/dal.py, line 4002, in execute
 return self.log_execute(a.decode('utf8'))
   File /Projects/www/gluon/dal.py, line 1653, in log_execute
 ret = self.cursor.execute(*a, **b)
   File /Library/Python/2.7/site-packages/MySQLdb/cursors.py, line 174, 
 in execute
   File /Library/Python/2.7/site-packages/MySQLdb/connections.py, line 
 36, in defaulterrorhandler
 OperationalError: (1071, 'Specified key was too long; max key length is 
 767 bytes')

 Temporary fix was to change from True to False.

 class DatabaseStoredFile:

 web2py_filesystem = True

 (I did already have the web2py_filesystem table of course)


-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Anthony
I haven't followed this closely, but instead of specifying a compute 
attribute for the field, could you instead specify the default attribute 
as a function? In that case, the field will appear on forms -- if the user 
enters a value it will be used, and otherwise the default value will be 
computed. Of course, the record is not passed to the default function, so 
instead the default function would have to directly access request.vars to 
get the values of the other fields if needed (so this works with form 
inserts, but not other inserts).

Anthony

On Tuesday, September 11, 2012 8:17:28 AM UTC-4, Alan Etkin wrote:

 On Thursday, September 6, 2012 9:34:51 AM UTC-3, Massimo Di Pierro wrote:

 Please open a ticket and this will be easy to fix. 


 Opened the ticket:

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

 Now it was closed with status fixed, but:

 -AFAIK, fileld.writable still has no effect in computed fields. You cannot 
 set a computed field as writable with crud so it shows the widget. You can 
 with SQLFORM (by using the fields argument), however, entering blank inputs 
 don't trigger the compute function server side.
 -There's no modification of SQLFORM to process empty form fields as 
 computable (in replacement of a previous or new record value)*
 -SQLFORM doesn't set computed fields as empty on form creation (I think 
 this should be the default behavior)*

 * Perhaps it would be necessary to add different checks by field type and 
 a standard way of detecting a blank input in each case.

 Of course, it's possible to show a given widget and do further record 
 processing in the controller without depending on the computed field 
 facility, but with this changes, it would save that extra code and give a 
 more clean and web2py like interface.



-- 





[web2py] Re: bug in 2.0.8

2012-09-11 Thread Massimo Di Pierro
I found the web2py bug that caused this problem. It was an indentation 
issue. Took the occasion to rewrite the logic a little better.

Can you please check this works now? You should be able to update to trunk 
and your missing fields should re-appear (they will be hidden, 
writable=False, readable=False) but web2py should be able to use them as 
intended.

Please let me know asap.

Massimo

On Tuesday, 11 September 2012 03:44:46 UTC-5, Matt wrote:

 Hi there,

 First off thanks for all of the fantastic work putting 2.0 together. 
 Looking forward to trying the new features.

 I've just upgraded from 1.99.7 - 2.0.8 and I've discovered a serious bug 
 which has resulted in the loss of my data.

 [I'm using both GAE with CloudSQL and dal(migrate_enabled = True)]

 The automatically created image_blob references for GAE fields like:

 Field('image', 'upload', required = True, length = 100)

 Have vanished and with them the data contained in the image_blob fields.

 It seems to have happened fairly randomly i.e. some tables are fine but 
 others are affected. Out of about 6 tables using uploads only two still 
 have the extra blob columns.

 I've had some of these table definitions around for a long time and they 
 haven't changed. Whereas some others have been edited more recently.

 Any help or suggestions would be appreciated. Happy to give mere 
 information if possible.

 Thanks in advance,
 Matt

 BTW: Also had this problem occur prior to the above:

  self.db.executesql(CREATE TABLE IF NOT EXISTS web2py_filesystem (path 
 VARCHAR(512), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;)
   File /Projects/www/gluon/dal.py, line 7234, in executesql
 adapter.execute(query)
   File /Projects/www/gluon/dal.py, line 4002, in execute
 return self.log_execute(a.decode('utf8'))
   File /Projects/www/gluon/dal.py, line 1653, in log_execute
 ret = self.cursor.execute(*a, **b)
   File /Library/Python/2.7/site-packages/MySQLdb/cursors.py, line 174, 
 in execute
   File /Library/Python/2.7/site-packages/MySQLdb/connections.py, line 
 36, in defaulterrorhandler
 OperationalError: (1071, 'Specified key was too long; max key length is 
 767 bytes')

 Temporary fix was to change from True to False.

 class DatabaseStoredFile:

 web2py_filesystem = True

 (I did already have the web2py_filesystem table of course)


-- 





[web2py] Re: postgres getting better and better....

2012-09-11 Thread Massimo Di Pierro
Rows yes:

rows = db().select()
rows.json()

Row no:

row = rows[0]
row.json() # not defined but
simplejson.dumps(row.as_dict())






On Tuesday, 11 September 2012 07:51:56 UTC-5, Alan Etkin wrote:

 Aren't dal Row and Rows classes capable of returning json also?

 On Tuesday, September 11, 2012 9:28:52 AM UTC-3, LightDot wrote:

 Native JSON features look really interesting.

 Basically, postgres can return a row or an array as JSON now. And 
 validate JSON. Seems quite handy!

 Regards,
 Ales

 On Tuesday, September 11, 2012 10:21:54 AM UTC+2, Niphlod wrote:

 Happy september with the 9.2 release for everybody

 http://wiki.postgresql.org/wiki/What%27s_new_in_PostgreSQL_9.2

 http://www.postgresql.org/about/news/1415/



-- 





Re: [web2py] Re: internal error crash with newest 2.0.6 and old 1.99.2

2012-09-11 Thread lucas
oh cr#p, because i was able to definitely trace that cPickle.load error to 
the unrecoverable error.  makes sense now.

so how can i narrow this terrible thing down. i am using apache httpd 
2.2.15 on centos 6.3, postgresql 9.1 with the web2py contrib pg8000 driver, 
and web2py 2.0.8.  i have excluded any unnecessary code as much as i could, 
pool_size=7 which changed from my first ticket to this unrecoverable, and i 
am not doing any hard commit() or rollback() and such.  i do a few 
db.update, db.insert, but that is the most manual i get, and again the 
exceptions are always when a user is logging in.  i have also noted that 
the server will kick off a user in mid session and the user has to 
re-login.  so i am not sure it is with the connection to the db or the 
session controller.

perhaps it is the way i have my /etc/httpd/conf.d/default.conf file 
configured for multiple domain names.  can someone point me to some example 
entries for that file for multiple domains using web2py applications?

but this has to be fixed, one way or the other because it is sucking wind 
like crazy and i have been chasing my tail for 3 weeks now.  thanx for the 
help and i hope some solution avails itself to bring in stability.  
please.  lucas

-- 





Re: [web2py] Re: Web2py. for a minimalist app, it feels bloated. Do it I need it?

2012-09-11 Thread Massimo Di Pierro
Adding support for other SQL databases is easy. I have no data about 
OrientDB but we can easily add an adapter if you help with testing.

On Tuesday, 11 September 2012 08:15:01 UTC-5, luckysmack wrote:

 Well its starting to seem like a good fit. But yes I won't be using DAL, 
 since I'll be using orientdb. I know I lose something with that decision, 
 but its what I need. I'm also curious how people are using it here as well 
 with web2py.
 On Sep 11, 2012 1:46 AM, pbreit pbreit...@gmail.com javascript: 
 wrote:

 It sounds like you know enough about these things to figure out if Web2py 
 is too bloated for you. My sense is that even if you think it might be 
 bloated, the extraneous stuff really doesn't get in the way too much. Not 
 using DAL means you are missing out on one of the core features. Building a 
 REST API should be fine either using what Web2py gives you out of the bos 
 or rolling your own. You can either build multiple Web2py apps or build 
 some web2py apps and some other apps. DAL doesn't really support NoSQL much 
 at this point so you're on your own there. I've used Web2py to build a POS 
 system and it works great.



 On Saturday, September 8, 2012 12:39:26 AM UTC-7, luckysmack wrote:

 I am somewhat new to python, and * shock * have an idea for a simple app 
 I want to build. To start the app will be relatively light weight, but if 
 it works out in my grand scheme could be far more complex.but the core will 
 be fairly simple. something an experienced python dev could probably whip 
 up in bottle in a few days. 

 The core will a simply be an advanced rest based api. The other half 
 dozen or so apps will all be built of this core. The either apps will 
 likely be built as a cms like system to manage each other. And as different 
 as a POS in store program. 

 So as many cool things as I thing web2py has, do you guys think its the 
 right system? I know w2p can do great APIs easily. But for that simple 
 aspect, I don't need a milti-application admin interface, or a code editor, 
 and I may not even use DAL. (For my project I may actually use something 
 like neo4j/orientdb/titan. Not sure yet. Might use mongodb as instead). So 
 for that simple part, all the other stuff seems a little bloated to me. 
 Stuff that I won't need.

 Sure as a whole, all the apps will be built into somewhat of a cms 
 (which I would like to build anyways), for that I'm not sure I would need 
 the web2py admin part. As a cms I would probably have my own interface, 
 even for the admins. How or would web2py admin ui fit in. I know you guys 
 are biased towards web2py, but does it sound like it would be a right fit? 
 Or would it be too complex? In comparison, I feel django is too bloated as 
 well since I would be doing a similar thing, except it would be done quite 
 a bit differently. The core of how it works doesn't seem to fit my ideas. 

 If I don't use web2py, the next best things I see as a starting point 
 are pyramid, or bottle/flask or even wheezy looks pretty cool. 

 What do you guys think? The core great api would be the crux of the 
 other apps. This core is what talks to the db. And each if the apps with 
 build on it. The rest part will be made so they can all communicate with 
 each other based on the URL. 

 The either individual apps, were they to be on their own, I can totally 
 see as a web2py app. So I'm curious how this idea as a whole, would fit 
 into web2py. If it can. Since there are a handful of web2py featured I 
 won't even use. I don't need them to be auto imported if I'm not using them 
 (since I can't see what's being imported). So in a way it feels like bloat. 
 A reason I don't like django. 

 What do you guys think? Any input is greatly appreciated.

  -- 
  
  
  



-- 





[web2py] Re: HTML truncate

2012-09-11 Thread Massimo Di Pierro
{{=db.publicaciones.descripcion.represent(tipo_3.descripcion,tipo_3}}

I do not think you want the extra =.

On Tuesday, 11 September 2012 08:47:00 UTC-5, villas wrote:

 I end up doing something like this:

 {{=db.publicaciones.descripcion.represent(=tipo_3.descripcion,tipo_3)}}

 I hope that helps,  but maybe there is a better way?



 On Tuesday, September 11, 2012 1:48:59 PM UTC+1, Pepe Araya wrote:

 Hi Massimo,

 Sorry for my poor explanation.

 What I don't get is in the view when i call the field value 
 {{=tipo_3.descripcion}}  I get the whole text and not the truncated one 
 like in the SQLFORM.grid case.




 On Tuesday, September 11, 2012 9:32:18 AM UTC-3, Massimo Di Pierro wrote:

 What does it mean it does not work? Can you import it? Can you import it 
 from python?

 On Tuesday, 11 September 2012 00:55:03 UTC-5, Pepe Araya wrote:

 Hello,

 I need to truncate a field that contains HTML content. 

 Now i'm using htmltruncate https://github.com/eentzel/htmltruncate.py in 
 a controller that return a SQLFORM.smartgrid and it works perfect:
  
 def noticias():
 
 db.noticias.cuerpo.represent = lambda field,row: 
 XML(htmltruncate.truncate(field, 100))
 grid = SQLFORM.smartgrid(db.noticias, 
 linked_tables=['adjuntos_noticia'])

 return dict(grid =grid)


 But when I try to implement a in a controller in this way:

 def index():
 db.publicaciones.descripcion.represent = lambda field, row: 
 XML(htmltruncate.truncate(field, 10))
 tipo_3 = db(db.publicaciones.tipo == 3).select().last()

 return dict(tipo_3 = tipo_3)


 It doesn't work


 The module is inside the modules folder of the app and it's imported 
 via:
 import htmltruncate


 any help is welcome!

 Best!



-- 





Re: [web2py] Re: internal error crash with newest 2.0.6 and old 1.99.2

2012-09-11 Thread Massimo Di Pierro
Some problems have been reported with pg8000. Can you reproduce the errors 
with psycopg2.

Can you email me one of the corrupt tickets? I may be able to read them and 
see what is going on.

On Tuesday, 11 September 2012 09:31:46 UTC-5, lucas wrote:

 oh cr#p, because i was able to definitely trace that cPickle.load error to 
 the unrecoverable error.  makes sense now.

 so how can i narrow this terrible thing down. i am using apache httpd 
 2.2.15 on centos 6.3, postgresql 9.1 with the web2py contrib pg8000 driver, 
 and web2py 2.0.8.  i have excluded any unnecessary code as much as i could, 
 pool_size=7 which changed from my first ticket to this unrecoverable, and i 
 am not doing any hard commit() or rollback() and such.  i do a few 
 db.update, db.insert, but that is the most manual i get, and again the 
 exceptions are always when a user is logging in.  i have also noted that 
 the server will kick off a user in mid session and the user has to 
 re-login.  so i am not sure it is with the connection to the db or the 
 session controller.

 perhaps it is the way i have my /etc/httpd/conf.d/default.conf file 
 configured for multiple domain names.  can someone point me to some example 
 entries for that file for multiple domains using web2py applications?

 but this has to be fixed, one way or the other because it is sucking wind 
 like crazy and i have been chasing my tail for 3 weeks now.  thanx for the 
 help and i hope some solution avails itself to bring in stability.  
 please.  lucas


-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Massimo Di Pierro
if the user does not pass a value it will still not trigger a computation 
because  is not None, I think.

On Tuesday, 11 September 2012 09:17:02 UTC-5, Anthony wrote:

 I haven't followed this closely, but instead of specifying a compute 
 attribute for the field, could you instead specify the default attribute 
 as a function? In that case, the field will appear on forms -- if the user 
 enters a value it will be used, and otherwise the default value will be 
 computed. Of course, the record is not passed to the default function, so 
 instead the default function would have to directly access request.vars to 
 get the values of the other fields if needed (so this works with form 
 inserts, but not other inserts).

 Anthony

 On Tuesday, September 11, 2012 8:17:28 AM UTC-4, Alan Etkin wrote:

 On Thursday, September 6, 2012 9:34:51 AM UTC-3, Massimo Di Pierro wrote:

 Please open a ticket and this will be easy to fix. 


 Opened the ticket:

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

 Now it was closed with status fixed, but:

 -AFAIK, fileld.writable still has no effect in computed fields. You 
 cannot set a computed field as writable with crud so it shows the widget. 
 You can with SQLFORM (by using the fields argument), however, entering 
 blank inputs don't trigger the compute function server side.
 -There's no modification of SQLFORM to process empty form fields as 
 computable (in replacement of a previous or new record value)*
 -SQLFORM doesn't set computed fields as empty on form creation (I think 
 this should be the default behavior)*

 * Perhaps it would be necessary to add different checks by field type and 
 a standard way of detecting a blank input in each case.

 Of course, it's possible to show a given widget and do further record 
 processing in the controller without depending on the computed field 
 facility, but with this changes, it would save that extra code and give a 
 more clean and web2py like interface.



-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Bruno Rocha
for that cases shouldn't use _before_insert and _before_update triggers?

-- 





[web2py] problem adding members to group

2012-09-11 Thread greaneym
Dear all,

I'm testing the pos plugin and have it mostly set up, but I'm stuck. I had 
commented all the auth statements and have now uncommented them, and was 
adding the group called manager and before I could add members was 
interrupted.  My session ended, and after that I could not use the admin 
interface to access the database from appadmin.  So I'm now trying to add 
members through the shell, but
I'm getting an error:

python web2py.py -S app -M -N -R applications/myapp -A 
Traceback (most recent call last):
  File web2py.py, line 16, in module
import gluon.widget
ImportError: No module named gluon.widget


I upgraded from version 1.99 to 2.06 and just added the web2py.app.

Do I need something else? Or how can I modify the shell command please?

thanks,
Margaret

-- 





[web2py] MENU helper and Server-side DOM work together?

2012-09-11 Thread amphisia pui
Hi to all 

I want to use the html helper MENU to have in the page footer a menu 
totally exploded without sliding items.
I changed the css classes and everything looks fine but I don't want the 
first level menu items to be clickable

 so the first thing I tried was the server-side parsing to remove 
unnecessary tags but in a web2py shell I got

mlist = ... well formatted web2py menu list

In [40]: mmenu = MENU(mlist)

 In [41]: mitems = mmenu.elements('a')
---
AttributeErrorTraceback (most recent call last)
/opt/web2py/applications/happy/models/menu.py in module()
 1 mmenu.elements('a')

/opt/web2py/gluon/html.pyc in elements(self, *args, **kargs)
   1079 # loop the components

   1080 if find_text or find_components:
- 1081 for i, c in enumerate(self.components):
   1082 if check and find_text and isinstance(c, str) and \
   1083((is_regex and find_text.search(c)) or 
(str(find_text) in c)):

AttributeError: 'MENU' object has no attribute 'components'

Is MENU helper supposed to work with sever side DOM parsing? Is web2py 
ipython Shell fault?   
Can you suggest something better to try to have first level items menu seem 
like simple labels?

Thanks to all

AP

Sys info
Python 2.7.3
web2py 2.0.8

-- 





[web2py] Re: Trying to reproduce Ex. in manual, sec. 6.21.1 (inner joins)

2012-09-11 Thread MichaelF
Great; I appreciate it.

Do you still want me to open a ticket with a suggestion for an enhancement?

Regards,
Michael

On Monday, September 10, 2012 5:29:12 PM UTC-6, Massimo Di Pierro wrote:

 Anyway, I changed the code in trunk so that the example in the book works 
 as described.

 On Monday, 10 September 2012 17:27:01 UTC-5, Massimo Di Pierro wrote:

 There is a mistake in the book. It should have been:

 rows = db(db.person).select(db.person.ALL, db.dog.ALL, join=db.dog.on(
 db.person.id==db.dog.owner))

 or

 rows = db(db.person).select(db.person.ALL, db.dog.ALL, left=db.dog.on(
 db.person.id==db.dog.owner))

 Perhaps is should default to select all fields as he book suggests. I 
 will look into this. Please open a ticket with a suggestion for enhancement.

 On Monday, September 10, 2012 4:58:25 PM UTC-5, MichaelF wrote:

 I have a db structure similar to the person/dog tables in section 6.21 
 One to many relation. I try the inner join (second form, from the book):

 1  rows = db(db.person).select(join=db.dog.on(db.person.id
 ==db.dog.owner))
 2  for row in rows:
 3 print row.person.name, 'has', row.dog.name
 4 Alex has Skipper
 5 Alex has Snoopy
 6 Bob has Puppy

 In my db the 'person' table is 'Meet', and 'dog' is 'Session'. Here's 
 what I used:

 meetAndSession = db(db.Meet).select(join=db.Session.on(db.Meet.id == 
 db.Session.Meet))

 I get back the 'person' ('Meet') fields, but not the 'dog' ('Session') 
 fields. For the Meet.Session field I get back a Set object. Should I be 
 using that as the set of Session records associated with the Meet record. 
 (I tried to reference row.Meet.Session.id, but got told there was no 
 such field. I also tried row.Session.id and got told the same thing.) 
 As the example shows row.dog.name, shouldn't I have a 
 row.Session.fieldName?

 Here's what db stats tells me it used:

 SELECT  Meet.id, Meet.Meet_name, Meet.Start_date, Meet.End_date, 
 Meet.Is_championship FROM Meet JOIN Session ON (Meet.id = Session.Meet) 
 WHERE (Meet.id  0);


 Given that, of course I'm getting no 'dog' ('Session') fields. What am I 
 missing?


 Thanks.



-- 





[web2py] Is 'second option' for one-many available for many-many?

2012-09-11 Thread MichaelF
Section 6.21.1 in the manual talks about an alternative syntax for 1-many 
joins, using the 'on' function. Is that technique available for many-many? 
I try this and get an error:

# In this example, Meet and Team are being connected through 
Participant_team
teamStaff = db(db.Meet.id == request.args(1)).select(
   db.Meet.ALL, db.Team.ALL,
   join = db.Team.on(
  (db.Participant_team.Meet == db.Meet.id) 
  (db.Participant_team.Team == db.Team.id)))

The error is: Unknown column 'Meet.id' in 'on clause'

I can change db.Team.on to db.Participant_team.on, but I get the same 
error.

I have a lot of other JOINs that I must do, but this is the smallest 
example that shows the problem.

-- 





[web2py] web2py default layout.html

2012-09-11 Thread Kevin Miller
Hi All,

I notice that when I use the layout.html, even though the div with
class=container and the Section with id=main are the same size, the
Section is pushed to the right.
I used the inspector in firefox to check it, when I noticed that text I had
was going out of the container div. This was obvious since I gave the
container a different color.

Is this the way the container div and main section should work?

I can work around it, but I want to be sure that this is not a bug.



Thanks.

-- 





Re: [web2py] Re: Web2py. for a minimalist app, it feels bloated. Do it I need it?

2012-09-11 Thread Shawn McElroy
Yes i can definately help with testing. Currently there seems to be 2
existing libs for using orientdb.

- Compass: https://github.com/emehrkay/Compass
  which ties directly into orientdb through its rest interface, and will
eventually have binary support.
- Bulbs with Rexter: http://bulbflow.com/http://bulbflow.com/ /
https://github.com/tinkerpop/rexster/wiki/Rexster-Configuration
  bulbflow uses a system called blueprints, which is eddentially an orm for
most graph databases. then there are a few layers that talk to the
different db's. most of them use rexter (second link for configuration for
orientdb).

While the first option, Comnpass, could probably be easier to work into
dal, if bulbflow/rexter is used, we can let people use whatever graphdb
they want, as long as it supports blueprint. Which I believe most do.

The main difference with them, is there is no relations like has many,
belongs to, or many to many. They have edges, which are still
relationships, but are represented in the form of fields. For an example, a
user, and a post, might have an edge of date (published date), and author
(who made the post). And bot hthe nodes themselves, and edges can be
searched for.



On Tue, Sep 11, 2012 at 7:32 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Adding support for other SQL databases is easy. I have no data about
 OrientDB but we can easily add an adapter if you help with testing.


 On Tuesday, 11 September 2012 08:15:01 UTC-5, luckysmack wrote:

 Well its starting to seem like a good fit. But yes I won't be using DAL,
 since I'll be using orientdb. I know I lose something with that decision,
 but its what I need. I'm also curious how people are using it here as well
 with web2py.
 On Sep 11, 2012 1:46 AM, pbreit pbreit...@gmail.com wrote:

 It sounds like you know enough about these things to figure out if
 Web2py is too bloated for you. My sense is that even if you think it might
 be bloated, the extraneous stuff really doesn't get in the way too much.
 Not using DAL means you are missing out on one of the core features.
 Building a REST API should be fine either using what Web2py gives you out
 of the bos or rolling your own. You can either build multiple Web2py apps
 or build some web2py apps and some other apps. DAL doesn't really support
 NoSQL much at this point so you're on your own there. I've used Web2py to
 build a POS system and it works great.



 On Saturday, September 8, 2012 12:39:26 AM UTC-7, luckysmack wrote:

 I am somewhat new to python, and * shock * have an idea for a simple
 app I want to build. To start the app will be relatively light weight, but
 if it works out in my grand scheme could be far more complex.but the core
 will be fairly simple. something an experienced python dev could probably
 whip up in bottle in a few days.

 The core will a simply be an advanced rest based api. The other half
 dozen or so apps will all be built of this core. The either apps will
 likely be built as a cms like system to manage each other. And as different
 as a POS in store program.

 So as many cool things as I thing web2py has, do you guys think its the
 right system? I know w2p can do great APIs easily. But for that simple
 aspect, I don't need a milti-application admin interface, or a code editor,
 and I may not even use DAL. (For my project I may actually use something
 like neo4j/orientdb/titan. Not sure yet. Might use mongodb as instead). So
 for that simple part, all the other stuff seems a little bloated to me.
 Stuff that I won't need.

 Sure as a whole, all the apps will be built into somewhat of a cms
 (which I would like to build anyways), for that I'm not sure I would need
 the web2py admin part. As a cms I would probably have my own interface,
 even for the admins. How or would web2py admin ui fit in. I know you guys
 are biased towards web2py, but does it sound like it would be a right fit?
 Or would it be too complex? In comparison, I feel django is too bloated as
 well since I would be doing a similar thing, except it would be done quite
 a bit differently. The core of how it works doesn't seem to fit my ideas.

 If I don't use web2py, the next best things I see as a starting point
 are pyramid, or bottle/flask or even wheezy looks pretty cool.

 What do you guys think? The core great api would be the crux of the
 other apps. This core is what talks to the db. And each if the apps with
 build on it. The rest part will be made so they can all communicate with
 each other based on the URL.

 The either individual apps, were they to be on their own, I can totally
 see as a web2py app. So I'm curious how this idea as a whole, would fit
 into web2py. If it can. Since there are a handful of web2py featured I
 won't even use. I don't need them to be auto imported if I'm not using them
 (since I can't see what's being imported). So in a way it feels like bloat.
 A reason I don't like django.

 What do you guys think? Any input is greatly appreciated.

  --




  

Re: [web2py] Is 'second option' for one-many available for many-many?

2012-09-11 Thread Richard Vézina
left join on the linking table and an other left join on the other table??

Would you sent a example in SQL of you complexe request, we could help you
translate it into web2py.

Richard



On Tue, Sep 11, 2012 at 11:04 AM, MichaelF mjfs...@gmail.com wrote:

 Section 6.21.1 in the manual talks about an alternative syntax for 1-many
 joins, using the 'on' function. Is that technique available for many-many?
 I try this and get an error:

 # In this example, Meet and Team are being connected through
 Participant_team
 teamStaff = db(db.Meet.id == request.args(1)).select(
db.Meet.ALL, db.Team.ALL,
join = db.Team.on(
   (db.Participant_team.Meet == db.Meet.id) 
   (db.Participant_team.Team == db.Team.id)))

 The error is: Unknown column 'Meet.id' in 'on clause'

 I can change db.Team.on to db.Participant_team.on, but I get the same
 error.

 I have a lot of other JOINs that I must do, but this is the smallest
 example that shows the problem.

 --





-- 





[web2py] Re: problem adding members to group

2012-09-11 Thread greaneym
I see on the groups that I might need to run from the source dist instead 
of web2py.app since I am on a mac,
so I'll try that first.


On Tuesday, September 11, 2012 9:48:48 AM UTC-5, greaneym wrote:

 Dear all,

 I'm testing the pos plugin and have it mostly set up, but I'm stuck. I had 
 commented all the auth statements and have now uncommented them, and was 
 adding the group called manager and before I could add members was 
 interrupted.  My session ended, and after that I could not use the admin 
 interface to access the database from appadmin.  So I'm now trying to add 
 members through the shell, but
 I'm getting an error:

 python web2py.py -S app -M -N -R applications/myapp -A 
 Traceback (most recent call last):
   File web2py.py, line 16, in module
 import gluon.widget
 ImportError: No module named gluon.widget


 I upgraded from version 1.99 to 2.06 and just added the web2py.app.

 Do I need something else? Or how can I modify the shell command please?

 thanks,
 Margaret



-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread villas
Add this line as a test:

db.executesql('create unique index idx_owner on bodypart(owner)')

to your code like this:

db = DAL('sqlite://storage.db')
person = db.define_table('person', Field('name'))
bodypart = db.define_table('bodypart', Field('name'), Field('owner', 'reference 
person', unique=True)) 
db.executesql('create unique index idx_owner on bodypart(owner)')
pid = person.insert(name='Sid')
bpid = bodypart.insert(name='arms', owner= pid) 
bodypart(bpid).owner 
bpid = bodypart.insert(name='mouth', owner= pid) 
bodypart(bpid).owner 


-- 





[web2py] Translation plural

2012-09-11 Thread Francisco Costa
How to use the plural featurein tranlation T.plural ?

-- 





[web2py] Re: Is 'second option' for one-many available for many-many?

2012-09-11 Thread MichaelF
I should have added that I can get the same effect with this:

# In this example, Meet and Team are being connected through 
Participant_team
teamStaff = db(db.Meet.id http://db.meet.id/ == request.args(1)).select(
   db.Meet.ALL, db.Team.ALL,
   join = [db.Participant_team.on(
  db.Participant_team.Meet == 
db.Meet.idhttp://db.meet.id/
),
   db.Team.on(db.Participant_team.Team == 
db.Team.idhttp://db.team.id/
)])


On Tuesday, September 11, 2012 9:04:25 AM UTC-6, MichaelF wrote:

 Section 6.21.1 in the manual talks about an alternative syntax for 1-many 
 joins, using the 'on' function. Is that technique available for many-many? 
 I try this and get an error:

 # In this example, Meet and Team are being connected through 
 Participant_team
 teamStaff = db(db.Meet.id == request.args(1)).select(
db.Meet.ALL, db.Team.ALL,
join = db.Team.on(
   (db.Participant_team.Meet == db.Meet.id) 
   (db.Participant_team.Team == db.Team.id)))

 The error is: Unknown column 'Meet.id' in 'on clause'

 I can change db.Team.on to db.Participant_team.on, but I get the same 
 error.

 I have a lot of other JOINs that I must do, but this is the smallest 
 example that shows the problem.


-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Massimo Di Pierro
I think so.

On Tuesday, 11 September 2012 09:42:05 UTC-5, rochacbruno wrote:

 for that cases shouldn't use _before_insert and _before_update triggers? 

-- 





[web2py] Re: MENU helper and Server-side DOM work together?

2012-09-11 Thread Massimo Di Pierro
I added components yet MENU is a little different then other helpers.

On Tuesday, 11 September 2012 09:49:59 UTC-5, amphisia pui wrote:

 Hi to all 

 I want to use the html helper MENU to have in the page footer a menu 
 totally exploded without sliding items.
 I changed the css classes and everything looks fine but I don't want the 
 first level menu items to be clickable

  so the first thing I tried was the server-side parsing to remove 
 unnecessary tags but in a web2py shell I got

 mlist = ... well formatted web2py menu list

 In [40]: mmenu = MENU(mlist)

  In [41]: mitems = mmenu.elements('a')
 ---
 AttributeErrorTraceback (most recent call last)
 /opt/web2py/applications/happy/models/menu.py in module()
  1 mmenu.elements('a')

 /opt/web2py/gluon/html.pyc in elements(self, *args, **kargs)
1079 # loop the components

1080 if find_text or find_components:
 - 1081 for i, c in enumerate(self.components):
1082 if check and find_text and isinstance(c, str) and \
1083((is_regex and find_text.search(c)) or 
 (str(find_text) in c)):

 AttributeError: 'MENU' object has no attribute 'components'

 Is MENU helper supposed to work with sever side DOM parsing? Is web2py 
 ipython Shell fault?   
 Can you suggest something better to try to have first level items menu 
 seem like simple labels?

 Thanks to all

 AP

 Sys info
 Python 2.7.3
 web2py 2.0.8



-- 





[web2py] Re: MENU helper and Server-side DOM work together?

2012-09-11 Thread Anthony
Looks like MENU doesn't generate a DOM structure until its .serialize() 
method is called. You could do:

mmenu = mmenu.serialize(mmenu.data)
mmenu.elements('a')

I'm not sure why it was done this way as opposed to generating the DOM upon 
initialization. Massimo?

Anthony

On Tuesday, September 11, 2012 10:49:59 AM UTC-4, amphisia pui wrote:

 Hi to all 

 I want to use the html helper MENU to have in the page footer a menu 
 totally exploded without sliding items.
 I changed the css classes and everything looks fine but I don't want the 
 first level menu items to be clickable

  so the first thing I tried was the server-side parsing to remove 
 unnecessary tags but in a web2py shell I got

 mlist = ... well formatted web2py menu list

 In [40]: mmenu = MENU(mlist)

  In [41]: mitems = mmenu.elements('a')
 ---
 AttributeErrorTraceback (most recent call last)
 /opt/web2py/applications/happy/models/menu.py in module()
  1 mmenu.elements('a')

 /opt/web2py/gluon/html.pyc in elements(self, *args, **kargs)
1079 # loop the components

1080 if find_text or find_components:
 - 1081 for i, c in enumerate(self.components):
1082 if check and find_text and isinstance(c, str) and \
1083((is_regex and find_text.search(c)) or 
 (str(find_text) in c)):

 AttributeError: 'MENU' object has no attribute 'components'

 Is MENU helper supposed to work with sever side DOM parsing? Is web2py 
 ipython Shell fault?   
 Can you suggest something better to try to have first level items menu 
 seem like simple labels?

 Thanks to all

 AP

 Sys info
 Python 2.7.3
 web2py 2.0.8



-- 





[web2py] Re: Trying to reproduce Ex. in manual, sec. 6.21.1 (inner joins)

2012-09-11 Thread Massimo Di Pierro
Non need. It is now supported as you expected it.

On Tuesday, 11 September 2012 09:52:22 UTC-5, MichaelF wrote:

 Great; I appreciate it.

 Do you still want me to open a ticket with a suggestion for an enhancement?

 Regards,
 Michael

 On Monday, September 10, 2012 5:29:12 PM UTC-6, Massimo Di Pierro wrote:

 Anyway, I changed the code in trunk so that the example in the book works 
 as described.

 On Monday, 10 September 2012 17:27:01 UTC-5, Massimo Di Pierro wrote:

 There is a mistake in the book. It should have been:

 rows = db(db.person).select(db.person.ALL, db.dog.ALL, join=db.dog.on(
 db.person.id==db.dog.owner))

 or

 rows = db(db.person).select(db.person.ALL, db.dog.ALL, left=db.dog.on(
 db.person.id==db.dog.owner))

 Perhaps is should default to select all fields as he book suggests. I 
 will look into this. Please open a ticket with a suggestion for enhancement.

 On Monday, September 10, 2012 4:58:25 PM UTC-5, MichaelF wrote:

 I have a db structure similar to the person/dog tables in section 6.21 
 One to many relation. I try the inner join (second form, from the book):

 1  rows = db(db.person).select(join=db.dog.on(db.person.id
 ==db.dog.owner))
 2  for row in rows:
 3 print row.person.name, 'has', row.dog.name
 4 Alex has Skipper
 5 Alex has Snoopy
 6 Bob has Puppy

 In my db the 'person' table is 'Meet', and 'dog' is 'Session'. Here's 
 what I used:

 meetAndSession = db(db.Meet).select(join=db.Session.on(db.Meet.id == 
 db.Session.Meet))

 I get back the 'person' ('Meet') fields, but not the 'dog' ('Session') 
 fields. For the Meet.Session field I get back a Set object. Should I be 
 using that as the set of Session records associated with the Meet record. 
 (I tried to reference row.Meet.Session.id, but got told there was no 
 such field. I also tried row.Session.id and got told the same thing.) 
 As the example shows row.dog.name, shouldn't I have a 
 row.Session.fieldName?

 Here's what db stats tells me it used:

 SELECT  Meet.id, Meet.Meet_name, Meet.Start_date, Meet.End_date, 
 Meet.Is_championship FROM Meet JOIN Session ON (Meet.id = Session.Meet) 
 WHERE (Meet.id  0);


 Given that, of course I'm getting no 'dog' ('Session') fields. What am I 
 missing?


 Thanks.



-- 





[web2py] Re: web2py default layout.html

2012-09-11 Thread Massimo Di Pierro
Not intended. Can you help us fix it?

On Tuesday, 11 September 2012 10:11:35 UTC-5, dundee wrote:


 Hi All,

 I notice that when I use the layout.html, even though the div with 
 class=container and the Section with id=main are the same size, the 
 Section is pushed to the right.
 I used the inspector in firefox to check it, when I noticed that text I 
 had was going out of the container div. This was obvious since I gave the 
 container a different color.

 Is this the way the container div and main section should work?

 I can work around it, but I want to be sure that this is not a bug.



 Thanks.


-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread Anthony
Why do you want a one-to-one relation? Can't you just put all the fields in 
one table?

Anthony

On Tuesday, September 11, 2012 9:23:16 AM UTC-4, martzi wrote:

 Unique = True,  has probably no effect. see below.
 ...
  db = DAL('sqlite://storage.db')
  person = db.define_table('person', Field('name'))
  bodypart = db.define_table('bodypart', Field('name'), Field('owner', 
 'reference person', unique=True)) #unique= True seems to have no effect
  pid = person.insert(name='Sid')
  bpid = bodypart.insert(name='arms', owner= pid) #pid = 1
  bodypart(bpid).owner #bpid = 1, first insertion of owner as 1
 1
  bpid = bodypart.insert(name='mouth', owner= pid) # multiple entries 
 not caught, pid is still 1
  bodypart(bpid).owner #bpid = 2, second insertion of owner as 1 AGAIN
 1

 On Tuesday, September 11, 2012 2:22:09 PM UTC+2, villas wrote:

 I am quite familiar with cascade;  I just couldn't figure out how it 
 could assist you.

 In my opinion,  Field('','reference other_table', unique=True)  
 should be supported and work.  Maybe you added the constraint later and the 
 DB didn't accept it because you already had duplicated field contents.

 In any case,  even if unique=True is not working for the moment,  then a 
 work-around would be to make a unique index on the field yourself.  You'll 
 have to handle exceptions when the insert/update fails due to duplicate 
 keys.




 On Tuesday, September 11, 2012 12:48:49 PM UTC+1, martzi wrote:

 Thanks for the reply. But if you meant Field('','reference 
 other_table', unique=True), I have tried that with failure, i am still 
 having a one-to-many relation. FYI: Regarding CASCADE, an  ondelete cascade 
 causes deletion of all referred data.

 On Tuesday, September 11, 2012 1:37:59 PM UTC+2, villas wrote:

 I may be wrong,  but I do not think Cascade could assist you with 
 enforcing a 1-1 relationship. 
 Maybe making the foreign key field unique would help?


 On Monday, September 10, 2012 11:45:28 AM UTC+1, martzi wrote:

 Hi,
 I wonder if there a way to enforce a one to one relationship with 
 Cascade via web2py  DAL API. ???



-- 





[web2py] Re: problem adding members to group

2012-09-11 Thread Massimo Di Pierro
I do not understand this line:

python web2py.py -S app -M -N -R applications/myapp -A

-R should specify a script, not an app
-A should be followed by command line arguments for the script but you do 
not have any

This is probably not the cause of your problem anyway.



On Tuesday, 11 September 2012 09:48:48 UTC-5, greaneym wrote:

 Dear all,

 I'm testing the pos plugin and have it mostly set up, but I'm stuck. I had 
 commented all the auth statements and have now uncommented them, and was 
 adding the group called manager and before I could add members was 
 interrupted.  My session ended, and after that I could not use the admin 
 interface to access the database from appadmin.  So I'm now trying to add 
 members through the shell, but
 I'm getting an error:

 python web2py.py -S app -M -N -R applications/myapp -A 
 Traceback (most recent call last):
   File web2py.py, line 16, in module
 import gluon.widget
 ImportError: No module named gluon.widget


 I upgraded from version 1.99 to 2.06 and just added the web2py.app.

 Do I need something else? Or how can I modify the shell command please?

 thanks,
 Margaret



-- 





Re: [web2py] Re: Is 'second option' for one-many available for many-many?

2012-09-11 Thread Richard Vézina
That look right...

There ways to write request in web2py when it comes to join. They will not
generate the same SQL syntax for example :

db((db.table1.field==something)(db.table2.field==something)).select(...)
= Old SQL

SELECT ...
FROM table1, table2
WHERE ...

When you use join in web2py, I guest it will use new SQL :

SELECT ...
FROM table1
JOIN ON table2...
WHERE ...

I never check...

But works and if you get out what you want form you web2py select who cares
the way the SQL is writed finally if it get executed...

:)

Richard

On Tue, Sep 11, 2012 at 11:25 AM, MichaelF mjfs...@gmail.com wrote:

 I should have added that I can get the same effect with this:

 # In this example, Meet and Team are being connected through
 Participant_team
 teamStaff = db(db.Meet.id http://db.meet.id/ == request.args(1)).select(
db.Meet.ALL, db.Team.ALL,
join = [db.Participant_team.on(
   db.Participant_team.Meet == 
 db.Meet.idhttp://db.meet.id/
 ),
db.Team.on(db.Participant_team.Team == 
 db.Team.idhttp://db.team.id/
 )])


 On Tuesday, September 11, 2012 9:04:25 AM UTC-6, MichaelF wrote:

 Section 6.21.1 in the manual talks about an alternative syntax for 1-many
 joins, using the 'on' function. Is that technique available for many-many?
 I try this and get an error:

 # In this example, Meet and Team are being connected through
 Participant_team
 teamStaff = db(db.Meet.id == request.args(1)).select(
db.Meet.ALL, db.Team.ALL,
join = db.Team.on(
   (db.Participant_team.Meet == db.Meet.id) 
   (db.Participant_team.Team == db.Team.id)))

 The error is: Unknown column 'Meet.id' in 'on clause'

 I can change db.Team.on to db.Participant_team.on, but I get the same
 error.

 I have a lot of other JOINs that I must do, but this is the smallest
 example that shows the problem.

  --





-- 





[web2py] Re: Is 'second option' for one-many available for many-many?

2012-09-11 Thread MichaelF
Thanks; I think I have it. The SQL is:

SELECT Meet.*, Team.*
FROM Meet INNER JOIN
 Participant_team ON Meet.id = Participant_team.Meet INNER JOIN
 Team ON Participant_team.Team = Team.id;

My web2py below implements that.

On Tuesday, September 11, 2012 9:25:01 AM UTC-6, MichaelF wrote:

 I should have added that I can get the same effect with this:

 # In this example, Meet and Team are being connected through 
 Participant_team
 teamStaff = db(db.Meet.id http://db.meet.id/ == request.args(1)).select(
db.Meet.ALL, db.Team.ALL,
join = [db.Participant_team.on(
   db.Participant_team.Meet == 
 db.Meet.idhttp://db.meet.id/
 ),
db.Team.on(db.Participant_team.Team == 
 db.Team.idhttp://db.team.id/
 )])


 On Tuesday, September 11, 2012 9:04:25 AM UTC-6, MichaelF wrote:

 Section 6.21.1 in the manual talks about an alternative syntax for 1-many 
 joins, using the 'on' function. Is that technique available for many-many? 
 I try this and get an error:

 # In this example, Meet and Team are being connected through 
 Participant_team
 teamStaff = db(db.Meet.id == request.args(1)).select(
db.Meet.ALL, db.Team.ALL,
join = db.Team.on(
   (db.Participant_team.Meet == db.Meet.id) 
   (db.Participant_team.Team == db.Team.id)))

 The error is: Unknown column 'Meet.id' in 'on clause'

 I can change db.Team.on to db.Participant_team.on, but I get the same 
 error.

 I have a lot of other JOINs that I must do, but this is the smallest 
 example that shows the problem.



-- 





[web2py] Re: Is 'second option' for one-many available for many-many?

2012-09-11 Thread Massimo Di Pierro
I cannot reproduce the problem. This works for me:

db=DAL()
db.define_table('Meet',Field('name'))
db.define_table('Team',Field('name'))
db.define_table('Participant_team',
Field('Meet',db.Meet),
Field('Team',db.Team))

a=db.Meet.insert(name='here')
b=db.Team.insert(name='snakes')
db.Participant_team.insert(Meet=a,Team=b)
teamStaff = db(db.Meet.id == a).select(
db.Meet.ALL, db.Team.ALL,
join = db.Team.on(
(db.Participant_team.Meet == db.Meet.id) 
(db.Participant_team.Team == db.Team.id)))

print teamStaff


On Tuesday, 11 September 2012 10:04:25 UTC-5, MichaelF wrote:

 Section 6.21.1 in the manual talks about an alternative syntax for 1-many 
 joins, using the 'on' function. Is that technique available for many-many? 
 I try this and get an error:

 # In this example, Meet and Team are being connected through 
 Participant_team
 teamStaff = db(db.Meet.id == request.args(1)).select(
db.Meet.ALL, db.Team.ALL,
join = db.Team.on(
   (db.Participant_team.Meet == db.Meet.id) 
   (db.Participant_team.Team == db.Team.id)))

 The error is: Unknown column 'Meet.id' in 'on clause'

 I can change db.Team.on to db.Participant_team.on, but I get the same 
 error.

 I have a lot of other JOINs that I must do, but this is the smallest 
 example that shows the problem.


-- 





[web2py] Display Image in text

2012-09-11 Thread BlueShadow
Hi I like to have an Image Displayed within the Content of an Article. The 
Content ist stored in a db table.
Up till now I simply displayed the content by this line {{Article.Content}} 
I thought an image with text flowing around the image would freshen up the 
article.
I tried the following I put somewhere in the content of my article 
Image and replace that Tag with the image. 
{{import string}}
{{try:}}
{{content=string.replace(Article.Content, lt;lt;Imagegt;gt;, 
IMG(_src=URL(r=request, c='default', 
f='download',args=Article.InTextImage.thumb),_style='display:block;'))}}
{{except:}}
{{content=string.replace(Article.Content, lt;lt;Imagegt;gt;, )}}
{{pass}}
{{=content}}
I put the whole part into a try clause so no errors are raised when There 
is no Image stored for an Article.
What happens is that every time the except part is executed only removing 
my tag.
Is it even possible to do put the Image in a Text that way?

-- 





[web2py] Re: Is 'second option' for one-many available for many-many?

2012-09-11 Thread MichaelF
Yikes! I *think* I have the same (or functionally the same), but maybe not. 
Might it be that I'm using an out-of-date version? Here's what I'm using:

web2py™(1, 99, 7, datetime.datetime(2012, 3, 4, 22, 12, 8), 
'stable')PythonPython 
2.5.4: C:\Program Files (x86)\web2py\web2py_no_console.exe
I assume the db itself (MySQL) isn't even in play with this problem.

???

On Tuesday, September 11, 2012 9:39:56 AM UTC-6, Massimo Di Pierro wrote:

 I cannot reproduce the problem. This works for me:

 db=DAL()
 db.define_table('Meet',Field('name'))
 db.define_table('Team',Field('name'))
 db.define_table('Participant_team',
 Field('Meet',db.Meet),
 Field('Team',db.Team))

 a=db.Meet.insert(name='here')
 b=db.Team.insert(name='snakes')
 db.Participant_team.insert(Meet=a,Team=b)
 teamStaff = db(db.Meet.id == a).select(
 db.Meet.ALL, db.Team.ALL,
 join = db.Team.on(
 (db.Participant_team.Meet == db.Meet.id) 
 (db.Participant_team.Team == db.Team.id)))

 print teamStaff


 On Tuesday, 11 September 2012 10:04:25 UTC-5, MichaelF wrote:

 Section 6.21.1 in the manual talks about an alternative syntax for 1-many 
 joins, using the 'on' function. Is that technique available for many-many? 
 I try this and get an error:

 # In this example, Meet and Team are being connected through 
 Participant_team
 teamStaff = db(db.Meet.id == request.args(1)).select(
db.Meet.ALL, db.Team.ALL,
join = db.Team.on(
   (db.Participant_team.Meet == db.Meet.id) 
   (db.Participant_team.Team == db.Team.id)))

 The error is: Unknown column 'Meet.id' in 'on clause'

 I can change db.Team.on to db.Participant_team.on, but I get the same 
 error.

 I have a lot of other JOINs that I must do, but this is the smallest 
 example that shows the problem.



-- 





Re: [web2py] Re: internal error crash with newest 2.0.6 and old 1.99.2

2012-09-11 Thread lucas


On Tuesday, September 11, 2012 10:35:02 AM UTC-4, Massimo Di Pierro wrote:

 Some problems have been reported with pg8000. Can you reproduce the errors 
 with psycopg2.


yes, i can reinstall the psycopg2 rpm package.  how do you specify and 
ensure that web2py is using that driver in the DAL?  what is the syntax in 
the DAL statement and is there a db.driver property to see which one it is 
using?  do you think i should use the psycopg2 rpm package or recompile it 
from source for postgresql 9.1?
 

 Can you email me one of the corrupt tickets? I may be able to read them 
 and see what is going on.


what is your email address? 

-- 





[web2py] Re: MENU helper and Server-side DOM work together?

2012-09-11 Thread Massimo Di Pierro
No good reason. The logic can be moved in the constructor but need to be 
tested to make sure nothing breaks.

On Tuesday, 11 September 2012 10:29:02 UTC-5, Anthony wrote:

 Looks like MENU doesn't generate a DOM structure until its .serialize() 
 method is called. You could do:

 mmenu = mmenu.serialize(mmenu.data)
 mmenu.elements('a')

 I'm not sure why it was done this way as opposed to generating the DOM 
 upon initialization. Massimo?

 Anthony

 On Tuesday, September 11, 2012 10:49:59 AM UTC-4, amphisia pui wrote:

 Hi to all 

 I want to use the html helper MENU to have in the page footer a menu 
 totally exploded without sliding items.
 I changed the css classes and everything looks fine but I don't want the 
 first level menu items to be clickable

  so the first thing I tried was the server-side parsing to remove 
 unnecessary tags but in a web2py shell I got

 mlist = ... well formatted web2py menu list

 In [40]: mmenu = MENU(mlist)

  In [41]: mitems = mmenu.elements('a')

 ---
 AttributeErrorTraceback (most recent call 
 last)
 /opt/web2py/applications/happy/models/menu.py in module()
  1 mmenu.elements('a')

 /opt/web2py/gluon/html.pyc in elements(self, *args, **kargs)
1079 # loop the components

1080 if find_text or find_components:
 - 1081 for i, c in enumerate(self.components):
1082 if check and find_text and isinstance(c, str) and 
 \
1083((is_regex and find_text.search(c)) or 
 (str(find_text) in c)):

 AttributeError: 'MENU' object has no attribute 'components'

 Is MENU helper supposed to work with sever side DOM parsing? Is web2py 
 ipython Shell fault?   
 Can you suggest something better to try to have first level items menu 
 seem like simple labels?

 Thanks to all

 AP

 Sys info
 Python 2.7.3
 web2py 2.0.8



-- 





[web2py] Re: Display Image in text

2012-09-11 Thread Massimo Di Pierro
You should not do it that way because the value of content would be escaped.

On Tuesday, 11 September 2012 10:53:18 UTC-5, BlueShadow wrote:

 Hi I like to have an Image Displayed within the Content of an Article. The 
 Content ist stored in a db table.
 Up till now I simply displayed the content by this line 
 {{Article.Content}} 
 I thought an image with text flowing around the image would freshen up the 
 article.
 I tried the following I put somewhere in the content of my article 
 Image and replace that Tag with the image. 
 {{import string}}
 {{try:}}
 {{content=string.replace(Article.Content, lt;lt;Imagegt;gt;, 
 IMG(_src=URL(r=request, c='default', 
 f='download',args=Article.InTextImage.thumb),_style='display:block;'))}}
 {{except:}}
 {{content=string.replace(Article.Content, lt;lt;Imagegt;gt;, )}}
 {{pass}}
 {{=content}}
 I put the whole part into a try clause so no errors are raised when There 
 is no Image stored for an Article.
 What happens is that every time the except part is executed only removing 
 my tag.
 Is it even possible to do put the Image in a Text that way?


-- 





[web2py] Re: Is 'second option' for one-many available for many-many?

2012-09-11 Thread Massimo Di Pierro
Move 2.0.8 or - better - the nightly build.

On Tuesday, 11 September 2012 11:06:11 UTC-5, MichaelF wrote:

 Yikes! I *think* I have the same (or functionally the same), but maybe 
 not. Might it be that I'm using an out-of-date version? Here's what I'm 
 using:

 web2py™(1, 99, 7, datetime.datetime(2012, 3, 4, 22, 12, 8), 'stable')
 PythonPython 2.5.4: C:\Program Files (x86)\web2py\web2py_no_console.exe
 I assume the db itself (MySQL) isn't even in play with this problem.

 ???

 On Tuesday, September 11, 2012 9:39:56 AM UTC-6, Massimo Di Pierro wrote:

 I cannot reproduce the problem. This works for me:

 db=DAL()
 db.define_table('Meet',Field('name'))
 db.define_table('Team',Field('name'))
 db.define_table('Participant_team',
 Field('Meet',db.Meet),
 Field('Team',db.Team))

 a=db.Meet.insert(name='here')
 b=db.Team.insert(name='snakes')
 db.Participant_team.insert(Meet=a,Team=b)
 teamStaff = db(db.Meet.id == a).select(
 db.Meet.ALL, db.Team.ALL,
 join = db.Team.on(
 (db.Participant_team.Meet == db.Meet.id) 
 (db.Participant_team.Team == db.Team.id)))

 print teamStaff


 On Tuesday, 11 September 2012 10:04:25 UTC-5, MichaelF wrote:

 Section 6.21.1 in the manual talks about an alternative syntax for 
 1-many joins, using the 'on' function. Is that technique available for 
 many-many? I try this and get an error:

 # In this example, Meet and Team are being connected through 
 Participant_team
 teamStaff = db(db.Meet.id == request.args(1)).select(
db.Meet.ALL, db.Team.ALL,
join = db.Team.on(
   (db.Participant_team.Meet == db.Meet.id) 
   (db.Participant_team.Team == db.Team.id)))

 The error is: Unknown column 'Meet.id' in 'on clause'

 I can change db.Team.on to db.Participant_team.on, but I get the 
 same error.

 I have a lot of other JOINs that I must do, but this is the smallest 
 example that shows the problem.



-- 





Re: [web2py] Re: internal error crash with newest 2.0.6 and old 1.99.2

2012-09-11 Thread Massimo Di Pierro
print db._adapter.driver_name

but psycopg2 always gets priority over pg8000 unless otherwise specified in 
driver_args.

On Tuesday, 11 September 2012 11:11:43 UTC-5, lucas wrote:



 On Tuesday, September 11, 2012 10:35:02 AM UTC-4, Massimo Di Pierro wrote:

 Some problems have been reported with pg8000. Can you reproduce the 
 errors with psycopg2.


 yes, i can reinstall the psycopg2 rpm package.  how do you specify and 
 ensure that web2py is using that driver in the DAL?  what is the syntax in 
 the DAL statement and is there a db.driver property to see which one it is 
 using?  do you think i should use the psycopg2 rpm package or recompile it 
 from source for postgresql 9.1?
  

 Can you email me one of the corrupt tickets? I may be able to read them 
 and see what is going on.


 what is your email address? 


-- 





[web2py] Re: short term roadmap

2012-09-11 Thread Andrew
For 1  2, if the only remote repository type being considered is Git, then 
using hg-git is probably ideal since it'll support both hg and git locally 
and working with remote git repo's. 

I would like to work on this. Does anyone else have interest / spare cycles 
to help implement this support?

Also, any feedback as to how the interface should be designed for all these 
actions?  Ie, do we keep all remote actions on the site page and then 
specific local actions within the app edit screens?

Andrew

On Saturday, September 8, 2012 6:37:55 PM UTC-5, Massimo Di Pierro wrote:

 I have been speaking with some friends and heavy web2py users and we agree 
 that the following issue need to be addressed:

 1) Improve Mercurial and Git support. Currently Git+web2py allows clone 
 and push whirl Hg+web2py allows commit, status and revert. I think 
 we need an abstraction layer that allows clone, push, commit, 
 status, revert, and pull with both the version control system (with a 
 preference for Git). I think we need an abstraction layer on top of both 
 VCS even if for now we may support only one of them.

 2) Handle gthub callback so that a push to github triggers a local web2py 
 pull (for testing)

 3) make it easier to run tests and manage databases (rename, backup, etc) 
 at the click of a button.

 4) Bootstrap looks great but it is not consistent throughout the 
 welcome app. The idea is that this should be edited in web2py.css instead 
 of any python code to allow backwards compatibility. Also we should 
 avoid changing bootstrap.css so that we can just drop-in new versions 
 of bootstrap, and or bootswatches. So we need someone with good CSS skills. 
 It shouldn't be too much extra work to make it look great out of the box.

 5) Port admin on top of bootstrap (while preserving the artwork).


 If you want to work on any of these topics, there may be funding 
 available. I think 1) should be a priority for web2py 2.1 or 2.2.



 P.S. Friends have suggested looking to the following links:

 Here are some issues and examples of what is possible from
 wrapbootstrap.com templates:
 1. Web2py forms: they are using no styling webkit (see
 registration/login/password reset). (Example:
 http://wbpreview.com/previews/WB00U99JJ/login.html
 2. Navbar has login/logout/password which seems to be styled
 differently that the other menu items. (Nice dropdown example:
 http://wbpreview.com/previews/WB0087188/account.html)
 3. Form Validation: would be nice to use bootstrap form validation
 perhaps with popovers overriding of the the redflash for incomplete
 forms.  (Example:
 http://wbpreview.com/previews/WB0F35928/form-validation.html )
 4. Notifications: Use Bootstrap notifications for flash, overriding
 the web2py growl notifications. (Lot's of options here:
 http://wbpreview.com/previews/WB0881879/noty.html)





-- 





[web2py] Re: Display Image in text

2012-09-11 Thread BlueShadow
So what is the right way to do it?

On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro wrote:

 You should not do it that way because the value of content would be 
 escaped.



-- 





Re: [web2py] Relocated admin using router, problem with appadmin

2012-09-11 Thread Jonathan Lundell
On 10 Sep 2012, at 9:02 AM, Marek Mollin rog...@gmail.com wrote:
 So i have cut down the router to bare minimum, just to check this admin issue.
 I now have:
 
 routers = dict(
   BASE  = dict(
   domains = {
   'myapp.com' : 'myapp1',
   'test.myapp.com' : 'myapp2',
   }
   ),
 )
 logging = 'debug'
 
 after tailing the uwsgi_log i get:
 
 in case of https://myapp.com/admin:
 Error opening file for reading: Permission denied
 and afterwards a few 404.
 
 while https://test.myapp.com/admin:
 just a few 404.
 
 If I turn off the domains and just set default app, everything is fine.
 Admin is accessible.
 

There's a fix (I think) in the trunk for this problem. I'm not sure it's 100% 
fixed; if you try it out, please let me know. 

-- 





Re: [web2py] Re: internal error crash with newest 2.0.6 and old 1.99.2

2012-09-11 Thread LightDot
About python-psycopg2 - I'd rebuild the source rpm with your 9.1 
posgresql-devel, just in case. RHEL/CentOS 6 originally ships with postgres 
8.4.x, so this might be an issue. Usual caveats apply - don't (re)build rpm 
packages as root, etc.

Regards,
Ales

On Tuesday, September 11, 2012 6:11:43 PM UTC+2, lucas wrote:



 On Tuesday, September 11, 2012 10:35:02 AM UTC-4, Massimo Di Pierro wrote:

 Some problems have been reported with pg8000. Can you reproduce the 
 errors with psycopg2.


 yes, i can reinstall the psycopg2 rpm package.  how do you specify and 
 ensure that web2py is using that driver in the DAL?  what is the syntax in 
 the DAL statement and is there a db.driver property to see which one it is 
 using?  do you think i should use the psycopg2 rpm package or recompile it 
 from source for postgresql 9.1?
  

 Can you email me one of the corrupt tickets? I may be able to read them 
 and see what is going on.


 what is your email address? 


-- 





[web2py] Re: short term roadmap

2012-09-11 Thread Massimo Di Pierro
+1

On Tuesday, 11 September 2012 11:18:00 UTC-5, Andrew wrote:

 For 1  2, if the only remote repository type being considered is Git, 
 then using hg-git is probably ideal since it'll support both hg and git 
 locally and working with remote git repo's. 

 I would like to work on this. Does anyone else have interest / spare 
 cycles to help implement this support?

 Also, any feedback as to how the interface should be designed for all 
 these actions?  Ie, do we keep all remote actions on the site page and then 
 specific local actions within the app edit screens?

 Andrew

 On Saturday, September 8, 2012 6:37:55 PM UTC-5, Massimo Di Pierro wrote:

 I have been speaking with some friends and heavy web2py users and we 
 agree that the following issue need to be addressed:

 1) Improve Mercurial and Git support. Currently Git+web2py allows clone 
 and push whirl Hg+web2py allows commit, status and revert. I think 
 we need an abstraction layer that allows clone, push, commit, 
 status, revert, and pull with both the version control system (with a 
 preference for Git). I think we need an abstraction layer on top of both 
 VCS even if for now we may support only one of them.

 2) Handle gthub callback so that a push to github triggers a local web2py 
 pull (for testing)

 3) make it easier to run tests and manage databases (rename, backup, etc) 
 at the click of a button.

 4) Bootstrap looks great but it is not consistent throughout the 
 welcome app. The idea is that this should be edited in web2py.css instead 
 of any python code to allow backwards compatibility. Also we should 
 avoid changing bootstrap.css so that we can just drop-in new versions 
 of bootstrap, and or bootswatches. So we need someone with good CSS skills. 
 It shouldn't be too much extra work to make it look great out of the box.

 5) Port admin on top of bootstrap (while preserving the artwork).


 If you want to work on any of these topics, there may be funding 
 available. I think 1) should be a priority for web2py 2.1 or 2.2.



 P.S. Friends have suggested looking to the following links:

 Here are some issues and examples of what is possible from
 wrapbootstrap.com templates:
 1. Web2py forms: they are using no styling webkit (see
 registration/login/password reset). (Example:
 http://wbpreview.com/previews/WB00U99JJ/login.html
 2. Navbar has login/logout/password which seems to be styled
 differently that the other menu items. (Nice dropdown example:
 http://wbpreview.com/previews/WB0087188/account.html)
 3. Form Validation: would be nice to use bootstrap form validation
 perhaps with popovers overriding of the the redflash for incomplete
 forms.  (Example:
 http://wbpreview.com/previews/WB0F35928/form-validation.html )
 4. Notifications: Use Bootstrap notifications for flash, overriding
 the web2py growl notifications. (Lot's of options here:
 http://wbpreview.com/previews/WB0881879/noty.html)





-- 





[web2py] Re: short term roadmap

2012-09-11 Thread Massimo Di Pierro
I think the first thing to to would be to create a module that implements 
the features we want. The logic should not be in the admin actions. I think 
we need a general purpose way to call scripts from apps (in this case 
admin)  that run in background and communicate with them. I am working on 
this mechanism.

On Tuesday, 11 September 2012 11:18:00 UTC-5, Andrew wrote:

 For 1  2, if the only remote repository type being considered is Git, 
 then using hg-git is probably ideal since it'll support both hg and git 
 locally and working with remote git repo's. 

 I would like to work on this. Does anyone else have interest / spare 
 cycles to help implement this support?

 Also, any feedback as to how the interface should be designed for all 
 these actions?  Ie, do we keep all remote actions on the site page and then 
 specific local actions within the app edit screens?

 Andrew

 On Saturday, September 8, 2012 6:37:55 PM UTC-5, Massimo Di Pierro wrote:

 I have been speaking with some friends and heavy web2py users and we 
 agree that the following issue need to be addressed:

 1) Improve Mercurial and Git support. Currently Git+web2py allows clone 
 and push whirl Hg+web2py allows commit, status and revert. I think 
 we need an abstraction layer that allows clone, push, commit, 
 status, revert, and pull with both the version control system (with a 
 preference for Git). I think we need an abstraction layer on top of both 
 VCS even if for now we may support only one of them.

 2) Handle gthub callback so that a push to github triggers a local web2py 
 pull (for testing)

 3) make it easier to run tests and manage databases (rename, backup, etc) 
 at the click of a button.

 4) Bootstrap looks great but it is not consistent throughout the 
 welcome app. The idea is that this should be edited in web2py.css instead 
 of any python code to allow backwards compatibility. Also we should 
 avoid changing bootstrap.css so that we can just drop-in new versions 
 of bootstrap, and or bootswatches. So we need someone with good CSS skills. 
 It shouldn't be too much extra work to make it look great out of the box.

 5) Port admin on top of bootstrap (while preserving the artwork).


 If you want to work on any of these topics, there may be funding 
 available. I think 1) should be a priority for web2py 2.1 or 2.2.



 P.S. Friends have suggested looking to the following links:

 Here are some issues and examples of what is possible from
 wrapbootstrap.com templates:
 1. Web2py forms: they are using no styling webkit (see
 registration/login/password reset). (Example:
 http://wbpreview.com/previews/WB00U99JJ/login.html
 2. Navbar has login/logout/password which seems to be styled
 differently that the other menu items. (Nice dropdown example:
 http://wbpreview.com/previews/WB0087188/account.html)
 3. Form Validation: would be nice to use bootstrap form validation
 perhaps with popovers overriding of the the redflash for incomplete
 forms.  (Example:
 http://wbpreview.com/previews/WB0F35928/form-validation.html )
 4. Notifications: Use Bootstrap notifications for flash, overriding
 the web2py growl notifications. (Lot's of options here:
 http://wbpreview.com/previews/WB0881879/noty.html)





-- 





[web2py] Re: Display Image in text

2012-09-11 Thread Massimo Di Pierro
It depends. Does content contain HTML?

On Tuesday, 11 September 2012 11:36:02 UTC-5, BlueShadow wrote:

 So what is the right way to do it?

 On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro wrote:

 You should not do it that way because the value of content would be 
 escaped.



-- 





[web2py] Re: Display Image in text

2012-09-11 Thread BlueShadow
It does I display it by this line to be exact: {{=XML(Artical.Content)}}

On Tuesday, September 11, 2012 6:49:40 PM UTC+2, Massimo Di Pierro wrote:

 It depends. Does content contain HTML?

 On Tuesday, 11 September 2012 11:36:02 UTC-5, BlueShadow wrote:

 So what is the right way to do it?

 On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro wrote:

 You should not do it that way because the value of content would be 
 escaped.



-- 





Re: [web2py] [OT] Ubuntu 12.10 will no longer ship with Python 2

2012-09-11 Thread LightDot
I have been running python and python3 packages side by side on Fedora ever 
since python 3 came out. I'm sure all bigger distros have this taken care 
of in a similar way... I was curious so I took a look:

- Debian has 2.x as 'python' and 3.x as 'python3'
- Fedora has 2.x as 'python' and 3.x as 'python3'
- Ubuntu has 2.x as 'python' and 3.x as 'python3'
- OpenSUSE has 2x as 'python' and 3.x as 'python3'
- Arch has 2.x as 'python2' and 3.x as 'python' (!).

Regards,
Ales

On Tuesday, September 11, 2012 4:11:57 PM UTC+2, Jonathan Lundell wrote:

 On 10 Sep 2012, at 11:32 PM, pbreit pbreit...@gmail.com javascript: 
 wrote: 
  
  Well...for starters, web2py, fabric and pil are 2.7. So, yes, I think it 
 is an absolutely, insanely user-hostile decision. The python ecosystem is 
 not even close to ready to move to 3. And from what I can tell, 3 offers 
 minimal benefits. 

 OTOH, it's never going to be ready to move until it gets a push. A first 
 step would be to be able to count on its presence.

-- 





Re: [web2py] Re: Web2py. for a minimalist app, it feels bloated. Do it I need it?

2012-09-11 Thread Andrew W
With its SQL http://code.google.com/p/orient/wiki/GraphDatabase#SQL it sounds 
like a candidate for a straight dal database adapter.  
A graph database sounds interesting..

-- 





[web2py] Error in appadmin

2012-09-11 Thread Martin Weissenboeck
I wanted to see a row of a table and I started the database administration
tool. I get the following snapshot.   There is a trailing %, but no s -
why?
self.label '%(last_name)s %(first_name)%'
Error snapshot [image: help]

type 'exceptions.KeyError'('first_name')

inspect attributes
 Frames

   -

   *File D:\dropbox\InfoSMS\web2py\gluon\restricted.py in restricted at
   line 209* code arguments variables
-

   *File
   D:\dropbox\InfoSMS\web2py\applications\secure\controllers\appadmin.py in
   module at line 441* code arguments variables
-

   *File D:\dropbox\InfoSMS\web2py\gluon\globals.py in lambda at line 185*
   code arguments variables
-

   *File
   D:\dropbox\InfoSMS\web2py\applications\secure\controllers\appadmin.py in
   update at line 283* code arguments variables
-

   *File D:\dropbox\InfoSMS\web2py\gluon\sqlhtml.py in __init__ at line 1015
   * code arguments variables
-

   *File D:\dropbox\InfoSMS\web2py\gluon\sqlhtml.py in widget at line 227*
   code arguments variables
-

   *File D:\dropbox\InfoSMS\web2py\gluon\validators.py in _options at line
   2480* code arguments variables
-

   *File D:\dropbox\InfoSMS\web2py\gluon\validators.py in options at line
   479* code arguments variables
-

   *File D:\dropbox\InfoSMS\web2py\gluon\validators.py in build_set at line
   474* code arguments variables
Function argument list

   (self=gluon.validators.IS_IN_DB object)
Code listing


   469.
   470.
   471.
   472.
   473.
   474.

   475.
   476.
   477.
   478.


   reduce(lambda a,b:a|b,(f for f in fields if not
f.name=='id'))

   dd = dict(orderby=orderby, cache=self.cache)

   records = self.dbset(table).select(table.ALL, **dd)

   self.theset = [str(r[self.kfield]) for r in records]

   if isinstance(self.label,str):
   self.labels = [self.label % dict(r) for r in records]

   else:
   self.labels = [self.label(r) for r in records]

   def options(self, zero=True):

 Variables  self.labels undefined  self gluon.validators.IS_IN_DB
   object  records Rows (897)  r Row {'sprechtag_wunsch': Set
   (sprechtag_wunsch... gluon.dal.RecordDeleter object at 0x09DB2350}
   self.label '%(last_name)s %(first_name)%'  builtindict type 'dict'

 Context

Regards, Martin

-- 





[web2py] Re: Display Image in text

2012-09-11 Thread Massimo Di Pierro
You should be able to do:

{{
if Article.InTextImage.thumb:
   src = URL('download',args=Article.InTextImage.thumb)
   content 
= 
Article.Content.replace('Image',IMG(_src=src,_style='display:block;').xml())
else:
   content = Article.Content.replace('Image','')
pass
=XML(content, sanitize=True) # sanitize=True is optional but recommended
}}



On Tuesday, 11 September 2012 11:51:42 UTC-5, BlueShadow wrote:

 It does contain HTML for formatting. I display it by this line: 
 {{=XML(Article.Content)}} to be exact

 On Tuesday, September 11, 2012 6:49:40 PM UTC+2, Massimo Di Pierro wrote:

 It depends. Does content contain HTML?

 On Tuesday, 11 September 2012 11:36:02 UTC-5, BlueShadow wrote:

 So what is the right way to do it?

 On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro wrote:

 You should not do it that way because the value of content would be 
 escaped.



-- 





Re: [web2py] [OT] Ubuntu 12.10 will no longer ship with Python 2

2012-09-11 Thread Massimo Di Pierro
yes. everybody is doing this right but Arch. python3 has to be available 
but has to treated as a different language.

On Tuesday, 11 September 2012 12:09:19 UTC-5, LightDot wrote:

 I have been running python and python3 packages side by side on Fedora 
 ever since python 3 came out. I'm sure all bigger distros have this taken 
 care of in a similar way... I was curious so I took a look:

 - Debian has 2.x as 'python' and 3.x as 'python3'
 - Fedora has 2.x as 'python' and 3.x as 'python3'
 - Ubuntu has 2.x as 'python' and 3.x as 'python3'
 - OpenSUSE has 2x as 'python' and 3.x as 'python3'
 - Arch has 2.x as 'python2' and 3.x as 'python' (!).

 Regards,
 Ales

 On Tuesday, September 11, 2012 4:11:57 PM UTC+2, Jonathan Lundell wrote:

 On 10 Sep 2012, at 11:32 PM, pbreit pbreit...@gmail.com wrote: 
  
  Well...for starters, web2py, fabric and pil are 2.7. So, yes, I think 
 it is an absolutely, insanely user-hostile decision. The python ecosystem 
 is not even close to ready to move to 3. And from what I can tell, 3 offers 
 minimal benefits. 

 OTOH, it's never going to be ready to move until it gets a push. A first 
 step would be to be able to count on its presence.



-- 





[web2py] Re: Error in appadmin

2012-09-11 Thread Massimo Di Pierro
Not in web2py. Perhaps in the code you are running?

$ grep '%(first_name)' gluon/*.py
gluon/tools.py:user_identifier = '%(first_name)s'
gluon/tools.py:return '%(first_name)s %(last_name)s' % user
gluon/tools.py:format='%(first_name)s %(last_name)s 
(%(id)s)'))




On Tuesday, 11 September 2012 13:14:11 UTC-5, mweissen wrote:

 I wanted to see a row of a table and I started the database administration 
 tool. I get the following snapshot.   There is a trailing %, but no s - 
 why?
 self.label '%(last_name)s %(first_name)%'
 Error snapshot [image: help]  

 type 'exceptions.KeyError'('first_name') 

 inspect attributes 
  Frames 

-  

*File D:\dropbox\InfoSMS\web2py\gluon\restricted.py in restricted at 
line 209* code arguments variables 
 -  

*File 
D:\dropbox\InfoSMS\web2py\applications\secure\controllers\appadmin.py in 
module at line 441* code arguments variables 
 -  

*File D:\dropbox\InfoSMS\web2py\gluon\globals.py in lambda at line 
185* code arguments variables 
 -  

*File 
D:\dropbox\InfoSMS\web2py\applications\secure\controllers\appadmin.py in 
update at line 283* code arguments variables 
 -  

*File D:\dropbox\InfoSMS\web2py\gluon\sqlhtml.py in __init__ at line 
1015* code arguments variables 
 -  

*File D:\dropbox\InfoSMS\web2py\gluon\sqlhtml.py in widget at line 227* 
code arguments variables 
 -  

*File D:\dropbox\InfoSMS\web2py\gluon\validators.py in _options at 
line 2480* code arguments variables 
 -  

*File D:\dropbox\InfoSMS\web2py\gluon\validators.py in options at line 
479* code arguments variables 
 -  

*File D:\dropbox\InfoSMS\web2py\gluon\validators.py in build_set at 
line 474* code arguments variables 
 Function argument list 

(self=gluon.validators.IS_IN_DB object)
 Code listing 

469.
470.
471.
472.
473.
474.

475.
476.
477.
478.

reduce(lambda a,b:a|b,(f for f in fields if not 
 f.name=='id'))


dd = dict(orderby=orderby, cache=self.cache)


records = self.dbset(table).select(table.ALL, **dd)


self.theset = [str(r[self.kfield]) for r in records]


if isinstance(self.label,str):

self.labels = [self.label % dict(r) for r in records]


else:
self.labels = [self.label(r) for r in records]


def options(self, zero=True):

  Variables  self.labels undefined  self gluon.validators.IS_IN_DB 
object  records Rows (897)  r Row {'sprechtag_wunsch': Set 
(sprechtag_wunsch... gluon.dal.RecordDeleter object at 0x09DB2350}  
self.label '%(last_name)s %(first_name)%'  builtindict type 'dict'  
 
  Context

 Regards, Martin


-- 





Re: [web2py] Relocated admin using router, problem with appadmin

2012-09-11 Thread Marek Mollin
We be rollin ;]
It works perfectly so far. Both admin and appadmin.
Relocating admin doesnt work but its no big deal I guess.

Thanks a million!

W dniu wtorek, 11 września 2012 18:36:12 UTC+2 użytkownik Jonathan Lundell 
napisał:

 On 10 Sep 2012, at 9:02 AM, Marek Mollin rog...@gmail.com javascript: 
 wrote:

 So i have cut down the router to bare minimum, just to check this admin 
 issue.
 I now have:

 routers = dict(
   BASE  = dict(
   domains = {
   'myapp.com' : 'myapp1',
   'test.myapp.com' : 'myapp2',
   }
   ),
 )
 logging = 'debug'


 after tailing the uwsgi_log i get:

 in case of https://myapp.com/admin:
 Error opening file for reading: Permission denied
 and afterwards a few 404.

 while https://test.myapp.com/admin:
 just a few 404.

 If I turn off the domains and just set default app, everything is fine.
 Admin is accessible.


 There's a fix (I think) in the trunk for this problem. I'm not sure it's 
 100% fixed; if you try it out, please let me know. 


-- 





[web2py] Do you value Matplotlib? Read this!

2012-09-11 Thread Massimo Di Pierro
http://numfocus.org/johnhunter/

quote
John Hunter, author of Matplotlib, founding board member of NumFOCUS, 
husband to Miriam, and father to three daughters: Clara, Ava, and Rahel, 
was diagnosed with cancer in late July 2012 after returning from his 
keynote address at SciPy in Austin, TX. He passed away on August 28th from 
complications arising from necessary cancer treatment. See the announcement 
email by his good friend, Fernando Perez.

John has given so much to all of us in the Python community, now is our 
time to give something back to his family by providing for the education 
and support of his children. We have setup the John Hunter Memorial Fund to 
provide a mechanism for individuals and companies who have appreciated 
John’s work, to give back to him by ensuring that his children have funds 
available for their education.
/quote

To donate: http://numfocus.org/johnhunter/

-- 





Re: [web2py] Relocated admin using router, problem with appadmin

2012-09-11 Thread Jonathan Lundell
On 11 Sep 2012, at 12:04 PM, Marek Mollin rog...@gmail.com wrote:
 We be rollin ;]
 It works perfectly so far. Both admin and appadmin.
 Relocating admin doesnt work but its no big deal I guess.

What happens when you relocate admin? 

 
 Thanks a million!
 
 W dniu wtorek, 11 września 2012 18:36:12 UTC+2 użytkownik Jonathan Lundell 
 napisał:
 On 10 Sep 2012, at 9:02 AM, Marek Mollin rog...@gmail.com wrote:
 So i have cut down the router to bare minimum, just to check this admin 
 issue.
 I now have:
 
 routers = dict(
   BASE  = dict(
   domains = {
   'myapp.com' : 'myapp1',
   'test.myapp.com' : 'myapp2',
   }
   ),
 )
 logging = 'debug'
 
 after tailing the uwsgi_log i get:
 
 in case of https://myapp.com/admin:
 Error opening file for reading: Permission denied
 and afterwards a few 404.
 
 while https://test.myapp.com/admin:
 just a few 404.
 
 If I turn off the domains and just set default app, everything is fine.
 Admin is accessible.
 
 
 There's a fix (I think) in the trunk for this problem. I'm not sure it's 100% 
 fixed; if you try it out, please let me know. 
 
 -- 
  
  
  


-- 





[web2py] What data should be private (for security) in a standard web2py installation?

2012-09-11 Thread monotasker
I'm using github for open-source development of some web2py apps and want 
to make sure I'm not exposing any data that would be a security risk. As 
far as I can tell, the sensitive pieces of data in a standard app would be:

- email account information (by default in db.py)
- any recaptcha keys (by default in db.py)
- the private/auth.key file

What about the Auth.settings.hmac_key that appears in my db.py? (As you can 
tell, I'm not familiar with much of how these encryption schemes work.) 
Anything else that I'm missing? My plan is to have db.py read any sensitive 
data from a text file on the server, in a folder that isn't shared on 
github.

Ian

-- 





Re: [web2py] Relocated admin using router, problem with appadmin

2012-09-11 Thread Marek Mollin
It fires up default app.

W dniu wtorek, 11 września 2012 21:15:50 UTC+2 użytkownik Jonathan Lundell 
napisał:

 On 11 Sep 2012, at 12:04 PM, Marek Mollin rog...@gmail.com javascript: 
 wrote:

 We be rollin ;]
 It works perfectly so far. Both admin and appadmin.
 Relocating admin doesnt work but its no big deal I guess.


 What happens when you relocate admin? 


 Thanks a million!

 W dniu wtorek, 11 września 2012 18:36:12 UTC+2 użytkownik Jonathan Lundell 
 napisał:

 On 10 Sep 2012, at 9:02 AM, Marek Mollin rog...@gmail.com wrote:

 So i have cut down the router to bare minimum, just to check this admin 
 issue.
 I now have:

 routers = dict(
   BASE  = dict(
   domains = {
   'myapp.com' : 'myapp1',
   'test.myapp.com' : 'myapp2',
   }
   ),
 )
 logging = 'debug'


 after tailing the uwsgi_log i get:

 in case of https://myapp.com/admin:
 Error opening file for reading: Permission denied
 and afterwards a few 404.

 while https://test.myapp.com/admin:
 just a few 404.

 If I turn off the domains and just set default app, everything is fine.
 Admin is accessible.


 There's a fix (I think) in the trunk for this problem. I'm not sure it's 
 100% fixed; if you try it out, please let me know. 


 -- 
  
  
  





-- 





Re: [web2py] Re: Web2py. for a minimalist app, it feels bloated. Do it I need it?

2012-09-11 Thread Shawn McElroy
yes that is true as well. but to me at least, using the gremlin syntax
seems a lot more intuitive for crud operations on a graph.

On Tue, Sep 11, 2012 at 11:13 AM, Andrew W awillima...@gmail.com wrote:

 With its SQL http://code.google.com/p/orient/wiki/GraphDatabase#SQL it
 sounds like a candidate for a straight dal database adapter.
 A graph database sounds interesting..

 --






-- 

 -- Shawn McElroy

Anything worth doing, is worth doing right  — Hunter S. Thompson

A mind troubled by doubt cannot focus on the course to victory —
Ahttp://www.goodreads.com/author/quotes/5237.Hunter_S_Thompsonrthur
Golden

-- 





Re: [web2py] Relocated admin using router, problem with appadmin

2012-09-11 Thread Marek Mollin
Checked again with restarting entire server and it seems fine.

Redirects to admin just fine:
small problem starts when you enter particular's app appadmin it goes under 
url: admin.myapp.com/myapp/appadmin
and css goes a bit wierd:
http://i.imgur.com/0eOYe.png 


W dniu wtorek, 11 września 2012 21:27:15 UTC+2 użytkownik Marek Mollin 
napisał:

 It fires up default app.

 W dniu wtorek, 11 września 2012 21:15:50 UTC+2 użytkownik Jonathan Lundell 
 napisał:

 On 11 Sep 2012, at 12:04 PM, Marek Mollin rog...@gmail.com wrote:

 We be rollin ;]
 It works perfectly so far. Both admin and appadmin.
 Relocating admin doesnt work but its no big deal I guess.


 What happens when you relocate admin? 


 Thanks a million!

 W dniu wtorek, 11 września 2012 18:36:12 UTC+2 użytkownik Jonathan 
 Lundell napisał:

 On 10 Sep 2012, at 9:02 AM, Marek Mollin rog...@gmail.com wrote:

 So i have cut down the router to bare minimum, just to check this admin 
 issue.
 I now have:

 routers = dict(
   BASE  = dict(
   domains = {
   'myapp.com' : 'myapp1',
   'test.myapp.com' : 'myapp2',
   }
   ),
 )
 logging = 'debug'


 after tailing the uwsgi_log i get:

 in case of https://myapp.com/admin:
 Error opening file for reading: Permission denied
 and afterwards a few 404.

 while https://test.myapp.com/admin:
 just a few 404.

 If I turn off the domains and just set default app, everything is fine.
 Admin is accessible.


 There's a fix (I think) in the trunk for this problem. I'm not sure it's 
 100% fixed; if you try it out, please let me know. 


 -- 
  
  
  





-- 





Re: [web2py] Relocated admin using router, problem with appadmin

2012-09-11 Thread Jonathan Lundell
On 11 Sep 2012, at 12:32 PM, Marek Mollin rog...@gmail.com wrote:
 Checked again with restarting entire server and it seems fine.
 
 Redirects to admin just fine:
 small problem starts when you enter particular's app appadmin it goes under 
 url: admin.myapp.com/myapp/appadmin

Post the router, please. I'll experiment when I get the chance.

Where/when do you see the above URL, exactly? 

 and css goes a bit wierd:
 http://i.imgur.com/0eOYe.png 
 
 
 W dniu wtorek, 11 września 2012 21:27:15 UTC+2 użytkownik Marek Mollin 
 napisał:
 It fires up default app.
 
 W dniu wtorek, 11 września 2012 21:15:50 UTC+2 użytkownik Jonathan Lundell 
 napisał:
 On 11 Sep 2012, at 12:04 PM, Marek Mollin rog...@gmail.com wrote:
 We be rollin ;]
 It works perfectly so far. Both admin and appadmin.
 Relocating admin doesnt work but its no big deal I guess.
 
 What happens when you relocate admin? 
 


-- 





[web2py] Re: What data should be private (for security) in a standard web2py installation?

2012-09-11 Thread Niphlod
- the dal URI if it contains logins/password/db that is not localhost
- eventually janrain key is to be kept private as well.
PS: Auth.settings_hmac_key in modern scaffolding apps is not written 
plainly: it is replaced by Auth.get_or_create_key() that reads from 
private/auth.key or it creates a new one (so if you don't ship 
private/auth.key you're fine)

My normal environment is having a 0_production.py and a 0_test.py with 
DAL URI, db connection, Auth and mail parameters. In the db.py reside all 
define_table() statements. Publishing 0_test.py to the repo, added 
0_production.py instead to the ignore list. When deploying to production 
server, 0_production.py is already there (or transferred separately), 
0_test.py is renamed to 0_test.py.bak.

Little trick, you can have a 0_Atest.py and a 0_Zproduction.py . As long as 
all the things defined into 0_Atest.py are redefined into 
0_Zproduction.py you are fine (models are executed alphabetically). Anyway 
it's not recommended, also for performance issues (ideally you have already 
a deployment script and renaming one file shouldn't be so hard ^_^)

On Tuesday, September 11, 2012 9:20:34 PM UTC+2, monotasker wrote:

 I'm using github for open-source development of some web2py apps and want 
 to make sure I'm not exposing any data that would be a security risk. As 
 far as I can tell, the sensitive pieces of data in a standard app would be:

 - email account information (by default in db.py)
 - any recaptcha keys (by default in db.py)
 - the private/auth.key file

 What about the Auth.settings.hmac_key that appears in my db.py? (As you 
 can tell, I'm not familiar with much of how these encryption schemes work.) 
 Anything else that I'm missing? My plan is to have db.py read any sensitive 
 data from a text file on the server, in a folder that isn't shared on 
 github.

 Ian


-- 





[web2py] Can I have 2 auth tables in a single application?

2012-09-11 Thread Pystar
In the application I am developing, I would like to know if I can have 2 
auth tables in it? The reason is that I would like to have ordinary users 
that would use the auth_user table with some 
extra fields added and then an admin table with some unique fields. How do 
I go about implementing something like this? Also I would like to 
autogenerate a username and password for users whenever they try to 
register for my app. How do I do this too?
I need help on this like yesterday. Thanks

-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread martzi
FYI : putting all the fields in one table will result to multiple columns 
...

On Tuesday, September 11, 2012 5:31:37 PM UTC+2, Anthony wrote:

 Why do you want a one-to-one relation? Can't you just put all the fields 
 in one table?

 Anthony

 On Tuesday, September 11, 2012 9:23:16 AM UTC-4, martzi wrote:

 Unique = True,  has probably no effect. see below.
 ...
  db = DAL('sqlite://storage.db')
  person = db.define_table('person', Field('name'))
  bodypart = db.define_table('bodypart', Field('name'), Field('owner', 
 'reference person', unique=True)) #unique= True seems to have no effect
  pid = person.insert(name='Sid')
  bpid = bodypart.insert(name='arms', owner= pid) #pid = 1
  bodypart(bpid).owner #bpid = 1, first insertion of owner as 1
 1
  bpid = bodypart.insert(name='mouth', owner= pid) # multiple entries 
 not caught, pid is still 1
  bodypart(bpid).owner #bpid = 2, second insertion of owner as 1 AGAIN
 1

 On Tuesday, September 11, 2012 2:22:09 PM UTC+2, villas wrote:

 I am quite familiar with cascade;  I just couldn't figure out how it 
 could assist you.

 In my opinion,  Field('','reference other_table', unique=True)  
 should be supported and work.  Maybe you added the constraint later and the 
 DB didn't accept it because you already had duplicated field contents.

 In any case,  even if unique=True is not working for the moment,  then a 
 work-around would be to make a unique index on the field yourself.  You'll 
 have to handle exceptions when the insert/update fails due to duplicate 
 keys.




 On Tuesday, September 11, 2012 12:48:49 PM UTC+1, martzi wrote:

 Thanks for the reply. But if you meant Field('','reference 
 other_table', unique=True), I have tried that with failure, i am still 
 having a one-to-many relation. FYI: Regarding CASCADE, an  ondelete 
 cascade 
 causes deletion of all referred data.

 On Tuesday, September 11, 2012 1:37:59 PM UTC+2, villas wrote:

 I may be wrong,  but I do not think Cascade could assist you with 
 enforcing a 1-1 relationship. 
 Maybe making the foreign key field unique would help?


 On Monday, September 10, 2012 11:45:28 AM UTC+1, martzi wrote:

 Hi,
 I wonder if there a way to enforce a one to one relationship with 
 Cascade via web2py  DAL API. ???



-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-11 Thread martzi
Thanks for the reply. But db.executesql('create unique index idx_owner on 
bodypart(owner)') returned the below error, and still didn't solve the 
problem.
Traceback (most recent call last):
  File console, line 1, in module
  File /home/martin/Documents/web2py2/gluon/dal.py, line 7234, in 
executesql
adapter.execute(query)
  File /home/martin/Documents/web2py2/gluon/dal.py, line 1659, in execute
return self.log_execute(*a, **b)
  File /home/martin/Documents/web2py2/gluon/dal.py, line 1653, in 
log_execute
ret = self.cursor.execute(*a, **b)
IntegrityError: indexed columns are not unique

On Tuesday, September 11, 2012 5:17:54 PM UTC+2, villas wrote:

 Add this line as a test:

 db.executesql('create unique index idx_owner on bodypart(owner)')

 to your code like this:

 db = DAL('sqlite://storage.db')
 person = db.define_table('person', Field('name'))
 bodypart = db.define_table('bodypart', Field('name'), Field('owner', 
 'reference 
 person', unique=True)) 
 db.executesql('create unique index idx_owner on bodypart(owner)')
 pid = person.insert(name='Sid')
 bpid = bodypart.insert(name='arms', owner= pid) 
 bodypart(bpid).owner 
 bpid = bodypart.insert(name='mouth', owner= pid) 
 bodypart(bpid).owner 




-- 





[web2py] Re: Trying to cook up a new web2py widget and it is going sour BIG TIME ... !!!!!^%%$#????

2012-09-11 Thread howesc
Don_x,

i would recommend that your break your problem down into small 
chunksyou listed several bits and pieces that you are having trouble 
with.  i suggest you look to fix them one at a time.

can you:
 - more clearly state your requirements
 - show/tell exactly what is going wrong, including error tracebacks
 - include sample code that shows the issue you are trying to solve.

thanks,

cfh

On Monday, September 10, 2012 7:28:19 PM UTC-7, Don_X wrote:

 Hello web2py users ...

 I am going out of my mind with this !

 I am trying to cook up a widget ... ( or a plugin )  inspired from the 
 SELECT_OR_ADD_OPTION widget ! but

  it uses radio buttons instead of a dropdown select menu, it is about 
 selecting a profile picture among a number of pics shown and defined   and 
 where the user has the alternative option to ADD ( or upload his own pic ( 
 by uploading that picture from his computer hard drive for example ) and 
 have it shown in the same view without refreshing the page with its related 
 radio button selected to choose the newly uploaded picture from the pack 
 and affect the field of the form ( table ) upon submit !

   How can I succeed in tweaking the SELECT_OR_ADD_OPTION widget and mixing 
 it with the js scripts proposed here : 
 http://blueimp.github.com/jQuery-File-Upload/

 Please advise, any assistance  with this matter will be greatly 
 appreciated !

 I am going out of my mind with this ! .. nothing works ! ... this shows me 
 I got so much to learn ..

 any suggestion anyone !

 PS. I used the IS_IN_SET instead of IS_IN_DB, and I defined the image set 
 like this : 

 default_pics =

 { 1:IMG(_src=URL('static','images/picture1.png')),
 2:IMG(_src=URL('static','images/picture2.png')),
 3:IMG(_src=URL('static','images/picture3.png')), 
 4: . }

 The images are showing up ... but the rest just cannot work out !! ... any 
 suggestions any one ? ...

 That would be a nice widget to have around !


-- 





[web2py] Re: Display Image in text

2012-09-11 Thread BlueShadow
thanks Massimo. that works. Is it also possible to make the image 
float:left or right So the text flowes around the image.
I tried adding float:left; to the _style but it doesnt have any effect.

On Tuesday, September 11, 2012 8:50:56 PM UTC+2, Massimo Di Pierro wrote:

 You should be able to do:

 {{
 if Article.InTextImage.thumb:
src = URL('download',args=Article.InTextImage.thumb)
content 
 = 
 Article.Content.replace('Image',IMG(_src=src,_style='display:block;').xml())
 else:
content = Article.Content.replace('Image','')
 pass
 =XML(content, sanitize=True) # sanitize=True is optional but recommended
 }}



 On Tuesday, 11 September 2012 11:51:42 UTC-5, BlueShadow wrote:

 It does contain HTML for formatting. I display it by this line: 
 {{=XML(Article.Content)}} to be exact

 On Tuesday, September 11, 2012 6:49:40 PM UTC+2, Massimo Di Pierro wrote:

 It depends. Does content contain HTML?

 On Tuesday, 11 September 2012 11:36:02 UTC-5, BlueShadow wrote:

 So what is the right way to do it?

 On Tuesday, September 11, 2012 6:15:29 PM UTC+2, Massimo Di Pierro 
 wrote:

 You should not do it that way because the value of content would be 
 escaped.



-- 





Re: [web2py] Re: Web2py. for a minimalist app, it feels bloated. Do it I need it?

2012-09-11 Thread David Marko
+1

-- 





Re: [web2py] Removing labels from forms

2012-09-11 Thread Richard Vézina
input is a reserved word...

Richard

On Fri, Aug 31, 2012 at 1:01 PM, Alec Taylor alec.tayl...@gmail.com wrote:

 Perfect, thanks to you both :)

 --





-- 





[web2py] When/how is 'format' used?

2012-09-11 Thread MichaelF
I have the following parent-child:

db.define_table('Institution',
Field('Institution_name', 'string', length=60, 
required=True,
   unique=True),
format='%(Institution_name)s')

db.define_table('Team',
Field('Institution', db.Institution),
...

I retrieve some records:

   meetTeams = db(db.Team.id == request.args(1)).select(
  db.Team.Institution, db.Team.Sex,
  db.Institution.Institution_name,
  join = [db.Team.on(db.Team.id == 
db.Participant_team.Team),
  db.Institution.on(db.Team.Institution == 
db.Institution.id)])

I pull out some data:
for team in meetTeams:
   message += %s %d %s\n % (team.Team.Sex,
 team.Team.Institution,
 team.Institution.Institution_name)

I return locals(), and I have no explicit view. When meetTeams is 
displayed, the field team.Team.Institution displays with the 
expected/defined 'format'. When 'message' is displayed, 
team.Team.Institution shows up as an int.

Three questions:

   1. What's the 'magic' going on that tells the display code for meetTeams 
   to use the 'format' expression (but not to use it when displaying 
   'message')? Does it realize it's a row, and the row knows how to display 
   using the format?
   2. Are the results of that 'format' expression stored in the row, 
   available to me to use? As you can see I can explicitly join with the 
   Institution to get the name. But if there's an easier way, then I'll do it.
   3. If I don't reference Team.Institution in the SELECT field list, will 
   that avoid the various other SELECTs that get done to 'translate' an 
   Institution.id to the corresponding name (according to 'format') when 
   meetTeams is displayed?

Thanks.

-- 





  1   2   >