Re: [web2py] Would this editor be useful for us?

2011-05-05 Thread Bruno Rocha
This is very usefull, I use a lot! it is not just an editor, it is a tool
for Java Script testing..

Look this example http://jsfiddle.net/pborreli/pJgyu/

Note the 'run' button on top.. you can load your awn Java script modules..
very useful for testing

--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]



On Fri, May 6, 2011 at 1:46 AM, Jason (spot) Brower wrote:

> http://jsfiddle.net/
>
>


[web2py] Re: ajax:whats wrong with this

2011-05-05 Thread pbreit
Get something simple working and then add complexity.

[web2py] spatial page load by ajax

2011-05-05 Thread 黄祥
hi,

does anyone knows how to create spatial page load by ajax (like
facebook does in your home page)? i mean, i want to create my index
view is to load the table fields spatial not all, currently, i'm tryin
to modify the pagination and use it into ajax function.
e.g.

def __index(table):
if len(request.args):
page = int(request.args[0])
else:
page = 0

items_per_page = 20
limitby = (page * items_per_page, (page + 1) * items_per_page + 1)
rows = db().select(table.ALL, limitby = limitby, orderby =
~table.id)
return dict(rows = rows, page = page, items_per_page =
items_per_page)


jQuery(document).ready(function(){
jQuery('.view').click(function(){ajax('{{=request.controller}}',
[page + 1], 'comments')});
});



{{for i, row in enumerate(rows):}}
{{if i == items_per_page: break}}
{{=row.title}}
{{=BR()}}
{{pass}}


{{if len(rows) > items_per_page:}}
{{=DIV(A(T('View'),
 _href = '#'),
   _class = 'view')}}
{{pass}}

no error occured but the ajax function is not running, i know there is
a mistook on my code, could anybody know how to fix it, please? or is
there any way to do spatial page load?
any help is greatly appreciate, thank you so much in advance


[web2py] Would this editor be useful for us?

2011-05-05 Thread Jason (spot) Brower
http://jsfiddle.net/


[web2py] Re: ajax:whats wrong with this

2011-05-05 Thread Anthony
On Friday, May 6, 2011 12:02:54 AM UTC-4, Resa wrote: 
>
> ok cool.. understood.. so how would i send variables to a function in 
> the controller?

 
You could pass them via the URL query string. The best way to do that is to 
use the URL function to create the URL -- see 
http://web2py.com/book/default/chapter/04#URL.
 
Anthony


[web2py] Re: ajax:whats wrong with this

2011-05-05 Thread Resa
ok cool.. understood.. so how would i send variables to a function in
the controller?

