[web2py] DAL and Unicode problem

2011-05-31 Thread Phyo Arkar
Hello all

I am having unicode problem whenever i try inserting into Database by
doing this :

db.tbl_data.insert( **data_dict )

when data_dict have a field with unicde value , decoded in UTF-8 .

How can i insert ? Why unicode is not fully supported by Web2py DAL ..?

Regards,

Phyo.


Re: [web2py] unicode problem in DAL

2011-05-31 Thread Phyo Arkar
I have the exactly same problem here.

Can anyone look into it? thanks alot.

Stef have you found a solution?

On Fri, Nov 5, 2010 at 5:47 PM, Stef Mientki  wrote:
>
> I'm trying to insert a record with a filed value
>  u"ëLocatie"
>
> and I get an error in sql.Table._insert at the last line:
>        return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v)
>
> here the traceback
>  File "D:\Data_Python_25\support\Web2Py_DAL_support.py", line 250, in 
> DAL_Table
>    Description = Value[3][:-1])
>  File "P:\Web2PY\web2py_src\web2py\gluon\sql.py", line 2035, in insert
>    query = self._insert(**fields)
>  File "P:\Web2PY\web2py_src\web2py\gluon\sql.py", line 2028, in _insert
>    return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v)
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 35: 
> ordinal not in range(128)
>
> I don't understand the problem and know what I'm doing wrong
>
> Wwith print statements I tried to narrow the problem, and in :
> def sql_represent(obj, fieldtype, dbname, db_codec='UTF-8'):
>
> there's is this part
>    if isinstance(obj, unicode):
>        print '', type(obj),obj
>        if len(obj)>0 : print ord(obj[0])
>        obj = obj.encode(db_codec)
>        print '', type(obj)
>        if len(obj)>0 : print ord(obj[0])
>
> which seems to convert the unicode to a string with byte values larger than 
> 128.
>
> Am I doing something wrong, or is this a bug ?
> And of course far more interesting, how do I solve this problem ?
>
> thanks,
> Stef Mientki
>
>
>


Re: [web2py] Re: Postgresql database schema

2011-05-31 Thread Massimiliano
Sure... That is the way I'm follow...
Fortunately I haven't tables with the same name...

Ciao

On Tue, May 31, 2011 at 3:50 AM, Mathew Grabau  wrote:

> You could always change the schema before executing the db commands:
>
> db.executesql("set search_path to 'schemaname,public';")
>
> If you could determine the name of the schema first that would be
> feasible.
>
> On May 30, 5:14 am, Massimiliano  wrote:
> > Hi all,
> >
> > I've a legacy enterprise application that use postgresql as database.
> >
> > Existing tables are divided on different database schemas (not only
> public).
> >
> > Now I want to rewrite a single application that use existing tables on
> > schema "xyz".
> >
> > Does web2py support that?
> >
> > Thank you
> > --
> > Massimiliano
>



-- 
Massimiliano


[web2py] Re : Re: Email invitation

2011-05-31 Thread Dwayne Blind
Thank you very much Massimo.
The "import uuid" had to be added inside the "invitation" function, not 
outside.

Thanks a lot to all three of you.


[web2py] How do we handle concurrent db update?

2011-05-31 Thread Iceberg
Hi there,

I got stuck with how or whether we can deal with the concurrent db
update, without the "overwrite" problem. This should be fundamental
but my brain is out of ideas. Please guide me.

Well, one specific example as a background. Think about a booking
system.

db.define_table('resource',
Field('name'),
Field('occupied', 'boolean', default=False),
Field('used_by'),
)

# Find any vacancy, then assign it to a user. FCFS.
def book_any_vacancy():
vacancy = db(db.resource.occupied==False).select().first()
vacancy.update_record(occupied=True,
used_by=request.vars.username)
return dict(foo='You just book resource #%d'%vacancy.id)

# But if we use db other than sqlite, those two db operations
# are not atomic. Then, will this sequence happen?
# 1. Alice visits book_any_vacancy(), triggers
db(...).select()
# 2. At the next 0.02 seconds, Bob visits and triggers
db(...).select()
# 3. Alice triggers update(...), got response 'You just book
resource #1'
# 4. Bob triggers update(...), got response 'You just book
resource #1'. Oops?!
#

Question:
1. Need to somehow combine the select()-then-update() procedures into
one atomic operation? And how?
2. What is the good practice to avoid above race condition?
3. Does different db backend (sqlite or postgrel) affect the answer to
question 1 and 2?

PS:

* There is even a web2py plugin designed for locking (http://
web2py.com/plugins/default/locking). But it still seems vulnerable,
what if two users obtain lock at the same time? At that moment, both
users thought they obtain the lock.

* I understand that a whole booking system can be complex. Here is an
old discussion but it did not clearly cover the "overwrite" issue.
http://comments.gmane.org/gmane.comp.python.web2py/20843

* It mentioned a prototype but it is not longer available? I wanna see
how it solves this problem. 
http://web2py.com/examples/static/web2py.app.booking.w2p

* Similar discussion here.
  critical problem - race condition in "check is in db" / "insert in
db" (IS_NOT_IN_DB) 
https://groups.google.com/group/web2py/browse_frm/thread/679f353e4dd10982

Regards,
Iceberg


[web2py] Most basic use of Views

2011-05-31 Thread Dwayne Blind
Dear all,
 
Here is the content of the view "myproject/views/invitation/invitation.html" 
:
 
{{extend 'layout.html'}}
{{=message}}
{{=T ('Enter an email address :')}}
{{=form}} 
{{=BEAUTIFY 
(response
._vars)}}
It works fine. The problem is that the output adds a summary of the 
variables inside the dictionnary. See below. Can somebody help me ?
 
Thank you very much,
Dwayne
 
P.S. : what is the exact role of the T function in T
('Enter an email address :') ? 
 Invitation to be sentEnter an email address : 
  form : 
  message : 
Invitation to be sent
 


[web2py] Re: Purpose of is_active in auth.signature?

2011-05-31 Thread villas
It was initially introduced with plugin_wiki and then included in
auth.signature for convenience.  I believe you can use it for your own
purpose.

On May 30, 8:10 pm, pbreit  wrote:
> If I use auth.signature in my own tables, I get is_active. Can I use it or
> is it reserved for something else? I understand it is useful in place of
> deleting a record?


[web2py] Re: importing a db/model from other app

2011-05-31 Thread blackthorne
Yes, that is the thing I want to change.
I don't want to be dependent of the source app, just its db/model. All
I want is an admin app that plugs into any other app by simply
defining it's name or path. It should run on the same machine and
there should be no problem in importing things by path.
Unfortunately, my attempts just fail :(

On May 31, 4:25 am, pbreit  wrote:
> I believe you are thinking of appadmin which is a controller in each app.


[web2py] Re: importing a db/model from other app

2011-05-31 Thread blackthorne
well, a script than runs every time when loading my admin app to copy/
sync the models's and the model DAL line, should work...

I think I will go for that solution if I can't find anything better.

On May 31, 5:38 am, mart  wrote:
> well then, not sure then is this helps, but I have 1 web app looking a
> db and a script (no web, just dal) that points to the same DB, both
> can select, update, insert from the same DB etc... as long as both
> know about the tables (and one has migrate=True). Changes on one side
> side can be seen by the other.
>
> when developing or making changes, or adding or removing tables
> (typically I do this from script), I always finish off by running a
> script that will look for all instances of db.define_table('',(bla)),
> and will re-write those lines in db.py
>
> I assume this can also be done as easily with 2 web apps...
>
> Is that what you mean?
>
> Mart :)
>
> On May 30, 11:25 pm, pbreit  wrote:
>
>
>
> > I believe you are thinking of appadmin which is a controller in each app.


[web2py] Changing an id... could it be really bad?

2011-05-31 Thread Jason (spot) Brower
I want to change the id of one of my items to the id of one that I have
deleted to avoid some URL rot.
Basically, I have:
http://interestid.com/welcome/default/view_event/12
and I want it to be:
http://interestid.com/welcome/default/view_event/11
ID 11 is gone now and 12 is the new one.  But my link won't work right if
it's not 11.
Can I just update the id to 11 and not worry?
BR,
Jason Brower


Re: [web2py] Re: Thanks to all members for all you time and effort !!

2011-05-31 Thread Jason (spot) Brower
It's a great framework when you know you can make a quick application for
some problem at the office on your lunch break.  You can't do that in many
webframeworks, I tell you that much. (I made a lunch coordination software
in about an hour.) Congrats and good luck!
BR,
Jason Brower