On May 5, 10:49 pm, Anthony  wrote:
> ajax('{{=URL('insert_updatedb')}}',
> ['numBer','mgp','total_time','correct'],'');
>
> The above will not send the values of your variables as request variables.
> The list submitted to the ajax() function is supposed to be a list of field
> IDs (seehttp://web2py.com/book/default/chapter/10#The-ajax-Function). It
> does not appear you have created fields with those IDs. You might be able to
> add the variables to the URL function, though.
>
> On Thursday, May 5, 2011 9:44:47 PM UTC-4, Resa wrote:
> > I am having huge issues with the parameters cause they are not being
> > sent to the function at all...
> > def insert_updatedb():
> >     session.correct=request.vars.correct
> >     session.numquest=request.vars.number
> >     session.time_quest=request.vars.total_time
> >     session.mgp=request.vars.mgp
> > .
> > .
> > .
>
> > On May 5, 8:37 pm, Resa  wrote:
> > > Correction:
> > >  function MGP(correct)
> > >     {
> > >         var time_per_question=2;                         //2 second to
> > > answer one question
> > >         var numBer={{=request.vars.number}};               // the
> > > number of questions in worksheet
> > >         var bonus= (numBer<20)? 1: (numBer<40)? 3 :(numBer<60)? 7:
> > > (numBer<80)? 9: (numBer<100)? 11 :13    // calculate bonus
> > >         var total_time=converttime();
> > >         var mgp= (((correct/numBer)+(total_time/
> > > (numBer*time_per_question))+bonus));
> > >         ajax('{{=URL('insert_updatedb')}}',
> > > ['numBer','mgp','total_time','correct'],'');
> > >      }
>
> > > On May 5, 7:35 pm, pbreit  wrote:
>
> > > > This is pretty confusing code.
>
> > > > I'm not sure how these assignments are going to work:
> > > > {{=numBer}}=numBer
> > > > ...
>
> > > > Normally you have something like num={{=row.num}}
>
> > > > In the dict() it looks like you are assigning strings. Normally it
> > would
> > > > look more like this dict(numBer=numBer,...)
>
> > > > You definitely don't want this: {{URL(...    That's not going to do
> > > > anything.
>
> > > > Then you need something to trigger the Ajax call.
>
> > > > Review the Book:
> >http://web2py.com/book/default/chapter/10#The-ajax-Function
>
> > > > I would suggest starting very simply, prove that it works and then add
> > the
> > > > complexity.
>
>


[web2py] Re: ajax:whats wrong with this

2011-05-05 Thread Anthony
ajax('{{=URL('insert_updatedb')}}', 
['numBer','mgp','total_time','correct'],''); 
 
The above will not send the values of your variables as request variables. 
The list submitted to the ajax() function is supposed to be a list of field 
IDs (see http://web2py.com/book/default/chapter/10#The-ajax-Function). It 
does not appear you have created fields with those IDs. You might be able to 
add the variables to the URL function, though.
 

On Thursday, May 5, 2011 9:44:47 PM UTC-4, Resa wrote:

> I am having huge issues with the parameters cause they are not being 
> sent to the function at all... 
> def insert_updatedb(): 
> session.correct=request.vars.correct 
> session.numquest=request.vars.number 
> session.time_quest=request.vars.total_time 
> session.mgp=request.vars.mgp 
> . 
> . 
> . 
>
> On May 5, 8:37 pm, Resa  wrote: 
> > Correction: 
> >  function MGP(correct) 
> > { 
> > var time_per_question=2; //2 second to 
> > answer one question 
> > var numBer={{=request.vars.number}};   // the 
> > number of questions in worksheet 
> > var bonus= (numBer<20)? 1: (numBer<40)? 3 :(numBer<60)? 7: 
> > (numBer<80)? 9: (numBer<100)? 11 :13// calculate bonus 
> > var total_time=converttime(); 
> > var mgp= (((correct/numBer)+(total_time/ 
> > (numBer*time_per_question))+bonus)); 
> > ajax('{{=URL('insert_updatedb')}}', 
> > ['numBer','mgp','total_time','correct'],''); 
> >  } 
> > 
> > On May 5, 7:35 pm, pbreit  wrote: 
> > 
> > > This is pretty confusing code. 
> > 
> > > I'm not sure how these assignments are going to work: 
> > > {{=numBer}}=numBer 
> > > ... 
> > 
> > > Normally you have something like num={{=row.num}} 
> > 
> > > In the dict() it looks like you are assigning strings. Normally it 
> would 
> > > look more like this dict(numBer=numBer,...) 
> > 
> > > You definitely don't want this: {{URL(...That's not going to do 
> > > anything. 
> > 
> > > Then you need something to trigger the Ajax call. 
> > 
> > > Review the Book:
> http://web2py.com/book/default/chapter/10#The-ajax-Function 
> > 
> > > I would suggest starting very simply, prove that it works and then add 
> the 
> > > complexity. 
> > 
> >



[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Massimo Di Pierro
good.

I am lost about the second part. What is plugin generator?

On May 5, 10:17 pm, Christopher Steel  wrote:
> Thanks Massimo, That was a really good call! I think I messed things
> up while I was creating a prototype for an automated plugin creator
> made some, um, adjustments so that my generated plugins where really
> organized, but apparently not functioning as expected because I forgot
> about that little exception with the model file and not files. LOL, I
> go t confused trying to make things clearer...
>
> and perhaps I noticed a similar effect when checking out the
> powerpack, hummm, how very interesting but unexpected.
>
> This is what my plugin generator and the resulting plugins looked like
> before:
>
> plugin_uc_plugin.py
> plugin_uc_plugin/initialization.py
> plugin_uc_plugin/menu.py
>
> in the above case a response.menu += [ bla bla] in plugin_uc_plugin/
> menu.py does NOT show up when visiting  
> http://127.0.0.1:8000/app/default/index.html
> but does show up when visitinghttp://127.0.0.1:8000/app/plugin_uc_plugin/index
>
> If you consolidating the contents of plugin_uc_plugin/menu.py into
> plugin_uc_plugin.py a response.menu += [ bla bla] will show up 
> inhttp://127.0.0.1:8000/app/default/index.html
>
> I have not experimented with the contents of plugin_uc_plugin/
> initialization.py yet but that could be interesting as well...
>
> the test plugin generator, plugin_plugin will generate a plugin called
> plugin_font_gothic with the following three files in the models if you
> want to check uut the effect. the menu.py has assignes the menus to
> response.menu += [ my menus ] as well:
>
> plugin_font_gothic.py
> plugin_font_gothic/initialization.py
> plugin_font_gothic/menu.py
> ...
>
> If you want to check it out the beginnings of a plugin to create
> plugins you can check it out here for now. if anyone has an idea of
> how to implement Web2py templates rather than using mako templates I
> can remove that dependence which could be nice since mako seems to
> have trouble dealling with two or more hash signs -> ##, for now
> something like:
>
> pip install mako
> hg clonehttps://uc-theme-dev.googlecode.com/hg/uc_theme_dev
>
> will get you going.
>
> I will move the plugin here after a little more cleanup.
>
> hg clonehttps://uc-plugin-dev.googlecode.com/hg/uc_plugin_dev
>
> Christopher Steel
>
> On May 5, 9:27 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > I doubt this is an issue with the new import or the new gluon.current
> > tread local object.
> > This is probably to the new use of subfolder in models.
> > Do you have subfolders under models/ ?
>
> > On May 5, 7:52 pm, Christopher Steel  wrote:
>
> > > my menu.py in my plugin no longer show up at the apps index and only
> > > display "in" the plugin directory. Is this due to the new current
> > > scope? Is their a way to get this working again or a "current scope"
> > > toggle ? I have a lot of plugins that use this for menu's so any help
> > > on this is very appreciated.
>
> > > Thanks,
>
> > > Chris
>
> > > example, before using something like
>
> > > response.menu+= [bla bla]
>
> > > in a plugin added the plugin menu to the main menu and it showed up
> > > at:
>
> > >  http://127.0.0.1:8000/blank/default/index
>
> > > Now it only shows up "in" the plugin, for example here:
>
> > >  http://127.0.0.1:8000/blank/plugin_uc_language/index
>
> > > but no longer shows up here:
>
> > >  http://127.0.0.1:8000/blank/default/index
>
> > > SO it does not work with 1.95.1 (2011-05-05 15:15:00)
> > > but does work with 1.95.1 (2011-04-27 ..:..:..)
>
> > > On May 4, 5:29 pm, Bruno Rocha  wrote:
>
> > > > I am testing right now, at this point I have 2 apps running with no
> > > > problems!
>
> > > > models subfolder, custom importer and current scope are great 
> > > > improvements
> > > > to web2py, I am waiting to rely on this for the app I am working now.
>
> > > > Thank you Massimo and Jonathan (of course all the other collaborators),
> > > > @web2py "the framework that evolves every two weeks"
>
> > > > --
> > > > Bruno Rocha
> > > > [ About me:http://zerp.ly/rochacbruno]
>
> > > > On Wed, May 4, 2011 at 6:09 PM, Massimo Di Pierro
> > > > wrote:
>
> > > > > Hello everybody
>
> > > > > Jonathan and I have been working on an internal web2py rewrite that 
> > > > > while
> > > > > keeping everything backward compatible will allow you to do this
>
> > > > >  modules/mymodule.py
> > > > > from gluon import *
> > > > > def f(): return DIV(A(current.request.function,_href=URL()))
> > > > >  end
>
> > > > >  default/controller.py
> > > > > def index():
> > > > >    from mymodule import f
> > > > >    return dict(div=f())
> > > > >  end
>
> > > > > Thanks to Pierre we can now import modules from the app local folder
> > > > > without local_import and thanks to Jonathan those modules only need 
> > > > > to do
> > > > > "from gluon import *" to see everything web2py has to offer. This 
> > > > > should
> > > > > make life e

[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Christopher Steel
Thanks Massimo, That was a really good call! I think I messed things
up while I was creating a prototype for an automated plugin creator
made some, um, adjustments so that my generated plugins where really
organized, but apparently not functioning as expected because I forgot
about that little exception with the model file and not files. LOL, I
go t confused trying to make things clearer...

and perhaps I noticed a similar effect when checking out the
powerpack, hummm, how very interesting but unexpected.

This is what my plugin generator and the resulting plugins looked like
before:

plugin_uc_plugin.py
plugin_uc_plugin/initialization.py
plugin_uc_plugin/menu.py

in the above case a response.menu += [ bla bla] in plugin_uc_plugin/
menu.py does NOT show up when visiting  
http://127.0.0.1:8000/app/default/index.html
but does show up when visiting http://127.0.0.1:8000/app/plugin_uc_plugin/index

If you consolidating the contents of plugin_uc_plugin/menu.py into
plugin_uc_plugin.py a response.menu += [ bla bla] will show up in
http://127.0.0.1:8000/app/default/index.html

I have not experimented with the contents of plugin_uc_plugin/
initialization.py yet but that could be interesting as well...

the test plugin generator, plugin_plugin will generate a plugin called
plugin_font_gothic with the following three files in the models if you
want to check uut the effect. the menu.py has assignes the menus to
response.menu += [ my menus ] as well:

plugin_font_gothic.py
plugin_font_gothic/initialization.py
plugin_font_gothic/menu.py
...

If you want to check it out the beginnings of a plugin to create
plugins you can check it out here for now. if anyone has an idea of
how to implement Web2py templates rather than using mako templates I
can remove that dependence which could be nice since mako seems to
have trouble dealling with two or more hash signs -> ##, for now
something like:

pip install mako
hg clone https://uc-theme-dev.googlecode.com/hg/ uc_theme_dev

will get you going.

I will move the plugin here after a little more cleanup.

hg clone https://uc-plugin-dev.googlecode.com/hg/ uc_plugin_dev


Christopher Steel



On May 5, 9:27 pm, Massimo Di Pierro 
wrote:
> I doubt this is an issue with the new import or the new gluon.current
> tread local object.
> This is probably to the new use of subfolder in models.
> Do you have subfolders under models/ ?
>
> On May 5, 7:52 pm, Christopher Steel  wrote:
>
> > my menu.py in my plugin no longer show up at the apps index and only
> > display "in" the plugin directory. Is this due to the new current
> > scope? Is their a way to get this working again or a "current scope"
> > toggle ? I have a lot of plugins that use this for menu's so any help
> > on this is very appreciated.
>
> > Thanks,
>
> > Chris
>
> > example, before using something like
>
> > response.menu+= [bla bla]
>
> > in a plugin added the plugin menu to the main menu and it showed up
> > at:
>
> >  http://127.0.0.1:8000/blank/default/index
>
> > Now it only shows up "in" the plugin, for example here:
>
> >  http://127.0.0.1:8000/blank/plugin_uc_language/index
>
> > but no longer shows up here:
>
> >  http://127.0.0.1:8000/blank/default/index
>
> > SO it does not work with 1.95.1 (2011-05-05 15:15:00)
> > but does work with 1.95.1 (2011-04-27 ..:..:..)
>
> > On May 4, 5:29 pm, Bruno Rocha  wrote:
>
> > > I am testing right now, at this point I have 2 apps running with no
> > > problems!
>
> > > models subfolder, custom importer and current scope are great improvements
> > > to web2py, I am waiting to rely on this for the app I am working now.
>
> > > Thank you Massimo and Jonathan (of course all the other collaborators),
> > > @web2py "the framework that evolves every two weeks"
>
> > > --
> > > Bruno Rocha
> > > [ About me:http://zerp.ly/rochacbruno]
>
> > > On Wed, May 4, 2011 at 6:09 PM, Massimo Di Pierro
> > > wrote:
>
> > > > Hello everybody
>
> > > > Jonathan and I have been working on an internal web2py rewrite that 
> > > > while
> > > > keeping everything backward compatible will allow you to do this
>
> > > >  modules/mymodule.py
> > > > from gluon import *
> > > > def f(): return DIV(A(current.request.function,_href=URL()))
> > > >  end
>
> > > >  default/controller.py
> > > > def index():
> > > >    from mymodule import f
> > > >    return dict(div=f())
> > > >  end
>
> > > > Thanks to Pierre we can now import modules from the app local folder
> > > > without local_import and thanks to Jonathan those modules only need to 
> > > > do
> > > > "from gluon import *" to see everything web2py has to offer. This should
> > > > make life easier for Eclipse users too.
>
> > > > In models/db.py you no longer need to pass globals() to Auth
>
> > > >   auth=Auth(globals(),db)
> > > > or
> > > >   auth=Auth(db)
>
> > > > both work.
>
> > > > Also error messages in validators (including default error messages) 
> > > > should
> > > > not be by T(...) by default.
>
> > > > This is now in

[web2py] Re: Component's non-ascii response.flash does not show well in IE and Firefox

2011-05-05 Thread Massimo Di Pierro
I apologize. Missed both patches.
You did not email them to me and I did not see them. :-)

Massimo


On May 5, 9:38 pm, Iceberg  wrote:
> Bug fixed. The culprit is exactly the utf8 encoding. Javascript only
> accepts Unicode string, not utf8. Most browsers stick to this
> standard, only Chrome can accept utf8 also.
>
> The fix is mentioned inhttp://code.google.com/p/web2py/issues/detail?id=260
>
> By the way, my another fix 
> tohttp://code.google.com/p/web2py/issues/detail?id=221
> is still not accepted into trunk?
>
> Regards,
> Ray Luo (a.k.a. Iceberg)
>
> On May 4, 11:17 pm, Iceberg  wrote:
>
>
>
>
>
>
>
> > As expected, that causes a ticket. Because my source code file is
> > already in utf8 encoding, and you can not do a "already-utf8-
> > string".encode('utf8')
>
> > On May 4, 9:37 pm, Massimo Di Pierro 
> > wrote:
>
> > > can you try replace
>
> > > response.flash = 'Erro na inserção'
>
> > > with
>
> > > response.flash = 'Erro na inserção'.encode('utf8')
>
> > > On May 4, 5:39 am, Iceberg  wrote:
>
> > > > Hi there,
>
> > > > I just noticed that, component's non-ascii response.flash does not
> > > > show well in IE7, IE8, Firefox 3.0.19.
>
> > > > def visit_me():
> > > >     return {'':LOAD('default', 'component.load', ajax=True)}
> > > > def component():
> > > >     response.flash = 'Erro na inserção'
> > > >     return {'':'Testing'}
>
> > > > But Chrome 11.x is fine.
>
> > > > So I guess that means the flash string is properly transfered to
> > > > client but, for some reason its encoding is not properly indicated
> > > > therefore incorrectly handled.
>
> > > > Is this a bug? Is there any workaround?
>
> > > > Regards,
> > > > Iceberg


Re: [web2py] Re: What is the convention for using web2py/site-packages for GAE?

2011-05-05 Thread howesc
i tracked down the error with _TEST(), and created a solution.  not at all 
sure that this is correct for web2py, but you can see my patch in the ticket 
i created: http://code.google.com/p/web2py/issues/detail?id=261


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread luckysmack
Wow this os great. This also looks like it may effect things like
autocomplete in ide's. For me, learning web2py, that was always one
thing that made it more difficult to learn. Not that it was hard.

On May 5, 7:25 pm, Plumo  wrote:
> fantastic news!
> This should let me move a lot of code from models in to modules.


[web2py] plugin_wiki syntaxed, but works fine

2011-05-05 Thread kawate
this is just a report.
The following construct is syntaxed, but works fine.


``
name: create
table: comment
message: 書き込みました
next: {{=request.url}}?title={{=request.vars['title']}}
hidden_fields: posted_at,title
default_fields:title={{=request.vars['title']}}
``:widget


[web2py] mongoDBAdapter test ......

2011-05-05 Thread joseph simpson
#!/usr/bin/python
import sys
import time
sys.path.append('/Users/pcode/Desktop/mongodb_test/web2py')
from gluon.dal import DAL, Field

db = DAL('mongodb://127.0.0.1:5984/db')
#mongodb test set
#start with simple data types
#then inser into mongodb

db.define_table('m_test',
Field('name','text'),
Field('number','integer'))

#
# The above code produces the following error
#
Traceback (most recent call last):
  File "./test_mdb_1.py", line 7, in 
db = DAL('mongodb://127.0.0.1:5984/db')
  File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line
3724, in __init__
raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
(attempts, error)
RuntimeError: Failure to connect, tried 5 times:
'MongoDBAdapter' object has no attribute '_uri'

#
### Make the following changes
#
Line number 3342
FROM:
 m = re.compile('^(?P[^\:/]+)(\:(?P[0-9]+))?/(?P.+)
$').match(self._uri[10:])
TO:
 m = re.compile('^(?P[^\:/]+)(\:(?P[0-9]+))?/(?P.+)
$').match(self.uri[10:])

Line number 3344
FROM:
 raise SyntaxError, "Invalid URI string in DAL: %s" % self._uri
TO:
 raise SyntaxError, "Invalid URI string in DAL: %s" % self.uri
#
### Execute code again
#
### New error listed below
#
Traceback (most recent call last):
  File "./test_mdb_1.py", line 7, in 
db = DAL('mongodb://127.0.0.1:5984/db')
  File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line
3724, in __init__
raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
(attempts, error)
RuntimeError: Failure to connect, tried 5 times:
port must be an instance of int
#
# Make the following change
#
Line 3351
FROM:
 port = m.group('port') or 27017
TO:
 port = 27017
#
# Now the code connects to the server but the error below is
reported
##
Traceback (most recent call last):
  File "./test_mdb_1.py", line 14, in 
Field('number','integer'))
  File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line
4032, in define_table
polymodel=polymodel)
  File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line
513, in create_table
% dict(length=field.length)
TypeError: unsupported operand type(s) for %: 'type' and 'dict'
#
### It is not clear to me why this error is generated
### So report back to the list
#


Have fun,

Joe


[web2py] Re: Component's non-ascii response.flash does not show well in IE and Firefox

2011-05-05 Thread Iceberg
Bug fixed. The culprit is exactly the utf8 encoding. Javascript only
accepts Unicode string, not utf8. Most browsers stick to this
standard, only Chrome can accept utf8 also.

The fix is mentioned in http://code.google.com/p/web2py/issues/detail?id=260

By the way, my another fix to 
http://code.google.com/p/web2py/issues/detail?id=221
is still not accepted into trunk?


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

On May 4, 11:17 pm, Iceberg  wrote:
> As expected, that causes a ticket. Because my source code file is
> already in utf8 encoding, and you can not do a "already-utf8-
> string".encode('utf8')
>
> On May 4, 9:37 pm, Massimo Di Pierro 
> wrote:
>
>
> > can you try replace
>
> > response.flash = 'Erro na inserção'
>
> > with
>
> > response.flash = 'Erro na inserção'.encode('utf8')
>
> > On May 4, 5:39 am, Iceberg  wrote:
>
> > > Hi there,
>
> > > I just noticed that, component's non-ascii response.flash does not
> > > show well in IE7, IE8, Firefox 3.0.19.
>
> > > def visit_me():
> > >     return {'':LOAD('default', 'component.load', ajax=True)}
> > > def component():
> > >     response.flash = 'Erro na inserção'
> > >     return {'':'Testing'}
>
> > > But Chrome 11.x is fine.
>
> > > So I guess that means the flash string is properly transfered to
> > > client but, for some reason its encoding is not properly indicated
> > > therefore incorrectly handled.
>
> > > Is this a bug? Is there any workaround?
>
> > > Regards,
> > > Iceberg


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Plumo
fantastic news!
This should let me move a lot of code from models in to modules.


[web2py] Re: ajax:whats wrong with this

2011-05-05 Thread Resa
I am having huge issues with the parameters cause they are not being
sent to the function at all...
def insert_updatedb():
session.correct=request.vars.correct
session.numquest=request.vars.number
session.time_quest=request.vars.total_time
session.mgp=request.vars.mgp
.
.
.

On May 5, 8:37 pm, Resa  wrote:
> Correction:
>  function MGP(correct)
>     {
>         var time_per_question=2;                         //2 second to
> answer one question
>         var numBer={{=request.vars.number}};               // the
> number of questions in worksheet
>         var bonus= (numBer<20)? 1: (numBer<40)? 3 :(numBer<60)? 7:
> (numBer<80)? 9: (numBer<100)? 11 :13    // calculate bonus
>         var total_time=converttime();
>         var mgp= (((correct/numBer)+(total_time/
> (numBer*time_per_question))+bonus));
>         ajax('{{=URL('insert_updatedb')}}',
> ['numBer','mgp','total_time','correct'],'');
>      }
>
> On May 5, 7:35 pm, pbreit  wrote:
>
> > This is pretty confusing code.
>
> > I'm not sure how these assignments are going to work:
> > {{=numBer}}=numBer
> > ...
>
> > Normally you have something like num={{=row.num}}
>
> > In the dict() it looks like you are assigning strings. Normally it would
> > look more like this dict(numBer=numBer,...)
>
> > You definitely don't want this: {{URL(...    That's not going to do
> > anything.
>
> > Then you need something to trigger the Ajax call.
>
> > Review the Book:http://web2py.com/book/default/chapter/10#The-ajax-Function
>
> > I would suggest starting very simply, prove that it works and then add the
> > complexity.
>
>


[web2py] Re: Problem connecting to mysql DB

2011-05-05 Thread Anthony
On Thursday, May 5, 2011 9:23:52 PM UTC-4, Massimo Di Pierro wrote: 
>
> I spoke with Dave and this is solved. For further reference... there 
> was a problem when upgrading form the old web2py version. The .table 
> files were case independent and the new web2py is not. 
> The solution was: 
>
> 1) delete databases/*.table 
> 2) edit models/db.py and set 
>
> db=DAL(...,fake_migrate_enabled=True)

 
Note, if you're using trunk (and starting with the next release after 
1.95.1), it will be fake_migrate_all instead of fake_migrate_enabled.
 
Anthony


[web2py] Re: ajax:whats wrong with this

2011-05-05 Thread Resa
Correction:
 function MGP(correct)
{
var time_per_question=2; //2 second to
answer one question
var numBer={{=request.vars.number}};   // the
number of questions in worksheet
var bonus= (numBer<20)? 1: (numBer<40)? 3 :(numBer<60)? 7:
(numBer<80)? 9: (numBer<100)? 11 :13// calculate bonus
var total_time=converttime();
var mgp= (((correct/numBer)+(total_time/
(numBer*time_per_question))+bonus));
ajax('{{=URL('insert_updatedb')}}',
['numBer','mgp','total_time','correct'],'');
 }

On May 5, 7:35 pm, pbreit  wrote:
> This is pretty confusing code.
>
> I'm not sure how these assignments are going to work:
> {{=numBer}}=numBer
> ...
>
> Normally you have something like num={{=row.num}}
>
> In the dict() it looks like you are assigning strings. Normally it would
> look more like this dict(numBer=numBer,...)
>
> You definitely don't want this: {{URL(...    That's not going to do
> anything.
>
> Then you need something to trigger the Ajax call.
>
> Review the Book:http://web2py.com/book/default/chapter/10#The-ajax-Function
>
> I would suggest starting very simply, prove that it works and then add the
> complexity.


[web2py] Re: Problem connecting to mysql DB

2011-05-05 Thread dsa42
Thanks for the help, Massimo.  Web2py is really cool.


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Massimo Di Pierro
I doubt this is an issue with the new import or the new gluon.current
tread local object.
This is probably to the new use of subfolder in models.
Do you have subfolders under models/ ?

On May 5, 7:52 pm, Christopher Steel  wrote:
> my menu.py in my plugin no longer show up at the apps index and only
> display "in" the plugin directory. Is this due to the new current
> scope? Is their a way to get this working again or a "current scope"
> toggle ? I have a lot of plugins that use this for menu's so any help
> on this is very appreciated.
>
> Thanks,
>
> Chris
>
> example, before using something like
>
> response.menu+= [bla bla]
>
> in a plugin added the plugin menu to the main menu and it showed up
> at:
>
>  http://127.0.0.1:8000/blank/default/index
>
> Now it only shows up "in" the plugin, for example here:
>
>  http://127.0.0.1:8000/blank/plugin_uc_language/index
>
> but no longer shows up here:
>
>  http://127.0.0.1:8000/blank/default/index
>
> SO it does not work with 1.95.1 (2011-05-05 15:15:00)
> but does work with 1.95.1 (2011-04-27 ..:..:..)
>
> On May 4, 5:29 pm, Bruno Rocha  wrote:
>
>
>
>
>
>
>
> > I am testing right now, at this point I have 2 apps running with no
> > problems!
>
> > models subfolder, custom importer and current scope are great improvements
> > to web2py, I am waiting to rely on this for the app I am working now.
>
> > Thank you Massimo and Jonathan (of course all the other collaborators),
> > @web2py "the framework that evolves every two weeks"
>
> > --
> > Bruno Rocha
> > [ About me:http://zerp.ly/rochacbruno]
>
> > On Wed, May 4, 2011 at 6:09 PM, Massimo Di Pierro
> > wrote:
>
> > > Hello everybody
>
> > > Jonathan and I have been working on an internal web2py rewrite that while
> > > keeping everything backward compatible will allow you to do this
>
> > >  modules/mymodule.py
> > > from gluon import *
> > > def f(): return DIV(A(current.request.function,_href=URL()))
> > >  end
>
> > >  default/controller.py
> > > def index():
> > >    from mymodule import f
> > >    return dict(div=f())
> > >  end
>
> > > Thanks to Pierre we can now import modules from the app local folder
> > > without local_import and thanks to Jonathan those modules only need to do
> > > "from gluon import *" to see everything web2py has to offer. This should
> > > make life easier for Eclipse users too.
>
> > > In models/db.py you no longer need to pass globals() to Auth
>
> > >   auth=Auth(globals(),db)
> > > or
> > >   auth=Auth(db)
>
> > > both work.
>
> > > Also error messages in validators (including default error messages) 
> > > should
> > > not be by T(...) by default.
>
> > > This is now in trunk but we are still working on it. This means trunk may
> > > not very stable for the next day or two.
> > > Meanwhile help us test it. In particular help us test if we are breaking
> > > your apps.
>
> > > Massimo


[web2py] Re: Problem connecting to mysql DB

2011-05-05 Thread Massimo Di Pierro
I spoke with Dave and this is solved. For further reference... there
was a problem when upgrading form the old web2py version. The .table
files were case independent and the new web2py is not.
The solution was:

1) delete databases/*.table
2) edit models/db.py and set

db=DAL(...,fake_migrate_enabled=True)

3) run web2py once (this will rebuild all .table)
4) restore the code as it was:

db=DAL(...)

This is the second time a user has a similar problem.

Massimo


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Christopher Steel
my menu.py in my plugin no longer show up at the apps index and only
display "in" the plugin directory. Is this due to the new current
scope? Is their a way to get this working again or a "current scope"
toggle ? I have a lot of plugins that use this for menu's so any help
on this is very appreciated.

Thanks,

Chris

example, before using something like

response.menu+= [bla bla]

in a plugin added the plugin menu to the main menu and it showed up
at:

  http://127.0.0.1:8000/blank/default/index


Now it only shows up "in" the plugin, for example here:

  http://127.0.0.1:8000/blank/plugin_uc_language/index

but no longer shows up here:

 http://127.0.0.1:8000/blank/default/index

SO it does not work with 1.95.1 (2011-05-05 15:15:00)
but does work with 1.95.1 (2011-04-27 ..:..:..)







On May 4, 5:29 pm, Bruno Rocha  wrote:
> I am testing right now, at this point I have 2 apps running with no
> problems!
>
> models subfolder, custom importer and current scope are great improvements
> to web2py, I am waiting to rely on this for the app I am working now.
>
> Thank you Massimo and Jonathan (of course all the other collaborators),
> @web2py "the framework that evolves every two weeks"
>
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]
>
> On Wed, May 4, 2011 at 6:09 PM, Massimo Di Pierro
> wrote:
>
> > Hello everybody
>
> > Jonathan and I have been working on an internal web2py rewrite that while
> > keeping everything backward compatible will allow you to do this
>
> >  modules/mymodule.py
> > from gluon import *
> > def f(): return DIV(A(current.request.function,_href=URL()))
> >  end
>
> >  default/controller.py
> > def index():
> >    from mymodule import f
> >    return dict(div=f())
> >  end
>
> > Thanks to Pierre we can now import modules from the app local folder
> > without local_import and thanks to Jonathan those modules only need to do
> > "from gluon import *" to see everything web2py has to offer. This should
> > make life easier for Eclipse users too.
>
> > In models/db.py you no longer need to pass globals() to Auth
>
> >   auth=Auth(globals(),db)
> > or
> >   auth=Auth(db)
>
> > both work.
>
> > Also error messages in validators (including default error messages) should
> > not be by T(...) by default.
>
> > This is now in trunk but we are still working on it. This means trunk may
> > not very stable for the next day or two.
> > Meanwhile help us test it. In particular help us test if we are breaking
> > your apps.
>
> > Massimo
>
>


[web2py] Re: ajax:whats wrong with this

2011-05-05 Thread pbreit
This is pretty confusing code.

I'm not sure how these assignments are going to work:
{{=numBer}}=numBer
...

Normally you have something like num={{=row.num}}

In the dict() it looks like you are assigning strings. Normally it would 
look more like this dict(numBer=numBer,...)

You definitely don't want this: {{URL(...That's not going to do 
anything.

Then you need something to trigger the Ajax call.

Review the Book: http://web2py.com/book/default/chapter/10#The-ajax-Function

I would suggest starting very simply, prove that it works and then add the 
complexity.


[web2py] ajax:whats wrong with this

2011-05-05 Thread Resa
I having been trying to send variables in a function .. this function
that is being called is then suppose to receive the vars from the ajax
function.. can you help me .. because the ajax is not passing
theparameters to the function insert_updatedb




var time_per_question=2; //2 second to answer
one question
var numBer={{=request.vars.number}};   // the
number of questions in worksheet
var bonus= (numBer<20)? 1: (numBer<40)? 3 :(numBer<60)? 7:
(numBer<80)? 9: (numBer<100)? 11 :13// calculate bonus
var total_time=converttime();
var mgp= (((correct/numBer)+(total_time/
(numBer*time_per_question))+bonus));
{{=numBer}}=numBer
{{=correct}}=correct
{{=total_time}}=total_time
{{=mgp}}=mgp
{{URL('insert_updatedb',
vars=dict(numBer='numBer',mgp='mgp',total_time='total_time',correct='correct'))}}
//ajax('{{=URL('insert_updatedb')}}',
['numBer','mgp','total_time','correct'],'');


[web2py] Re: fak_migrate_all error

2011-05-05 Thread pbreit
I re-cloned web2py from scratch. I was trying to avoid that but I guess it 
was good practice.

[web2py] Re: a chance to vote for web2py

2011-05-05 Thread Anthony
Cool -- web2py is up to #11 on the list. :-)

On Wednesday, May 4, 2011 10:59:52 AM UTC-4, Massimo Di Pierro wrote:

> http://list.ly/list/9E-tools-and-services-for-a-lean-startup
>


[web2py] Re: vertical submenu width pb

2011-05-05 Thread Anthony
I see a few problems:

   - It should be =MENU(...), not MENU=(...) 
   - The arguments should be separated by commas, not spaces. 
   - _lu_class should be ul_class.

So, try:
 
{{=MENU(response.menu,_class='sf-menu', ul_class='my-class', 
li_class='my-class')}}
 
Anthony

On Thursday, May 5, 2011 6:30:15 PM UTC-4, francois wrote:

> Hi, 
>
> I have a submenu pb width (too small), where is the class web2py-menu- 
> vertical? 
> because if I try to add ul_class = 'my-class' and li_class = 'my- 
> class', they are assigned to top-level menu and 
> submenu remains with li class = "menu-expand-web2py" and ul class = 
> "web2py-menu-vertical " 
> eg in layout.html 
> {{#-- Superfish menu --}} 
> {{MENU = (response.menu, _class = 'sf-menu ' _lu_class = 'my-class' 
> li_class = 'my-class')}} 
>
> the html result 
>  href="">HomeLunettes href="">Lentilles href="">Visage href="i">Envoyer votre photoRéglages 
>
> in my menu, "Envoyer votre photo"is written on two lines. 
>
> Thanks 
>
> Francois



Re: [web2py] Re: MongoDBAdapter -- in DAL

2011-05-05 Thread joseph simpson
Try the following code:
##
#!/usr/bin/python
import sys
import time
sys.path.append('/Users/pcode/Desktop/mongodb_test/web2py')
from gluon.dal import DAL, Field

db = DAL('mongodb://127.0.0.1:5984/db')

db.define_table('m_test',
Field('name','text'),
Field('number','integer'))

So a quick check of the current mongoDBAdaptor provides the following error
stream:
#
# The above code produces the following error
#
Traceback (most recent call last):
  File "./test_mdb_1.py", line 7, in 
db = DAL('mongodb://127.0.0.1:5984/db')
  File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line 3724,
in __init__
raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
(attempts, error)
RuntimeError: Failure to connect, tried 5 times:
'MongoDBAdapter' object has no attribute '_uri'

#
### Make the following changes
#
Line number 3342
FROM:
 m =
re.compile('^(?P[^\:/]+)(\:(?P[0-9]+))?/(?P.+)$').match(self._uri[10:])
TO:
 m =
re.compile('^(?P[^\:/]+)(\:(?P[0-9]+))?/(?P.+)$').match(self.uri[10:])

Line number 3344
FROM:
 raise SyntaxError, "Invalid URI string in DAL: %s" % self._uri
TO:
 raise SyntaxError, "Invalid URI string in DAL: %s" % self.uri
#
### New error listed below
#
Traceback (most recent call last):
  File "./test_mdb_1.py", line 7, in 
db = DAL('mongodb://127.0.0.1:5984/db')
  File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line 3724,
in __init__
raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
(attempts, error)
RuntimeError: Failure to connect, tried 5 times:
port must be an instance of int
#
# Make the following change
#
Line 3351
FROM:
 port = m.group('port') or 27017
TO:
 port = 27017
#
# Now the code connects to the server but the error below is
reported
##
Traceback (most recent call last):
  File "./test_mdb_1.py", line 14, in 
Field('number','integer'))
  File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line 4032,
in define_table
polymodel=polymodel)
  File "/Users/pcode/Desktop/mongodb_test/web2py/gluon/dal.py", line 513, in
create_table
% dict(length=field.length)
TypeError: unsupported operand type(s) for %: 'type' and 'dict'
#
### It is not clear to me why this error is generated
### So report back to the list
#

On Wed, May 4, 2011 at 9:24 PM, joseph simpson  wrote:

> OK, I will find some time in the next few days to look at this..
>
> Thanks for your quick response to the question..
>
>
>
>
> On Wed, May 4, 2011 at 8:02 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Please help me try if
>>
>> db=DAL('mongodb://127.0.0.1:5984/db')
>> db.define_table('mytable',...)
>> db.mytable.insert(...)
>>
>> try different field types and let me know which ones fail.
>>
>> works.
>>
>> On May 4, 9:42 am, "David J."  wrote:
>> > Ahh; Ok;
>> >
>> > Perhaps I will use MongEngine for now and then come back to DAL once we
>> > have time for it;
>> >
>> > I think its not worth your time to build in support for something not so
>> > many people are using;
>> >
>> > Besides anyone can use MongoEngine with Web2py without much difficulty;
>> >
>> > I did some simple tests before just to see; I am going to spend more
>> > time with it now and see what problems I run into;
>> >
>> > Thanks.
>> >
>> > On 5/4/11 10:30 AM, Massimo Di Pierro wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > mongodb with DAL does not currently work but, if you help with tests,
>> > > we could make it work
>> >
>> > > On May 4, 8:56 am, "David J."  wrote:
>> > >> Is this in trunk;
>> >
>> > >> I will start a new project today and use Mongo For DB
>> >
>> > >> I think I tried it last month and I had some problems; I didnt have
>> the
>> > >> time to look into it.
>> >
>> > >> I will update and try again.
>> >
>> > >> Thanks.
>> >
>> > >> On 5/4/11 9:30 AM, Massimo Di Pierro wrote:
>> >
>> > >>> fixing it now. Looks like not many people testing it. :-)
>> > >>> On May 3, 9:56 pm, joseph simpsonwrote:
>> >  The current dal.py file contains the following code, between lines
>> >  3381 and 3404:
>> >  ADAPTERS = {
>> >    'sqlite': SQLiteAdapter,
>> >    'sqlite:memory': SQLiteAdapter,
>> >    'mysql': MySQLAdapter,
>> >   

[web2py] vertical submenu width pb

2011-05-05 Thread francois
Hi,

I have a submenu pb width (too small), where is the class web2py-menu-
vertical?
because if I try to add ul_class = 'my-class' and li_class = 'my-
class', they are assigned to top-level menu and
submenu remains with li class = "menu-expand-web2py" and ul class =
"web2py-menu-vertical "
eg in layout.html
{{#-- Superfish menu --}}
{{MENU = (response.menu, _class = 'sf-menu ' _lu_class = 'my-class'
li_class = 'my-class')}}

the html result
HomeLunettesLentillesVisageEnvoyer votre photoRéglages

in my menu, "Envoyer votre photo"is written on two lines.

Thanks

Francois


[web2py] Re: Problem connecting to mysql DB

2011-05-05 Thread dsa42
Sorry to the group.  I had to rereate my account so the earlier
messages in this thread got deleted.

Massimo, when I upgrade and restart, I'm now getting these errors:

web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.95.1 (2011-04-25 15:04:14)
Database drivers available: SQLite3, pymysql
Traceback (most recent call last):
  File "/web2py/web2py/gluon/restricted.py", line 181, in
restricted
exec ccode in environment
  File "applications/phones/models/db.py", line 13, in 
db.define_table('idsChecked',SQLField('idChecked'))
  File "/web2py/web2py/gluon/dal.py", line 4028, in define_table
polymodel=polymodel)
  File "/web2py/web2py/gluon/dal.py", line 613, in create_table
fake_migrate=fake_migrate)
  File "/web2py/web2py/gluon/dal.py", line 657, in migrate_table
and not isinstance(table[key].type, SQLCustomType) \
  File "/web2py/web2py/gluon/dal.py", line 4378, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'idchecked'


On May 5, 2:46 pm, Massimo Di Pierro 
wrote:
> You should upgrade. That version is more than one year old. That
> problem has been fixed.
>
> Massimo
>
> On May 5, 2:43 pm, dsa42  wrote:
>
>
>
>
>
>
>
> > I think it's 1.76.5
>
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2010
> > Version 1.76.5 (2010-03-11 15:19:08)
> > Database drivers available: SQLite3
>
> > I also think that the probley is that Ubuntu 10.04 installed pythin
> > 2.6.  Somehow, that installation ruined the MySQLdb module for python
> > 2.6.  I can't even "inport MySQLdb" in either python 2.5 or 2.6, so
> > I'm working on solving that first.
>
> > On May 5, 1:16 pm, Massimo Di Pierro 
> > wrote:
>
> > > Which web2py version? the latest web2py should be using pymysql and
> > > not mysqldb.
>
> > > On May 5, 11:41 am, dsa42  wrote:
>
> > > > I am a noob to web2py.  I am working on a previously installed system
> > > > at a client site (not installed by me).
>
> > > > I upgraded the system from Ubuntu server 9.10 (karmic) to 10.04
> > > > (lucid).  After reboot, I'm getting the following traceback from the
> > > > web2py server:
>
> > > > Error traceback
>
> > > > 1.Traceback (most recent call last):
> > > > 2.  File "/web2py/web2py/gluon/restricted.py", line 173, in restricted
> > > > 3.       exec ccode in environment
> > > > 4.  File "/web2py/web2py/applications/MyAppName/models/db.py", line 9,
> > > > in 
> > > > 5.    db = DAL('mysql://user:password@localhost/DBname')
> > > > 6.  File "/web2py/web2py/gluon/sql.py", line 3783, in DAL
> > > > 7.    db_codec=db_codec, check_reserved=check_reserved)
> > > > 8.  File "/web2py/web2py/gluon/sql.py", line 919, in __init__
> > > > 9.    self._pool_connection(lambda : MySQLdb.Connection(
> > > > 10.  File "/web2py/web2py/gluon/sql.py", line 829, in _pool_connection
> > > > 11.    self._connection = f()
> > > > 12.  File "/web2py/web2py/gluon/sql.py", line 919, in 
> > > > 13.    self._pool_connection(lambda : MySQLdb.Connection(
> > > > 14.NameError: global name 'MySQLdb' is not defined
> > > > 15.
>
> > > > The mysql daemon is running.  The username, password, and DBname are
> > > > correct.  Any ideas on where to look?


[web2py] Re: Problem connecting to mysql DB

2011-05-05 Thread dsa42
Thanks for the responses.

It doesn't seem to be the case with different case.  Sorry, I didn't
write this app.  Here is what I get on a find:

12255433  128 -rw-r--r--   1 root root   125292 Apr  6  2010 ./
controllers/test.py.1
> find . -not -name "*.pyc" -not -name "*.py" -not -name "*.JPG" -not -name 
> "*.html" -not -name "*.gif" -not -name "67*" -not -name "68*" -not -name 
> "99*" -not -name "127*" -not -name "*.bak" -not -name "*.db" -not -name 
> "*.table" -not -name "*.js" -not -name "*.jpg" -not -name "*.pdf" -not -name 
> "*.txt" -not -name "*.css" -not -name "*.csv" -not -name "75*" -exec grep -i 
> idchecked {} \; -ls
idChecked CHAR(32)
idChecked VARCHAR(32),
ALTER TABLE idsChecked ADD idChecked__tmp VARCHAR(512);
UPDATE idsChecked SET idChecked__tmp=idChecked;
ALTER TABLE idsChecked DROP COLUMN idChecked;
ALTER TABLE idsChecked ADD idChecked VARCHAR(512);
UPDATE idsChecked SET idChecked=idChecked__tmp;
ALTER TABLE idsChecked DROP COLUMN idChecked__tmp;
idChecked CHAR(512)
idChecked CHAR(512)
idChecked VARCHAR(512),
idChecked VARCHAR(512),
idChecked VARCHAR(512),
idChecked VARCHAR(512),
12255494  196 -rw-r--r--   1 root root   194993 Jul 15  2010 ./
databases/sql.log
db(db.idsChecked.idChecked==item.id).delete()
db.idsChecked.insert(idChecked=id)
db.idsChecked.insert(idChecked=id)
db.idsChecked.insert(idChecked=id)
db.idsChecked.insert(idChecked=id)
12255433  128 -rw-r--r--   1 root root   125292 Apr  6  2010 ./
controllers/test.py.1
>


Is there something else I could check?


On May 5, 4:58 pm, Massimo Di Pierro 
wrote:
> The problem is that the code uses (or used) inconsistent case. Old versions 
> were forgiving about this. New versions are less forgiving because this soon 
> or later causes problems.
>
> You have
>
> > db.define_table('idsChecked',SQLField('idChecked'))
>
> and somewhere else you use 'idchecked'.
>
> First thing to do is make sure you have consistent case.
>
> Do you have an existing database of does it need to be created?
>
> On May 5, 2011, at 4:52 PM, dsa42 wrote:
>
>
>
>
>
>
>
> > Sorry to the group.  I had to rereate my account so the earlier
> > messages in this thread got deleted.
>
> > Massimo, when I upgrade and restart, I'm now getting these errors:
>
> >    web2py Enterprise Web Framework
> >    Created by Massimo Di Pierro, Copyright 2007-2011
> >    Version 1.95.1 (2011-04-25 15:04:14)
> >    Database drivers available: SQLite3, pymysql
> >    Traceback (most recent call last):
> >      File "/web2py/web2py/gluon/restricted.py", line 181, in
> > restricted
> >        exec ccode in environment
> >      File "applications/phones/models/db.py", line 13, in 
> >        db.define_table('idsChecked',SQLField('idChecked'))
> >      File "/web2py/web2py/gluon/dal.py", line 4028, in define_table
> >        polymodel=polymodel)
> >      File "/web2py/web2py/gluon/dal.py", line 613, in create_table
> >        fake_migrate=fake_migrate)
> >      File "/web2py/web2py/gluon/dal.py", line 657, in migrate_table
> >        and not isinstance(table[key].type, SQLCustomType) \
> >      File "/web2py/web2py/gluon/dal.py", line 4378, in __getitem__
> >        return dict.__getitem__(self, str(key))
> >    KeyError: 'idchecked'
>
> > On May 5, 2:46 pm, Massimo Di Pierro 
> > wrote:
> >> You should upgrade. That version is more than one year old. That
> >> problem has been fixed.
>
> >> Massimo
>
> >> On May 5, 2:43 pm, dsa42  wrote:
>
> >>> I think it's 1.76.5
>
> >>> web2py Enterprise Web Framework
> >>> Created by Massimo Di Pierro, Copyright 2007-2010
> >>> Version 1.76.5 (2010-03-11 15:19:08)
> >>> Database drivers available: SQLite3
>
> >>> I also think that the probley is that Ubuntu 10.04 installed pythin
> >>> 2.6.  Somehow, that installation ruined the MySQLdb module for python
> >>> 2.6.  I can't even "inport MySQLdb" in either python 2.5 or 2.6, so
> >>> I'm working on solving that first.
>
> >>> On May 5, 1:16 pm, Massimo Di Pierro 
> >>> wrote:
>
>  Which web2py version? the latest web2py should be using pymysql and
>  not mysqldb.
>
>  On May 5, 11:41 am, dsa42  wrote:
>
> > I am a noob to web2py.  I am working on a previously installed system
> > at a client site (not installed by me).
>
> > I upgraded the system from Ubuntu server 9.10 (karmic) to 10.04
> > (lucid).  After reboot, I'm getting the following traceback from the
> > web2py server:
>
> > Error traceback
>
> > 1.Traceback (most recent call last):
> > 2.  File "/web2py/web2py/gluon/restricted.py", line 173, in restricted
> > 3.       exec ccode in environment
> > 4.  File "/web2py/web2py/applications/MyAppName/models/db.py", line 9,
> > in 
> > 5.    db = DAL('mysql://user:password@localhost/DBname')
> > 6.  File "/web2py/web2py/gluon/sql.py", line 3783, in DAL
> > 7.    db_codec=db_codec, check_reserved=check_r

[web2py] fak_migrate_all error

2011-05-05 Thread pbreit
I can't figure out why I am getting this error:

Traceback (most recent call last):
  File "/var/web2py/gluon/restricted.py", line 181, in restricted
exec ccode in environment
  File "/var/web2py/applications/init/models/0_settings.py" 
, line 8, in 

db = DAL('postgres://postgres:password@localhost/main', pool_size=2, 
migrate_enabled=False, fake_migrate_all=False)
TypeError: __init__() got an unexpected keyword argument 'fake_migrate_all'

As far as I can tell, I'm working with trunk (hg update tip). Although admin 
shows an old version: 
Version 1.95.1 (2011-04-25 08:57:54)

[web2py] Re: can anyone guess what's wrong with this?

2011-05-05 Thread mart
thanks Guys! made the change :)

On May 5, 11:10 am, Anthony  wrote:
> On Thursday, May 5, 2011 11:05:53 AM UTC-4, rochacbruno wrote:
>
> > Should have a 'quick tips and advices' section on the book for this kind of
> > stuff. May be a blockquote on DAL chapter. Too much information that get
> > lost in google group.
>
> > Need to be documented as soon we catch this.
>
> I'm on it. :-)
>
> Anthony


[web2py] Re: Problem connecting to mysql DB

2011-05-05 Thread Massimo Di Pierro
The problem is that the code uses (or used) inconsistent case. Old versions 
were forgiving about this. New versions are less forgiving because this soon or 
later causes problems.

You have

> db.define_table('idsChecked',SQLField('idChecked'))

and somewhere else you use 'idchecked'.

First thing to do is make sure you have consistent case.

Do you have an existing database of does it need to be created?


 

On May 5, 2011, at 4:52 PM, dsa42 wrote:

> Sorry to the group.  I had to rereate my account so the earlier
> messages in this thread got deleted.
> 
> Massimo, when I upgrade and restart, I'm now getting these errors:
> 
>web2py Enterprise Web Framework
>Created by Massimo Di Pierro, Copyright 2007-2011
>Version 1.95.1 (2011-04-25 15:04:14)
>Database drivers available: SQLite3, pymysql
>Traceback (most recent call last):
>  File "/web2py/web2py/gluon/restricted.py", line 181, in
> restricted
>exec ccode in environment
>  File "applications/phones/models/db.py", line 13, in 
>db.define_table('idsChecked',SQLField('idChecked'))
>  File "/web2py/web2py/gluon/dal.py", line 4028, in define_table
>polymodel=polymodel)
>  File "/web2py/web2py/gluon/dal.py", line 613, in create_table
>fake_migrate=fake_migrate)
>  File "/web2py/web2py/gluon/dal.py", line 657, in migrate_table
>and not isinstance(table[key].type, SQLCustomType) \
>  File "/web2py/web2py/gluon/dal.py", line 4378, in __getitem__
>return dict.__getitem__(self, str(key))
>KeyError: 'idchecked'
> 
> 
> On May 5, 2:46 pm, Massimo Di Pierro 
> wrote:
>> You should upgrade. That version is more than one year old. That
>> problem has been fixed.
>> 
>> Massimo
>> 
>> On May 5, 2:43 pm, dsa42  wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> I think it's 1.76.5
>> 
>>> web2py Enterprise Web Framework
>>> Created by Massimo Di Pierro, Copyright 2007-2010
>>> Version 1.76.5 (2010-03-11 15:19:08)
>>> Database drivers available: SQLite3
>> 
>>> I also think that the probley is that Ubuntu 10.04 installed pythin
>>> 2.6.  Somehow, that installation ruined the MySQLdb module for python
>>> 2.6.  I can't even "inport MySQLdb" in either python 2.5 or 2.6, so
>>> I'm working on solving that first.
>> 
>>> On May 5, 1:16 pm, Massimo Di Pierro 
>>> wrote:
>> 
 Which web2py version? the latest web2py should be using pymysql and
 not mysqldb.
>> 
 On May 5, 11:41 am, dsa42  wrote:
>> 
> I am a noob to web2py.  I am working on a previously installed system
> at a client site (not installed by me).
>> 
> I upgraded the system from Ubuntu server 9.10 (karmic) to 10.04
> (lucid).  After reboot, I'm getting the following traceback from the
> web2py server:
>> 
> Error traceback
>> 
> 1.Traceback (most recent call last):
> 2.  File "/web2py/web2py/gluon/restricted.py", line 173, in restricted
> 3.   exec ccode in environment
> 4.  File "/web2py/web2py/applications/MyAppName/models/db.py", line 9,
> in 
> 5.db = DAL('mysql://user:password@localhost/DBname')
> 6.  File "/web2py/web2py/gluon/sql.py", line 3783, in DAL
> 7.db_codec=db_codec, check_reserved=check_reserved)
> 8.  File "/web2py/web2py/gluon/sql.py", line 919, in __init__
> 9.self._pool_connection(lambda : MySQLdb.Connection(
> 10.  File "/web2py/web2py/gluon/sql.py", line 829, in _pool_connection
> 11.self._connection = f()
> 12.  File "/web2py/web2py/gluon/sql.py", line 919, in 
> 13.self._pool_connection(lambda : MySQLdb.Connection(
> 14.NameError: global name 'MySQLdb' is not defined
> 15.
>> 
> The mysql daemon is running.  The username, password, and DBname are
> correct.  Any ideas on where to look?



[web2py] useful shipping APIs

2011-05-05 Thread Massimo Di Pierro
https://rocketship.it/


[web2py] Re: Memory error with numpy large array

2011-05-05 Thread Massimo Di Pierro
I do not think so although there may be less memory available. Apache,
if you use, may set restrictions.

On May 5, 3:00 pm, Kostas M  wrote:
> I have an application which uses the function numpy.zeros to create a
> very big array (~16500 x 16500) with the command:
> data = numpy.zeros( (lgos,lgos), dtype=float)
> This causes a MemoryError ticket in web2py. However when I run the
> same function as a python module (outside web2py) it finishes without
> any problem.
> Any hints?
> Are there any additional memory restrictions when modules run through
> web2py that I should somehow consider?


[web2py] Re: problem with {{block}}s inside included files (v.1.95.1)

2011-05-05 Thread Massimo Di Pierro
I have reverted the change the causes the problem (r1748). There must
have been a reason for the change but I do not remember it and there
is no detail in the log.

If anybody remembers why I changed:

-content.append(str(t.content))
+content.append(t.content)

in gluon/template.py in March 22, 2011.
This must have been a response to a bug report.
Please let me know.

Massimo



On May 5, 3:30 pm, kasapo  wrote:
> Here's perhaps a better example of when the problem occurs.
>
> I've posted the needed files on pastebin.
>
> views/default/index.htmlhttp://pastebin.com/eqyegpQH
>
> views/bare.htmlhttp://pastebin.com/jT8hEASR
>
> views/right-col.htmlhttp://pastebin.com/ziL9V55p
>
> views/base.htmlhttp://pastebin.com/6R1uTV8N
>
> So, if you modify template.py, the issue is fixed. Or if you replace
> {{ include 'right-col.html' }}
>
> with the contents of 'right-col.html', then it also works.
>
> Note that this is just a silly example and as such I'm not even sure
> where the side-nav and live-nav "menus" would appear, but the point is
> that they don't.
>
> PS: I'm testing HTML5 stuff, hence the  and  elements,
> but that should have absolutely no bearing on the template parsing.
>
> -Kas
>
> On May 5, 2:53 pm, kasapo  wrote:
>
>
>
>
>
>
>
> > First off -- let me say that my usage of the templating in this case
> > is somewhat peculiar, and if they are not supposed to work like this,
> > that is fine.
>
> > After reviewing my app, I only have one instance of code like this,
> > and it is "vestigial" and should be removed anyhow. But I thought it
> > strange that it broke, and I'm wondering if I might have another
> > include/block problem.
>
> > Solution:
>
> > diff -r fe58378e989b gluon/template.py
> > --- a/gluon/template.py Wed May 04 18:58:40 2011 -0500
> > +++ b/gluon/template.py Thu May 05 14:46:21 2011 -0500
> > @@ -454,7 +454,8 @@
> >                             writer  = self.writer,
> >                             delimiters = self.delimiters)
>
> > -        content.append(str(t.content))
> > +        content.append(t.content)
> > +        #content.append(str(t.content))
>
> >      def extend(self, filename):
> >          """
>
> > Read on for how I got there and a strange LDAP_auth issue...
>
> > On May 5, 1:37 pm, Massimo Di Pierro 
> > wrote:
>
> > > Hello kasapo,
>
> > > I do not completely follow you code. If I do, you have two blocks. The
> > > code included in one of the blocks seems to extend a  block included
> > > in another block. I am unsure this is supposed to work. Anyway, let's
> > > try figure out what has changed that broke and then we may be able to
> > > revert the previous behavior.
>
> > So I have this structure:
>
> > bare (defines html, head, style, script (jquery includes), body
> > sections, and some containing blocks) -- ancestor to almost all
> > templates
>
> > right-col (included by bare, defines blocks which base will extend --
> > base extends bare, bare includes right-col so therefore base should be
> > able to see blocks defined by bare)
>
> > base (defines styles, background, etc -- the base template for most
> > things -- defines actual markup for blocks which are DEFINED in right-
> > col)
>
> > page (extends base, does not use blocks -- the menu rendered on the
> > page view is defined in base inside of a block that is defined in bare
> > via right-col include)
> > page-no-side-nav ( extends base, uses {{ block right-col }}{{end}} to
> > delete the right column )
>
> > > Can you try:
>
> > > hg revert -r 1488 gluon/template.py > ~/Downloads/template.diff
>
> > Sadly, I am on RHEL and mercurial isn't present... so I will use my
> > local machine (Macintosh).
>
> > First off, I use LDAP authentication for a login method, and (this
> > happened on 1.95.1 on RHEL server as well) I get this error:
>
> > Traceback (most recent call last):
> >   File "/Users/csburreson/web2py/gluon/restricted.py", line 181, in
> > restricted
> >     exec ccode in environment
> >   File "/Users/csburreson/web2py/applications/icecube/models/
> > 0_init.py", line 42, in 
> >     from gluon.contrib.login_methods.ldap_auth import ldap_auth
> >   File "/Users/csburreson/web2py/gluon/custom_import.py", line 80, in
> > _web2py__import__
> >     return _old__import__(name, globals, locals, fromlist, level)
> >   File "/Users/csburreson/web2py/gluon/contrib/login_methods/
> > ldap_auth.py", line 5, in 
> >     except e:
> > NameError: name 'e' is not defined
>
> > So I just copied the working ldap_auth.py from the 1.89 version of
> > web2py... problem solved (could this somehow create an issue with
> > templates?)
>
> > Then I realized I did not have python-ldap installed, so I did
> > easy_install python-ldap and all was good.
>
> > [I did exactly these same things earlier today when installing the
> > TEST server]
>
> > SO, now the application is again working, and I check out my code into
> > the applications folder using SVN.
>
> > The menu is not present :(
>
> > Then I run :
>

[web2py] Re: problem with {{block}}s inside included files (v.1.95.1)

2011-05-05 Thread kasapo
Here's perhaps a better example of when the problem occurs.

I've posted the needed files on pastebin.

views/default/index.html
http://pastebin.com/eqyegpQH

views/bare.html
http://pastebin.com/jT8hEASR

views/right-col.html
http://pastebin.com/ziL9V55p

views/base.html
http://pastebin.com/6R1uTV8N

So, if you modify template.py, the issue is fixed. Or if you replace
{{ include 'right-col.html' }}

with the contents of 'right-col.html', then it also works.

Note that this is just a silly example and as such I'm not even sure
where the side-nav and live-nav "menus" would appear, but the point is
that they don't.

PS: I'm testing HTML5 stuff, hence the  and  elements,
but that should have absolutely no bearing on the template parsing.

-Kas

On May 5, 2:53 pm, kasapo  wrote:
> First off -- let me say that my usage of the templating in this case
> is somewhat peculiar, and if they are not supposed to work like this,
> that is fine.
>
> After reviewing my app, I only have one instance of code like this,
> and it is "vestigial" and should be removed anyhow. But I thought it
> strange that it broke, and I'm wondering if I might have another
> include/block problem.
>
> Solution:
>
> diff -r fe58378e989b gluon/template.py
> --- a/gluon/template.py Wed May 04 18:58:40 2011 -0500
> +++ b/gluon/template.py Thu May 05 14:46:21 2011 -0500
> @@ -454,7 +454,8 @@
>                             writer  = self.writer,
>                             delimiters = self.delimiters)
>
> -        content.append(str(t.content))
> +        content.append(t.content)
> +        #content.append(str(t.content))
>
>      def extend(self, filename):
>          """
>
> Read on for how I got there and a strange LDAP_auth issue...
>
> On May 5, 1:37 pm, Massimo Di Pierro 
> wrote:
>
> > Hello kasapo,
>
> > I do not completely follow you code. If I do, you have two blocks. The
> > code included in one of the blocks seems to extend a  block included
> > in another block. I am unsure this is supposed to work. Anyway, let's
> > try figure out what has changed that broke and then we may be able to
> > revert the previous behavior.
>
> So I have this structure:
>
> bare (defines html, head, style, script (jquery includes), body
> sections, and some containing blocks) -- ancestor to almost all
> templates
>
> right-col (included by bare, defines blocks which base will extend --
> base extends bare, bare includes right-col so therefore base should be
> able to see blocks defined by bare)
>
> base (defines styles, background, etc -- the base template for most
> things -- defines actual markup for blocks which are DEFINED in right-
> col)
>
> page (extends base, does not use blocks -- the menu rendered on the
> page view is defined in base inside of a block that is defined in bare
> via right-col include)
> page-no-side-nav ( extends base, uses {{ block right-col }}{{end}} to
> delete the right column )
>
> > Can you try:
>
> > hg revert -r 1488 gluon/template.py > ~/Downloads/template.diff
>
> Sadly, I am on RHEL and mercurial isn't present... so I will use my
> local machine (Macintosh).
>
> First off, I use LDAP authentication for a login method, and (this
> happened on 1.95.1 on RHEL server as well) I get this error:
>
> Traceback (most recent call last):
>   File "/Users/csburreson/web2py/gluon/restricted.py", line 181, in
> restricted
>     exec ccode in environment
>   File "/Users/csburreson/web2py/applications/icecube/models/
> 0_init.py", line 42, in 
>     from gluon.contrib.login_methods.ldap_auth import ldap_auth
>   File "/Users/csburreson/web2py/gluon/custom_import.py", line 80, in
> _web2py__import__
>     return _old__import__(name, globals, locals, fromlist, level)
>   File "/Users/csburreson/web2py/gluon/contrib/login_methods/
> ldap_auth.py", line 5, in 
>     except e:
> NameError: name 'e' is not defined
>
> So I just copied the working ldap_auth.py from the 1.89 version of
> web2py... problem solved (could this somehow create an issue with
> templates?)
>
> Then I realized I did not have python-ldap installed, so I did
> easy_install python-ldap and all was good.
>
> [I did exactly these same things earlier today when installing the
> TEST server]
>
> SO, now the application is again working, and I check out my code into
> the applications folder using SVN.
>
> The menu is not present :(
>
> Then I run :
>
> hg revert -r 1488 gluon/template.py
>
> And check my app and the side menu IS present
>
> So, I go back to 1.95.1 (with the exception of the old ldap_auth.py
> from 1.89)
>
> and try
>
> hg diff -r 1488 gluon/template.py
>
> This bugger seems to be the culprit:
>
> @@ -455,7 +454,7 @@
> ...
> +        content.append(str(t.content))
> -        content.append(t.content)
>
> After changing it, i verified that I had not changed anything else by
> re-diffing the file against the repo:
>
> bash-3.2$ hg diff gluon/template.py
> diff -r fe58378e989b gluon/template.py
> --- a/gluon/template.py Wed May 04 18:58:40 2011 -0500
> +++ b/

Re: [web2py] Re: problem with {{block}}s inside included files (v.1.95.1)

2011-05-05 Thread Thadeus Burgess
Take a look at the ``template.Content.__str__`` method, this is what is
responsible for flattening the tree.

Calling ``str()`` on any instance of Content effectively flattens it to
text, since there is only text in the parent tree, it has no knowledge of
any blocks that might have existed in the included tree.

The only point at which the tree should be flattened is at the very end of
the parsing when the entire tree is assembled.

--
Thadeus




On Thu, May 5, 2011 at 3:24 PM, Thadeus Burgess wrote:

> Your code should work just fine kasapo, the template system was designed to
> do that.
>
> Someone at some point made a patch to the template that broke the way this
> is supposed to work.
>
>
> http://code.google.com/p/web2py/source/diff?spec=svnc6ff592d73ef81257a8d238a74b688c9b3a09360&r=e6868622d71ec96947b4bb08a44c527c9722b062&format=side&path=/gluon/template.py&old_path=/gluon/template.py&old=8d5d7f6bd391d2e30888c2c9fc168c081d02877f
>
> Basically, instead of just copying the included templates tree into the
> parent templates tree, they changed it so it would flatten the tree to text,
> and just include the text into the parent tree. All contexts are lost when
> the tree gets flattened.
>
> --
> Thadeus
>
>
>
>
>
> On Thu, May 5, 2011 at 2:53 PM, kasapo  wrote:
>
>> First off -- let me say that my usage of the templating in this case
>> is somewhat peculiar, and if they are not supposed to work like this,
>> that is fine.
>>
>> After reviewing my app, I only have one instance of code like this,
>> and it is "vestigial" and should be removed anyhow. But I thought it
>> strange that it broke, and I'm wondering if I might have another
>> include/block problem.
>>
>> Solution:
>>
>> diff -r fe58378e989b gluon/template.py
>> --- a/gluon/template.py Wed May 04 18:58:40 2011 -0500
>> +++ b/gluon/template.py Thu May 05 14:46:21 2011 -0500
>> @@ -454,7 +454,8 @@
>>writer  = self.writer,
>>delimiters = self.delimiters)
>>
>> -content.append(str(t.content))
>> +content.append(t.content)
>> +#content.append(str(t.content))
>>
>> def extend(self, filename):
>> """
>>
>> Read on for how I got there and a strange LDAP_auth issue...
>>
>> On May 5, 1:37 pm, Massimo Di Pierro 
>> wrote:
>> > Hello kasapo,
>> >
>> > I do not completely follow you code. If I do, you have two blocks. The
>> > code included in one of the blocks seems to extend a  block included
>> > in another block. I am unsure this is supposed to work. Anyway, let's
>> > try figure out what has changed that broke and then we may be able to
>> > revert the previous behavior.
>> >
>>
>> So I have this structure:
>>
>> bare (defines html, head, style, script (jquery includes), body
>> sections, and some containing blocks) -- ancestor to almost all
>> templates
>>
>> right-col (included by bare, defines blocks which base will extend --
>> base extends bare, bare includes right-col so therefore base should be
>> able to see blocks defined by bare)
>>
>> base (defines styles, background, etc -- the base template for most
>> things -- defines actual markup for blocks which are DEFINED in right-
>> col)
>>
>> page (extends base, does not use blocks -- the menu rendered on the
>> page view is defined in base inside of a block that is defined in bare
>> via right-col include)
>> page-no-side-nav ( extends base, uses {{ block right-col }}{{end}} to
>> delete the right column )
>>
>> > Can you try:
>> >
>> > hg revert -r 1488 gluon/template.py > ~/Downloads/template.diff
>> >
>>
>> Sadly, I am on RHEL and mercurial isn't present... so I will use my
>> local machine (Macintosh).
>>
>> First off, I use LDAP authentication for a login method, and (this
>> happened on 1.95.1 on RHEL server as well) I get this error:
>>
>> Traceback (most recent call last):
>>  File "/Users/csburreson/web2py/gluon/restricted.py", line 181, in
>> restricted
>>exec ccode in environment
>>  File "/Users/csburreson/web2py/applications/icecube/models/
>> 0_init.py", line 42, in 
>>from gluon.contrib.login_methods.ldap_auth import ldap_auth
>>  File "/Users/csburreson/web2py/gluon/custom_import.py", line 80, in
>> _web2py__import__
>>return _old__import__(name, globals, locals, fromlist, level)
>>  File "/Users/csburreson/web2py/gluon/contrib/login_methods/
>> ldap_auth.py", line 5, in 
>>except e:
>> NameError: name 'e' is not defined
>>
>> So I just copied the working ldap_auth.py from the 1.89 version of
>> web2py... problem solved (could this somehow create an issue with
>> templates?)
>>
>> Then I realized I did not have python-ldap installed, so I did
>> easy_install python-ldap and all was good.
>>
>> [I did exactly these same things earlier today when installing the
>> TEST server]
>>
>> SO, now the application is again working, and I check out my code into
>> the applications folder using SVN.
>>
>> The menu is not present :(
>>
>> Then I run :
>>
>> hg revert -r 1488 gluon/templ

Re: [web2py] Re: problem with {{block}}s inside included files (v.1.95.1)

2011-05-05 Thread Thadeus Burgess
Your code should work just fine kasapo, the template system was designed to
do that.

Someone at some point made a patch to the template that broke the way this
is supposed to work.

http://code.google.com/p/web2py/source/diff?spec=svnc6ff592d73ef81257a8d238a74b688c9b3a09360&r=e6868622d71ec96947b4bb08a44c527c9722b062&format=side&path=/gluon/template.py&old_path=/gluon/template.py&old=8d5d7f6bd391d2e30888c2c9fc168c081d02877f

Basically, instead of just copying the included templates tree into the
parent templates tree, they changed it so it would flatten the tree to text,
and just include the text into the parent tree. All contexts are lost when
the tree gets flattened.

--
Thadeus




On Thu, May 5, 2011 at 2:53 PM, kasapo  wrote:

> First off -- let me say that my usage of the templating in this case
> is somewhat peculiar, and if they are not supposed to work like this,
> that is fine.
>
> After reviewing my app, I only have one instance of code like this,
> and it is "vestigial" and should be removed anyhow. But I thought it
> strange that it broke, and I'm wondering if I might have another
> include/block problem.
>
> Solution:
>
> diff -r fe58378e989b gluon/template.py
> --- a/gluon/template.py Wed May 04 18:58:40 2011 -0500
> +++ b/gluon/template.py Thu May 05 14:46:21 2011 -0500
> @@ -454,7 +454,8 @@
>writer  = self.writer,
>delimiters = self.delimiters)
>
> -content.append(str(t.content))
> +content.append(t.content)
> +#content.append(str(t.content))
>
> def extend(self, filename):
> """
>
> Read on for how I got there and a strange LDAP_auth issue...
>
> On May 5, 1:37 pm, Massimo Di Pierro 
> wrote:
> > Hello kasapo,
> >
> > I do not completely follow you code. If I do, you have two blocks. The
> > code included in one of the blocks seems to extend a  block included
> > in another block. I am unsure this is supposed to work. Anyway, let's
> > try figure out what has changed that broke and then we may be able to
> > revert the previous behavior.
> >
>
> So I have this structure:
>
> bare (defines html, head, style, script (jquery includes), body
> sections, and some containing blocks) -- ancestor to almost all
> templates
>
> right-col (included by bare, defines blocks which base will extend --
> base extends bare, bare includes right-col so therefore base should be
> able to see blocks defined by bare)
>
> base (defines styles, background, etc -- the base template for most
> things -- defines actual markup for blocks which are DEFINED in right-
> col)
>
> page (extends base, does not use blocks -- the menu rendered on the
> page view is defined in base inside of a block that is defined in bare
> via right-col include)
> page-no-side-nav ( extends base, uses {{ block right-col }}{{end}} to
> delete the right column )
>
> > Can you try:
> >
> > hg revert -r 1488 gluon/template.py > ~/Downloads/template.diff
> >
>
> Sadly, I am on RHEL and mercurial isn't present... so I will use my
> local machine (Macintosh).
>
> First off, I use LDAP authentication for a login method, and (this
> happened on 1.95.1 on RHEL server as well) I get this error:
>
> Traceback (most recent call last):
>  File "/Users/csburreson/web2py/gluon/restricted.py", line 181, in
> restricted
>exec ccode in environment
>  File "/Users/csburreson/web2py/applications/icecube/models/
> 0_init.py", line 42, in 
>from gluon.contrib.login_methods.ldap_auth import ldap_auth
>  File "/Users/csburreson/web2py/gluon/custom_import.py", line 80, in
> _web2py__import__
>return _old__import__(name, globals, locals, fromlist, level)
>  File "/Users/csburreson/web2py/gluon/contrib/login_methods/
> ldap_auth.py", line 5, in 
>except e:
> NameError: name 'e' is not defined
>
> So I just copied the working ldap_auth.py from the 1.89 version of
> web2py... problem solved (could this somehow create an issue with
> templates?)
>
> Then I realized I did not have python-ldap installed, so I did
> easy_install python-ldap and all was good.
>
> [I did exactly these same things earlier today when installing the
> TEST server]
>
> SO, now the application is again working, and I check out my code into
> the applications folder using SVN.
>
> The menu is not present :(
>
> Then I run :
>
> hg revert -r 1488 gluon/template.py
>
> And check my app and the side menu IS present
>
> So, I go back to 1.95.1 (with the exception of the old ldap_auth.py
> from 1.89)
>
> and try
>
> hg diff -r 1488 gluon/template.py
>
> This bugger seems to be the culprit:
>
> @@ -455,7 +454,7 @@
> ...
> +content.append(str(t.content))
> -content.append(t.content)
>
>
>
> After changing it, i verified that I had not changed anything else by
> re-diffing the file against the repo:
>
> bash-3.2$ hg diff gluon/template.py
> diff -r fe58378e989b gluon/template.py
> --- a/gluon/template.py Wed May 04 18:58:40 2011 -0500
> +++ b/gluon/template.py Thu May 05 14:46:21 201

[web2py] Memory error with numpy large array

2011-05-05 Thread Kostas M
I have an application which uses the function numpy.zeros to create a
very big array (~16500 x 16500) with the command:
data = numpy.zeros( (lgos,lgos), dtype=float)
This causes a MemoryError ticket in web2py. However when I run the
same function as a python module (outside web2py) it finishes without
any problem.
Any hints?
Are there any additional memory restrictions when modules run through
web2py that I should somehow consider?


[web2py] Re: problem with {{block}}s inside included files (v.1.95.1)

2011-05-05 Thread kasapo
First off -- let me say that my usage of the templating in this case
is somewhat peculiar, and if they are not supposed to work like this,
that is fine.

After reviewing my app, I only have one instance of code like this,
and it is "vestigial" and should be removed anyhow. But I thought it
strange that it broke, and I'm wondering if I might have another
include/block problem.

Solution:

diff -r fe58378e989b gluon/template.py
--- a/gluon/template.py Wed May 04 18:58:40 2011 -0500
+++ b/gluon/template.py Thu May 05 14:46:21 2011 -0500
@@ -454,7 +454,8 @@
writer  = self.writer,
delimiters = self.delimiters)

-content.append(str(t.content))
+content.append(t.content)
+#content.append(str(t.content))

 def extend(self, filename):
 """

Read on for how I got there and a strange LDAP_auth issue...

On May 5, 1:37 pm, Massimo Di Pierro 
wrote:
> Hello kasapo,
>
> I do not completely follow you code. If I do, you have two blocks. The
> code included in one of the blocks seems to extend a  block included
> in another block. I am unsure this is supposed to work. Anyway, let's
> try figure out what has changed that broke and then we may be able to
> revert the previous behavior.
>

So I have this structure:

bare (defines html, head, style, script (jquery includes), body
sections, and some containing blocks) -- ancestor to almost all
templates

right-col (included by bare, defines blocks which base will extend --
base extends bare, bare includes right-col so therefore base should be
able to see blocks defined by bare)

base (defines styles, background, etc -- the base template for most
things -- defines actual markup for blocks which are DEFINED in right-
col)

page (extends base, does not use blocks -- the menu rendered on the
page view is defined in base inside of a block that is defined in bare
via right-col include)
page-no-side-nav ( extends base, uses {{ block right-col }}{{end}} to
delete the right column )

> Can you try:
>
> hg revert -r 1488 gluon/template.py > ~/Downloads/template.diff
>

Sadly, I am on RHEL and mercurial isn't present... so I will use my
local machine (Macintosh).

First off, I use LDAP authentication for a login method, and (this
happened on 1.95.1 on RHEL server as well) I get this error:

Traceback (most recent call last):
  File "/Users/csburreson/web2py/gluon/restricted.py", line 181, in
restricted
exec ccode in environment
  File "/Users/csburreson/web2py/applications/icecube/models/
0_init.py", line 42, in 
from gluon.contrib.login_methods.ldap_auth import ldap_auth
  File "/Users/csburreson/web2py/gluon/custom_import.py", line 80, in
_web2py__import__
return _old__import__(name, globals, locals, fromlist, level)
  File "/Users/csburreson/web2py/gluon/contrib/login_methods/
ldap_auth.py", line 5, in 
except e:
NameError: name 'e' is not defined

So I just copied the working ldap_auth.py from the 1.89 version of
web2py... problem solved (could this somehow create an issue with
templates?)

Then I realized I did not have python-ldap installed, so I did
easy_install python-ldap and all was good.

[I did exactly these same things earlier today when installing the
TEST server]

SO, now the application is again working, and I check out my code into
the applications folder using SVN.

The menu is not present :(

Then I run :

hg revert -r 1488 gluon/template.py

And check my app and the side menu IS present

So, I go back to 1.95.1 (with the exception of the old ldap_auth.py
from 1.89)

and try

hg diff -r 1488 gluon/template.py

This bugger seems to be the culprit:

@@ -455,7 +454,7 @@
...
+content.append(str(t.content))
-content.append(t.content)



After changing it, i verified that I had not changed anything else by
re-diffing the file against the repo:

bash-3.2$ hg diff gluon/template.py
diff -r fe58378e989b gluon/template.py
--- a/gluon/template.py Wed May 04 18:58:40 2011 -0500
+++ b/gluon/template.py Thu May 05 14:46:21 2011 -0500
@@ -454,7 +454,8 @@
writer  = self.writer,
delimiters = self.delimiters)

-content.append(str(t.content))
+content.append(t.content)
+#content.append(str(t.content))

 def extend(self, filename):
 """


So, that seems to be the problem.

Is there a case where not explicitly calling str() on the content
causes something else undesirable to happen?

Well, thanks very much Massimo, mystery solved. I'll leave it to you
whether this is actually an issue that should be patched or an
unnecessary mis-use of templates and {{block}}s

I plan to remove the include of right-col since in the end I really
don't need it.

-Kasapo


> Dow it work?
>
> If yes, download the latest web2py again and do
>
> hg diff -r 1488 gluon/template.py > ~/Downloads/template.diff
>
> you will see what has changed in the file. mostly comments.
> Try manually revert each of t

[web2py] Re: Problem connecting to mysql DB

2011-05-05 Thread Massimo Di Pierro
You should upgrade. That version is more than one year old. That
problem has been fixed.

Massimo

On May 5, 2:43 pm, dsa42  wrote:
> I think it's 1.76.5
>
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2010
> Version 1.76.5 (2010-03-11 15:19:08)
> Database drivers available: SQLite3
>
> I also think that the probley is that Ubuntu 10.04 installed pythin
> 2.6.  Somehow, that installation ruined the MySQLdb module for python
> 2.6.  I can't even "inport MySQLdb" in either python 2.5 or 2.6, so
> I'm working on solving that first.
>
> On May 5, 1:16 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > Which web2py version? the latest web2py should be using pymysql and
> > not mysqldb.
>
> > On May 5, 11:41 am, dsa42  wrote:
>
> > > I am a noob to web2py.  I am working on a previously installed system
> > > at a client site (not installed by me).
>
> > > I upgraded the system from Ubuntu server 9.10 (karmic) to 10.04
> > > (lucid).  After reboot, I'm getting the following traceback from the
> > > web2py server:
>
> > > Error traceback
>
> > > 1.Traceback (most recent call last):
> > > 2.  File "/web2py/web2py/gluon/restricted.py", line 173, in restricted
> > > 3.       exec ccode in environment
> > > 4.  File "/web2py/web2py/applications/MyAppName/models/db.py", line 9,
> > > in 
> > > 5.    db = DAL('mysql://user:password@localhost/DBname')
> > > 6.  File "/web2py/web2py/gluon/sql.py", line 3783, in DAL
> > > 7.    db_codec=db_codec, check_reserved=check_reserved)
> > > 8.  File "/web2py/web2py/gluon/sql.py", line 919, in __init__
> > > 9.    self._pool_connection(lambda : MySQLdb.Connection(
> > > 10.  File "/web2py/web2py/gluon/sql.py", line 829, in _pool_connection
> > > 11.    self._connection = f()
> > > 12.  File "/web2py/web2py/gluon/sql.py", line 919, in 
> > > 13.    self._pool_connection(lambda : MySQLdb.Connection(
> > > 14.NameError: global name 'MySQLdb' is not defined
> > > 15.
>
> > > The mysql daemon is running.  The username, password, and DBname are
> > > correct.  Any ideas on where to look?


[web2py] Re: Confusion using experts4solutions

2011-05-05 Thread Massimo Di Pierro
I agree this Plumo.

"I want a facebook clone or other web site targeted to community XYZ"
is not an idea worth any money.
The ideas worth money are those that translate directly into code that
you would not know how to write yourself.
We all have good ideas that do not carry on because have no time.
There are lots of people out there that are great salespeople (and
there is lots of value in that) but it is them who should work for you
(you who make a product), not you for them. If selling and making
money becomes more important than the quality of the product, the
product sucks and you lose interest.

I have been there. I suggest:

1) attach a price to any work done by any party
2) agree to percentages of ownership
3) agree on partial deadlines and figure out who owns what (time or
money) to the company
4) put the money into a bank account even if unused.
5) Agree on conditions for getting out at any time without or without
default.
6) As a developer, make sure that if things do not work out at least
you do not lose ownership of your work.
7) If it does not work because the other party did not put the money
due in, they still owe you money if you did your part.
8) Having connections is an asset if your are looking for a job, does
not help you much if you hope to sell a product to those
"connections". If the product is good, people you do know know are
more likely to buy from you than your closest friends and colleagues.

On May 3, 6:14 pm, Plumo  wrote:
> $0.02 ...
>
> Be wary of taking a percentage of profit as payment.
> This can mean the other guy doesn't need to invest anything - neither time
> nor money. Ideas are cheap.
> So there is no risk for them, but there is a high risk that you will never
> get paid since most web apps go no where.
> If they really believe in their idea they should be willing to invest some
> money upfront.


[web2py] Re: Problem connecting to mysql DB

2011-05-05 Thread dsa42
I think it's 1.76.5

web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2010
Version 1.76.5 (2010-03-11 15:19:08)
Database drivers available: SQLite3

I also think that the probley is that Ubuntu 10.04 installed pythin
2.6.  Somehow, that installation ruined the MySQLdb module for python
2.6.  I can't even "inport MySQLdb" in either python 2.5 or 2.6, so
I'm working on solving that first.


On May 5, 1:16 pm, Massimo Di Pierro 
wrote:
> Which web2py version? the latest web2py should be using pymysql and
> not mysqldb.
>
> On May 5, 11:41 am, dsa42  wrote:
>
>
>
>
>
>
>
> > I am a noob to web2py.  I am working on a previously installed system
> > at a client site (not installed by me).
>
> > I upgraded the system from Ubuntu server 9.10 (karmic) to 10.04
> > (lucid).  After reboot, I'm getting the following traceback from the
> > web2py server:
>
> > Error traceback
>
> > 1.Traceback (most recent call last):
> > 2.  File "/web2py/web2py/gluon/restricted.py", line 173, in restricted
> > 3.       exec ccode in environment
> > 4.  File "/web2py/web2py/applications/MyAppName/models/db.py", line 9,
> > in 
> > 5.    db = DAL('mysql://user:password@localhost/DBname')
> > 6.  File "/web2py/web2py/gluon/sql.py", line 3783, in DAL
> > 7.    db_codec=db_codec, check_reserved=check_reserved)
> > 8.  File "/web2py/web2py/gluon/sql.py", line 919, in __init__
> > 9.    self._pool_connection(lambda : MySQLdb.Connection(
> > 10.  File "/web2py/web2py/gluon/sql.py", line 829, in _pool_connection
> > 11.    self._connection = f()
> > 12.  File "/web2py/web2py/gluon/sql.py", line 919, in 
> > 13.    self._pool_connection(lambda : MySQLdb.Connection(
> > 14.NameError: global name 'MySQLdb' is not defined
> > 15.
>
> > The mysql daemon is running.  The username, password, and DBname are
> > correct.  Any ideas on where to look?


Re: [web2py] Re: Confusion using experts4solutions

2011-05-05 Thread Jason Brower

I too have been contacted through it.  No money yet, but I do get contacts.
On 05/03/2011 09:39 PM, Massimo Di Pierro wrote:

I did not know Ross (or I did not remember). That means there are even
more people doing experts4solution work than I thought.

Massimo

On May 3, 12:39 pm, Ross Peoples  wrote:

Experts4solutions has hooked me up with someone nearby looking to do a long
term job which plans to sell a web2py app as an appliance. Instead of
getting paid up front or by the hour, I chose to take a percentage of
profits, since it's just me and the other person working on it. I can only
devote 10 to 20 hours a week to it, as I have a day job, but if jobs keep
coming down the pipeline, I could actually make a career out of web2py.

Jim or Steve, if you have any small jobs that only take a few hours to do,
I'd be happy to take a look. As I said, most of my time is spent at my day
job or working on a big project during the weekend, but if there's some
small things that I can work on during the week after work to make some
extra cash, I would be very interested. Feel free to email me.

Ross




Re: [web2py] Re: problem with {{block}}s inside included files (v.1.95.1)

2011-05-05 Thread Thadeus Burgess
It should be possible to do this. The way templates handle include files has
been broken. This is what it should be doing

PARENT
LOAD include_filename
CREATE PARSE TREE
EXTEND PARSE TREE TO PARENT
CONTINUE

In effect, the entire tree of the included file gets grafted back onto the
parent tree as if the included file never existed.

tl;dr; Should work just fine, somethings broke, plz help fix!

--
Thadeus




On Thu, May 5, 2011 at 1:37 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> uded in one of the blocks seems to extend a  block included
> in another block. I am unsure this is suppo
>


Re: [web2py] spam in this list

2011-05-05 Thread Ovidio Marinho
eh good to check the domain of blacklisted domains.
http://www.blacklistalert.org/
 
Ovidio Marinho Falcao Neto
 ovidio...@gmail.com
 88269088
   Paraiba-Brasil



2011/5/5 Massimo Di Pierro 

> Almost all of the spam emails I have to block on this list include a
> link to the same web site
>
> http://[somenumber]maza.com
>
> what can we do? I can continue to block these emails one my one but
> perhaps you have a better suggestion?
>
> Massimo


[web2py] Re: problem with {{block}}s inside included files (v.1.95.1)

2011-05-05 Thread Massimo Di Pierro
Hello kasapo,


I do not completely follow you code. If I do, you have two blocks. The
code included in one of the blocks seems to extend a  block included
in another block. I am unsure this is supposed to work. Anyway, let's
try figure out what has changed that broke and then we may be able to
revert the previous behavior.

Can you try:

hg revert -r 1488 gluon/template.py > ~/Downloads/template.diff

Dow it work?

If yes, download the latest web2py again and do

hg diff -r 1488 gluon/template.py > ~/Downloads/template.diff

you will see what has changed in the file. mostly comments.
Try manually revert each of the changes. Which ones causes the
problem?


On May 5, 11:55 am, kasapo  wrote:
> Hi all,
>
> I recently setup another instance of web2py for testing on a new
> system, and noticed something strange with blocks.
>
> Basically, I have three slightly different versions of web2py running:
> 1.89.3 (DEMO server), 1.91.6 (DEV server) and 1.95.1 which I just
> installed with the auto-upgrade feature (TEST server -- soon to be the
> Production server).
>
> The problem is, i have an include directive inside of a block/end
> block pair. The included file (right-col.html) then goes on to define
> a couple other blocks (for navigation mainly) which are filled in by
> different templates associated with different areas of the site.
>
> However, templates which extend the file which includes right-col.html
> do not have access to BLOCKs that are defined INSIDE of right-
> col.html, but this behavior occurs only on the TEST server (v1.95.1)
>
> This code WORKED before 1.95.1 (on DEMO and DEV):
>
> #
> # views/bare.html
> #
> 
>  ... (abbreviated for brevity's sake)
>      
>      {{ block content }}{{ end }}
>      
>
>       {{ block right-col }}
>            {{ include 'base/right-col.html' }}
>       {{ end }}
>
> ...
> 
> #EOF bare.html
>
> ###
> # views/base/right-col.html
> ###
> 
>    {{ block nav }}
>    {{ end }}
>
>    
>    {{ block social }}{{end}}
>    
>
> 
> #EOF
>
> #
> # views/base.html
> #
> {{ extends 'bare.html }}
>
> {{ block content }}
>     {{ include }}
> {{ end }}
>
> 
> {{ block nav }}
>     
>     {{=MENU(get_menu(request.controller) or standard_menu)}}
>     
> {{ end }}
>
> {{ block social }}
>    ... stuff to do with social networking
> {{ end }}
> #EOF
>
> 
> # view/some-page.html
> 
> {{ extends 'base.html' }}
>
> Blah blah blah. Wait, my side menu is missing. Crap.
>
> But the outline of the sidebar is still there since div#right-col is
> present
>
> #EOF
>
> What I had to do to get it to work with the TEST version was to take
> away the include statement for right-col.html and move the contents of
> the file inside the right-col block in bare.html. This works fine.
>
>  The strange thing is that the  id='social'> (the markup in right-col.html) shows up
> -- even if I wrap it in a block within the included file. The problem
> is just that the template blocks defined in the right-col.html file
> seem to be forgotten later on in the template. So even though
> bare.html includes right-col, the base file, which extends bare,
> cannot access the blocks defined in the right-col file. Thus, when
> rendering "some-page" which extends "base", the contents of the right
> column aren't included.
>
> So, the question:
>
> Is my usage of blocks improper? Or is this an undesired outcome of
> code updates?
>
> I just checked the code.google.com page and did not see any issues,
> open or closed, that mentioned anything about this.
>
> Thanks,
> Faithful web2py user
>
> PS:
>
> I think the reason I did this was to be able to reuse HTML chunks
> which might be included in different places on the page, or even among
> different templates from the site (e.g. bare.html is the ancestor of
> most public pages, but user.html is the ancestor of another, and both
> should be able to use right-col.html).
>
> Also, I would love to see the include directive supported within for
> loops, though I think I see why it is not. I think the include
> directives are always handled first and the file is included before
> the template is parsed, thus template variables are not available and
> loops cannot be iterated. Oh well.


Re: [web2py] spam in this list

2011-05-05 Thread Jonathan Lundell
On May 5, 2011, at 11:11 AM, Massimo Di Pierro wrote:
> 
> Almost all of the spam emails I have to block on this list include a
> link to the same web site
> 
> http://[somenumber]maza.com
> 
> what can we do? I can continue to block these emails one my one but
> perhaps you have a better suggestion?

I expect that once enough of them get marked as spam, Google will start 
blocking them.

[web2py] Re: Problem connecting to mysql DB

2011-05-05 Thread Massimo Di Pierro
Which web2py version? the latest web2py should be using pymysql and
not mysqldb.

On May 5, 11:41 am, dsa42  wrote:
> I am a noob to web2py.  I am working on a previously installed system
> at a client site (not installed by me).
>
> I upgraded the system from Ubuntu server 9.10 (karmic) to 10.04
> (lucid).  After reboot, I'm getting the following traceback from the
> web2py server:
>
> Error traceback
>
> 1.Traceback (most recent call last):
> 2.  File "/web2py/web2py/gluon/restricted.py", line 173, in restricted
> 3.       exec ccode in environment
> 4.  File "/web2py/web2py/applications/MyAppName/models/db.py", line 9,
> in 
> 5.    db = DAL('mysql://user:password@localhost/DBname')
> 6.  File "/web2py/web2py/gluon/sql.py", line 3783, in DAL
> 7.    db_codec=db_codec, check_reserved=check_reserved)
> 8.  File "/web2py/web2py/gluon/sql.py", line 919, in __init__
> 9.    self._pool_connection(lambda : MySQLdb.Connection(
> 10.  File "/web2py/web2py/gluon/sql.py", line 829, in _pool_connection
> 11.    self._connection = f()
> 12.  File "/web2py/web2py/gluon/sql.py", line 919, in 
> 13.    self._pool_connection(lambda : MySQLdb.Connection(
> 14.NameError: global name 'MySQLdb' is not defined
> 15.
>
> The mysql daemon is running.  The username, password, and DBname are
> correct.  Any ideas on where to look?


[web2py] spam in this list

2011-05-05 Thread Massimo Di Pierro
Almost all of the spam emails I have to block on this list include a
link to the same web site

http://[somenumber]maza.com

what can we do? I can continue to block these emails one my one but
perhaps you have a better suggestion?

Massimo


[web2py] Problem connecting to mysql DB

2011-05-05 Thread dsa42
I am a noob to web2py.  I am working on a previously installed system
at a client site (not installed by me).

I upgraded the system from Ubuntu server 9.10 (karmic) to 10.04
(lucid).  After reboot, I'm getting the following traceback from the
web2py server:


Error traceback

1.Traceback (most recent call last):
2.  File "/web2py/web2py/gluon/restricted.py", line 173, in restricted
3.   exec ccode in environment
4.  File "/web2py/web2py/applications/MyAppName/models/db.py", line 9,
in 
5.db = DAL('mysql://user:password@localhost/DBname')
6.  File "/web2py/web2py/gluon/sql.py", line 3783, in DAL
7.db_codec=db_codec, check_reserved=check_reserved)
8.  File "/web2py/web2py/gluon/sql.py", line 919, in __init__
9.self._pool_connection(lambda : MySQLdb.Connection(
10.  File "/web2py/web2py/gluon/sql.py", line 829, in _pool_connection
11.self._connection = f()
12.  File "/web2py/web2py/gluon/sql.py", line 919, in 
13.self._pool_connection(lambda : MySQLdb.Connection(
14.NameError: global name 'MySQLdb' is not defined
15.


The mysql daemon is running.  The username, password, and DBname are
correct.  Any ideas on where to look?


[web2py] problem with {{block}}s inside included files (v.1.95.1)

2011-05-05 Thread kasapo
Hi all,

I recently setup another instance of web2py for testing on a new
system, and noticed something strange with blocks.

Basically, I have three slightly different versions of web2py running:
1.89.3 (DEMO server), 1.91.6 (DEV server) and 1.95.1 which I just
installed with the auto-upgrade feature (TEST server -- soon to be the
Production server).

The problem is, i have an include directive inside of a block/end
block pair. The included file (right-col.html) then goes on to define
a couple other blocks (for navigation mainly) which are filled in by
different templates associated with different areas of the site.

However, templates which extend the file which includes right-col.html
do not have access to BLOCKs that are defined INSIDE of right-
col.html, but this behavior occurs only on the TEST server (v1.95.1)

This code WORKED before 1.95.1 (on DEMO and DEV):

#
# views/bare.html
#

 ... (abbreviated for brevity's sake)
 
 {{ block content }}{{ end }}
 

  {{ block right-col }}
   {{ include 'base/right-col.html' }}
  {{ end }}

...

#EOF bare.html

###
# views/base/right-col.html
###

   {{ block nav }}
   {{ end }}

   
   {{ block social }}{{end}}
   


#EOF

#
# views/base.html
#
{{ extends 'bare.html }}

{{ block content }}
{{ include }}
{{ end }}


{{ block nav }}

{{=MENU(get_menu(request.controller) or standard_menu)}}

{{ end }}

{{ block social }}
   ... stuff to do with social networking
{{ end }}
#EOF


# view/some-page.html

{{ extends 'base.html' }}

Blah blah blah. Wait, my side menu is missing. Crap.

But the outline of the sidebar is still there since div#right-col is
present

#EOF


What I had to do to get it to work with the TEST version was to take
away the include statement for right-col.html and move the contents of
the file inside the right-col block in bare.html. This works fine.

 The strange thing is that the  (the markup in right-col.html) shows up
-- even if I wrap it in a block within the included file. The problem
is just that the template blocks defined in the right-col.html file
seem to be forgotten later on in the template. So even though
bare.html includes right-col, the base file, which extends bare,
cannot access the blocks defined in the right-col file. Thus, when
rendering "some-page" which extends "base", the contents of the right
column aren't included.


So, the question:

Is my usage of blocks improper? Or is this an undesired outcome of
code updates?

I just checked the code.google.com page and did not see any issues,
open or closed, that mentioned anything about this.

Thanks,
Faithful web2py user

PS:

I think the reason I did this was to be able to reuse HTML chunks
which might be included in different places on the page, or even among
different templates from the site (e.g. bare.html is the ancestor of
most public pages, but user.html is the ancestor of another, and both
should be able to use right-col.html).

Also, I would love to see the include directive supported within for
loops, though I think I see why it is not. I think the include
directives are always handled first and the file is included before
the template is parsed, thus template variables are not available and
loops cannot be iterated. Oh well.



[web2py] Re: Computed fields from multiple tables

2011-05-05 Thread villas
Hi Happy Rob,

If you want this to be flexible,  I guess you would need something
more like this:

entrants: id, name
exams: id, descr
exam_entry: exam_id, entrant_id, total_scrore
questions: id, exam_id, question_num, question_text
options: id, question_id, option_text, score
answers: id, exam_entry_id, option_id

It is important to try not to compromise on your data structure. It
may be more difficult to display the forms and process them,  but
usually you win in the long run by 'normalising' your data as much as
possible.

Best wishes,  D

On May 4, 12:44 pm, Happy Rob  wrote:
> Computed fields from multiple columns
> I'm new to programming and have a question
> How can I make a computed field that adds up from another table
> depending on the contents of the first table?
> eg A multi choice exam has the results entered by formfactory.
> The answers and their scores are stored in a separate table
>
> db
> table:answers
> answers.question,       answers.answer, answers.score
> 1. 3rd planet,          a. mars,                        0
> 1. 3rd planet,          b. Earth,                       10
> 1. 3rd planet,          c. Pluto,                       0
> 2. Best movie,          a. Toy Story 3,         5
> 2. Best movie,          b. Casablanka,          10
> 3. Best movie,          c. Twilight,                    -1000
>
> db
> table:exam
> exam.id exam.name       exam.score      exam.question01 exam.question02
> 1               Fred  Smith     20                      b. Earth              
>           b.Casablanka
> 2               Sarah Smith     15                      b. Earth              
>           a.Toy Story 3
>
> As can be seen, the exam score is the sum of the answer scores given.
>
> My difficulty is in the model...
>
> m = DAL ('sqlite://storage.sqlite')
> from gluon.tools import *
> crud = Crud(globals(),m)
> m.define_table('answers',
> Field('question'),
> Field('answer'),
> Field('score',int))
>
> m.define_table('exam',
> Field('name'),
>
> Field('score',compute=lambda
> r:m(m.answers.answer==r.question01).select()[0].score
>
> +m(m.answers.answer==r.question02).select()[0].score),
> Field('question01'),
> Field('question02'))
>
> It reads the score quite well if checking only one question, but if
> adding both, it returns None.
> How could I modify it to add up from multiple questions?
> You help is greatly appreciated.


Re: [web2py] Skytoop : a web desktop like, created with Web2Py on server side

2011-05-05 Thread danto
2011/5/4 Syed Mushtaq :
> Looks really beautiful :) Are you planning on open-sourcing it ?
>
> Thanks
> -Syed
>
> On Wed, May 4, 2011 at 11:37 AM, Jason (spot) Brower 
> wrote:
>>
>> It would be fun to put a widget for online radio.
>> > src='http://www.shoutcast.com/media/popupPlayer_V19.swf?stationid=http://yp.shoutcast.com/sbin/tunein-station.pls?id=1628913&play_status=1'
>> quality='high' bgcolor='#ff' width='398' height='104'
>> name='popupPlayer_V19' align='middle' allowScriptAccess='always'
>> allowFullScreen='true' type='application/x-shockwave-flash'
>> pluginspage='http://www.adobe.com/go/getflashplayer' >
>> Like that. :D  It's the station I listen to.
>> BR,
>> Jason Brower
>>
>> On Mon, May 2, 2011 at 8:08 PM, Jason Brower  wrote:
>>>
>>> On 05/02/2011 07:13 PM, Alexandre Strzelewicz wrote:

 I have the pleasure to present you Skytoop,

 http://www.skytoop.com/

 If someone have tips or feedback to give me it coould be nice !
>>>
>>> Throw this in and you got your self a desktop!
>>>
>>> http://www.webupd8.org/2011/03/gtk-32-will-let-you-run-any-application.html
>>>  :D Great work!
>>> BR,
>>> Jason Brower
>>
>
>


++1, if you are planning to release it don't forget to use a good
license to protect your work, I would strongly recommend The GNU
Affero General Public License 


Re: [web2py] Re: can anyone guess what's wrong with this?

2011-05-05 Thread Anthony
On Thursday, May 5, 2011 11:05:53 AM UTC-4, rochacbruno wrote: 
>
> Should have a 'quick tips and advices' section on the book for this kind of 
> stuff. May be a blockquote on DAL chapter. Too much information that get 
> lost in google group.
>
> Need to be documented as soon we catch this.
>
I'm on it. :-)
 
Anthony
 


Re: [web2py] Re: can anyone guess what's wrong with this?

2011-05-05 Thread Bruno Rocha
Should have a 'quick tips and advices' section on the book for this kind of
stuff. May be a blockquote on DAL chapter. Too much information that get
lost in google group.

Need to be documented as soon we catch this.
Em 05/05/2011 11:17, "Massimo Di Pierro" 
escreveu:
> good catch. Actually the safest thing is
>
> default=lambda:str(uuid.uuid4())
>
> since uuid4() returns an object, not a string.
>
>
> On May 5, 9:10 am, Anthony  wrote:
>> Also, you might want default=uuid.uuid4 instead of default=uuid.uuid4().
I
>> believe the former will call the uuid4 function separately for every
record
>> inserted (probably what you want), whereas the latter will generate a
single
>> unique uuid only once per call to db.define_table (which presumably may
>> endure for more than one record insert, depending on what your code
does).
>>
>> Anthony
>>
>>
>>
>>
>>
>>
>>
>> On Wednesday, May 4, 2011 11:49:42 PM UTC-4, mart wrote:
>> > Hi,
>>
>> > I think I may have been looking at this too long... its giving the
>> > following error, and I can't see why...
>> > (using DAL in script)
>>
>> > Thanks in advance,
>> > Mart :)
>>
>> > db.define_table('mail',
>> > Field('uuid',length=64,default=uuid.uuid4()),
>> > Field('recipients','list:string'),Field('From'),
>> > Field('password'),Field('smtp_server'),Field('smtp_port'))
>> > db.commit()
>>
>> > Traceback (most recent call last):
>> >   File "/Users/mart/Applications/Aptana Studio 2.0/plugins/
>> > org.python.pydev.debug_1.6.5.2011020317/pysrc/pydevd.py", line 1133,
>> > in 
>> > debugger.run(setup['file'], None, None)
>> >   File "/Users/mart/Applications/Aptana Studio 2.0/plugins/
>> > org.python.pydev.debug_1.6.5.2011020317/pysrc/pydevd.py", line 918, in
>> > run
>> > execfile(file, globals, locals) #execute the script
>> >   File "/Users/mart/aptanaApps/src/_purple.py", line 524, in 
>> > dbBlueObj.defineTables()
>> >   File "/Users/mart/aptanaApps/src/blueLite/db_storage/db_blue.py",
>> > line 278, in defineTables
>> > Field('password'),Field('smtp_server'),Field('smtp_port'))
>> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
>> > dal.py", line 4028, in define_table
>> > polymodel=polymodel)
>> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
>> > dal.py", line 590, in create_table
>> > self.create_sequence_and_triggers(query,table)
>> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
>> > dal.py", line 1142, in create_sequence_and_triggers
>> > self.execute(query)
>> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
>> > dal.py", line 1152, in execute
>> > return self.log_execute(*a, **b)
>> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
>> > dal.py", line 1147, in log_execute
>> > ret = self.cursor.execute(*a,**b)
>> > sqlite3.OperationalError: near "From": syntax error


[web2py] Re: Very Soft Pre-Alpha Launch: Pricetack ecommerce service

2011-05-05 Thread Anthony
Very nice. Congratulations. Just added it to http://web2py.com/poweredby.
 
Anthony


[web2py] Re: can anyone guess what's wrong with this?

2011-05-05 Thread Massimo Di Pierro
good catch. Actually the safest thing is

default=lambda:str(uuid.uuid4())

since uuid4() returns an object, not a string.


On May 5, 9:10 am, Anthony  wrote:
> Also, you might want default=uuid.uuid4 instead of default=uuid.uuid4(). I
> believe the former will call the uuid4 function separately for every record
> inserted (probably what you want), whereas the latter will generate a single
> unique uuid only once per call to db.define_table (which presumably may
> endure for more than one record insert, depending on what your code does).
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, May 4, 2011 11:49:42 PM UTC-4, mart wrote:
> > Hi,
>
> > I think I may have been looking at this too long... its giving the
> > following error, and I can't see why...
> > (using DAL in script)
>
> > Thanks in advance,
> > Mart :)
>
> >         db.define_table('mail',
> >             Field('uuid',length=64,default=uuid.uuid4()),
> >             Field('recipients','list:string'),Field('From'),
> >             Field('password'),Field('smtp_server'),Field('smtp_port'))
> >         db.commit()
>
> > Traceback (most recent call last):
> >   File "/Users/mart/Applications/Aptana Studio 2.0/plugins/
> > org.python.pydev.debug_1.6.5.2011020317/pysrc/pydevd.py", line 1133,
> > in 
> >     debugger.run(setup['file'], None, None)
> >   File "/Users/mart/Applications/Aptana Studio 2.0/plugins/
> > org.python.pydev.debug_1.6.5.2011020317/pysrc/pydevd.py", line 918, in
> > run
> >     execfile(file, globals, locals) #execute the script
> >   File "/Users/mart/aptanaApps/src/_purple.py", line 524, in 
> >     dbBlueObj.defineTables()
> >   File "/Users/mart/aptanaApps/src/blueLite/db_storage/db_blue.py",
> > line 278, in defineTables
> >     Field('password'),Field('smtp_server'),Field('smtp_port'))
> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
> > dal.py", line 4028, in define_table
> >     polymodel=polymodel)
> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
> > dal.py", line 590, in create_table
> >     self.create_sequence_and_triggers(query,table)
> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
> > dal.py", line 1142, in create_sequence_and_triggers
> >     self.execute(query)
> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
> > dal.py", line 1152, in execute
> >     return self.log_execute(*a, **b)
> >   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/
> > dal.py", line 1147, in log_execute
> >     ret = self.cursor.execute(*a,**b)
> > sqlite3.OperationalError: near "From": syntax error


[web2py] Re: can anyone guess what's wrong with this?

2011-05-05 Thread Anthony
Also, you might want default=uuid.uuid4 instead of default=uuid.uuid4(). I 
believe the former will call the uuid4 function separately for every record 
inserted (probably what you want), whereas the latter will generate a single 
unique uuid only once per call to db.define_table (which presumably may 
endure for more than one record insert, depending on what your code does).
 
Anthony
 
On Wednesday, May 4, 2011 11:49:42 PM UTC-4, mart wrote:

> Hi, 
>
> I think I may have been looking at this too long... its giving the 
> following error, and I can't see why... 
> (using DAL in script) 
>
> Thanks in advance, 
> Mart :) 
>
>
> db.define_table('mail', 
> Field('uuid',length=64,default=uuid.uuid4()), 
> Field('recipients','list:string'),Field('From'), 
> Field('password'),Field('smtp_server'),Field('smtp_port')) 
> db.commit() 
>
>
> Traceback (most recent call last): 
>   File "/Users/mart/Applications/Aptana Studio 2.0/plugins/ 
> org.python.pydev.debug_1.6.5.2011020317/pysrc/pydevd.py", line 1133, 
> in  
> debugger.run(setup['file'], None, None) 
>   File "/Users/mart/Applications/Aptana Studio 2.0/plugins/ 
> org.python.pydev.debug_1.6.5.2011020317/pysrc/pydevd.py", line 918, in 
> run 
> execfile(file, globals, locals) #execute the script 
>   File "/Users/mart/aptanaApps/src/_purple.py", line 524, in  
> dbBlueObj.defineTables() 
>   File "/Users/mart/aptanaApps/src/blueLite/db_storage/db_blue.py", 
> line 278, in defineTables 
> Field('password'),Field('smtp_server'),Field('smtp_port')) 
>   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/ 
> dal.py", line 4028, in define_table 
> polymodel=polymodel) 
>   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/ 
> dal.py", line 590, in create_table 
> self.create_sequence_and_triggers(query,table) 
>   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/ 
> dal.py", line 1142, in create_sequence_and_triggers 
> self.execute(query) 
>   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/ 
> dal.py", line 1152, in execute 
> return self.log_execute(*a, **b) 
>   File "/Users/mart/aptanaApps/src/blueLite/pyUtils/sql/web2py/ 
> dal.py", line 1147, in log_execute 
> ret = self.cursor.execute(*a,**b) 
> sqlite3.OperationalError: near "From": syntax error 
>


[web2py] Re: validator for self-join

2011-05-05 Thread Massimo Di Pierro
You will need your own. It may be easier to use the onvalidate
attribute of the crud.update/crud.create forms

On May 5, 8:29 am, Dave  wrote:
> I'm using a self join on one of my data tables, and need a validator
> that makes sure a record isn't joined to itself.   I also need to
> combine it with 2 other validators, IS_NULL_OR and IS_IN_DB.
> currently it looks like this:
>
> db.mytable.myfield.requires=IS_NULL_OR(IS_IN_DB(db,'mytable.id'))
>
> but i need to add one more check to make sure mytable.myfield does not
> equal mytable.id.  Is there something like this available or do i need
> to create a custom validator?
>
> Thanks,
> DR


[web2py] validator for self-join

2011-05-05 Thread Dave
I'm using a self join on one of my data tables, and need a validator
that makes sure a record isn't joined to itself.   I also need to
combine it with 2 other validators, IS_NULL_OR and IS_IN_DB.
currently it looks like this:

db.mytable.myfield.requires=IS_NULL_OR(IS_IN_DB(db,'mytable.id'))

but i need to add one more check to make sure mytable.myfield does not
equal mytable.id.  Is there something like this available or do i need
to create a custom validator?

Thanks,
DR


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Ross Peoples
Thanks for clearing that up. I'll start rewriting my modules and let you 
know how it all turns out.

[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Massimo Di Pierro
Almost. You cannot do do this:

self.env = Storage(globals())
self.cache = self.env.cache
self.request = self.env.request
self.response = self.env.response
self.db = self.env.db
self.obj1 = self.env.obj1
self.obj2 = self.env.obj2


but you can do

current.db = db
current.obj1=obj1
current.obj2=obj2
...
(in model)

and


self.cache =current.cache
self.request = current.request
self.response = current.response
self.db = current.db
self.obj1 = current.obj1
self.obj2 = current.obj2
(in module)

I would still pass db,obj1 and obj2 explicitly and try avoid circular
references as possible (they increate time for garbage collection).


On May 5, 8:10 am, Ross Peoples  wrote:
> I work a lot with modules, so I have a question. I have a
> 'z_import_modules.py' model that would look something like this:
>
> DEBUG = True
> module1 = local_import('module1', reload=DEBUG)
> module2 = local_import('module2', reload=DEBUG)
> module3 = local_import('module3', reload=DEBUG)
>
> obj1 = module1.Object1(globals(), db)
> obj2 = module2.Object2(globals(), db)
> obj3 = module3.Object3(globals(), db, obj1, obj2)
> # obj3 is dependent on obj1 and obj2 instances
>
> And my Object3 class' init method might look like this:
>    def __init__(self, environment, db, obj1, obj2):
>         self.env = Storage(environment)
>         self.cache = self.env.cache
>         self.request = self.env.request
>         self.response = self.env.response
>         self.db = db
>         self.obj1 = obj1
>         self.obj2 = obj2
>
> With the new changes in the trunk, would I be able to rewrite my
> 'z_import_modules.py' model to this?
>
> from module1 import Object1
> from module2 import Object2
> from module3 import Object3
>
> obj1 = Object1()
> obj1 = Object1()
>
> And would I be able to rewrite Object3's init method to something like this:
>     def __init__(self):
>         # assuming from gluon import *
>         self.env = Storage(globals())
>         self.cache = self.env.cache
>         self.request = self.env.request
>         self.response = self.env.response
>         self.db = self.env.db
>         self.obj1 = self.env.obj1
>         self.obj2 = self.env.obj2
>
> Is this what you mean by "only need to do "from gluon import *" to see
> everything web2py has to offer"?


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Ross Peoples
I made a typo in my second 'z_import_modules.py' model:

obj1 = Object1()
obj1 = Object1()

Should be:

obj1 = Object1()
obj2 = Object2()
obj3 = Object3()

Sorry about that.


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Ross Peoples
I work a lot with modules, so I have a question. I have a 
'z_import_modules.py' model that would look something like this:

DEBUG = True
module1 = local_import('module1', reload=DEBUG)
module2 = local_import('module2', reload=DEBUG)
module3 = local_import('module3', reload=DEBUG)

obj1 = module1.Object1(globals(), db)
obj2 = module2.Object2(globals(), db)
obj3 = module3.Object3(globals(), db, obj1, obj2)
# obj3 is dependent on obj1 and obj2 instances

And my Object3 class' init method might look like this:
   def __init__(self, environment, db, obj1, obj2):
self.env = Storage(environment)
self.cache = self.env.cache
self.request = self.env.request
self.response = self.env.response
self.db = db
self.obj1 = obj1
self.obj2 = obj2

With the new changes in the trunk, would I be able to rewrite my 
'z_import_modules.py' model to this?

from module1 import Object1
from module2 import Object2
from module3 import Object3

obj1 = Object1()
obj1 = Object1()

And would I be able to rewrite Object3's init method to something like this:
def __init__(self):
# assuming from gluon import *
self.env = Storage(globals())
self.cache = self.env.cache
self.request = self.env.request
self.response = self.env.response
self.db = self.env.db
self.obj1 = self.env.obj1
self.obj2 = self.env.obj2

Is this what you mean by "only need to do "from gluon import *" to see 
everything web2py has to offer"?


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread carlo
what a great work!

I just want to thank all developers for this wonderful framework which
is improving weekly: I can not understand why big media publishers are
still ignoring web2py and not aware about its growing user base.

carlo

On May 4, 11:09 pm, Massimo Di Pierro  wrote:
> Hello everybody
>
> Jonathan and I have been working on an internal web2py rewrite that while 
> keeping everything backward compatible will allow you to do this
>
>  modules/mymodule.py
> from gluon import *
> def f(): return DIV(A(current.request.function,_href=URL()))
>  end
>
>  default/controller.py
> def index():
>     from mymodule import f
>     return dict(div=f())
>  end
>
> Thanks to Pierre we can now import modules from the app local folder without 
> local_import and thanks to Jonathan those modules only need to do "from gluon 
> import *" to see everything web2py has to offer. This should make life easier 
> for Eclipse users too.
>
> In models/db.py you no longer need to pass globals() to Auth
>
>    auth=Auth(globals(),db)
> or
>    auth=Auth(db)
>
> both work.
>
> Also error messages in validators (including default error messages) should 
> not be by T(...) by default.
>
> This is now in trunk but we are still working on it. This means trunk may not 
> very stable for the next day or two.
> Meanwhile help us test it. In particular help us test if we are breaking your 
> apps.
>
> Massimo


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Massimo Di Pierro
Not really. These changes made the code simpler and shorter.

On May 5, 6:53 am, Stodge  wrote:
> This should make it more attractive to a wider audience, especially as
> web2py has a decent feature list overall. I know web2py has a mantra
> of retaining backward compatibility, but at what cost? Does it
> complicate the code? Not a fair comment I know --> but look where it
> got Microsoft. ;)
>
> On May 4, 5:09 pm, Massimo Di Pierro  wrote:
>
>
>
>
>
>
>
> > Hello everybody
>
> > Jonathan and I have been working on an internal web2py rewrite that while 
> > keeping everything backward compatible will allow you to do this
>
> >  modules/mymodule.py
> > from gluon import *
> > def f(): return DIV(A(current.request.function,_href=URL()))
> >  end
>
> >  default/controller.py
> > def index():
> >     from mymodule import f
> >     return dict(div=f())
> >  end
>
> > Thanks to Pierre we can now import modules from the app local folder 
> > without local_import and thanks to Jonathan those modules only need to do 
> > "from gluon import *" to see everything web2py has to offer. This should 
> > make life easier for Eclipse users too.
>
> > In models/db.py you no longer need to pass globals() to Auth
>
> >    auth=Auth(globals(),db)
> > or
> >    auth=Auth(db)
>
> > both work.
>
> > Also error messages in validators (including default error messages) should 
> > not be by T(...) by default.
>
> > This is now in trunk but we are still working on it. This means trunk may 
> > not very stable for the next day or two.
> > Meanwhile help us test it. In particular help us test if we are breaking 
> > your apps.
>
> > Massimo


[web2py] Re: getting characters before encryption

2011-05-05 Thread Massimo Di Pierro
Try:

 define_table('identity_card'
,Field('person', 'reference auth_user')
,Field('id_type', 'reference valid_id')
,Field('id_number','string',requires=CRYPT()
,Field('id_prefix',default=str(request.vars.id_number)[:
4])
)



On May 5, 6:50 am, niknok  wrote:
> I have SSNs in a table as text strings. I'm planning to use CRYPT() on
> the web2py app fields that will store these SSNs.
>
>         define_table('identity_card'
>             ,Field('person', 'reference auth_user')
>             ,Field('id_type', 'reference valid_id')
>             ,Field('id_number','string',requires=CRYPT()
>             ,Field('id_prefix',compute=lambda r: r['id_number'][:4])
>             )
>
> The 'id_prefix' field is for human users facilitating person
> verification, without having to ask for the full id number. As it is,
> the id_prefix will take the first 4 chars of the hashed id number, and
> not the original string. Right now I use a custom form that takes in the
> id_number, without encryption, take the id_prefix, then encrypt the
> id_number and finally do a manual insert into the database.
>
> Is there a way to get the prefix characters before encryption without a
> custom form?


[web2py] getting characters before encryption

2011-05-05 Thread niknok
I have SSNs in a table as text strings. I'm planning to use CRYPT() on
the web2py app fields that will store these SSNs.

define_table('identity_card'
,Field('person', 'reference auth_user')
,Field('id_type', 'reference valid_id')
,Field('id_number','string',requires=CRYPT()
,Field('id_prefix',compute=lambda r: r['id_number'][:4])
)



The 'id_prefix' field is for human users facilitating person
verification, without having to ask for the full id number. As it is,
the id_prefix will take the first 4 chars of the hashed id number, and
not the original string. Right now I use a custom form that takes in the
id_number, without encryption, take the id_prefix, then encrypt the
id_number and finally do a manual insert into the database.

Is there a way to get the prefix characters before encryption without a
custom form?




[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread Stodge
This should make it more attractive to a wider audience, especially as
web2py has a decent feature list overall. I know web2py has a mantra
of retaining backward compatibility, but at what cost? Does it
complicate the code? Not a fair comment I know --> but look where it
got Microsoft. ;)

On May 4, 5:09 pm, Massimo Di Pierro  wrote:
> Hello everybody
>
> Jonathan and I have been working on an internal web2py rewrite that while 
> keeping everything backward compatible will allow you to do this
>
>  modules/mymodule.py
> from gluon import *
> def f(): return DIV(A(current.request.function,_href=URL()))
>  end
>
>  default/controller.py
> def index():
>     from mymodule import f
>     return dict(div=f())
>  end
>
> Thanks to Pierre we can now import modules from the app local folder without 
> local_import and thanks to Jonathan those modules only need to do "from gluon 
> import *" to see everything web2py has to offer. This should make life easier 
> for Eclipse users too.
>
> In models/db.py you no longer need to pass globals() to Auth
>
>    auth=Auth(globals(),db)
> or
>    auth=Auth(db)
>
> both work.
>
> Also error messages in validators (including default error messages) should 
> not be by T(...) by default.
>
> This is now in trunk but we are still working on it. This means trunk may not 
> very stable for the next day or two.
> Meanwhile help us test it. In particular help us test if we are breaking your 
> apps.
>
> Massimo


[web2py] represented fields and jqgrid

2011-05-05 Thread niknok
I .represent a field as follows:

db.auth_user.gender.represent=lambda i: db.aux_gender[i].concept[:1] if 
i>0 else '?'
db.auth_user.member_status.represent=lambda i: 
config.member_status.get(i)[:1] or '?'


The first one works, and displays data in jqgrid as expected:'M','F'
or'?'. The second only shows a blank cell in jqgrid.

I tried a DAL select query and crud.search and the data is represented
correctly.


Re: [web2py] Very Soft Pre-Alpha Launch: Pricetack ecommerce service

2011-05-05 Thread Martín Mulone
Congrats!.

+1 to this dog http://cheekob.pricetack.com/item/38

2011/5/5 Stifan Kristi 

> very nice, congrats and gud luck in your business...
>



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


[web2py] Re: query question

2011-05-05 Thread LightOfMooN
But it will be the list with dublicates of thing? for example:
[[thing_1, photo_1],[thing_1, photo_2],[thing_1, photo_3],[thing_2,
photo_4],[thing_2, photo_5]]

But I need unique things with just one or zero photo per thing, like:
[[thing_1, photo_1],[thing_2, photo_4], [thing_3, None]]

On 5 май, 15:43, rāma  wrote:
> the loop is wrong. The below will be it.
>
> list=[]
>
> for row in query:
>
> list.append([row.things.title, row.photos_things.photo_id.image])


[web2py] Re: query question

2011-05-05 Thread rāma
the loop is wrong. The below will be it.

list=[]

for row in query:

list.append([row.things.title, row.photos_things.photo_id.image])



[web2py] Re: query question

2011-05-05 Thread rāma
I think this should be it:

query=db((db.things.id>0)&(db.photos_things.id==db.photos_things.thing_id)).select()

for row in query:

list = [row.things.title, row.photos_things.photo_id.image]



[web2py] Re: Seperating HTML from JavaScript (while preserving templating with {{= }} in JS ) ... BUG

2011-05-05 Thread selecta
> the DIV is rendered fine in my tests, no need to add any prefix such
> as '.html' or '.load' for it to work.
hmm ok, i have to try some more, maybe i can find out how to reproduce
this strange behavior

>
> But having a LOAD in the controller generates an unnecessary ajax
> call,
this was just for demonstration purposes, but that failed :D

> and having the script action and view just makes web2py work
> harder instead of letting the web server do it from static, not to
> mention the clutter of having js all over your views directory.
I am working alot with js functions that init tab menus ...
When I write these i usually use things like {{=URL(foobar)}} in the
JS
With the example above  you can mix the web2py template language with
pure JS. This is nicer for me since vim highlits, indents, ... pure JS
much better than embedded JS. Also you can then pass args and vars to
your JS, and use URL() (which is better if you need routing)

Here is an example how i use it. This are the views of the annotate
controller
http://semanticsbml.svn.sourceforge.net/viewvc/semanticsbml/trunk/webui/views/annotate/
In the controller i just load the script.js once (index), all other
ajax loaded functions just use a JS init_foobar() function to activate
their buttons/fields with special functions
http://semanticsbml.svn.sourceforge.net/viewvc/semanticsbml/trunk/webui/controllers/annotate.py?revision=3325&view=markup
now i can apply this to a server and reroute all URL without having to
worry that i hard-coded them into the JS file


Re: [web2py] Very Soft Pre-Alpha Launch: Pricetack ecommerce service

2011-05-05 Thread Stifan Kristi
very nice, congrats and gud luck in your business...


[web2py] query question

2011-05-05 Thread LightOfMooN
db.define_table('things',
Field('title', 'string'),
)

db.define_table('photos',
Field('title', 'string'),
Field('image', 'upload', autodelete=True),
)

db.define_table('photos_things',
Field('thing_id', db.things),
Field('photo_id', db.photos),
)

Is there a way to get all things and one photo per thing with 1 query?


Re: [web2py] Very Soft Pre-Alpha Launch: Pricetack ecommerce service

2011-05-05 Thread pbreit
I looked at the e-store appliance a tiny bit but pretty much coded Pricetack 
from scratch. At one point I was interested in building an open source 
shopping cart on Web2py so perhaps I'll have another look.

Re: [web2py] Very Soft Pre-Alpha Launch: Pricetack ecommerce service

2011-05-05 Thread pbreit
Ouch, that's no good! It looks like I had a column whose type got messed up 
when I had that migration problem yesterday. Fixed. Thanks for reporting.

Shipping to South America might be tricky but I'd be happy to look into it 
and sell for my wholesale cost + shipping/customs/etc.