On Tue, May 31, 2011 at 7:36 AM, ron_m  wrote:

> Good for you on the course completion. There is a lot to learn especially
> if you have never done web development before of this type. For web
> development many people do HTML/CSS and to a lesser degree Javascript only
> so the server only pushes pages that are pre-canned. I worked with Java for
> many years doing server development and by comparison web2py is a dream.
> Part of the comparative ease of use is Python but much of it is the
> organization and integration of web2py. At first it looks like magic, then
> you learn a little because magic is an uneasy feeling but as you gain
> experience you learn some more and start to realize how well put together it
> all is.
>
> Java in it's own way is okay, just so much boiler plate code and some of
> the frameworks have you writing pages of XML that has no equivalent in
> web2py mainly because it follows a philosophy similar to Ruby on Rails
> (convention not configuration).
>
> Maybe see you back if you do more with web2py.
>


[web2py] Re: {{=response.toolbar()}}

2011-05-31 Thread Massimo Di Pierro
You must have an older web2py version

On May 31, 1:04 am, Johan  wrote:
> Hi,
>
> I get following error when I include this in my default index view:
>
> Traceback (most recent call last):
>   File "/Users/webdev/web2py/gluon/restricted.py", line 181, in
> restricted
>     exec ccode in environment
>   File "/Users/webdev/web2py/applications/test/views/default/
> index.html", line 117, in 
> TypeError: 'NoneType' object is not callable
> Frames
> File /Users/webdev/web2py/gluon/restricted.py in restricted at line
> 181
>
> File /Users/webdev/web2py/applications/test/views/default/index.html
> in  at line 117
> code
>
>     response.write('\n  ', escape=False)
>     response.write(T('You can modify this application and adapt it to
> your needs'))
>     response.write('\n  ', escape=False)
>     response.write(A(B(T("click here for the administrative
> interface")), _href=URL('admin','default','index')))
>     response.write('\n  ', escape=False)
>     response.write(A(T("click here for online examples"),
> _href=URL('examples','default','index')))
>     response.write('\n  web2py.com\n  http://web2py.com/
> book">', escape=False)
>     response.write(T('documentation'))
>     response.write('\n\n', escape=False)
>     response.write(response.toolbar(request))
>
>     response.write('\n\n  ', escape=False)
>     response.write(T('You visited the url'))
>     response.write(' ', escape=False)
>
> response.write(A(request.env.path_info,_href=request.env.path_info))
>     response.write('\n  ', escape=False)
>     response.write(T('Which called the function'))
>     response.write(' ', escape=False)
>     response.write(A(request.function+'()',_href='#'))
>     response.write(' ', escape=False)
>     response.write(T('located in the file'))
>
> Johan
>
> On May 30, 7:54 am, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > We can make this better in two ways...
>
> > 1) make it display its own stylesheet and display as a slide-in/out
> > panel.
> > 2) have it read the options.profiler file and extract all the profiler
> > info
>
> > 1) requires simply a good css designer.
> > 2) requires a little more work to parse the profiler log and extract
> > the corresponding entry.
>
> > On May 30, 12:36 am, "Jason (spot) Brower" 
> > wrote:
>
> > > YEAH!
> > > Your Increadable!!
> > > ---
> > > BR,
> > > Jason
>
> > > On Mon, May 30, 2011 at 3:16 AM, Massimo Di Pierro <
>
> > > massimo.dipie...@gmail.com> wrote:
> > > > This is in trunk. Give it a try:
>
> > > > {{=response.toolbar()}}
>
> > > > display request,response, session and db stats.


[web2py] Re: unicode problem in DAL

2011-05-31 Thread Massimo Di Pierro
I am not sure there is a problem here. I cannot help without seeing an
example of the data you insert.

If you do:

db.table.insert(**a)

a must be a dictionary with str key and str (ut8 encoded) values. You
cannot have unicode field names.

Massimo



On May 31, 2:40 am, Phyo Arkar  wrote:
> I have the exactly same problem here.
>
> Can anyone look into it? thanks alot.
>
> Stef have you found a solution?
>
>
>
>
>
>
>
> On Fri, Nov 5, 2010 at 5:47 PM, Stef Mientki  wrote:
>
> > I'm trying to insert a record with a filed value
> >  u"ëLocatie"
>
> > and I get an error in sql.Table._insert at the last line:
> >        return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v)
>
> > here the traceback
> >  File "D:\Data_Python_25\support\Web2Py_DAL_support.py", line 250, in 
> > DAL_Table
> >    Description = Value[3][:-1])
> >  File "P:\Web2PY\web2py_src\web2py\gluon\sql.py", line 2035, in insert
> >    query = self._insert(**fields)
> >  File "P:\Web2PY\web2py_src\web2py\gluon\sql.py", line 2028, in _insert
> >    return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v)
> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 35: 
> > ordinal not in range(128)
>
> > I don't understand the problem and know what I'm doing wrong
>
> > Wwith print statements I tried to narrow the problem, and in :
> > def sql_represent(obj, fieldtype, dbname, db_codec='UTF-8'):
>
> > there's is this part
> >    if isinstance(obj, unicode):
> >        print '', type(obj),obj
> >        if len(obj)>0 : print ord(obj[0])
> >        obj = obj.encode(db_codec)
> >        print '', type(obj)
> >        if len(obj)>0 : print ord(obj[0])
>
> > which seems to convert the unicode to a string with byte values larger than 
> > 128.
>
> > Am I doing something wrong, or is this a bug ?
> > And of course far more interesting, how do I solve this problem ?
>
> > thanks,
> > Stef Mientki


[web2py] Re: Changing an id... could it be really bad?

2011-05-31 Thread Massimo Di Pierro
I do not understand

On May 31, 6:20 am, "Jason (spot) Brower"  wrote:
> I want to change the id of one of my items to the id of one that I have
> deleted to avoid some URL rot.
> Basically, I have:http://interestid.com/welcome/default/view_event/12
> and I want it to be:http://interestid.com/welcome/default/view_event/11
> ID 11 is gone now and 12 is the new one.  But my link won't work right if
> it's not 11.
> Can I just update the id to 11 and not worry?
> BR,
> Jason Brower


[web2py] Re: Most basic use of Views

2011-05-31 Thread Massimo Di Pierro
I think you want to remove

{{=BEAUTIFY (response ._vars)}}

Massimo

On May 31, 4:23 am, Dwayne Blind  wrote:
> Dear all,
>
> Here is the content of the view "myproject/views/invitation/invitation.html"
> :
>
> {{extend 'layout.html'}}
> {{=message}}
> {{=T ('Enter an email address :')}}
> {{=form}}
> {{=BEAUTIFY 
> (response
> ._vars)}}
> It works fine. The problem is that the output adds a summary of the
> variables inside the dictionnary. See below. Can somebody help me ?
>
> Thank you very much,
> Dwayne
>
> P.S. : what is the exact role of the T function in T
> ('Enter an email address :') ?
>  Invitation to be sentEnter an email address :
>   form :
>   message :
> Invitation to be sent


Re: [web2py] Changing an id... could it be really bad?

2011-05-31 Thread Bruno Rocha
I guess it is better to have a redirect mechanism. If the id in args does
not exist you can try a lower one. Or upper. Or may be create a reference
table.
Em 31/05/2011 08:20, "Jason (spot) Brower"  escreveu:
> I want to change the id of one of my items to the id of one that I have
> deleted to avoid some URL rot.
> Basically, I have:
> http://interestid.com/welcome/default/view_event/12
> and I want it to be:
> http://interestid.com/welcome/default/view_event/11
> ID 11 is gone now and 12 is the new one. But my link won't work right if
> it's not 11.
> Can I just update the id to 11 and not worry?
> BR,
> Jason Brower


[web2py] field.represent doesn't work with plugin_jqgrid in controller

2011-05-31 Thread Dmitriy
It is works inside model file. But I have several controllers that
working with a same table and I need to set the controller name in
model. Currently I can't setup second controller. So assigning
field.represent in model is not suitable for me.

Can anyone describe me why assigning the field.represent in controller
with plugin_jqgrid doesn't work?


Model code:

db.define_table('plot',
Field('id','id',
  represent=lambda id: SPAN(id,'
',A('edit',_href=URL(r=request,c='default',f='plot_update',args=id)))
#works!
...

Controller code:

def plot_list():
db.plot.id.represent=lambda id: SPAN(id,'
',A('edit',_href=URL(r=request,c='default',f='plot_update',args=id)))
# not works!!!

table=plugin_jqgrid(db.plot)
return dict(table=table)

Please help.


[web2py] matplotlib vs mod_wsgi... again

2011-05-31 Thread Manuele Pesenti

Hi *,

old question still without answer... installing plugin_matplotlib inside 
the welcome app under a web2py installation that runs under apache using 
mod_wsgi I still got this:


AttributeError: 'module' object has no attribute 'cbook'

but the solution to load matplotlib and matplotlib.cbook before every 
other matplotlib import it's not a solution... what's the correct way to 
resolve it?


PS: please don't suggest not to use mod_wsgi... isn't there a real solution?

thank you very mutch

Manuele


[web2py] Re: ProgrammingError: there is no unique constraint matching given keys for referenced table "xuser"

2011-05-31 Thread Carlos
Hi Massimo,

I believe I've found the problem, it happens with any table (not just 
auth_user).

If I define the 'id' field in any position other than first, and if there 
are references to the same table, then the error occurs.

E.g.

   db.define_table(
   'xtable',
   Field('xfield'),
   Field('id', 'id'),
   Field('xref', 'reference xtable'),
   )

With the above definition, I will get the following error:

   ProgrammingError: there is no unique constraint matching given keys for 
referenced table "xtable"

This seems to solve my problem, but now I'm facing other issues (only with 
the latest changesets in trunk), I'm still checking.

   Carlos




[web2py] versioning and uploads

2011-05-31 Thread Joseph.Piron
Hi all,

I wonder if the uploads directory shouldn't be added in the .hgignore
file by the versioning command live databases, cache and so on.

What do you think ?


Re: [web2py] How do we handle concurrent db update?

2011-05-31 Thread Vasile Ermicioi
you can use record versioning to solve that somehow

http://web2py.com/book/default/chapter/07#Record-Versioning


[web2py] new site in web2py

2011-05-31 Thread danto
Hi, to gain experience with python, ajax and my beloved framework I
developed an app accesible from http://blogosfera.cl

The intention of the site is to give oportunity for anyone to publish it's
site on the chilean blogosphere. Later I will put a ranking system.

Despite it's still on development, omg was very easy to do it ^^


[web2py] Re: How do we handle concurrent db update?

2011-05-31 Thread Iceberg
On May 31, 10:29 pm, Vasile Ermicioi  wrote:
> you can use record versioning to solve that somehow
>
> http://web2py.com/book/default/chapter/07#Record-Versioning


Thanks for the feedback, but the info you provided is for archive, not
for dealing with parallel update. Or do I miss something?

Regards,
Iceberg


[web2py] Re: new site in web2py

2011-05-31 Thread JorgeRpo
very nice!!

a lil suggestion: set the links to be open in a new window


Re: [web2py] Re: new site in web2py

2011-05-31 Thread danto
2011/5/31 JorgeRpo 

> very nice!!
>
> a lil suggestion: set the links to be open in a new window
>

what a quick response! :)

I'll do it, thank you for your suggestion!


[web2py] Re: Most basic use of Views

2011-05-31 Thread Dwayne Blind
Thank you Massimo.

Where can I read more about the beautify function ?

Dwayne


On 31 mai, 14:22, Massimo Di Pierro 
wrote:
> I think you want to remove
>
> {{=BEAUTIFY (response vars/response> ._vars)}}
>
> Massimo
>
> On May 31, 4:23 am, Dwayne Blind  wrote:
>
>
>
> > Dear all,
>
> > Here is the content of the view "myproject/views/invitation/invitation.html"
> > :
>
> > {{extend 'layout.html'}}
> > {{=message}}
> > {{=T ('Enter an email address :')}}
> > {{=form}}
> > {{=BEAUTIFY 
> > (response
> > ._vars)}}
> > It works fine. The problem is that the output adds a summary of the
> > variables inside the dictionnary. See below. Can somebody help me ?
>
> > Thank you very much,
> > Dwayne
>
> > P.S. : what is the exact role of the T function in 
> > T
> > ('Enter an email address :') ?
> >  Invitation to be sentEnter an email address :
> >   form :
> >   message :
> > Invitation to be sent- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -


[web2py] bug in latest trunk - incomplete fields

2011-05-31 Thread Carlos
Hi,

I believe there's a bug in dal.py (latest trunk), lines # 4439 and 4440.

Currently ...

if isinstance(field, Field) and not field.name in fieldnames:
if hasattr(field, '_db'):
field = copy.copy(field)
else:
newfields.append(field)
fieldnames.add(field.name)

New proposed fix ...

if isinstance(field, Field) and not field.name in fieldnames:
if hasattr(field, '_db'):
field = copy.copy(field)
newfields.append(field)
fieldnames.add(field.name)

Must append to newfields regardless if _db or not ... right?.

Thanks,

   Carlos



[web2py] Re: How do we handle concurrent db update?

2011-05-31 Thread pbreit
I wouldn't worry too much about it. As long as you check for its 
availability immediately before assigning it to a traveler, you'll be fine. 
Then you'll need to run a periodic job to release pending reservations that 
do not complete.

[web2py] Re: Most basic use of Views

2011-05-31 Thread pbreit
The Book's search function works pretty well for most search terms:
http://web2py.com/book/default/search?search=beautify

T() is for translating text into other languages. I typically advise new 
users to not use it in the beginning, especially if you have no intention of 
translating your site.

I would highly advise going through the first 8 chapters of the book and 
especially chapter 3:
http://web2py.com/book/default/chapter/03


[web2py] Re: versioning and uploads

2011-05-31 Thread pbreit
Which .hgignore? The main distro includes:
applications/*/uploads/*

http://code.google.com/p/web2py/source/browse/.hgignore#45


[web2py] Re: Most basic use of Views

2011-05-31 Thread Dwayne Blind
Thank you pbreit.

I have already gone through chapter 3. It convinced me to try web2py.

I also ordered the web2py book on Amazon.

Dwayne


On 31 mai, 17:14, pbreit  wrote:
> The Book's search function works pretty well for most search 
> terms:http://web2py.com/book/default/search?search=beautify
>
> T() is for translating text into other languages. I typically advise new
> users to not use it in the beginning, especially if you have no intention of
> translating your site.
>
> I would highly advise going through the first 8 chapters of the book and
> especially chapter 3:http://web2py.com/book/default/chapter/03


Re: [web2py] new site in web2py

2011-05-31 Thread Stifan Kristi
very cool, congratulations, keep happy web2pying...


[web2py] Re: ProgrammingError: there is no unique constraint matching given keys for referenced table "xuser"

2011-05-31 Thread pbreit
It sounds like you know what you are doing but I'll point out that typically 
you don't define an 'id' field since Web2py does that already.

[web2py] Re: Most basic use of Views

2011-05-31 Thread pbreit
I'm sure the paper version of the book is good but it's beneficial to become 
proficient at searching the online book.

[web2py] Re: field.represent doesn't work with plugin_jqgrid in controller

2011-05-31 Thread pbreit
Isn't it a problem including a field "id" in your table since Web2py already 
does that?

[web2py] Re: Changing an id... could it be really bad?

2011-05-31 Thread pbreit
You want to avoid changing id's if at all possible because it can easily 
cause the DB to become inconsistent. I suppose in a worse case scenario you 
might be able to change it with a database tool (there's an SQLite add-on 
for Firefox). If you move forward, make sure to consider any other 
references to that record.

A redirect might be a better idea.


[web2py] Re: Changing an id... could it be really bad?

2011-05-31 Thread ron_m
If the id in the link the 11 or 12 is then used to reference an id in the 
database which is an id field in the DAL definition sense then the database 
engine will usually block you. The id field at the database level is meant 
to be a non repeating key so reuse of an id numeric value is discouraged and 
most often prevented by the database engine.

Having said that many databases allow for a way around that - look at the 
output of mysqldump or pg_dump if you happen to use MySQL or PostgreSQL and 
you will see they use special commands to defeat the autonumber or sequence 
feature while loading the data. The problem of course with disabling 
autonumber fields and updating is this possibly forms a relation to foreign 
keys in other tables.

If you look at the db.export_to_csv_file and db.import_from_csv_file it will 
pack the id fields down when you load the exported data back into a database 
created with tables and relations defined but no data inserted.

If you are dependent on your id fields being contiguous in order to create 
next and previous links then I think you need to reconsider. Perhaps a 
select of all ids in the table ordered by id, find the one you are currently 
on in the list and back up one or move forward one and then use that number. 
Every time you delete there will be a hole in the sequence where that item 
used to be.


[web2py] Re: importing a db/model from other app

2011-05-31 Thread pbreit
It appears that DAL() supports a variable "folder". Maybe that would work?

### create DAL connection (and create DB if not exists)
>>> db=DAL(('mysql://a:b@locahost/x','sqlite://storage.sqlite'),folder=None)


Re: [web2py] super in templates

2011-05-31 Thread pbreit
What does "super" do? I don't see it in the docs.

[web2py] Re: ProgrammingError: there is no unique constraint matching given keys for referenced table "xuser"

2011-05-31 Thread Massimo Di Pierro
You are correct. Thanks for reporting this problem.
This should now be fixed in trunk.

Massimo

On May 31, 9:15 am, Carlos  wrote:
> Hi Massimo,
>
> I believe I've found the problem, it happens with any table (not just
> auth_user).
>
> If I define the 'id' field in any position other than first, and if there
> are references to the same table, then the error occurs.
>
> E.g.
>
>    db.define_table(
>        'xtable',
>        Field('xfield'),
>        Field('id', 'id'),
>        Field('xref', 'reference xtable'),
>    )
>
> With the above definition, I will get the following error:
>
>    ProgrammingError: there is no unique constraint matching given keys for
> referenced table "xtable"
>
> This seems to solve my problem, but now I'm facing other issues (only with
> the latest changesets in trunk), I'm still checking.
>
>    Carlos


[web2py] Re: bug in latest trunk - incomplete fields

2011-05-31 Thread Massimo Di Pierro
very good catch!

On May 31, 10:07 am, Carlos  wrote:
> Hi,
>
> I believe there's a bug in dal.py (latest trunk), lines # 4439 and 4440.
>
> Currently ...
>
>             if isinstance(field, Field) and not field.name in fieldnames:
>                 if hasattr(field, '_db'):
>                     field = copy.copy(field)
>                 else:
>                     newfields.append(field)
>                 fieldnames.add(field.name)                
>
> New proposed fix ...
>
>             if isinstance(field, Field) and not field.name in fieldnames:
>                 if hasattr(field, '_db'):
>                     field = copy.copy(field)
>                 newfields.append(field)
>                 fieldnames.add(field.name)                
>
> Must append to newfields regardless if _db or not ... right?.
>
> Thanks,
>
>    Carlos


[web2py] Re: How do we handle concurrent db update?

2011-05-31 Thread ron_m
If you have a record version number field in the table then you can read it 
for the record of interest. When you go to update the record you specify the 
expected version number in the update equivalent to the SQL WHERE along with 
the field id so if the version number has been incremented by another user 
update, your update will fail because the WHERE version=x part of the update 
will not match.

I think this depends on the database you use as well. I thought most modern 
databases apply a read lock while you are looking at a record and if you try 
to update the lock is upgraded to a write lock and if someone else beat you 
to the update an error is thrown. You would need to check your database 
documentation looks for pessimistic vs optimistic locking or just locking.


[web2py] Re: Postgresql database schema

2011-05-31 Thread Mathew Grabau
You could always do the db.define_table calls specific to the tables
that are in the schema:

def define_schema1():
db.define_table("table1")
# and so forth

def define_schema1():
db.define_table("tablea")
# and so forth

# later on... (after changing the schema)

if current_schema == "schema1":
define_schema1()
elif current_schema == "schema2":
define_schema2()


You would have to be very careful then to only make the right calls
given the schema otherwise you would end up with an error.

Also be careful with the schema changing - be on the lookout for SQL
injection.


On May 31, 2:47 am, Massimiliano  wrote:
> Sure... That is the way I'm follow...
> Fortunately I haven't tables with the same name...
>
> Ciao
>
>
>
>
>
> On Tue, May 31, 2011 at 3:50 AM, Mathew Grabau  wrote:
> > You could always change the schema before executing the db commands:
>
> > db.executesql("set search_path to 'schemaname,public';")
>
> > If you could determine the name of the schema first that would be
> > feasible.
>
> > On May 30, 5:14 am, Massimiliano  wrote:
> > > Hi all,
>
> > > I've a legacy enterprise application that use postgresql as database.
>
> > > Existing tables are divided on different database schemas (not only
> > public).
>
> > > Now I want to rewrite a single application that use existing tables on
> > > schema "xyz".
>
> > > Does web2py support that?
>
> > > Thank you
> > > --
> > > Massimiliano
>
> --
> Massimiliano


[web2py] Re: How do we handle concurrent db update?

2011-05-31 Thread Iceberg
On May 31, 11:10 pm, pbreit  wrote:
> I wouldn't worry too much about it. As long as you check for its
> availability immediately before assigning it to a traveler, you'll be fine.
> Then you'll need to run a periodic job to release pending reservations that
> do not complete.


But I am not that confident about it. Allow me to quote some word from
[1].

"I was able to exploit this race condition and create two
identical
user records in SQLDB (In test environment, I had to add a small
time.sleep(), but in real world such problems DO happen - for
example
when server load is higher)."

And, in case of [1], there is a last ditch, duplicated record can be
denied if our db has a unique=True constraint. But in my booking
system case, no constraint can help. User Bob can overwrite user
Alice's booking, and we don't even have an easy way to detect and
repair that. :-/

[1] http://groups.google.com/group/web2py/browse_frm/thread/679f353e4dd10982



[web2py] Re: How do we handle concurrent db update?

2011-05-31 Thread pbreit
It's a theoretical problem, not an actual one. If you check room 
availability before reserving the room, you'll be fine. If your service ever 
gets enough traffic for it to become a problem (highly unlikely), you will 
have the resources to address it. It's better to spend your energy trying to 
get to that point.

Re: [web2py] super in templates

2011-05-31 Thread Bruno Rocha
On Tue, May 31, 2011 at 12:52 PM, pbreit  wrote:

> What does "super" do? I don't see it in the docs.


Having a block defined in layout.html

{{block sidebar}}
something
{{end}}

if you want to extend this in any view and inherit the content of the
original you can use {{super}}

index.html

{{block sidebar}}

another thing 
   {{super}}

{{end}}

will be rendered as

another thing
something





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


[web2py] Re: importing a db/model from other app

2011-05-31 Thread mart
yeah that works, although both apps need to know about the model and
one of the 2 apps needs to have migrate=True.

Mart :)

On May 31, 11:50 am, pbreit  wrote:
> It appears that DAL() supports a variable "folder". Maybe that would work?
>
> ### create DAL connection (and create DB if not exists)
>
>
>
>
>
>
>
> >>> db=DAL(('mysql://a:b@locahost/x','sqlite://storage.sqlite'),folder=None)


[web2py] Re: Google app engine

2011-05-31 Thread dhmorgan
You probably *will* want to to get Python 2.5.x

also, your app name cannot be web2py because there is already an app
by that name at web2py.appspot.com;

rename your app to a name you've registered at appspot and edit your
app.yaml file accordingly, then try again

Danny



On May 27, 11:22 pm, Resa  wrote:
>  Can someone assist me in deploying google app engine.. I am getting
> this error:
>
> File "/usr/lib/python2.6/urllib2.py", line 1169, in https_open
>     return self.do_open(httplib.HTTPSConnection, req)
>   File "/home/tara/Downloads/google_appengine/lib/fancy_urllib/
> fancy_urllib/__init__.py", line 367, in do_open
>     raise url_error
> urllib2.URLError: 
>
> This is what i did:
>
>      1locate dev_appser
>   2  /home/tara/Downloads/google_appengine/dev_appserver.py
>   3  /home/tara/Downloads/google_appengine/appcfg.py update ~/
> Documents/web2py
>
> I also specified the application in the routes file


[web2py] web2py_component() Problem

2011-05-31 Thread David J.

I see a strange behavior using web2py_component()

I am using current Trunk version;

I have the following code.

href="javascript:web2py_component('contacts.load','contact_list')">Load 
Contacts






The URL is http://mydomain.com/list (or whatever controller)

clicking the link on the page works fine it loads the 'contacts.load' view.

But here is the strange thing I see;

if I add args to the URL for example

http://mydomain.com/list/joe

and I click the click the link

web2py_component returns a HTML view not the LOAD view;

I hope I am being clear while trying to describe the issue.

Thanks.

David.



[web2py] Re: Most basic use of Views

2011-05-31 Thread Dwayne Blind
You are right.

Dwayne

On 31 mai, 17:29, pbreit  wrote:
> I'm sure the paper version of the book is good but it's beneficial to become
> proficient at searching the online book.


Re : Re: [web2py] Re: Email invitation

2011-05-31 Thread Dwayne Blind
Thank you Jonathan. I added the argument host='127.0.0.1:8000' to the URL.
 
I thank user570039 (
http://stackoverflow.com/questions/6087855/django-vs-pylons-vs-web2py-registration-invitation-events
).
 
Here is the final code, corrected from two typos ("uuid" instead of "token") 
:
 
# coding: utf8

def invitation():

import uuid

form = FORM (INPUT
(_name='email', requires=IS_NOT_EMPTY 
()),
INPUT (_type='submit'))

if form.accepts(request .vars):
uuid=str(uuid.uuid4())
db.invitation.insert(token = uuid)
mail.send(to=form.vars.email,message='click %s to register' % 
URL
('register',args=uuid,host='127.0.0.1:8000'))
session .latest_invitation=form.vars.
email
redirect (URL
('success_invitation'))

return dict(message=T ('Invitation to be sent'
),form=form,address=form.vars.email)

def success_invitation():
return dict()

def register():   # registration after invitation
if not db(db.invitation.token==request .
args(0)).count():   # FIRST TYPO
redirect ('error')
delete = lambda 
form:db(db.invitation.token==request
.args(0)).delete()  #SECOND TYPO
return dict(form=auth.register(onaccept=delete))
 
The only problem I now have is to make sure that people who are not invited 
cannot register. How to do that ?
 
Thanks a lot,
Dwayne
 


Re: Re : Re: [web2py] Re: Email invitation

2011-05-31 Thread Jonathan Lundell
On May 31, 2011, at 11:46 AM, Dwayne Blind wrote:
> Thank you Jonathan. I added the argument host='127.0.0.1:8000' to the URL.

There's a separate port argument that you might want to use, rather than 
including the port in the host. (Though in this case it doesn't make any 
difference, I think.)


> The only problem I now have is to make sure that people who are not invited 
> cannot register. How to do that ?

I don't have details for you, but it occurs to me that you might take advantage 
of the existing registration logic for email validation. Put the invitee in the 
database as registered with email validation pending, and use the validation 
step to complete the registration. IIRC, it uses a uuid to connect the response 
to the database entry.




[web2py] Re: super in templates

2011-05-31 Thread teemu
Hi

I tried to figure out this problem more carefully and I found the
reason why my app didn't work anymore:

If the parent block contains {{include 'some_file'}} and view tries to
extend it by calling {{super}}, whole parent block will be ignored!!!
I don't see any error messages etc. This behavior has been changed
after version 1.94.6. The same code works in 1.94.6 but not in
1.95.1.  Unfortunately I do not know web2py internals enough to figure
out what has been changed since!

Simplified test case:

controller function (default.py):
--
def test():
return dict();
--

view (test.html):
-
{{extend 'layout.html'}}
{{block content}}
this text will be shown in web page correctly
{{super}}
{{end content}}
--

view (layout.html): (stripped down, only relevant block is shown)
-
.
{{block content}}
this text wont be seen in web page if this block is
extended by calling super!
{{include 'test.txt'}}
{{end content}}
.
-

dummy text file (test.txt)
-
"some irrelevant text to be included into view"
-


If I remove {{include 'text.txt'}} from layout.html everything works
perfectly (text/code from the parent block will be included in
extended block). Web2py doesn't allow include directives in parent
blocks anymore!!

Teemu


[web2py] Err on request_reset_password

2011-05-31 Thread pbreit
I'm getting an error on request_reset_password.

Traceback (most recent call last):
  File "/Users/pbreit/web2py/gluon/restricted.py", line 184, in restricted
exec ccode in environment
  File "/Users/pbreit/web2py/applications/init/views/default/user.html", line 
160, in 
AttributeError: 'str' object has no attribute 'custom'


The form is not getting generated. From "locals":

form:
''
I'm not sure when the problem started. One changeset that is experiencing it 
is f328ec96be32.


[web2py] Markmin nested list

2011-05-31 Thread snapy666
Hello,

how can I make nested lists with markmin? With markdown you can indent
it with four spaces to go to the next level.

Thanks in advance

regards,
snapy666


[web2py] Re: Err on request_reset_password

2011-05-31 Thread pbreit
Note that I am using a custom form. I have been trying different changesets 
but can't seem to pinpoint the problem in my code or web2py.

{{elif request.args(0)=='request_reset_password':}}
Reset Password

{{=form.custom.begin}}
Email: 

{{=form.custom.widget.email}}

{{=form.custom.end}}



[web2py] Re: Err on request_reset_password

2011-05-31 Thread pbreit
Also, the error is on this line:

{{=form.custom.begin}}


[web2py] Re: Err on request_reset_password

2011-05-31 Thread pbreit
I think I might know what the problem is. I recently switched mailers and I 
suspect I'm hitting this:

if not self.settings.mailer:
response.flash = self.messages.function_disabled
return ''

Should/could this raise a more descriptive error?


Re: [web2py] Re: LOAD: ajax_trap errors...

2011-05-31 Thread Sebastian E. Ovide
Hi cfh

I agree with you and I believe in the community. So any time that I can I
give my small contribution to different communities (web2py is one of them).
At the same time I believe that the main reason because web2py is not so
commercially popular as Django o RoR (just have a look to any job site)is
not just because of the marketing or age. I keep getting the same comments
from most of the people that I've introduced the framework to: ie: it is
great, easy to learn and to use. but it is not stable/robust, bugs
are found frequently after each so called "stable" release, (even if most
are fixed within days and released in another "stable" release), users
(developers that didn't choose RoR or Django and want to use their time for
solving other problems not related to the tools) keep finding bugs in Stable
releases (just see the  mailing list) so basically they say that they do
not want to be what common users were (are??) for Microsoft: TESTERS  !

probably this is not the right thread to talk about it...

by the way, I've tried the last night build and I still getting the same JS
error and therefore the trap doesn't work:

syntax error
web2py_trap_form('('/soso/default/user_info.load/2',)','c286956013765');
4 (line 125)
missing ) after argument list
web2py_trap_form('('/soso/plugin_sebas...load/solution_4',)','c792900619289');

4 (line 142)
missing ) after argument list


What Am I missing ?

Thanks, and again, I like the great ideas behind web2py !

On Mon, May 30, 2011 at 12:11 AM, howesc  wrote:

> Sebastian,
>
> I agree with your views completely!  i *never* use anything but stable
> releases with my clients, but sometimes when i have issues i get help and
> fixes from the maintainers much more quickly if i can test their fixes in
> trunk.  Help us out (if you can) and confirm that the fix is in trunk and
> will be ready for you with the next stable release.
>
> thanks,
>
> cfh
>



-- 
Sebastian E. Ovide


[web2py] error on crud.update delete

2011-05-31 Thread selecta
ERROR:web2py:Traceback (most recent call last):
  File "/home/select/Dev/web2py/gluon/restricted.py", line 181, in
restricted
exec ccode in environment
  File "/home/select/Dev/web2py/applications/pyMantis/controllers/
plugin_whishlist.py", line 118, in 
  File "/home/select/Dev/web2py/gluon/globals.py", line 133, in

self._caller = lambda f: f()
  File "/home/select/Dev/web2py/gluon/tools.py", line 2335, in f
return action(*a, **b)
  File "/home/select/Dev/web2py/applications/pyMantis/controllers/
plugin_whishlist.py", line 68, in edit
if form.accepts(request.vars, session):
  File "/home/select/Dev/web2py/gluon/sqlhtml.py", line 1200, in
accepts
self.table._db(self.table.id == self.record.id).update(**fields)
  File "/home/select/Dev/web2py/gluon/dal.py", line 5173, in update
fields = self.db[tablename]._listify(update_fields,update=True)
  File "/home/select/Dev/web2py/gluon/dal.py", line 4464, in _listify
raise SyntaxError, 'Field %s does not belong to the table' % name
SyntaxError: Field delete_this_record does not belong to the table

is this somehow my fault? not sure how to debug


[web2py] getting a formstyle with 2 fields per row

2011-05-31 Thread apple
I would like my forms to show 2 fields per row so they take up less
vertical space on the screen e.g.

Name: X Address:
xx
Age:
xx
Date of birth: x

Had a look at custom formstyles but this only allows customising of
one field at a time. It will not allow every other field to be treated
as a TD rather than a TR.

Another possibility is to use formstyle=DIVS and manipulate the HTML
to wrap a table around it and put in the TRs every other field. Seems
a bit painful though.

Is there anyone who has done this already or can suggest an
alternative?


[web2py] Re: getting a formstyle with 2 fields per row

2011-05-31 Thread apple
Sorry formatting not quite as expected. I meant:

Name: xxx Address:  xxx
Age:xx   date of b:  xx

On May 31, 10:17 pm, apple  wrote:
> I would like my forms to show 2 fields per row so they take up less
> vertical space on the screen e.g.
>
> Name: X         Address:
> xx
> Age:
> xx
> Date of birth: x
>
> Had a look at custom formstyles but this only allows customising of
> one field at a time. It will not allow every other field to be treated
> as a TD rather than a TR.
>
> Another possibility is to use formstyle=DIVS and manipulate the HTML
> to wrap a table around it and put in the TRs every other field. Seems
> a bit painful though.
>
> Is there anyone who has done this already or can suggest an
> alternative?


[web2py] Re: field.represent doesn't work with plugin_jqgrid in controller

2011-05-31 Thread Dmitriy
It is a problem.
I need to have the id field link to the two different controllers in
the one table.

For example:
1) db.define_table('plot',
Field('id','id',
  represent=lambda id: SPAN(id,'
',A('edit',_href=URL(r=request,c='controller1',f='plot_update',args=id)))

2) db.define_table('plot',
Field('id','id',
  represent=lambda id: SPAN(id,'
',A('edit',_href=URL(r=request,c='controller2',f='plot_update',args=id)))


[web2py] dashboard...

2011-05-31 Thread Richard Vézina
Hello All,

Here a 5 min search and a bunch of links refering differents dashboard
implementation or code :

http://plugins.jquery.com/plugin-tags/dashboard
http://civicactions.com/blog/2009/feb/22/jquerydashboard_plugin
http://jqueryui.com/demos/sortable/#portlets
http://stackoverflow.com/questions/1648008/igoogle-style-dashboard-using-jquery
http://net.tutsplus.com/tutorials/javascript-ajax/inettuts/
http://civicrm.org/node/677
http://nettuts.s3.amazonaws.com/127_iNETTUTS/demo/index.html
http://www.dynamicdashboards.net/
http://sweettam.blogspot.com/2011/02/creating-webpage-like-igoogle-using.html
http://www.webappers.com/2008/11/19/how-to-create-igoogle-interface-with-jquery/

If you would like to share experiences with w2p of any dashboard
implementation of your own...

I will have to make friendlier dashboard in the near future... So I am
interresting in web2py user experience about that topic...

Thanks.

Richard


[web2py] crud onaccept vs form.accepts - is this expected

2011-05-31 Thread selecta
def edit():
record_id = request.args(0)
def on_accept(form):
print 'in on accept'
response.headers['web2py-component-command'] =
XML("web2py_component('%s','list')"%URL('list'))
if not record_id:
db.plugin_whishlist.open.readable,
db.plugin_whishlist.open.writable = False, False
form = crud.create(db.plugin_whishlist, onaccept = on_accept)
else:
form = crud.update(db.plugin_whishlist, record_id,
onaccept = on_accept)
if form.accepts(request.vars, session):
print 'in this on accept ', form.vars.id
response.headers['web2py-component-command'] =
XML("web2py_component('%s','list')"%URL('list'))
return ''
return form

if the form is accepted it will print
"in this on accept" that means it uses form.accepts instead of the
function that is passed.
is this behavior expected? it confused me a bit


[web2py] Re: getting a formstyle with 2 fields per row

2011-05-31 Thread pbreit
I use custom forms for all my forms: http://pricetack.com

Then you can do whatever you want.

http://web2py.com/book/default/chapter/07#Custom-forms


Re: [web2py] dashboard...

2011-05-31 Thread Bruno Rocha
Are you aware of it?  ->
http://web2py.com/jpolite/



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



On Tue, May 31, 2011 at 6:50 PM, Richard Vézina  wrote:

> Hello All,
>
> Here a 5 min search and a bunch of links refering differents dashboard
> implementation or code :
>
> http://plugins.jquery.com/plugin-tags/dashboard
> http://civicactions.com/blog/2009/feb/22/jquerydashboard_plugin
> http://jqueryui.com/demos/sortable/#portlets
>
> http://stackoverflow.com/questions/1648008/igoogle-style-dashboard-using-jquery
> http://net.tutsplus.com/tutorials/javascript-ajax/inettuts/
> http://civicrm.org/node/677
> http://nettuts.s3.amazonaws.com/127_iNETTUTS/demo/index.html
> http://www.dynamicdashboards.net/
>
> http://sweettam.blogspot.com/2011/02/creating-webpage-like-igoogle-using.html
>
> http://www.webappers.com/2008/11/19/how-to-create-igoogle-interface-with-jquery/
>
> If you would like to share experiences with w2p of any dashboard
> implementation of your own...
>
> I will have to make friendlier dashboard in the near future... So I am
> interresting in web2py user experience about that topic...
>
> Thanks.
>
> Richard
>


[web2py] running python on client side browser

2011-05-31 Thread selecta
in case you do no know this yet
http://syntensity.com/static/python.html


Re: [web2py] Re: super in templates

2011-05-31 Thread Thadeus Burgess
Ah right, you can't have includes inside of blocks ! This is not a bug, just
a side-effect of how includes are implemented vs blocks.

I know understand the reasoning behind the str(t.content) patch, which was a
workaround to getting includes to work inside of blocks, but not the proper
solution.

It only worked because of the str(t.content) workaround, otherwise you were
not able to have includes inside blocks from the beginning.

--
Thadeus




On Tue, May 31, 2011 at 1:59 PM, teemu  wrote:

> Hi
>
> I tried to figure out this problem more carefully and I found the
> reason why my app didn't work anymore:
>
> If the parent block contains {{include 'some_file'}} and view tries to
> extend it by calling {{super}}, whole parent block will be ignored!!!
> I don't see any error messages etc. This behavior has been changed
> after version 1.94.6. The same code works in 1.94.6 but not in
> 1.95.1.  Unfortunately I do not know web2py internals enough to figure
> out what has been changed since!
>
> Simplified test case:
>
> controller function (default.py):
> --
> def test():
>return dict();
> --
>
> view (test.html):
> -
> {{extend 'layout.html'}}
> {{block content}}
>this text will be shown in web page correctly
>{{super}}
> {{end content}}
> --
>
> view (layout.html): (stripped down, only relevant block is shown)
> -
> .
> {{block content}}
>this text wont be seen in web page if this block is
> extended by calling super!
>{{include 'test.txt'}}
> {{end content}}
> .
> -
>
> dummy text file (test.txt)
> -
> "some irrelevant text to be included into view"
> -
>
>
> If I remove {{include 'text.txt'}} from layout.html everything works
> perfectly (text/code from the parent block will be included in
> extended block). Web2py doesn't allow include directives in parent
> blocks anymore!!
>
> Teemu


[web2py] Re: Markmin nested list

2011-05-31 Thread Massimo Di Pierro
Not supported but should be.

On May 31, 2:31 pm, snapy666  wrote:
> Hello,
>
> how can I make nested lists with markmin? With markdown you can indent
> it with four spaces to go to the next level.
>
> Thanks in advance
>
> regards,
> snapy666


[web2py] Re: dashboard...

2011-05-31 Thread Massimo Di Pierro
very old code, should be rewritten using LOAD(...).

On May 31, 5:25 pm, Bruno Rocha  wrote:
> Are you aware of it?  
> ->http://web2py.com/jpolite/
>
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]
> [ Aprenda a programar:http://CursoDePython.com.br]
> [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
> [ Consultoria em desenvolvimento web:http://www.blouweb.com]
>
> On Tue, May 31, 2011 at 6:50 PM, Richard Vézina 
>
>
>
>
>
>
> > wrote:
> > Hello All,
>
> > Here a 5 min search and a bunch of links refering differents dashboard
> > implementation or code :
>
> >http://plugins.jquery.com/plugin-tags/dashboard
> >http://civicactions.com/blog/2009/feb/22/jquerydashboard_plugin
> >http://jqueryui.com/demos/sortable/#portlets
>
> >http://stackoverflow.com/questions/1648008/igoogle-style-dashboard-us...
> >http://net.tutsplus.com/tutorials/javascript-ajax/inettuts/
> >http://civicrm.org/node/677
> >http://nettuts.s3.amazonaws.com/127_iNETTUTS/demo/index.html
> >http://www.dynamicdashboards.net/
>
> >http://sweettam.blogspot.com/2011/02/creating-webpage-like-igoogle-us...
>
> >http://www.webappers.com/2008/11/19/how-to-create-igoogle-interface-w...
>
> > If you would like to share experiences with w2p of any dashboard
> > implementation of your own...
>
> > I will have to make friendlier dashboard in the near future... So I am
> > interresting in web2py user experience about that topic...
>
> > Thanks.
>
> > Richard


Re: Re : Re: [web2py] Re: Email invitation

2011-05-31 Thread Dwayne Blind
On 31 mai, 20:56, Jonathan Lundell  wrote:
> On May 31, 2011, at 11:46 AM, Dwayne Blind wrote:
>
> > Thank you Jonathan. I added the argument host='127.0.0.1:8000' to the URL.
>
> There's a separate port argument that you might want to use, rather than 
> including the port in the host. (Though in this case it doesn't make any 
> difference, I think.)
>
> > The only problem I now have is to make sure that people who are not invited 
> > cannot register. How to do that ?
>
> I don't have details for you, but it occurs to me that you might take 
> advantage of the existing registration logic for email validation. Put the 
> invitee in the database as registered with email validation pending, and use 
> the validation step to complete the registration. IIRC, it uses a uuid to 
> connect the response to the database entry.

Thank you Jonathan for this suggestion. I will try that but any
additional help or suggestion is welcome.

Dwayne


Re: [web2py] Re: LOAD: ajax_trap errors...

2011-05-31 Thread pbreit
I kind of understand but realistically I think Web2py users have to 
recognize where the framework is at. It is still being iterated on at a very 
rapid pace. If you need stability, stay on an previous version. If you run 
into problems with esoteric features, don't use them or try to fix them 
locally.

[web2py] possible bug in main.py when using GAE.

2011-05-31 Thread Matt
HI there,

I've just updated my codebase to the latest in trunk  (Version 1.96.0
(2011-05-31 10:38:00))

When I attempt to run my GAE app via the launcher (1.5) I get the
following error:

ERROR2011-05-31 23:28:34,017 restricted.py:148] Traceback (most
recent call last):
  File "/Projects/www/app/gluon/main.py", line 391, in wsgibase
local_hosts = (http_host, socket.gethostname(),
AttributeError: 'module' object has no attribute 'gethostname'

I'm using http://localhost:8000/ btw.

Any ideas?

Thanks in advance,
Matt


[web2py] uuid and id comparation

2011-05-31 Thread 黄祥
hi,

did anyone know the comparation between uuid and id? and what is use
for?

thank you so much in advance


[web2py] Re: uuid and id comparation

2011-05-31 Thread pbreit
The two are mostly unrelated.

uuid is a python library that you generally don't need to use or worry 
about. It basically generates a unique string.
http://docs.python.org/library/uuid.html

id, when talking about web2py, usually refers to the "id" field that Web2py 
automatically adds to every table definition that serves as a table's 
primary key.


[web2py] Re: How do we handle concurrent db update?

2011-05-31 Thread kawate
This is not a theoretical but a very actual and serious problem.
Think about a bank account, you might be in a deadly embrace.
Web2py is not a only user that access database.
So the problem is not solved in web2py.
If i were you, i would write a raw sql statement.



On 6月1日, 午前1:25, pbreit  wrote:
> It's a theoretical problem, not an actual one. If you check room
> availability before reserving the room, you'll be fine. If your service ever
> gets enough traffic for it to become a problem (highly unlikely), you will
> have the resources to address it. It's better to spend your energy trying to
> get to that point.


[web2py] Re: possible bug in main.py when using GAE.

2011-05-31 Thread pbreit
GAE doesn't support "socket" so that probably needs to be changed, perhaps 
to os.environ['REMOTE_ADDR']

[web2py] Re: How do we handle concurrent db update?

2011-05-31 Thread pbreit
We aren't talking about a bank account (and even if we were, that's why 
banks rely on reconciliation procedures), we are talking about a booking 
system. It's like security, you're never 100%, just as close to 100% as you 
need to be.

Re: [web2py] Re: uuid and id comparation

2011-05-31 Thread Stifan Kristi
thank you so much for your detail explaination and reference, pbreit.

On Wed, Jun 1, 2011 at 6:48 AM, pbreit  wrote:

> The two are mostly unrelated.
>
> uuid is a python library that you generally don't need to use or worry
> about. It basically generates a unique string.
> http://docs.python.org/library/uuid.html
>
> id, when talking about web2py, usually refers to the "id" field that Web2py
> automatically adds to every table definition that serves as a table's
> primary key.
>


Re: [web2py] Re: How do we handle concurrent db update?

2011-05-31 Thread David J
I am confused. Isn't this exactly what transactions are for?
On May 31, 2011 7:54 PM, "pbreit"  wrote:
> We aren't talking about a bank account (and even if we were, that's why
> banks rely on reconciliation procedures), we are talking about a booking
> system. It's like security, you're never 100%, just as close to 100% as
you
> need to be.


Re: Re : Re: [web2py] Re: Email invitation

2011-05-31 Thread Dwayne Blind
At the beginning, I was thinking of granting some permissions to the
registration page. Isn't that possible ?

Thanks for your help,
Dwayne


On 1 juin, 00:43, Dwayne Blind  wrote:
> On 31 mai, 20:56, Jonathan Lundell  wrote:
>
> > On May 31, 2011, at 11:46 AM, Dwayne Blind wrote:
>
> > > Thank you Jonathan. I added the argument host='127.0.0.1:8000' to the URL.
>
> > There's a separate port argument that you might want to use, rather than 
> > including the port in the host. (Though in this case it doesn't make any 
> > difference, I think.)
>
> > > The only problem I now have is to make sure that people who are not 
> > > invited cannot register. How to do that ?
>
> > I don't have details for you, but it occurs to me that you might take 
> > advantage of the existing registration logic for email validation. Put the 
> > invitee in the database as registered with email validation pending, and 
> > use the validation step to complete the registration. IIRC, it uses a uuid 
> > to connect the response to the database entry.
>
> Thank you Jonathan for this suggestion. I will try that but any
> additional help or suggestion is welcome.
>
> Dwayne


[web2py] Re: validator for self-join

2011-05-31 Thread Dave
Thanks, that did it!

On May 6, 9:56 am, pbreit  wrote:
> I think this might be what you want:
>
> crud.settings.create_onvalidation.mytablename.append(lambda form:)
>
> http://web2py.com/book/default/chapter/07#Settings


Re: [web2py] Re: LOAD: ajax_trap errors...

2011-05-31 Thread Anthony
On Tuesday, May 31, 2011 1:33:34 PM UTC-7, sebastian wrote: 
>
> Hi cfh 
>
> I agree with you and I believe in the community. So any time that I can I 
> give my small contribution to different communities (web2py is one of them). 
> At the same time I believe that the main reason because web2py is not so 
> commercially popular as Django o RoR (just have a look to any job site)is 
> not just because of the marketing or age. I keep getting the same comments 
> from most of the people that I've introduced the framework to: ie: it is 
> great, easy to learn and to use. but it is not stable/robust, bugs 
> are found frequently after each so called "stable" release, (even if most 
> are fixed within days and released in another "stable" release), users 
> (developers that didn't choose RoR or Django and want to use their time for 
> solving other problems not related to the tools) keep finding bugs in Stable 
> releases (just see the  mailing list) so basically they say that they do 
> not want to be what common users were (are??) for Microsoft: TESTERS  !
>
 
Note, I don't Massimo was asking you to be a tester. You identified a bug, 
which he thinks might be fixed in trunk, but he can't know unless you tell 
him. If you tell him it's not fixed in trunk, then he'll probably fix it. If 
you wait until trunk is released and becomes stable, and the bug has not 
actually been fixed, then you'll have to wait for a whole new release before 
the bug is fixed. So, it just depends on how fast you want the bug fixed.
 
Also, note that the nightly build is not necessarily the same as trunk 
(i.e., I don't think it is actually updated nightly), so you should test 
trunk if you want to see if it is fixed.
 
Finally, note that it's not really the case that "stable" releases have a 
lot of bugs. You should really think of the 1.xx.1 release as a release 
candidate. When that is released, bugs are identified and fixed within a few 
days, and it becomes stable fairly quickly. The alternative is to have 
actual release candidates, but it turns out that no one is ever really 
willing to test them when labeled as such (actually, that's what the nightly 
builds are supposed to be for).
 
Best,
Anthony


[web2py] web2py rpc

2011-05-31 Thread 黄祥
hi,

did anyone can explain what is web2py rpc used for? i've already read
http://web2py.com/book/default/chapter/09#Remote-Procedure-Calls but
still don't get it what web2py rpc (XMLRPC, JSONRPC and Pyjamas,
AMFRPC, SOAP) used for in the application.

thank you so much before


[web2py] Re: web2py rpc

2011-05-31 Thread pbreit
I'm not sure you're going to get a better explanation than what's in the 
book, which is excellent. These are sort of easy, sort of standardized ways 
way to create interfaces between different systems. For example, PayPal 
supports a SOAP interface in which case you can use the SOAP capabilities 
included with Web2py to interact with the PayPal system.

XMLRPC was gaining popularity awhile back but not so much anymore. More 
info: http://www.xmlrpc.com/

JSONRPC is similar but uses the JSON data format instead of XML. JSON is 
easier to work with, especially with JavaScript.


Re: Re : Re: [web2py] Re: Email invitation

2011-05-31 Thread pbreit
Maybe we should take a step back and try to understand what you are doing? 
You want to send out emails to some list of people? And include in that 
email a link which brings them back to your web site where they, and only 
they, can register for something?

If you are trying to learn how to program, seems OK. But if you just want to 
get on with your needs, have you considered Eventbrite or some other 
service?


Re: [web2py] Re: web2py rpc

2011-05-31 Thread Stifan Kristi
Thank you so much for your detail explaination, example and reference,
pbreit, honestly, i'm new in this feature, and don't know what is the use
for when i follow the guidance in the book, now, my mind is open and i'll
learn it on the book.

On Wed, Jun 1, 2011 at 8:46 AM, pbreit  wrote:

> I'm not sure you're going to get a better explanation than what's in the
> book, which is excellent. These are sort of easy, sort of standardized ways
> way to create interfaces between different systems. For example, PayPal
> supports a SOAP interface in which case you can use the SOAP capabilities
> included with Web2py to interact with the PayPal system.
>
> XMLRPC was gaining popularity awhile back but not so much anymore. More
> info: http://www.xmlrpc.com/
>
> JSONRPC is similar but uses the JSON data format instead of XML. JSON is
> easier to work with, especially with JavaScript.
>


Re: [web2py] Re: LOAD: ajax_trap errors...

2011-05-31 Thread pbreit
I'm pretty comfortable with the current pace. I think the next logical bit 
of progress would be to have two branches: 1) the current trunk and 2) the 
current 1.xx.x releases with critical bug fixes.

Re: Re : Re: [web2py] Re: Email invitation

2011-05-31 Thread Jason Brower

On 06/01/2011 04:51 AM, pbreit wrote:
Maybe we should take a step back and try to understand what you are 
doing? You want to send out emails to some list of people? And include 
in that email a link which brings them back to your web site where 
they, and only they, can register for something?


If you are trying to learn how to program, seems OK. But if you just 
want to get on with your needs, have you considered Eventbrite or some 
other service?

Or interestID.
It's still in alpha, but it does invites too. :D
It's "A conference management tool for the entire event life-cycle."
It's a shameless plug cause it runs on Web2py. :D
Best Regards,
Jason Brower



[web2py] Re: Fwd: Markmin with Markitup is not not playing right...

2011-05-31 Thread pbreit
Your code looks different from I see here:
http://markitup.jaysalvat.com/documentation/

Maybe we need to see your view code?


Re: [web2py] Markmin with Markitup is not not playing right...

2011-05-31 Thread Bruno Rocha
You need the markitup that us packed within plugin_wiki. Massimo made some
changes
Em 01/06/2011 00:38, "Jason Brower"  escreveu:
> So I know I have markItUp installed... (Notice Screenshot.png)
> But I get this error... (Notice Screenshot-1.png)
> What could I possibly be doing wrong here?
> Best Regards,
> Jason Brower


[web2py] Re: How do we handle concurrent db update?

2011-05-31 Thread Mathew Grabau
Yes - that is exactly the problem that transactions are intended to
take care of.

What would writing raw SQL do? Raw SQL statements (unless explicitly
contained in a transaction) would be executed outside of the
transaction and therefore still vulnerable.

On May 31, 6:57 pm, David J  wrote:
> I am confused. Isn't this exactly what transactions are for?
> On May 31, 2011 7:54 PM, "pbreit"  wrote:
>
>
>
> > We aren't talking about a bank account (and even if we were, that's why
> > banks rely on reconciliation procedures), we are talking about a booking
> > system. It's like security, you're never 100%, just as close to 100% as
> you
> > need to be.


Re: [web2py] Re: Cannot register or login a user

2011-05-31 Thread Jon Molesa
I started a new app by copying the welcome folder instead of using the
wizard. I copied over the models, views, and controllers from my old
app. I also updated web2py to the latest. Using local account reg and
login works perfectly. Enabling janrain bring up the login form, but
after authenticating with my gmail account the page refreshes, but
appears to not log me in. I just keep getting the sign in form. Anyone
seen this before that cares to comment and point out the silly mistake
I'm making?

On Tue, May 31, 2011 at 1:40 AM, Jon Molesa  wrote:
> Nevermind. Thanks anyway.
>
> On Mon, May 30, 2011 at 10:23 PM, Jon Molesa  wrote:
>> That line exists in default.py.
>>
>> On Mon, May 30, 2011 at 7:08 PM, Massimo Di Pierro
>>  wrote:
>>> LOL. Make sure that you have
>>>
>>> def user(): return dict(form=auth())
>>>
>>> If still does not work, show us your db.py
>>>
>>>
>>> On May 30, 5:41 pm, rjmolesa  wrote:
 I've goofed up my application in some way that prevents me from
 registering or logging in. How do I fix this please?
>>
>>
>>
>> --
>> Jon Molesa
>> rjmol...@gmail.com
>>
>
>
>
> --
> Jon Molesa
> rjmol...@gmail.com
>



-- 
Jon Molesa
rjmol...@gmail.com


Re: Re : Re: [web2py] Re: Email invitation

2011-05-31 Thread Anthony
On Tuesday, May 31, 2011 8:31:25 PM UTC-7, encompass wrote: 
>
> Or interestID.
> It's still in alpha, but it does invites too. :D
> It's "A conference management tool for the entire event life-cycle."
> It's a shameless plug cause it runs on Web2py. :D

 
What's the URL?


[web2py] Re: matplotlib vs mod_wsgi... again

2011-05-31 Thread Manuele Pesenti

Ok, here it is the steps I followed...

on a new web2py instance version 1.95.1 (2011-04-25 15:04:14)
installed under mod_wsgi 3.3 and Apache/2.2.3 and python 2.6

I have downloaded and installed matplotlib-1.0.0

than under the welcome application I have installed plugin_matplotlib

but visiting  http://127.0.0.1:8000/welcome/plugin_matplotlib/index

this is the traceback of the error I got

Traceback (most recent call last):
  File "/data/www/meteoproject_all/web2py/gluon/restricted.py", line 
181, in restricted

exec ccode in environment
  File 
"/data/www/meteoproject_all/web2py/applications/welcome/models/plugin_matplotlib.py", 
line 5, in 
from matplotlib.backends.backend_agg import FigureCanvasAgg as 
FigureCanvas
  File 
"/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_agg.py", 
line 31, in 

from matplotlib.figure import Figure
  File "/usr/lib64/python2.6/site-packages/matplotlib/figure.py", line 
18, in 

from axes import Axes, SubplotBase, subplot_class_factory
  File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 
19, in 

import matplotlib.collections as mcoll
  File "/usr/lib64/python2.6/site-packages/matplotlib/collections.py", 
line 15, in 

import matplotlib.cbook as cbook
AttributeError: 'module' object has no attribute 'cbook'

thank you
cheers

Manuele

On 31/05/2011 15:55, Manuele Pesenti wrote:

Hi *,

old question still without answer... installing plugin_matplotlib inside
the welcome app under a web2py installation that runs under apache using
mod_wsgi I still got this:

AttributeError: 'module' object has no attribute 'cbook'

but the solution to load matplotlib and matplotlib.cbook before every
other matplotlib import it's not a solution... what's the correct way to
resolve it?

PS: please don't suggest not to use mod_wsgi... isn't there a real
solution?

thank you very mutch

 Manuele