[web2py] Quoting reserved words in DAL

2012-06-18 Thread Michael Toomim
I just got bit by the reserved-word problem:
https://groups.google.com/d/msg/web2py/aSPtD_mGXdM/c7et_2l_54wJ

I am trying to port a postgres database to a friend's mysql database, but 
we are stuck because the DAL does not quote identifiers.

This problem has been discussed a fair amount:
https://groups.google.com/d/msg/web2py/QKktETHk3yo/Mwm3D-JhNmAJ

...and it seems all we need to do is add some quoting mechanisms to the 
DAL. In postgresql you surround names with "quotes" and in mysql you use 
`backticks`.

Does anyone have ideas for what to do?


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-18 Thread Niphlod


>
> Ok, just to double check, that is for all DB back-ends or just for SQLite? 
>
> This is true for every backend.  

>
>
> Ah, OK. So it would be easier to write code that uses any DB except 
> for SQLite... Hmmm 
>

It's not a question of "easier" or "harder" : as always it's just choosing 
the right tools for the job :D
 

>
> Ok, so I think we've established that is a special limitation for SQLite. 
> For all the other DBs, I can have my Web2py app inserting new records 
> willy nilly and the background process updating them (mail sent, mail 
> failed, whatever) without the Web2py app having performance/response 
> time issues due to database contention. 
>
> The trick comes in when SQLite is being used. 
> Just for completeness, if I do a commit on every loop, what is the 
> window where Web2py is causing the SQLite lock to be taken? 
> Is it just between the update_record and the commit? 
>

Yep, it's from when you do the first thing that changes the data in the 
database (update, delete) and the commit.
 

>
> I ask because I'm not yet clear on how it is that the commit on every 
> loop will allow the Web2py app to be more responsive than the commit 
> after all 500 cases. It must be that in the commit on every loop there 
> is a substantial chance for the Web2py app to get to the database. But 
> if a commit causes a new transaction to start, how does Web2py get in? 
> In fact, the example in the book shows an outer loop that looks for 
> new work, and when done, sleeps for 60 seconds. If the commit call 
> starts a new transaction, the on the very last of the 500 records, 
> we'll fall out of the inner loop and then sleep for 60 seconds, which 
> should lock Web2py out for a full minute? how does the server process 
> drop the transaction in that case so that the Web2py process has a 
> chance to get in to the DB? 
>

Web2py is not blocked, and again, it's only with SQLite that there is the 
problem. From the first update on the queue to the commit, no-one can 
access a SQLite database, hence an app trying to read from that will 
"hang". Anyway, in the "sleeping" loop, no modifications to the db are made 
so also with SQLite there will be no problems.
 

>
> (I'm beginning to think that The Book should just say: This example is 
> for any DB except SQLite, don't use SQLite for this kind of processing 
> ???) 
>

Yep, I'll be fine with it ;-D 

Maybe I should make a slice on how to fix this behaviour also for 
SQLite. it's just a bit complicated because it requires to rebuild the 
sqlite module with an updated library.
 


[web2py] Re: Best practice using scheduler as a task queue?

2012-06-18 Thread Niphlod
I'll get back to you this evening, but for now, maybe it's a fix.

You're afraid that starting n web2py processes your code in "initialize" 
will duplicate inserts. That is the common behaviour in db 
transactions. if you're running three processes, and you're not lucky, 
all three will "see" a clean slate and will try to insert data.  

But, what if you schedule the "initialize_task_queue" as a repeating task ?

Then you'll be sure that it gets processed not concurrently, and that 
function will be the one in charge of reinitializing the task queue. 
I use a similar method in w2p_tvseries to enable group of tasks that are 
yet scheduled: not quite the same thing but it should work nonetheless.

On Monday, June 18, 2012 1:29:56 AM UTC+2, Michael Toomim wrote:
>
> To respond to your last two points:
>
> You're right that models only runs on every request... I figured if my 
> website isn't getting any usage then the tasks don't matter anyway. :P
>  
> Yes, I think there are design issues here, but I haven't found a better 
> solution. I'm very interested in hearing better overall solutions! The 
> obvious alternative is to write a standalone script that loops forever, and 
> launch it separately using something like "python web2py.py -S 
> app/controller -M -N -R background_work.py -A foo". But this requires 
> solving the following problems that are *already solved* by the scheduler:
>   • During development, restarting & reloading models as I change code
>   • Killing these background processes when I quit the server
>   • Ensuring that no more than one background process runs at a time
>
> On Wednesday, June 13, 2012 7:16:56 AM UTC-7, Niphlod wrote:
>>
>> Maybe I didn't get exactly what you need , but .. you have 3 tasks, 
>> that needs to be unique.
>> Also, you want to be sure that if a task crashes doesn't remain "hanged".
>>
>> This should never happen with the scheduler  the worst situation is 
>> that if a worker crashes (here "crashes" is it disconnects from the 
>> database) leaves the task status as running, but as soon as another 
>> scheduler checks if that one sends heartbeats, he removes the dead worker 
>> and requeue that task.
>> If your task goes into timeout and it's a repeating task the best 
>> practice should be to raise the timeout.
>>
>> Assured this, you need to initialize the database if someone truncates 
>> the scheduler_task table, inserting the 3 records in one transaction.
>>
>> If you need to be sure, why all the hassle when you can "prepare" the 
>> task_name column as a unique value and then do 
>> db.update_or_insert(task_name==myuniquetaskname, **task_record) ?
>>
>> PS: code in models get executed every request. What if you have no users 
>> accessing the site and in the need to call initialize_task_queue ? Isn't it 
>> better to insert the values and then start the workers ?
>>
>> BTW: a task that needs to be running "forever" but can't be "launched" in 
>> two instances seems to suffer some design issues but hey, everyone needs to 
>> be able to do what he wants ;-)
>>
>

[web2py] Re: Users Poll: To keep the button look for the welcome app's auth options, or not ?

2012-06-18 Thread Andrew
Looks Great to me !



On Monday, June 18, 2012 4:38:09 PM UTC+12, Massimo Di Pierro wrote:
>
> Check what's in trunk now. Let me know if you think it needs improvement.
>
> On Sunday, 17 June 2012 15:45:41 UTC-5, Cliff Kachinske wrote:
>>
>> I agree that the old look, with dividers, *looks* better.
>>
>> I also think the buttons are easier to find on the page, so I would like 
>> to optionally use them.
>>
>> Would you take a patch with the option?
>>
>>
>> On Saturday, June 16, 2012 11:30:04 PM UTC-4, Andrew wrote:
>>>
>>> A  week or two ago a change was made to the nav bar to give the auth 
>>> buttons for Login, Register, etc   a button look.   This was part of the 
>>> fix to the dropdown menus to get them to work with bootstrap.  Another 
>>> change was made to revert back to the old look (but only as an attachment 
>>> to a previous post in this list).  
>>>
>>> There are two screen shots, current welcome app, and with the buttons 
>>> reverted to the old look.
>>>
>>> Credit to Paolo for making both changes.  Given that the buttons have 
>>> been in trunk for a while, it is worth getting a consensus to keep it or 
>>> revert it.  So:
>>>
>>> *Vote:*
>>> *A) KEEP THE BUTTON LOOK*
>>> *B) REVERT TO THE OLD LOOK*
>>> *
>>> *
>>> *if B) *
>>> *
>>> *
>>> *B.1) Revert to the Pipe separator between the options (as shown)*
>>> *B.2) Don't include the Pipe separator.*
>>>
>>>
>>> B.1) involves updating a recent patch to layout.html:
>>> {{='auth' in globals() and auth.navbar(separators=(' 
>>> ',' | ','')) or ''}}
>>>
>>> A patch for B.1) has already been sent to Massimo (that's my vote :) ) , 
>>> but let's see what the general feeling is.
>>>
>>> Thanks
>>>
>>

[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-06-18 Thread Andrew
My understanding is that the themes are all contained in a new 
bootstrap.css, or bootstrap.min.css file.   These are the ones we don't 
want to touch.  I've downloaded a few to have a look.
I thought the bootswatch.css is just some extra styling to get the 
bootswatch themes (the different bootstrap.css files) to work with web2py.  

I think we're good.

Maybe it could be contained in web2py.css, but it sounds like bootstrap 
specific styling has been put in there.   Not a bad idea if someone does 
not want to use bootstrap -keep the necessary web2py stuff and leave out 
the bootstrap specifics.



On Monday, June 18, 2012 4:39:23 PM UTC+12, Massimo Di Pierro wrote:
>
> I included your patch but not version V2. That is because we do not want 
> to mantain our own modified bootswatch. People should be able to download a 
> theme and use it without editing. Can this be addressed in web2py.css?
>
> On Sunday, 17 June 2012 18:42:12 UTC-5, LightDot wrote:
>>
>> I have tested the V2 versions attached with Issue 856 and they seem to 
>> address the issues perfectly.
>>
>> Regards
>>
>> On Sunday, June 17, 2012 9:14:33 PM UTC+2, Paolo Caruccio wrote:
>>>
>>> Patch submitted http://code.google.com/p/web2py/issues/detail?id=856
>>>
>>> Il giorno domenica 17 giugno 2012 17:32:53 UTC+2, Massimo Di Pierro ha 
>>> scritto:

 Can you coordinate with Andrew and Paolo and send me a single fix that 
 applies to latest trunk and addresses the outstanding issues?

 On Sunday, 17 June 2012 08:42:50 UTC-5, LightDot wrote:
>
> I have tried your updated bootswatch.css from another thread here, 
> which also incorporates this fix. I confirm that BS 2.0.4 works now.
>
> Thanks!
>
> On Sunday, June 17, 2012 12:33:52 AM UTC+2, Paolo Caruccio wrote:
>>
>> LightDot,
>>
>>  try to append in static/css/bootswatch.css this rule:
>>
>> .dropdown-menu ul{display:block;}
>>
>> I spotted the issue some days ago, but I didn't propose a patch 
>> because web2py still has bs 2.0.2
>>
>> Let me know if the fix works for you also.
>>
>> Il giorno domenica 17 giugno 2012 00:27:18 UTC+2, LightDot ha scritto:
>>>
>>> Changes in dev in the last week or so have effect on Bootstrap. 2nd 
>>> level submenus don't work anymore if using Bootstrap 2.0.4, while 
>>> bundled 
>>> 2.0.2 works.
>>>
>>> - clean welcome app from latest dev, Bootstrap css and js upgraded 
>>> to 2.0.4
>>> - clicking over the yellow "web2py" opens the first submenu level
>>> - clicking or hovering over e.g. Documentation, does nothing.
>>>
>>> Tested in Firefox 13 and Opera 12... Are there plans to update 
>>> Bootstrap to 2.0.4 in web2py itself?
>>>
>>> Regards
>>>
>>>
>>> On Friday, June 15, 2012 4:49:29 PM UTC+2, Paolo Caruccio wrote:

 Andrew, do you mean the code for old auth_navbar style? If yes, I 
 think it's better if you open a new thread for asking to the web2py 
 users 
 what style they prefer and after we will send a patch to Massimo. It's 
 possible that most of w2p users loves the current style (bootstrap 
 buttons 
 group).

 Il giorno giovedì 14 giugno 2012 22:55:38 UTC+2, Andrew ha scritto:
>
> Hi Paolo,
>
> Are you able to send a patch to Massimo for your layout and 
> bootswatch files.  The bootstrap menu issue is holdnig up 2.0 and I 
> think 
> your changes have addressed this.   Would love to see it in trunk.
>
> If you can't I can have a go at working out what you did.
>
> Thanks
>
> Andrew W
>
>
>
> On Thursday, June 7, 2012 8:24:44 PM UTC+12, Paolo Caruccio wrote:
>>
>> I'm afraid you can not do it. The first item in the dropdown menu 
>> (having class="dropdown") can not contain an URL. The structure of 
>> the 
>> dropdown menu is as follows (taken from this page 
>> http://twitter.github.com/bootstrap/components.html#navbar):
>>
>> Adding dropdown menus
>>
>> Adding dropdowns and dropups to the nav is super simple, but does 
>> require the use of our javascript 
>> plugin
>> .
>>
>>
>>1. 
>>2.   
>>3. >4.   class="dropdown-toggle"
>>5.   data-toggle="dropdown">
>>6.   Account
>>7.   
>>8. 
>>9. 
>>10.   ...
>>11. 
>>12.   
>>13. 
>>
>>
>> Il giorno giovedì 7 giugno 2012 04:13:19 UTC+2, LightDot ha 
>> scritto:
>>>
>>> I can confirm this, usi

Re: [web2py] Re: id.max()

2012-06-18 Thread Vasile Ermicioi
or

max_id = db(db.Node).select(db.Node.id, orderby=~db.Node.id,
limitby=(0,1)).first().id

-- 





Re: [web2py] Re: Users Poll: To keep the button look for the welcome app's auth options, or not ?

2012-06-18 Thread Alec Taylor
b 1

Also, make it contrast with the background, e.g.: white text colour

On Mon, Jun 18, 2012 at 6:30 PM, Andrew  wrote:
> Looks Great to me !
>
>
>
> On Monday, June 18, 2012 4:38:09 PM UTC+12, Massimo Di Pierro wrote:
>>
>> Check what's in trunk now. Let me know if you think it needs improvement.
>>
>> On Sunday, 17 June 2012 15:45:41 UTC-5, Cliff Kachinske wrote:
>>>
>>> I agree that the old look, with dividers, looks better.
>>>
>>> I also think the buttons are easier to find on the page, so I would like
>>> to optionally use them.
>>>
>>> Would you take a patch with the option?
>>>
>>>
>>> On Saturday, June 16, 2012 11:30:04 PM UTC-4, Andrew wrote:

 A  week or two ago a change was made to the nav bar to give the auth
 buttons for Login, Register, etc   a button look.   This was part of the 
 fix
 to the dropdown menus to get them to work with bootstrap.  Another change
 was made to revert back to the old look (but only as an attachment to a
 previous post in this list).

 There are two screen shots, current welcome app, and with the buttons
 reverted to the old look.

 Credit to Paolo for making both changes.  Given that the buttons have
 been in trunk for a while, it is worth getting a consensus to keep it or
 revert it.  So:

 Vote:
 A)     KEEP THE BUTTON LOOK
 B)     REVERT TO THE OLD LOOK

 if B)

 B.1)     Revert to the Pipe separator between the options (as shown)
 B.2)     Don't include the Pipe separator.


 B.1) involves updating a recent patch to layout.html:
 {{='auth' in globals() and auth.navbar(separators=('
 ',' | ','')) or ''}}

 A patch for B.1) has already been sent to Massimo (that's my vote :) ) ,
 but let's see what the general feeling is.

 Thanks


[web2py] CVE-2012-2122: A Tragically Comedic Security Flaw in MySQL

2012-06-18 Thread Lazarof
CVE-2012-2122: A Tragically Comedic Security Flaw in MySQL


Re: [web2py] CVE-2012-2122: A Tragically Comedic Security Flaw in MySQL

2012-06-18 Thread Bruno Rocha
more info about it?

http://zerp.ly/rochacbruno
Em 18/06/2012 06:29, "Lazarof"  escreveu:

> CVE-2012-2122: A Tragically Comedic Security Flaw in MySQL
>


Re: [web2py] CVE-2012-2122: A Tragically Comedic Security Flaw in MySQL

2012-06-18 Thread Bruno Rocha
ok I got it
http://thehackernews.com/2012/06/cve-2012-2122-serious-mysql.html?m=1
 Em 18/06/2012 07:07, "Bruno Rocha"  escreveu:

> more info about it?
>
> http://zerp.ly/rochacbruno
> Em 18/06/2012 06:29, "Lazarof"  escreveu:
>
>> CVE-2012-2122: A Tragically Comedic Security Flaw in MySQL
>>
>


[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-06-18 Thread Paolo Caruccio
Massimo,

actually files with prefix V2_ allow this: download and apply in w2p a 
bootswacth theme without other actions by user.


Il giorno lunedì 18 giugno 2012 06:39:23 UTC+2, Massimo Di Pierro ha 
scritto:
>
> I included your patch but not version V2. That is because we do not want 
> to mantain our own modified bootswatch. People should be able to download a 
> theme and use it without editing. Can this be addressed in web2py.css?
>
> On Sunday, 17 June 2012 18:42:12 UTC-5, LightDot wrote:
>>
>> I have tested the V2 versions attached with Issue 856 and they seem to 
>> address the issues perfectly.
>>
>> Regards
>>
>> On Sunday, June 17, 2012 9:14:33 PM UTC+2, Paolo Caruccio wrote:
>>>
>>> Patch submitted http://code.google.com/p/web2py/issues/detail?id=856
>>>
>>> Il giorno domenica 17 giugno 2012 17:32:53 UTC+2, Massimo Di Pierro ha 
>>> scritto:

 Can you coordinate with Andrew and Paolo and send me a single fix that 
 applies to latest trunk and addresses the outstanding issues?

 On Sunday, 17 June 2012 08:42:50 UTC-5, LightDot wrote:
>
> I have tried your updated bootswatch.css from another thread here, 
> which also incorporates this fix. I confirm that BS 2.0.4 works now.
>
> Thanks!
>
> On Sunday, June 17, 2012 12:33:52 AM UTC+2, Paolo Caruccio wrote:
>>
>> LightDot,
>>
>>  try to append in static/css/bootswatch.css this rule:
>>
>> .dropdown-menu ul{display:block;}
>>
>> I spotted the issue some days ago, but I didn't propose a patch 
>> because web2py still has bs 2.0.2
>>
>> Let me know if the fix works for you also.
>>
>> Il giorno domenica 17 giugno 2012 00:27:18 UTC+2, LightDot ha scritto:
>>>
>>> Changes in dev in the last week or so have effect on Bootstrap. 2nd 
>>> level submenus don't work anymore if using Bootstrap 2.0.4, while 
>>> bundled 
>>> 2.0.2 works.
>>>
>>> - clean welcome app from latest dev, Bootstrap css and js upgraded 
>>> to 2.0.4
>>> - clicking over the yellow "web2py" opens the first submenu level
>>> - clicking or hovering over e.g. Documentation, does nothing.
>>>
>>> Tested in Firefox 13 and Opera 12... Are there plans to update 
>>> Bootstrap to 2.0.4 in web2py itself?
>>>
>>> Regards
>>>
>>>
>>> On Friday, June 15, 2012 4:49:29 PM UTC+2, Paolo Caruccio wrote:

 Andrew, do you mean the code for old auth_navbar style? If yes, I 
 think it's better if you open a new thread for asking to the web2py 
 users 
 what style they prefer and after we will send a patch to Massimo. It's 
 possible that most of w2p users loves the current style (bootstrap 
 buttons 
 group).

 Il giorno giovedì 14 giugno 2012 22:55:38 UTC+2, Andrew ha scritto:
>
> Hi Paolo,
>
> Are you able to send a patch to Massimo for your layout and 
> bootswatch files.  The bootstrap menu issue is holdnig up 2.0 and I 
> think 
> your changes have addressed this.   Would love to see it in trunk.
>
> If you can't I can have a go at working out what you did.
>
> Thanks
>
> Andrew W
>
>
>
> On Thursday, June 7, 2012 8:24:44 PM UTC+12, Paolo Caruccio wrote:
>>
>> I'm afraid you can not do it. The first item in the dropdown menu 
>> (having class="dropdown") can not contain an URL. The structure of 
>> the 
>> dropdown menu is as follows (taken from this page 
>> http://twitter.github.com/bootstrap/components.html#navbar):
>>
>> Adding dropdown menus
>>
>> Adding dropdowns and dropups to the nav is super simple, but does 
>> require the use of our javascript 
>> plugin
>> .
>>
>>
>>1. 
>>2.   
>>3. >4.   class="dropdown-toggle"
>>5.   data-toggle="dropdown">
>>6.   Account
>>7.   
>>8. 
>>9. 
>>10.   ...
>>11. 
>>12.   
>>13. 
>>
>>
>> Il giorno giovedì 7 giugno 2012 04:13:19 UTC+2, LightDot ha 
>> scritto:
>>>
>>> I can confirm this, using fresh welcome application and 
>>> Bootstrap upgraded to 2.0.4.
>>>
>>> If a menu item has both an URL specified and also additional 
>>> submenus, these don't get displayed. Regardless if this is a first 
>>> or a 
>>> second level menu item. If the URL is set as None, additional 
>>> submenus 
>>> display properly.
>>>
>>> Regards
>>>
>>> On Wednesday, June 6, 2

[web2py] Problem while using two sqlform.grid in a single form

2012-06-18 Thread rahulserver
I tried to use two sqlform.grid in a web2py form. It does work as intended 
except for the problem that when I try to edit on of the form's row, other 
form's row with same Id also appears to be edited. How should i stop it?
my controller:
def CommitmentBrowse_rep():
rows=db(db.Commitments.Account==session.id).select()
commtot=0
compen=0
comfull=0
for row in rows:
commtot=commtot+int(row.Amount)
if row.pending:
compen=compen+int(row.Amount)
else:
comfull=comfull+int(row.Amount)

rows=db(db.Transaction_Master.Account==session.id).select()
netdue=0
for row in rows:
netdue=netdue+int(row.Net_Due)

pay=0
rows=db(db.Payments.Account==session.id).select()
for row in rows:
pay=pay+int(row.Amount)
a=[]
b=[]
count=0
a.append([TH('Due Amount'),TH('Commited Amount'),TH('Commitment 
Fulfilled'),TH('Commitment Pending'),TH('Uncommitted Amount'),TH('Payments 
Received')])
a.append([netdue,commtot,comfull,compen,pay])

COMMITMENTS=SQLFORM.grid(db.Commitments.Account==session.id,user_signature=False)

PAYMENTS=SQLFORM.grid(db.Payments.Account==session.id,user_signature=False)
return dict(COMMITMENTS=COMMITMENTS,PAYMENTS=PAYMENTS,SUMMARY=TABLE(a))


Re: [web2py] Re: Upload the more than 100 MB file

2012-06-18 Thread Khalil KHAMLICHI
In case it might help, here is my trace back file and the controller (I am
doing a manual insert, maybe I should not ?) :

## CONTROLLER STARTS HERE

   form = SQLFORM(db.fichiers, fields=['nom_fichier',
'fichier', 'project', 'description', 'users', 'deleted'])
if form.validate():
form.vars.create_date =
str(datetime.datetime.today().date())
form.vars.create_time =
str(datetime.datetime.today().time())
form.vars.id = db.fichiers.insert(**dict(form.vars))

## CONTROLLER ENDS HERE

## START TRACEBACK

(dp1
S'output'
p2
S" "
p3
sS'layer'
p4
S'/var/opt/app/applications/init/views/default/fichiers.html'
p5
sS'code'
p6
S'left_sidebar_enabled,right_sidebar_enabled=False,True\nresponse.write(\'\\n\',
escape=False)\nresponse.write(\'\\n\\n\\n\\n\\n\\n  \\n\\n  \\n  \\n  \\n  \\n  \\n  \',
escape=False)\nresponse.write(response.title or
request.application)\nresponse.write(\'\\n  \\n  \\n  \\n  \\n  \\n  \\n\\n  \\n  \\n  \\n  \\n  \\n  \\n\\n
 \\n  
 \\n\\n  \\n  \',
escape=False)\nresponse.files.append(URL(\'static\',\'css/skeleton.css\'))\nresponse.files.append(URL(\'static\',\'css/web2py.css\'))\nresponse.files.append(URL(\'static\',\'css/archimanager.css\'))\nif
response.menu:\n
 response.files.append(URL(\'static\',\'css/superfish.css\'))\n
 response.files.append(URL(\'static\',\'js/superfish.js\'))\n
 pass\nresponse.write(\'\\n\\n  \', escape=False)\nresponse.write(\'\\n\',
escape=False)\nresponse.files.insert(0,URL(\'static\',\'js/jquery.js\'))\nresponse.files.insert(1,URL(\'static\',\'css/calendar.css\'))\nresponse.files.insert(2,URL(\'static\',\'js/calendar.js\'))\nresponse.files.insert(3,URL(\'static\',\'js/web2py.js\'))\nresponse.include_meta()\nresponse.include_files()\nresponse.write(\'\\n\',
escape=False)\nresponse.write(\'\\n\\n  \', escape=False)\nif
response.menu:\nresponse.write(\'\\n  \\njQuery(function(){
jQuery(\\\'ul.sf-menu\\\').supersubs({minWidth:12,maxWidth:30,extraWidth:3}).superfish();
});\\n  \\n  \', escape=False)\npass\nresponse.write(\'\\n\\n
 \', escape=False)\n# using sidebars need to know what sidebar you want to
use\nleft_sidebar_enabled =
globals().get(\'left_sidebar_enabled\',False)\nright_sidebar_enabled =
globals().get(\'right_sidebar_enabled\',False)\nmiddle_columns =
{0:\'sixteen\',1:\'twelve\',2:\'eight\'}[\n(left_sidebar_enabled and 1 or
0)+(right_sidebar_enabled and 1 or 0)]\nresponse.write(\'\\n\\n  \\n\\n\\n  \\n  \\n\\n  \\n
   \\n  \',
escape=False)\nresponse.write(\'auth\' in globals() and
auth.navbar(separators=(\' \',\' | \',\'\')))\nresponse.write(\'\\n
   \',
escape=False)\nis_mobile=request.user_agent().is_mobile\nresponse.write(\'\\n\\t
 \', escape=False)\nif response.menu:\nresponse.write(\'\\n
 \\n \', escape=False)\n
 response.write(MENU(response.menu, _class=\'mobile-menu\' if is_mobile
else \'sf-menu\',mobile=is_mobile))\nresponse.write(\'\\n
 \\n  \', escape=False)\npass\nresponse.write(\'\\n
 \\n  \\n\\n\\n\\n   \\n\\n  \\n  Archimanager\\n  \\n
   \', escape=False)\nresponse.write(response.subtitle or
\'\')\nresponse.write(\'\\n\\n\\n  \\n
 \', escape=False)\nresponse.write(\'\\n\',
escape=False)\nresponse.write(request.function.replace(\'_\', \'
\').title())\nresponse.write(\'\\n\',
escape=False)\nresponse.write(\'\\n  \\n\\n
 \\n\\n\\n\\n   \\n\\n\\n  \',
escape=False)\nresponse.write(\'\\n  \',
escape=False)\nresponse.write(\'\\n\\n\', escape=False)\nif msg !=
\'start\':\nresponse.write(\'\\n\\t\', escape=False)\n
 response.write(msg)\nresponse.write(\'\\n\', escape=False)\n
 pass\nresponse.write(\'\\n\\n\',
escape=False)\nresponse.write(SQLTABLE(rex,\nlinkto=URL(r=request,
f=\'fichiers\'),\nheaders={ \'fichiers.id\':\'ID\',
\'fichiers.nom_fichier\':\'Fichier\', \'fichiers.fichier\':\'download\',
\'projects.project\':\'Projet\', \'fichiers.create_date\':\'Date
Creation\', \'fichiers.create_time\':\'Heure Creation\',
\'fichiers.description\':\'Description\', \'fichiers.users\':\'List
Utilisateurs\'},\nupload=URL(\'download\')\n))\nresponse.write(\'\\n\\n\\nAjouter Nouveau\\n\\n\\n\',
escape=False)\nresponse.write(form)\nresponse.write(\'\\n\\n\\n\',
escape=False)\nresponse.write(\'\\n\\n\',
escape=

[web2py] Problems with using downloaded layouts

2012-06-18 Thread rahulserver
I am facing two problems in general with downloaded layouts from web2py 
site:
1) whenever a form or table extends beyond the page body area, it goes 
beyound the middle area's margin.In default layout, the middle area appears 
to expand to accomodate the form or table.
2) In Sqlform.grid or smartgrid, the view edit or delete link appears like 
vieweditdelete i.e.with no spaces in between. In default layout,they appear 
spaced apart.

I am currently using corporate office template(
http://web2py.com/layouts/static/plugin_layouts/plugins/web2py.plugin.layout_CorporateOffice.w2p).
 

Is there a way to restore the default web2py template?
Also in my typical case, I am using hindi fonts from google IME. The 
template does not seems to render these fonts.The default web2py template 
does render these. So how should I get around these problems?
<>

Re: [web2py] CVE-2012-2122: A Tragically Comedic Security Flaw in MySQL

2012-06-18 Thread Michele Comitini
Here is some more detail

http://ow.ly/bDXWk

mic

2012/6/18 Bruno Rocha :
> more info about it?
>
> http://zerp.ly/rochacbruno
>
> Em 18/06/2012 06:29, "Lazarof"  escreveu:
>
>> CVE-2012-2122: A Tragically Comedic Security Flaw in MySQL


[web2py] Gaema/ web2py_multiauth, login_form not defined

2012-06-18 Thread wiel
I am trying to setup the gaema port from here 
http://code.google.com/p/cfhowes/source/browse/
now I followed the installation instructions to the T, but when the time 
came to view login_area.html i get this error: 
 name 'login_form' is not defined
did anybody get this error and get over it?


[web2py] Getting Aptana3 / GAE / web2py

2012-06-18 Thread sspiel
What are the recommended configuration settings for getting Aptana3 and GAE 
working with web2py?

Currently, I'm using:
1. Project Type: PyDev
2. Workspace View: Web
3. Run Configurations: {web2py local server instance, webrowser with URL 
set to Application Administration interface
4. Added a code block to certain files to reduce the erroneous static 
analyzer warnings

# Workaround for IDE to ignore errors for runtime variables
if 0:
None
import gluon
global cache; cache = gluon.cache.Cache()
global request; request = gluon.globals.Request()
global response; response = gluon.globals.Response()
global session; session = gluon.globals.Session()
global settings; settings = gluon.globals.settings
global DAL; DAL = gluon.dal()
global HTTP; HTTP = gluon.http()
global LOAD; LOAD = gluon.compileapp.LoadFactory()
global db, Field, auth, crud
global plugin_wiki_theme, plugin_wiki_level, plugin_wiki_migrate, 
plugin_wiki_editor, plugin_wiki_mode
global web2py_aggregator_link, feeds, max_entried, d
global IS_SLUG, IS_NOT_IN_DB, IS_NOT_EMPTY, IS_EMPTY_OR, IS_IN_DB

These settings work well with web2py and the local development server 
127.0.0.1:8000. What changes should I make to work with GAE (ie use PyDev 
GAE project instead of PyDev)? Are there any other useful features, 
configurations I can use?


[web2py] Re: Crappy downloaded image names

2012-06-18 Thread Anthony
What is your db.UserImageStore model, and what is the code for downloading 
the image?

On Monday, June 18, 2012 7:49:58 AM UTC-4, Sushant Taneja wrote:
>
> Hi,
>
> I am building an app using AppEngine + Web2py
>
> A user's profile image is retrieved from his Facebook profile via the 
> Graph API and stored in database.
> The image is stored and displayed correctly. 
> But whenever I right-click and save the image, the saved file name is just 
> some set unicode characters I guess and not the name from which the image 
> is saved.
>
> *Eg:  *-îÏìÄÊ-¨-¢‚H-¦_â.jpg
>
> How do I correct this file name ? Below is the code which I am using to 
> generate image names:
>
>
> def create_user_pic_fb():
> """
> This method fetches the FB profile image of the user and sets it 
> as user profile image
> """
>
> from google.appengine.api import urlfetch
> from random import randint
>
> user_fb_id = request.args[0]
> user_profile_image_url = 
> FB_PROFILE_IMAGE_URL.replace('USER_FB_ID',user_fb_id)
>
> random_str = str(randint(1,))
> logger.debug(random_str)
>
> # Get profile image blob from facebook
> result = urlfetch.fetch(user_profile_image_url)
> logger.debug("Read profile image")
> profile_image = result.content
>
> profile_image_name = 'UserImageStore.profile_image.' + random_str + 
> '_' + user_fb_id + '.' + result.headers['Content-Type'].split('/').pop()
>
> # Insert the images in DB
> dal_db.UserImageStore.insert(profile_image=profile_image_name,
> profile_blob=profile_image,
> upload_ts = datetime.now(),
> change_ts = datetime.now()
> )
> 
>
>
> The same result is received from using urllib2 instead of urlfetch.
>


Re: [web2py] Re: Web2py RAM usage

2012-06-18 Thread Lucas R. Martins
i'm not using web2py-level caching, but i would like to use, if i can limit
memory usage and expire it when i need.
i have compiled app and i'm using sqlite. sqlite is a problem?


2012/6/18 Massimo Di Pierro 

> Are you using caching? Are you using sqlite? We should nail down the cause
> of this problem.
> Did you try to bytecode compile the app?
>
> Massimo
>
>
> On Sunday, 17 June 2012 21:17:01 UTC-5, Lucas R. Martins wrote:
>>
>> Hi guys,
>>
>> I'm running a website with ~ 900 urls and no many daily access in a small
>> vps. I have observed that, when a start the server, this use only 10mb, in
>> my case.
>>
>> However, with the time and natural access (specially googlebot), the
>> server memory usage grow and grows indefinitely until use all server
>> memory.
>>
>> There is anything to do to limit web2py memory usage and force it to free
>> unused memory? There is any kind of internal ram cache which can be
>> disabled?
>>
>>
>>
>> Thanks.
>>
>


[web2py] Re: Crappy downloaded image names

2012-06-18 Thread Sushant Taneja
The code for the model UserImageStore is :

dal_db.define_table('UserImageStore',
Field('profile_image','upload',uploadfield='profile_blob'),
Field('profile_blob','blob'),
Field('upload_ts','datetime'),
Field('change_ts','datetime')
)

and the my show_image function is :

def show_image():
return response.download(request,dal_db)




On Monday, June 18, 2012 5:58:27 PM UTC+5:30, Anthony wrote:
>
> What is your db.UserImageStore model, and what is the code for downloading 
> the image?
>
> On Monday, June 18, 2012 7:49:58 AM UTC-4, Sushant Taneja wrote:
>>
>> Hi,
>>
>> I am building an app using AppEngine + Web2py
>>
>> A user's profile image is retrieved from his Facebook profile via the 
>> Graph API and stored in database.
>> The image is stored and displayed correctly. 
>> But whenever I right-click and save the image, the saved file name is 
>> just some set unicode characters I guess and not the name from which the 
>> image is saved.
>>
>> *Eg:  *-îÏìÄÊ-¨-¢‚H-¦_â.jpg
>>
>> How do I correct this file name ? Below is the code which I am using to 
>> generate image names:
>>
>>
>> def create_user_pic_fb():
>> """
>> This method fetches the FB profile image of the user and sets it 
>> as user profile image
>> """
>>
>> from google.appengine.api import urlfetch
>> from random import randint
>>
>> user_fb_id = request.args[0]
>> user_profile_image_url = 
>> FB_PROFILE_IMAGE_URL.replace('USER_FB_ID',user_fb_id)
>>
>> random_str = str(randint(1,))
>> logger.debug(random_str)
>>
>> # Get profile image blob from facebook
>> result = urlfetch.fetch(user_profile_image_url)
>> logger.debug("Read profile image")
>> profile_image = result.content
>>
>> profile_image_name = 'UserImageStore.profile_image.' + random_str + 
>> '_' + user_fb_id + '.' + result.headers['Content-Type'].split('/').pop()
>>
>> # Insert the images in DB
>> dal_db.UserImageStore.insert(profile_image=profile_image_name,
>> profile_blob=profile_image,
>> upload_ts = datetime.now(),
>> change_ts = datetime.now()
>> )
>> 
>>
>>
>> The same result is received from using urllib2 instead of urlfetch.
>>
>

[web2py] Re: Crappy downloaded image names

2012-06-18 Thread Anthony

>
> and the my show_image function is :
>
> def show_image():
> return response.download(request,dal_db)
>

That's the problem -- response.download() calls dal.Field.retrieve(), which 
assumes the filename is encoded via base64.b16encode (i.e., it assumes the 
file was stored using dal.Field.store(), which encodes the filename). 
Instead of manually creating the filename, you could use this procedure: 
http://web2py.com/books/default/chapter/29/6#Manual-uploads. Just make the 
filename exactly what you want the downloaded filename to be (including the 
extension), and do the insert into the upload field -- it should 
automatically create the encoded name, store the name in the upload field, 
and store the image in the blob field. In this case, the image should be a 
file stream, and I think fetch will return a string, so you might need to 
do:

import cStringIO
profile_image = cStringIO.StringIO(result.content)

Anthony


[web2py] Re: Users Poll: To keep the button look for the welcome app's auth options, or not ?

2012-06-18 Thread Omi Chiba
Absolutely b1! but how about change color to WHITE ? 
It will match the color on the left corner, such as menus, and blue link is 
hard to see on the black background.


On Saturday, June 16, 2012 10:30:04 PM UTC-5, Andrew wrote:
>
> A  week or two ago a change was made to the nav bar to give the auth 
> buttons for Login, Register, etc   a button look.   This was part of the 
> fix to the dropdown menus to get them to work with bootstrap.  Another 
> change was made to revert back to the old look (but only as an attachment 
> to a previous post in this list).  
>
> There are two screen shots, current welcome app, and with the buttons 
> reverted to the old look.
>
> Credit to Paolo for making both changes.  Given that the buttons have been 
> in trunk for a while, it is worth getting a consensus to keep it or revert 
> it.  So:
>
> *Vote:*
> *A) KEEP THE BUTTON LOOK*
> *B) REVERT TO THE OLD LOOK*
> *
> *
> *if B) *
> *
> *
> *B.1) Revert to the Pipe separator between the options (as shown)*
> *B.2) Don't include the Pipe separator.*
>
>
> B.1) involves updating a recent patch to layout.html:
> {{='auth' in globals() and auth.navbar(separators=(' ',' 
> | ','')) or ''}}
>
> A patch for B.1) has already been sent to Massimo (that's my vote :) ) , 
> but let's see what the general feeling is.
>
> Thanks
>


[web2py] Re: Users Poll: To keep the button look for the welcome app's auth options, or not ?

2012-06-18 Thread Omi Chiba
Never mind, I just confirmed it's WHITE in the latest trunk.

On Monday, June 18, 2012 8:51:29 AM UTC-5, Omi Chiba wrote:
>
> Absolutely b1! but how about change color to WHITE ? 
> It will match the color on the left corner, such as menus, and blue link 
> is hard to see on the black background.
>
>
> On Saturday, June 16, 2012 10:30:04 PM UTC-5, Andrew wrote:
>>
>> A  week or two ago a change was made to the nav bar to give the auth 
>> buttons for Login, Register, etc   a button look.   This was part of the 
>> fix to the dropdown menus to get them to work with bootstrap.  Another 
>> change was made to revert back to the old look (but only as an attachment 
>> to a previous post in this list).  
>>
>> There are two screen shots, current welcome app, and with the buttons 
>> reverted to the old look.
>>
>> Credit to Paolo for making both changes.  Given that the buttons have 
>> been in trunk for a while, it is worth getting a consensus to keep it or 
>> revert it.  So:
>>
>> *Vote:*
>> *A) KEEP THE BUTTON LOOK*
>> *B) REVERT TO THE OLD LOOK*
>> *
>> *
>> *if B) *
>> *
>> *
>> *B.1) Revert to the Pipe separator between the options (as shown)*
>> *B.2) Don't include the Pipe separator.*
>>
>>
>> B.1) involves updating a recent patch to layout.html:
>> {{='auth' in globals() and auth.navbar(separators=(' ',' 
>> | ','')) or ''}}
>>
>> A patch for B.1) has already been sent to Massimo (that's my vote :) ) , 
>> but let's see what the general feeling is.
>>
>> Thanks
>>
>

Re: [web2py] Re: Users Poll: To keep the button look for the welcome app's auth options, or not ?

2012-06-18 Thread Richard Vézina
+1 option to use them!

Richard

On Sun, Jun 17, 2012 at 4:45 PM, Cliff Kachinske  wrote:

> I agree that the old look, with dividers, *looks* better.
>
> I also think the buttons are easier to find on the page, so I would like
> to optionally use them.
>
> Would you take a patch with the option?
>
>
> On Saturday, June 16, 2012 11:30:04 PM UTC-4, Andrew wrote:
>
>> A  week or two ago a change was made to the nav bar to give the auth
>> buttons for Login, Register, etc   a button look.   This was part of the
>> fix to the dropdown menus to get them to work with bootstrap.  Another
>> change was made to revert back to the old look (but only as an attachment
>> to a previous post in this list).
>>
>> There are two screen shots, current welcome app, and with the buttons
>> reverted to the old look.
>>
>> Credit to Paolo for making both changes.  Given that the buttons have
>> been in trunk for a while, it is worth getting a consensus to keep it or
>> revert it.  So:
>>
>> *Vote:*
>> *A) KEEP THE BUTTON LOOK*
>> *B) REVERT TO THE OLD LOOK*
>> *
>> *
>> *if B) *
>> *
>> *
>> *B.1) Revert to the Pipe separator between the options (as shown)*
>> *B.2) Don't include the Pipe separator.*
>>
>>
>> B.1) involves updating a recent patch to layout.html:
>> {{='auth' in globals() and auth.navbar(separators=(' ','
>> | ','')) or ''}}
>>
>> A patch for B.1) has already been sent to Massimo (that's my vote :) ) ,
>> but let's see what the general feeling is.
>>
>> Thanks
>>
>


Re: [web2py] Infinite loop: Auth using OAuth2 with Facebook

2012-06-18 Thread Alec Taylor
It seems to all work on facebook's side, I think there is something
wrong with the aforementioned implementation I used.

Can you review the ~20 lines of code and its positioning to highlight
the problem?

Thanks a heap

On Sun, Jun 17, 2012 at 11:02 PM, Michele Comitini
 wrote:
> Alec,
>
> There could be many reason for that behavior.  Two are common:
> 1. For some reason facebook does not grant access to your application,
> ex. domain name mismatch. If are you trying on localhost that should
> not happen.
> 2. Some problem with cookies, clean the cookies and/or try a different
> browser, be sure the browser accepts cookies.
>
> mic
>
>
> 2012/6/16 Alec Taylor :
>> Unfortunately I haven't been able to get Facebook login with OAuth2 working.
>>
>> I've created a tiny test-case below with the problem.
>>
>> The only major changes I have made is to models/db.py with a minor
>> function (foobar) in controllers/default.py.
>>
>> https://gist.github.com/9967cb95fe026890dae7
>>
>> I have placed the facebook.py file in the modules folder and the
>> CLIENT_ID and CLIENT_SECRET in another .py file in my modules
>> directory [file starts with `from gluon import *`].
>>
>> Please tell me how I can get this to work.
>>
>> Thanks for all suggestions,
>>
>> Alec Taylor
>>
>> FYI: Not showing a ticket because it actually is stuck in an infinite
>> loop. However when I take out the `@auth.requires_login()` decorator
>> before the `foobar` function the page loads, but "Login" still appears
>> in the top-right.


[web2py] Re: Crappy downloaded image names

2012-06-18 Thread Sushant Taneja
Will this work on AppEngine ? Since there is no filesystem

The code for manual uploads is :

stream = open(filename,'rb')

Will this not give error since it will not be able to find the file ? 

On Monday, June 18, 2012 6:52:02 PM UTC+5:30, Anthony wrote:
>
> and the my show_image function is :
>>
>> def show_image():
>> return response.download(request,dal_db)
>>
>
> That's the problem -- response.download() calls dal.Field.retrieve(), 
> which assumes the filename is encoded via base64.b16encode (i.e., it 
> assumes the file was stored using dal.Field.store(), which encodes the 
> filename). Instead of manually creating the filename, you could use this 
> procedure: http://web2py.com/books/default/chapter/29/6#Manual-uploads. 
> Just make the filename exactly what you want the downloaded filename to be 
> (including the extension), and do the insert into the upload field -- it 
> should automatically create the encoded name, store the name in the upload 
> field, and store the image in the blob field. In this case, the image 
> should be a file stream, and I think fetch will return a string, so you 
> might need to do:
>
> import cStringIO
> profile_image = cStringIO.StringIO(result.content)
>
> Anthony
>


[web2py] Re: Crappy downloaded image names

2012-06-18 Thread Sushant Taneja
Sorry got confused.
Made it work !

Here is the final code :

dal_db.UserImageStore.insert(profile_image = 
dal_db.UserImageStore.profile_image.store(profile_image,),
profile_blob = profile_image,
upload_ts = datetime.now(),
change_ts = datetime.now()
)

Thanks Anthony !

On Monday, June 18, 2012 8:28:25 PM UTC+5:30, Sushant Taneja wrote:
>
> Will this work on AppEngine ? Since there is no filesystem
>
> The code for manual uploads is :
>
> stream = open(filename,'rb')
>
> Will this not give error since it will not be able to find the file ? 
>
> On Monday, June 18, 2012 6:52:02 PM UTC+5:30, Anthony wrote:
>>
>> and the my show_image function is :
>>>
>>> def show_image():
>>> return response.download(request,dal_db)
>>>
>>
>> That's the problem -- response.download() calls dal.Field.retrieve(), 
>> which assumes the filename is encoded via base64.b16encode (i.e., it 
>> assumes the file was stored using dal.Field.store(), which encodes the 
>> filename). Instead of manually creating the filename, you could use this 
>> procedure: http://web2py.com/books/default/chapter/29/6#Manual-uploads. 
>> Just make the filename exactly what you want the downloaded filename to be 
>> (including the extension), and do the insert into the upload field -- it 
>> should automatically create the encoded name, store the name in the upload 
>> field, and store the image in the blob field. In this case, the image 
>> should be a file stream, and I think fetch will return a string, so you 
>> might need to do:
>>
>> import cStringIO
>> profile_image = cStringIO.StringIO(result.content)
>>
>> Anthony
>>
>

[web2py] Re: Crappy downloaded image names

2012-06-18 Thread Anthony
Actually, on GAE, I don't think you have to explicitly define the blob 
field at all -- the DAL will automatically create a blob field for each 
upload field and store uploaded files in the blob field. So, I think this 
should work:

dal_db.define_table('UserImageStore',
Field('profile_image', 'upload'),
Field('upload_ts', 'datetime'),
Field('change_ts', 'datetime'))

dal_db.UserImageStore.insert(
profile_image=dal_db.UserImageStore.profile_image.store(profile_image, 
),
upload_ts=datetime.now(),
change_ts=datetime.now())

Anthony

On Monday, June 18, 2012 11:09:54 AM UTC-4, Sushant Taneja wrote:
>
> Sorry got confused.
> Made it work !
>
> Here is the final code :
>
> dal_db.UserImageStore.insert(profile_image = 
> dal_db.UserImageStore.profile_image.store(profile_image, give>),
> profile_blob = profile_image,
> upload_ts = datetime.now(),
> change_ts = datetime.now()
> )
>
> Thanks Anthony !
>
> On Monday, June 18, 2012 8:28:25 PM UTC+5:30, Sushant Taneja wrote:
>>
>> Will this work on AppEngine ? Since there is no filesystem
>>
>> The code for manual uploads is :
>>
>> stream = open(filename,'rb')
>>
>> Will this not give error since it will not be able to find the file ? 
>>
>> On Monday, June 18, 2012 6:52:02 PM UTC+5:30, Anthony wrote:
>>>
>>> and the my show_image function is :

 def show_image():
 return response.download(request,dal_db)

>>>
>>> That's the problem -- response.download() calls dal.Field.retrieve(), 
>>> which assumes the filename is encoded via base64.b16encode (i.e., it 
>>> assumes the file was stored using dal.Field.store(), which encodes the 
>>> filename). Instead of manually creating the filename, you could use this 
>>> procedure: http://web2py.com/books/default/chapter/29/6#Manual-uploads. 
>>> Just make the filename exactly what you want the downloaded filename to be 
>>> (including the extension), and do the insert into the upload field -- it 
>>> should automatically create the encoded name, store the name in the upload 
>>> field, and store the image in the blob field. In this case, the image 
>>> should be a file stream, and I think fetch will return a string, so you 
>>> might need to do:
>>>
>>> import cStringIO
>>> profile_image = cStringIO.StringIO(result.content)
>>>
>>> Anthony
>>>
>>

[web2py] how can I pick a directory from a web2py form (equivalent to WxDirPickerCtrl)

2012-06-18 Thread Janath
I need a control in a form which allows me to browse and select a directory 
(folder).

any clue is appreciated!
Janath


[web2py] Web2Py compute fields not working on update

2012-06-18 Thread Brandon Reynolds
I have this problem when i try to generate thumbnails. If the field is 
empty it inserts the photo thumb into the thumbnail. But when i try to 
update that record the thumbnail doesn't change. 

Here is my model:

# coding: utf8
from image import THUMBER

db.define_table('park', 
Field('park_name', requires=IS_NOT_EMPTY()),
Field('park_city', requires=IS_NOT_EMPTY()),
Field('park_state', requires=IS_NOT_EMPTY()),
Field('park_address', requires=IS_NOT_EMPTY()),
Field('park_zip', requires=IS_NOT_EMPTY()),
Field('country', default="USA", notnull=True, readable=False, 
writable=False),
Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
]+'))),
Field('photo1', 'upload'),
Field('photo_thumb1', 'upload', readable=False, writable=False),
Field('photo2', 'upload'),
Field('photo_thumb2', 'upload', readable=False, writable=False),
Field('photo3', 'upload'),
Field('photo_thumb3', 'upload', readable=False, writable=False),
Field('photo4', 'upload'),
Field('photo_thumb4', 'upload', readable=False, writable=False),
Field('photo5', 'upload'),
Field('photo_thumb5', 'upload', readable=False, writable=False),
Field('manager', requires=IS_NOT_EMPTY()),
Field('manager_email', requires=IS_EMAIL()),
Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
Field('vacant', 'integer'),
Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
Field('water', 'boolean'),
Field('sewer', 'boolean'),
Field('trash', 'boolean'),
Field('pool', 'boolean'),
Field('playground', 'boolean'),
Field('clubhouse', 'boolean'),
Field('laundromat', 'boolean'),
Field('rv_spaces', 'boolean'),
Field('storage', 'boolean'),
Field('handicap_accessible', 'boolean'),
Field('community_description', 'text'),
format='%(park_name)s')

db.define_table('home', 
Field('pid', notnull=True, readable=False, writable=False),
Field('lot'),
Field('year', length=4, requires=IS_NOT_EMPTY()),
Field('make'),
Field('model'),
Field('width', requires=IS_NOT_EMPTY()),
Field('length', requires=IS_NOT_EMPTY()),
Field('wide', requires=IS_NOT_EMPTY()),
Field('for_sale', 'boolean', default=True),
Field('beds', requires=IS_NOT_EMPTY()),
Field('baths', requires=IS_NOT_EMPTY()),
Field('fridge', 'boolean'),
Field('stove', 'boolean'),
Field('dishwasher', 'boolean'),
Field('microwave', 'boolean'),
Field('washer', 'boolean'),
Field('dryer', 'boolean'),
Field('photo1', 'upload'),
Field('photo1_text'),
Field('photo_thumb1', 'upload', readable=False, writable=False),
Field('photo2', 'upload'),
Field('photo2_text'),
Field('photo_thumb2', 'upload', readable=False, writable=False),
Field('photo3', 'upload'),
Field('photo3_text'),
Field('photo_thumb3', 'upload', readable=False, writable=False),
Field('photo4', 'upload'),
Field('photo4_text'),
Field('photo_thumb4', 'upload', readable=False, writable=False),
Field('photo5', 'upload'),
Field('photo5_text'),
Field('photo_thumb5', 'upload', readable=False, writable=False),
Field('price',requires=IS_NOT_EMPTY()),
Field('description', 'text', requires=IS_NOT_EMPTY()),
Field('posted_on', 'datetime', readable=False, writable=False))

db.define_table('state',
Field('name'),
Field('full_name'))

db.define_table('wide',
Field('type'),
format='%(type)s')


db.park.park_state.requires = IS_IN_DB(db, 'state.name', '%(full_name)s 
(%(name)s)', zero=T('Select State'))
db.home.wide.requires = IS_IN_DB(db, 'wide.type', '%(type)s', 
zero=T('Select Home Type'))

db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
"photo_thumb1", 144, 115)
db.park.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
"photo_thumb2", 144, 115)
db.park.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
"photo_thumb3", 144, 115)
db.park.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
"photo_thumb4", 144, 115)
db.park.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
"photo_thumb5", 144, 115)
db.home.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
"photo_thumb1", 144, 115)
db.home.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
"photo_thumb2", 144, 115)
db.home.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
"photo_thumb3", 144, 115)
db.home.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
"photo_thumb4", 144, 115)
db.home.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
"photo_thumb5", 144, 115)


Here is my controller:

def index():
return locals()

def parks():
if request.args(0):
parks = 
db(db.park.park_state==request.args(0)).select(orderby=db.park.park_city|db.park.park_name)
else:
parks = 
db(db.park).select(orderby=db.park.park_state|db.park.park_city|db.park.park_name)
return locals()

def park():
park = db.park(request.args(0)) or redirect(URL('parks'))
homes = db(db.home.pid==(request.args(0))).select(orderby=db.home.id)
return locals()

def home():
home = db.home(request.args(0)) or redirect(URL('parks'))
par

[web2py] uwsgi enable-thread option and web2py

2012-06-18 Thread mrtn

I'm deploying web2py with uwsgi 1.2.3, and upon starting the app, there is 
message in the uwsgi log says;

*** Python threads support is disabled. You can enable it with --enable-threads 
***

And in the uwsgi doc, it says the following for option enable-thread:

Enable threads in the embedded languages. This will allow to spawn threads 
in your app.

I wonder if I really need this enabled for web2py. If so, what would be a 
common use case for it. Thanks. 




[web2py] Re: how can I pick a directory from a web2py form (equivalent to WxDirPickerCtrl)

2012-06-18 Thread Anthony
>From what I've read, this is not possible in HTML/Javascript from a browser 
(you can select a file, but not a folder path). Apparently it can be done 
via a Java applet, ActiveX plugin, or Flash.

Anthony

On Monday, June 18, 2012 11:52:06 AM UTC-4, Janath wrote:
>
> I need a control in a form which allows me to browse and select a 
> directory (folder).
>
> any clue is appreciated!
> Janath
>


[web2py] count current visitors

2012-06-18 Thread ctrlSoft
hi, how to count current site visitors? smth like in google analitycs ... 
real-time visitors.

Re: [web2py] count current visitors

2012-06-18 Thread Richard Vézina
There is this :
http://web2py.com/books/default/chapter/29/3?search=say#Let's-count



On Mon, Jun 18, 2012 at 2:16 PM, ctrlSoft  wrote:

> hi, how to count current site visitors? smth like in google analitycs ...
> real-time visitors.


Re: [web2py] count current visitors

2012-06-18 Thread Richard Vézina
Or more like google analytic there is the python Piwik : http://piwik.org/

Richard

On Mon, Jun 18, 2012 at 2:23 PM, Richard Vézina  wrote:

> There is this :
> http://web2py.com/books/default/chapter/29/3?search=say#Let's-count
>
>
>
> On Mon, Jun 18, 2012 at 2:16 PM, ctrlSoft  wrote:
>
>> hi, how to count current site visitors? smth like in google analitycs ...
>> real-time visitors.
>
>
>


[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-06-18 Thread Massimo Di Pierro
How is that possible? You edited bootswatch.css?

On Monday, 18 June 2012 05:24:36 UTC-5, Paolo Caruccio wrote:
>
> Massimo,
>
> actually files with prefix V2_ allow this: download and apply in w2p a 
> bootswacth theme without other actions by user.
>
>
> Il giorno lunedì 18 giugno 2012 06:39:23 UTC+2, Massimo Di Pierro ha 
> scritto:
>>
>> I included your patch but not version V2. That is because we do not want 
>> to mantain our own modified bootswatch. People should be able to download a 
>> theme and use it without editing. Can this be addressed in web2py.css?
>>
>> On Sunday, 17 June 2012 18:42:12 UTC-5, LightDot wrote:
>>>
>>> I have tested the V2 versions attached with Issue 856 and they seem to 
>>> address the issues perfectly.
>>>
>>> Regards
>>>
>>> On Sunday, June 17, 2012 9:14:33 PM UTC+2, Paolo Caruccio wrote:

 Patch submitted http://code.google.com/p/web2py/issues/detail?id=856

 Il giorno domenica 17 giugno 2012 17:32:53 UTC+2, Massimo Di Pierro ha 
 scritto:
>
> Can you coordinate with Andrew and Paolo and send me a single fix that 
> applies to latest trunk and addresses the outstanding issues?
>
> On Sunday, 17 June 2012 08:42:50 UTC-5, LightDot wrote:
>>
>> I have tried your updated bootswatch.css from another thread here, 
>> which also incorporates this fix. I confirm that BS 2.0.4 works now.
>>
>> Thanks!
>>
>> On Sunday, June 17, 2012 12:33:52 AM UTC+2, Paolo Caruccio wrote:
>>>
>>> LightDot,
>>>
>>>  try to append in static/css/bootswatch.css this rule:
>>>
>>> .dropdown-menu ul{display:block;}
>>>
>>> I spotted the issue some days ago, but I didn't propose a patch 
>>> because web2py still has bs 2.0.2
>>>
>>> Let me know if the fix works for you also.
>>>
>>> Il giorno domenica 17 giugno 2012 00:27:18 UTC+2, LightDot ha 
>>> scritto:

 Changes in dev in the last week or so have effect on Bootstrap. 2nd 
 level submenus don't work anymore if using Bootstrap 2.0.4, while 
 bundled 
 2.0.2 works.

 - clean welcome app from latest dev, Bootstrap css and js upgraded 
 to 2.0.4
 - clicking over the yellow "web2py" opens the first submenu level
 - clicking or hovering over e.g. Documentation, does nothing.

 Tested in Firefox 13 and Opera 12... Are there plans to update 
 Bootstrap to 2.0.4 in web2py itself?

 Regards


 On Friday, June 15, 2012 4:49:29 PM UTC+2, Paolo Caruccio wrote:
>
> Andrew, do you mean the code for old auth_navbar style? If yes, I 
> think it's better if you open a new thread for asking to the web2py 
> users 
> what style they prefer and after we will send a patch to Massimo. 
> It's 
> possible that most of w2p users loves the current style (bootstrap 
> buttons 
> group).
>
> Il giorno giovedì 14 giugno 2012 22:55:38 UTC+2, Andrew ha scritto:
>>
>> Hi Paolo,
>>
>> Are you able to send a patch to Massimo for your layout and 
>> bootswatch files.  The bootstrap menu issue is holdnig up 2.0 and I 
>> think 
>> your changes have addressed this.   Would love to see it in trunk.
>>
>> If you can't I can have a go at working out what you did.
>>
>> Thanks
>>
>> Andrew W
>>
>>
>>
>> On Thursday, June 7, 2012 8:24:44 PM UTC+12, Paolo Caruccio wrote:
>>>
>>> I'm afraid you can not do it. The first item in the dropdown 
>>> menu (having class="dropdown") can not contain an URL. The 
>>> structure of the 
>>> dropdown menu is as follows (taken from this page 
>>> http://twitter.github.com/bootstrap/components.html#navbar):
>>>
>>> Adding dropdown menus
>>>
>>> Adding dropdowns and dropups to the nav is super simple, but 
>>> does require the use of our javascript 
>>> plugin
>>> .
>>>
>>>
>>>1. 
>>>2.   
>>>3. >>4.   class="dropdown-toggle"
>>>5.   data-toggle="dropdown">
>>>6.   Account
>>>7.   
>>>8. 
>>>9. 
>>>10.   ...
>>>11. 
>>>12.   
>>>13. 
>>>
>>>
>>> Il giorno giovedì 7 giugno 2012 04:13:19 UTC+2, LightDot ha 
>>> scritto:

 I can confirm this, using fresh welcome application and 
 Bootstrap upgraded to 2.0.4.

 If a menu item has both an URL specified and also additional 
 submenus, these don

[web2py] Re: Problem while using two sqlform.grid in a single form

2012-06-18 Thread Massimo Di Pierro
You cannot have two grids in the same page.

On Monday, 18 June 2012 06:09:24 UTC-5, rahulserver wrote:
>
> I tried to use two sqlform.grid in a web2py form. It does work as intended 
> except for the problem that when I try to edit on of the form's row, other 
> form's row with same Id also appears to be edited. How should i stop it?
> my controller:
> def CommitmentBrowse_rep():
> rows=db(db.Commitments.Account==session.id).select()
> commtot=0
> compen=0
> comfull=0
> for row in rows:
> commtot=commtot+int(row.Amount)
> if row.pending:
> compen=compen+int(row.Amount)
> else:
> comfull=comfull+int(row.Amount)
> 
> rows=db(db.Transaction_Master.Account==session.id).select()
> netdue=0
> for row in rows:
> netdue=netdue+int(row.Net_Due)
> 
> pay=0
> rows=db(db.Payments.Account==session.id).select()
> for row in rows:
> pay=pay+int(row.Amount)
> a=[]
> b=[]
> count=0
> a.append([TH('Due Amount'),TH('Commited Amount'),TH('Commitment 
> Fulfilled'),TH('Commitment Pending'),TH('Uncommitted Amount'),TH('Payments 
> Received')])
> a.append([netdue,commtot,comfull,compen,pay])
> COMMITMENTS=SQLFORM.grid(db.Commitments.Account==session.id
> ,user_signature=False)
> PAYMENTS=SQLFORM.grid(db.Payments.Account==session.id
> ,user_signature=False)
> return dict(COMMITMENTS=COMMITMENTS,PAYMENTS=PAYMENTS,SUMMARY=TABLE(a))
>


Re: [web2py] Re: Web2py RAM usage

2012-06-18 Thread Massimo Di Pierro
Currently there is not built-in way to limit memory usage. You can expire 
it but does not get deleted, only overwritten. You can explicitly delete an 
item from the cache using cache.ram.clear(regex) clears all items with ket 
matching regex.

On Monday, 18 June 2012 07:42:06 UTC-5, Lucas R. Martins wrote:
>
> i'm not using web2py-level caching, but i would like to use, if i can 
> limit memory usage and expire it when i need.
> i have compiled app and i'm using sqlite. sqlite is a problem?
>
>
> 2012/6/18 Massimo Di Pierro 
>
>> Are you using caching? Are you using sqlite? We should nail down the 
>> cause of this problem.
>> Did you try to bytecode compile the app?
>>
>> Massimo
>>
>>
>> On Sunday, 17 June 2012 21:17:01 UTC-5, Lucas R. Martins wrote:
>>>
>>> Hi guys,
>>>
>>> I'm running a website with ~ 900 urls and no many daily access in a 
>>> small vps. I have observed that, when a start the server, this use only 
>>> 10mb, in my case.
>>>
>>> However, with the time and natural access (specially googlebot), the 
>>> server memory usage grow and grows indefinitely until use all server 
>>> memory.
>>>
>>> There is anything to do to limit web2py memory usage and force it to 
>>> free unused memory? There is any kind of internal ram cache which can be 
>>> disabled?
>>>
>>>
>>>
>>> Thanks.
>>>
>>
>

[web2py] Re: Web2Py compute fields not working on update

2012-06-18 Thread Massimo Di Pierro
Let me understand this better.

on insert, the thumbnails are created.
on update, if you upload a new photo1 is photo_thing1 generated? 

Can you provide a simpler code to reproduce the problem with a just one 
upload field and one thumbnail field?

massimo




On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:
>
> I have this problem when i try to generate thumbnails. If the field is 
> empty it inserts the photo thumb into the thumbnail. But when i try to 
> update that record the thumbnail doesn't change. 
>
> Here is my model:
>
> # coding: utf8
> from image import THUMBER
>
> db.define_table('park', 
> Field('park_name', requires=IS_NOT_EMPTY()),
> Field('park_city', requires=IS_NOT_EMPTY()),
> Field('park_state', requires=IS_NOT_EMPTY()),
> Field('park_address', requires=IS_NOT_EMPTY()),
> Field('park_zip', requires=IS_NOT_EMPTY()),
> Field('country', default="USA", notnull=True, readable=False, 
> writable=False),
> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
> ]+'))),
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('manager', requires=IS_NOT_EMPTY()),
> Field('manager_email', requires=IS_EMAIL()),
> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
> Field('vacant', 'integer'),
> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
> Field('water', 'boolean'),
> Field('sewer', 'boolean'),
> Field('trash', 'boolean'),
> Field('pool', 'boolean'),
> Field('playground', 'boolean'),
> Field('clubhouse', 'boolean'),
> Field('laundromat', 'boolean'),
> Field('rv_spaces', 'boolean'),
> Field('storage', 'boolean'),
> Field('handicap_accessible', 'boolean'),
> Field('community_description', 'text'),
> format='%(park_name)s')
>
> db.define_table('home', 
> Field('pid', notnull=True, readable=False, writable=False),
> Field('lot'),
> Field('year', length=4, requires=IS_NOT_EMPTY()),
> Field('make'),
> Field('model'),
> Field('width', requires=IS_NOT_EMPTY()),
> Field('length', requires=IS_NOT_EMPTY()),
> Field('wide', requires=IS_NOT_EMPTY()),
> Field('for_sale', 'boolean', default=True),
> Field('beds', requires=IS_NOT_EMPTY()),
> Field('baths', requires=IS_NOT_EMPTY()),
> Field('fridge', 'boolean'),
> Field('stove', 'boolean'),
> Field('dishwasher', 'boolean'),
> Field('microwave', 'boolean'),
> Field('washer', 'boolean'),
> Field('dryer', 'boolean'),
> Field('photo1', 'upload'),
> Field('photo1_text'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo2_text'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo3_text'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo4_text'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo5_text'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('price',requires=IS_NOT_EMPTY()),
> Field('description', 'text', requires=IS_NOT_EMPTY()),
> Field('posted_on', 'datetime', readable=False, writable=False))
>
> db.define_table('state',
> Field('name'),
> Field('full_name'))
>
> db.define_table('wide',
> Field('type'),
> format='%(type)s')
>
>
> db.park.park_state.requires = IS_IN_DB(db, 'state.name', '%(full_name)s 
> (%(name)s)', zero=T('Select State'))
> db.home.wide.requires = IS_IN_DB(db, 'wide.type', '%(type)s', 
> zero=T('Select Home Type'))
>
> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.park.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.park.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
> "photo_thumb3", 144, 115)
> db.park.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
> "photo_thumb4", 144, 115)
> db.park.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
> "photo_thumb5", 144, 115)
> db.home.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.home.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.home.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
> "photo_thumb3", 144, 115)
> db.home.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
> "photo_thumb4", 144, 115)
> db.home.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
> "photo_thumb5", 144, 115)
>
>
> Here is my controller:
>
> def ind

[web2py] Re: uwsgi enable-thread option and web2py

2012-06-18 Thread Massimo Di Pierro
There are pros and cons. If you use threads in a python program, the more 
computing cores you have, the slower - not faster - the program gets. This 
is a python feature because even if you have threads, there is only one 
interpreted and therefore execution is serialized anyway. For scalability 
you should have processes (not threads) one per core.

On Monday, 18 June 2012 11:34:39 UTC-5, mrtn wrote:
>
>
> I'm deploying web2py with uwsgi 1.2.3, and upon starting the app, there is 
> message in the uwsgi log says;
>
> *** Python threads support is disabled. You can enable it with 
> --enable-threads 
> ***
>
> And in the uwsgi doc, it says the following for option enable-thread:
>
> Enable threads in the embedded languages. This will allow to spawn 
> threads in your app.
>
> I wonder if I really need this enabled for web2py. If so, what would be a 
> common use case for it. Thanks. 
>
>
>

[web2py] Re: Web2Py compute fields not working on update

2012-06-18 Thread Brandon Reynolds
In a new record a thumbnail is correctly generated from photo. But if I 
didn't upload a photo or want to change the photo the thumbnail doesn't 
generate. So basically a new record works properly but when updating 
nothing in the thumbnail changes at all whether or not is currently has a 
photo in it. 


model:

from image import THUMBER
db.define_table('park', 
Field('photo1', 'upload'),
Field('photo_thumb1', 'upload', readable=False, writable=False))

db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
"photo_thumb1", 144, 115)


image.py:

from gluon import current
 
def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
if image:
try:
request = current.request
from PIL import Image
import os
img = Image.open(request.folder + 'uploads/' + image)
img.db_photo_var((nx, ny), Image.ANTIALIAS)
root, ext = os.path.splitext(image)
thumb = '%s_%s%s' % (root, name, ext)
img.save(request.folder + 'uploads/' + thumb)
return thumb
except Exception:
return image
   


On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:
>
> Let me understand this better.
>
> on insert, the thumbnails are created.
> on update, if you upload a new photo1 is photo_thing1 generated? 
>
> Can you provide a simpler code to reproduce the problem with a just one 
> upload field and one thumbnail field?
>
> massimo
>
>
>
>
> On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:
>>
>> I have this problem when i try to generate thumbnails. If the field is 
>> empty it inserts the photo thumb into the thumbnail. But when i try to 
>> update that record the thumbnail doesn't change. 
>>
>> Here is my model:
>>
>> # coding: utf8
>> from image import THUMBER
>>
>> db.define_table('park', 
>> Field('park_name', requires=IS_NOT_EMPTY()),
>> Field('park_city', requires=IS_NOT_EMPTY()),
>> Field('park_state', requires=IS_NOT_EMPTY()),
>> Field('park_address', requires=IS_NOT_EMPTY()),
>> Field('park_zip', requires=IS_NOT_EMPTY()),
>> Field('country', default="USA", notnull=True, readable=False, 
>> writable=False),
>> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
>> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
>> ]+'))),
>> Field('photo1', 'upload'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>> Field('photo2', 'upload'),
>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>> Field('photo3', 'upload'),
>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>> Field('photo4', 'upload'),
>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>> Field('photo5', 'upload'),
>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>> Field('manager', requires=IS_NOT_EMPTY()),
>> Field('manager_email', requires=IS_EMAIL()),
>> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
>> Field('vacant', 'integer'),
>> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
>> Field('water', 'boolean'),
>> Field('sewer', 'boolean'),
>> Field('trash', 'boolean'),
>> Field('pool', 'boolean'),
>> Field('playground', 'boolean'),
>> Field('clubhouse', 'boolean'),
>> Field('laundromat', 'boolean'),
>> Field('rv_spaces', 'boolean'),
>> Field('storage', 'boolean'),
>> Field('handicap_accessible', 'boolean'),
>> Field('community_description', 'text'),
>> format='%(park_name)s')
>>
>> db.define_table('home', 
>> Field('pid', notnull=True, readable=False, writable=False),
>> Field('lot'),
>> Field('year', length=4, requires=IS_NOT_EMPTY()),
>> Field('make'),
>> Field('model'),
>> Field('width', requires=IS_NOT_EMPTY()),
>> Field('length', requires=IS_NOT_EMPTY()),
>> Field('wide', requires=IS_NOT_EMPTY()),
>> Field('for_sale', 'boolean', default=True),
>> Field('beds', requires=IS_NOT_EMPTY()),
>> Field('baths', requires=IS_NOT_EMPTY()),
>> Field('fridge', 'boolean'),
>> Field('stove', 'boolean'),
>> Field('dishwasher', 'boolean'),
>> Field('microwave', 'boolean'),
>> Field('washer', 'boolean'),
>> Field('dryer', 'boolean'),
>> Field('photo1', 'upload'),
>> Field('photo1_text'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>> Field('photo2', 'upload'),
>> Field('photo2_text'),
>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>> Field('photo3', 'upload'),
>> Field('photo3_text'),
>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>> Field('photo4', 'upload'),
>> Field('photo4_text'),
>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>> Field('photo5', 'upload'),
>> Field('photo5_text'),
>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>> Field('price',requires=IS_NOT_EMPTY()),
>> Field('description', 'text', re

[web2py] Re: GAE query cursors

2012-06-18 Thread howesc
thanks!  now how do i go about updating the book to discuss these new 
features?

On Sunday, June 17, 2012 9:09:33 PM UTC-7, Massimo Di Pierro wrote:
>
> uploading :-)
>
> On Sunday, 17 June 2012 10:40:51 UTC-5, howesc wrote:
>>
>> sorry if i confused you by submitting 2 non-inclusive patches. :(  the 
>> reference patch for 
>> https://groups.google.com/forum/?fromgroups#!topic/web2py/mKgLFC5pxcY is 
>> what you applied, and with your change still works for me.
>>
>> if the cursor patch in this thread looks ok can you add it as well?  this 
>> is the same patch file with updated line numbers for tip of tunk.
>>
>> thanks!
>>
>> christian
>>
>> On Saturday, June 16, 2012 3:04:00 PM UTC-7, Massimo Di Pierro wrote:
>>>
>>> In trunk with a minor change. Please make sure I did not break your 
>>> patch.
>>>
>>> massimo
>>>
>>> On Saturday, 16 June 2012 13:59:34 UTC-5, howesc wrote:

 Hello again,

 I wanna use cursors on my GAE queries: 
 https://developers.google.com/appengine/docs/python/datastore/queries#Query_Cursors

 i have attached a patch that adds an optional parameter "reusecursor" 
 to select on GAE.  If True, and the query has a limitby, it indicates that 
 db['_lastcursor'] will have the cursor (i didn't want to store it if you 
 are not gonna use it because i'm not sure of the cost of getting that 
 cursor).  If a reusecursor is a string that string will be passed to the 
 GAE query as the cursor.  Note that you must use limitby on all queries 
 that you want to return the cursor for, and that queries that use a cursor 
 must have the exact same filters.  Keep in mind that limitby will be in 
 relation to the cursor, so in most cases you want offset of 0.

 my suggested patch is attached.  i welcome comments.

 example:

 def test3():
 cursor = request.vars.cursor or True

 #say the manu_item has about a hundred rows
 rows = db(db.menu_item.id>0).select(reusecursor=cursor, 
 limitby=(0,10))
 cursor = db['_lastcursor']
 next_link = A('next', _href=URL(r=request, vars={'cursor':cursor}))
 
 
 # Use generic HTML views
 response.generic_patterns = ['html']
 return dict(
 rows=rows,
 cursor=cursor,
 next_link = next_link)

 thanks,

 christian

>>>

Re: [web2py] Re: Problem while using two sqlform.grid in a single form

2012-06-18 Thread Jonathan Lundell
On Jun 18, 2012, at 3:06 PM, Massimo Di Pierro wrote:
> You cannot have two grids in the same page.

I'm using two grids on a page. It seemed all I needed to do was specify 
different formnames and it seemed to work. The second table is pretty much 
read-only, but it does have a paging control, and that works. What should I 
expect to go wrong?

> 
> On Monday, 18 June 2012 06:09:24 UTC-5, rahulserver wrote:
> I tried to use two sqlform.grid in a web2py form. It does work as intended 
> except for the problem that when I try to edit on of the form's row, other 
> form's row with same Id also appears to be edited. How should i stop it?
> my controller:
> def CommitmentBrowse_rep():
> rows=db(db.Commitments.Account==session.id).select()
> commtot=0
> compen=0
> comfull=0
> for row in rows:
> commtot=commtot+int(row.Amount)
> if row.pending:
> compen=compen+int(row.Amount)
> else:
> comfull=comfull+int(row.Amount)
> 
> rows=db(db.Transaction_Master.Account==session.id).select()
> netdue=0
> for row in rows:
> netdue=netdue+int(row.Net_Due)
> 
> pay=0
> rows=db(db.Payments.Account==session.id).select()
> for row in rows:
> pay=pay+int(row.Amount)
> a=[]
> b=[]
> count=0
> a.append([TH('Due Amount'),TH('Commited Amount'),TH('Commitment 
> Fulfilled'),TH('Commitment Pending'),TH('Uncommitted Amount'),TH('Payments 
> Received')])
> a.append([netdue,commtot,comfull,compen,pay])
> 
> COMMITMENTS=SQLFORM.grid(db.Commitments.Account==session.id,user_signature=False)
> 
> PAYMENTS=SQLFORM.grid(db.Payments.Account==session.id,user_signature=False)
> return dict(COMMITMENTS=COMMITMENTS,PAYMENTS=PAYMENTS,SUMMARY=TABLE(a))




Re: [web2py] Re: Problem while using two sqlform.grid in a single form

2012-06-18 Thread Cornelius Koelbel
+1
I am also using two grids (sometimes 4 grids) on one page.

Why not?

Kind regards
Cornelius

Am 18.06.2012 22:02, schrieb Jonathan Lundell:
> On Jun 18, 2012, at 3:06 PM, Massimo Di Pierro wrote:
>> You cannot have two grids in the same page.
>
> I'm using two grids on a page. It seemed all I needed to do was
> specify different formnames and it seemed to work. The second table is
> pretty much read-only, but it does have a paging control, and that
> works. What should I expect to go wrong?
>
>>
>> On Monday, 18 June 2012 06:09:24 UTC-5, rahulserver wrote:
>>
>> I tried to use two sqlform.grid in a web2py form. It does work as
>> intended except for the problem that when I try to edit on of the
>> form's row, other form's row with same Id also appears to be
>> edited. How should i stop it?
>> my controller:
>> def CommitmentBrowse_rep():
>> rows=db(db.Commitments.Account==session.id
>> ).select()
>> commtot=0
>> compen=0
>> comfull=0
>> for row in rows:
>> commtot=commtot+int(row.Amount)
>> if row.pending:
>> compen=compen+int(row.Amount)
>> else:
>> comfull=comfull+int(row.Amount)
>>
>> rows=db(db.Transaction_Master.Account==session.id
>> ).select()
>> netdue=0
>> for row in rows:
>> netdue=netdue+int(row.Net _Due)
>>
>> pay=0
>> rows=db(db.Payments.Account==session.id
>> ).select()
>> for row in rows:
>> pay=pay+int(row.Amount)
>> a=[]
>> b=[]
>> count=0
>> a.append([TH('Due Amount'),TH('Commited
>> Amount'),TH('Commitment Fulfilled'),TH('Commitment
>> Pending'),TH('Uncommitted Amount'),TH('Payments Received')])
>> a.append([netdue,commtot,comfull,compen,pay])
>> COMMITMENTS=SQLFORM.grid(db.Commitments.Account==session.id
>> ,user_signature=False)
>> PAYMENTS=SQLFORM.grid(db.Payments.Account==session.id
>> ,user_signature=False)
>> return
>> dict(COMMITMENTS=COMMITMENTS,PAYMENTS=PAYMENTS,SUMMARY=TABLE(a))
>>
>
>



[web2py] Re: Admin - edit static files is broken

2012-06-18 Thread Neil
Arnaud - did you find a solution to this?

I am having the same problem: I deployed to nginx, and I can edit the 
models/views/controllers/etc. without any problems. However, I get a 404 
when I try to edit static files (like a css). All files appear to have the 
same permissions. Anyone have ideas of other things I can check?

Thanks,
Neil

On Sunday, October 3, 2010 10:09:48 AM UTC+1, Arnaud Masselin wrote:
>
> Hi MAssimo, 
>
> on localhost, I use web2py server. I look in httpd config. 
>
> Thanks. 
>
>
> On 2 oct, 22:04, mdipierro  wrote: 
> > Could be a permission issue. When you open it from localhost do you 
> > still use lighttpd or do you start web2py user your user account? 
> > 
> > On Oct 2, 10:58 am, Arnaud Masselin  wrote: 
> > 
> > 
> > 
> > > Hi all, 
> > 
> > > i have deployed Web2py 1.83.2 on lighttpd production server. And i 
> > > have a problem for edit css files in the admin interface. I raise a 
> > > 404 error when I try  to edit files. 
> > 
> > > Files seems to be accessible because, for example, /static/ 
> > > landing_a_default_new.css display content of my css file. 
> > 
> > > All others files (language, contoller, html files in views) are 
> > > editable without problems. 
> > 
> > > When i run the same app on localhost, I can edit my css. 
> > 
> > > Where comes this problem ? 
> > 
> > > Thanks.



[web2py] Re: Web2Py compute fields not working on update

2012-06-18 Thread Massimo Di Pierro
Will look into this asap. Please open a ticket about it so that it is 
tracked.


On Monday, 18 June 2012 14:40:30 UTC-5, Brandon Reynolds wrote:
>
> In a new record a thumbnail is correctly generated from photo. But if I 
> didn't upload a photo or want to change the photo the thumbnail doesn't 
> generate. So basically a new record works properly but when updating 
> nothing in the thumbnail changes at all whether or not is currently has a 
> photo in it. 
>
> 
> model:
>
> from image import THUMBER
> db.define_table('park', 
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False))
>
> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
>
> 
> image.py:
>
> from gluon import current
>  
> def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
> if image:
> try:
> request = current.request
> from PIL import Image
> import os
> img = Image.open(request.folder + 'uploads/' + image)
> img.db_photo_var((nx, ny), Image.ANTIALIAS)
> root, ext = os.path.splitext(image)
> thumb = '%s_%s%s' % (root, name, ext)
> img.save(request.folder + 'uploads/' + thumb)
> return thumb
> except Exception:
> return image
>
>
>
> On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:
>>
>> Let me understand this better.
>>
>> on insert, the thumbnails are created.
>> on update, if you upload a new photo1 is photo_thing1 generated? 
>>
>> Can you provide a simpler code to reproduce the problem with a just one 
>> upload field and one thumbnail field?
>>
>> massimo
>>
>>
>>
>>
>> On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:
>>>
>>> I have this problem when i try to generate thumbnails. If the field is 
>>> empty it inserts the photo thumb into the thumbnail. But when i try to 
>>> update that record the thumbnail doesn't change. 
>>>
>>> Here is my model:
>>>
>>> # coding: utf8
>>> from image import THUMBER
>>>
>>> db.define_table('park', 
>>> Field('park_name', requires=IS_NOT_EMPTY()),
>>> Field('park_city', requires=IS_NOT_EMPTY()),
>>> Field('park_state', requires=IS_NOT_EMPTY()),
>>> Field('park_address', requires=IS_NOT_EMPTY()),
>>> Field('park_zip', requires=IS_NOT_EMPTY()),
>>> Field('country', default="USA", notnull=True, readable=False, 
>>> writable=False),
>>> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
>>> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>>> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
>>> ]+'))),
>>> Field('photo1', 'upload'),
>>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>>> Field('photo2', 'upload'),
>>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>>> Field('photo3', 'upload'),
>>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>>> Field('photo4', 'upload'),
>>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>>> Field('photo5', 'upload'),
>>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>>> Field('manager', requires=IS_NOT_EMPTY()),
>>> Field('manager_email', requires=IS_EMAIL()),
>>> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
>>> Field('vacant', 'integer'),
>>> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
>>> Field('water', 'boolean'),
>>> Field('sewer', 'boolean'),
>>> Field('trash', 'boolean'),
>>> Field('pool', 'boolean'),
>>> Field('playground', 'boolean'),
>>> Field('clubhouse', 'boolean'),
>>> Field('laundromat', 'boolean'),
>>> Field('rv_spaces', 'boolean'),
>>> Field('storage', 'boolean'),
>>> Field('handicap_accessible', 'boolean'),
>>> Field('community_description', 'text'),
>>> format='%(park_name)s')
>>>
>>> db.define_table('home', 
>>> Field('pid', notnull=True, readable=False, writable=False),
>>> Field('lot'),
>>> Field('year', length=4, requires=IS_NOT_EMPTY()),
>>> Field('make'),
>>> Field('model'),
>>> Field('width', requires=IS_NOT_EMPTY()),
>>> Field('length', requires=IS_NOT_EMPTY()),
>>> Field('wide', requires=IS_NOT_EMPTY()),
>>> Field('for_sale', 'boolean', default=True),
>>> Field('beds', requires=IS_NOT_EMPTY()),
>>> Field('baths', requires=IS_NOT_EMPTY()),
>>> Field('fridge', 'boolean'),
>>> Field('stove', 'boolean'),
>>> Field('dishwasher', 'boolean'),
>>> Field('microwave', 'boolean'),
>>> Field('washer', 'boolean'),
>>> Field('dryer', 'boolean'),
>>> Field('photo1', 'upload'),
>>> Field('photo1_text'),
>>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>>> Field('photo2', 'upload'),
>>> Field('photo2_text'),
>>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>>> Field('photo3', 'upload'),
>>> Field('photo3_text'),
>>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>>> Field(

[web2py] Re: GAE query cursors

2012-06-18 Thread Massimo Di Pierro
Login and I will give you edit access.

On Monday, 18 June 2012 14:44:39 UTC-5, howesc wrote:
>
> thanks!  now how do i go about updating the book to discuss these new 
> features?
>
> On Sunday, June 17, 2012 9:09:33 PM UTC-7, Massimo Di Pierro wrote:
>>
>> uploading :-)
>>
>> On Sunday, 17 June 2012 10:40:51 UTC-5, howesc wrote:
>>>
>>> sorry if i confused you by submitting 2 non-inclusive patches. :(  the 
>>> reference patch for 
>>> https://groups.google.com/forum/?fromgroups#!topic/web2py/mKgLFC5pxcYis 
>>> what you applied, and with your change still works for me.
>>>
>>> if the cursor patch in this thread looks ok can you add it as well? 
>>>  this is the same patch file with updated line numbers for tip of tunk.
>>>
>>> thanks!
>>>
>>> christian
>>>
>>> On Saturday, June 16, 2012 3:04:00 PM UTC-7, Massimo Di Pierro wrote:

 In trunk with a minor change. Please make sure I did not break your 
 patch.

 massimo

 On Saturday, 16 June 2012 13:59:34 UTC-5, howesc wrote:
>
> Hello again,
>
> I wanna use cursors on my GAE queries: 
> https://developers.google.com/appengine/docs/python/datastore/queries#Query_Cursors
>
> i have attached a patch that adds an optional parameter "reusecursor" 
> to select on GAE.  If True, and the query has a limitby, it indicates 
> that 
> db['_lastcursor'] will have the cursor (i didn't want to store it if you 
> are not gonna use it because i'm not sure of the cost of getting that 
> cursor).  If a reusecursor is a string that string will be passed to the 
> GAE query as the cursor.  Note that you must use limitby on all queries 
> that you want to return the cursor for, and that queries that use a 
> cursor 
> must have the exact same filters.  Keep in mind that limitby will be in 
> relation to the cursor, so in most cases you want offset of 0.
>
> my suggested patch is attached.  i welcome comments.
>
> example:
>
> def test3():
> cursor = request.vars.cursor or True
>
> #say the manu_item has about a hundred rows
> rows = db(db.menu_item.id>0).select(reusecursor=cursor, 
> limitby=(0,10))
> cursor = db['_lastcursor']
> next_link = A('next', _href=URL(r=request, vars={'cursor':cursor}))
> 
> 
> # Use generic HTML views
> response.generic_patterns = ['html']
> return dict(
> rows=rows,
> cursor=cursor,
> next_link = next_link)
>
> thanks,
>
> christian
>


Re: [web2py] Re: Problem while using two sqlform.grid in a single form

2012-06-18 Thread Massimo Di Pierro
The grid uses the request args to figure out which grid page to visualize. 
There is only one set of request.args so if you have two grids each of them 
thinks the args are for them. You may get some un-intuitive behavior like 
navigating one grid affecting the other grid. The proper way to include two 
grids it by using LOAD.

On Monday, 18 June 2012 15:02:31 UTC-5, Jonathan Lundell wrote:
>
> On Jun 18, 2012, at 3:06 PM, Massimo Di Pierro wrote:
>
> You cannot have two grids in the same page.
>
>
> I'm using two grids on a page. It seemed all I needed to do was specify 
> different formnames and it seemed to work. The second table is pretty much 
> read-only, but it does have a paging control, and that works. What should I 
> expect to go wrong?
>
>
> On Monday, 18 June 2012 06:09:24 UTC-5, rahulserver wrote:
>>
>> I tried to use two sqlform.grid in a web2py form. It does work as 
>> intended except for the problem that when I try to edit on of the form's 
>> row, other form's row with same Id also appears to be edited. How should i 
>> stop it?
>> my controller:
>> def CommitmentBrowse_rep():
>> rows=db(db.Commitments.Account==session.id).select()
>> commtot=0
>> compen=0
>> comfull=0
>> for row in rows:
>> commtot=commtot+int(row.Amount)
>> if row.pending:
>> compen=compen+int(row.Amount)
>> else:
>> comfull=comfull+int(row.Amount)
>> 
>> rows=db(db.Transaction_Master.Account==session.id).select()
>> netdue=0
>> for row in rows:
>> netdue=netdue+int(row.Net_Due)
>> 
>> pay=0
>> rows=db(db.Payments.Account==session.id).select()
>> for row in rows:
>> pay=pay+int(row.Amount)
>> a=[]
>> b=[]
>> count=0
>> a.append([TH('Due Amount'),TH('Commited Amount'),TH('Commitment 
>> Fulfilled'),TH('Commitment Pending'),TH('Uncommitted Amount'),TH('Payments 
>> Received')])
>> a.append([netdue,commtot,comfull,compen,pay])
>> COMMITMENTS=SQLFORM.grid(db.Commitments.Account==session.id
>> ,user_signature=False)
>> PAYMENTS=SQLFORM.grid(db.Payments.Account==session.id
>> ,user_signature=False)
>> return 
>> dict(COMMITMENTS=COMMITMENTS,PAYMENTS=PAYMENTS,SUMMARY=TABLE(a))
>>
>
>
>

[web2py] Re: uwsgi enable-thread option and web2py

2012-06-18 Thread mrtn

Thanks Massimo. So what're the pros of having multiple threads in the 
context of web2py, if any? Asynchronous processing?

On Monday, 18 June 2012 15:19:03 UTC-4, Massimo Di Pierro wrote:
>
> There are pros and cons. If you use threads in a python program, the more 
> computing cores you have, the slower - not faster - the program gets. This 
> is a python feature because even if you have threads, there is only one 
> interpreted and therefore execution is serialized anyway. For scalability 
> you should have processes (not threads) one per core.
>
> On Monday, 18 June 2012 11:34:39 UTC-5, mrtn wrote:
>>
>>
>> I'm deploying web2py with uwsgi 1.2.3, and upon starting the app, there 
>> is message in the uwsgi log says;
>>
>> *** Python threads support is disabled. You can enable it with 
>> --enable-threads 
>> ***
>>
>> And in the uwsgi doc, it says the following for option enable-thread:
>>
>> Enable threads in the embedded languages. This will allow to spawn 
>> threads in your app.
>>
>> I wonder if I really need this enabled for web2py. If so, what would be a 
>> common use case for it. Thanks. 
>>
>>
>>

[web2py] Re: Web2Py compute fields not working on update

2012-06-18 Thread peter
I would try removing the readable and writeable false for the compute 
fields. It seems that it does automatically not show them. I found that 
setting readable and writeable to False means the thumbs only get computed 
on insert, not update. I reported this a while back. 
Peter

On Monday, 18 June 2012 22:14:09 UTC+1, Massimo Di Pierro wrote:
>
> Will look into this asap. Please open a ticket about it so that it is 
> tracked.
>
>
> On Monday, 18 June 2012 14:40:30 UTC-5, Brandon Reynolds wrote:
>>
>> In a new record a thumbnail is correctly generated from photo. But if I 
>> didn't upload a photo or want to change the photo the thumbnail doesn't 
>> generate. So basically a new record works properly but when updating 
>> nothing in the thumbnail changes at all whether or not is currently has a 
>> photo in it. 
>>
>> 
>> model:
>>
>> from image import THUMBER
>> db.define_table('park', 
>> Field('photo1', 'upload'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False))
>>
>> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
>> "photo_thumb1", 144, 115)
>>
>> 
>> image.py:
>>
>> from gluon import current
>>  
>> def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
>> if image:
>> try:
>> request = current.request
>> from PIL import Image
>> import os
>> img = Image.open(request.folder + 'uploads/' + image)
>> img.db_photo_var((nx, ny), Image.ANTIALIAS)
>> root, ext = os.path.splitext(image)
>> thumb = '%s_%s%s' % (root, name, ext)
>> img.save(request.folder + 'uploads/' + thumb)
>> return thumb
>> except Exception:
>> return image
>>
>>
>>
>> On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:
>>>
>>> Let me understand this better.
>>>
>>> on insert, the thumbnails are created.
>>> on update, if you upload a new photo1 is photo_thing1 generated? 
>>>
>>> Can you provide a simpler code to reproduce the problem with a just one 
>>> upload field and one thumbnail field?
>>>
>>> massimo
>>>
>>>
>>>
>>>
>>> On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:

 I have this problem when i try to generate thumbnails. If the field is 
 empty it inserts the photo thumb into the thumbnail. But when i try to 
 update that record the thumbnail doesn't change. 

 Here is my model:

 # coding: utf8
 from image import THUMBER

 db.define_table('park', 
 Field('park_name', requires=IS_NOT_EMPTY()),
 Field('park_city', requires=IS_NOT_EMPTY()),
 Field('park_state', requires=IS_NOT_EMPTY()),
 Field('park_address', requires=IS_NOT_EMPTY()),
 Field('park_zip', requires=IS_NOT_EMPTY()),
 Field('country', default="USA", notnull=True, readable=False, 
 writable=False),
 Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
 Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('park_phone_2', 'string', 
 requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('photo1', 'upload'),
 Field('photo_thumb1', 'upload', readable=False, writable=False),
 Field('photo2', 'upload'),
 Field('photo_thumb2', 'upload', readable=False, writable=False),
 Field('photo3', 'upload'),
 Field('photo_thumb3', 'upload', readable=False, writable=False),
 Field('photo4', 'upload'),
 Field('photo_thumb4', 'upload', readable=False, writable=False),
 Field('photo5', 'upload'),
 Field('photo_thumb5', 'upload', readable=False, writable=False),
 Field('manager', requires=IS_NOT_EMPTY()),
 Field('manager_email', requires=IS_EMAIL()),
 Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
 Field('vacant', 'integer'),
 Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
 Field('water', 'boolean'),
 Field('sewer', 'boolean'),
 Field('trash', 'boolean'),
 Field('pool', 'boolean'),
 Field('playground', 'boolean'),
 Field('clubhouse', 'boolean'),
 Field('laundromat', 'boolean'),
 Field('rv_spaces', 'boolean'),
 Field('storage', 'boolean'),
 Field('handicap_accessible', 'boolean'),
 Field('community_description', 'text'),
 format='%(park_name)s')

 db.define_table('home', 
 Field('pid', notnull=True, readable=False, writable=False),
 Field('lot'),
 Field('year', length=4, requires=IS_NOT_EMPTY()),
 Field('make'),
 Field('model'),
 Field('width', requires=IS_NOT_EMPTY()),
 Field('length', requires=IS_NOT_EMPTY()),
 Field('wide', requires=IS_NOT_EMPTY()),
 Field('for_sale', 'boolean', default=True),
 Field('beds', requires=IS_NOT_EMPTY()),
 Field('baths', requires=IS_NOT_EMPTY()),
 Field('fridge', 'boolean'),
 Field('stove', 'boolean'),
 Field('dishwasher', 'boolean'),
 Fiel

Re: [web2py] count current visitors

2012-06-18 Thread ctrlSoft
thanks, very helpfull


[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-06-18 Thread Paolo Caruccio
Massimo,

"bootswatch.css" overwrites some css rules of "bootstrap.min.css" and 
"web2py.css" to allow layout to comply with bootstrap twitter theme (and 
consequently with bootswatch themes derived from it).

"bootswatch.css" is a web2py file like "web2py.css", therefore we can edit 
it. Maybe we should change its name in "bootswatch4w2p.css" to remove any 
doubt.
Having two file "bootswatch.css" and "web2py.css" is useful: if someone 
doesn't like bootstrap and he want apply its own theme, he has only to 
remove "bootstrap.min.css" and "bootswatch.css" to obtain basic web2py css 
theme

Instead "bootstrap.min.css" (from twitter or from bootswatch) contains 
bootstrap css theme.


Il giorno lunedì 18 giugno 2012 21:06:20 UTC+2, Massimo Di Pierro ha 
scritto:
>
> How is that possible? You edited bootswatch.css?
>
> On Monday, 18 June 2012 05:24:36 UTC-5, Paolo Caruccio wrote:
>>
>> Massimo,
>>
>> actually files with prefix V2_ allow this: download and apply in w2p a 
>> bootswacth theme without other actions by user.
>>
>>
>> Il giorno lunedì 18 giugno 2012 06:39:23 UTC+2, Massimo Di Pierro ha 
>> scritto:
>>>
>>> I included your patch but not version V2. That is because we do not want 
>>> to mantain our own modified bootswatch. People should be able to download a 
>>> theme and use it without editing. Can this be addressed in web2py.css?
>>>
>>> On Sunday, 17 June 2012 18:42:12 UTC-5, LightDot wrote:

 I have tested the V2 versions attached with Issue 856 and they seem to 
 address the issues perfectly.

 Regards

 On Sunday, June 17, 2012 9:14:33 PM UTC+2, Paolo Caruccio wrote:
>
> Patch submitted http://code.google.com/p/web2py/issues/detail?id=856
>
> Il giorno domenica 17 giugno 2012 17:32:53 UTC+2, Massimo Di Pierro ha 
> scritto:
>>
>> Can you coordinate with Andrew and Paolo and send me a single fix 
>> that applies to latest trunk and addresses the outstanding issues?
>>
>> On Sunday, 17 June 2012 08:42:50 UTC-5, LightDot wrote:
>>>
>>> I have tried your updated bootswatch.css from another thread here, 
>>> which also incorporates this fix. I confirm that BS 2.0.4 works now.
>>>
>>> Thanks!
>>>
>>> On Sunday, June 17, 2012 12:33:52 AM UTC+2, Paolo Caruccio wrote:

 LightDot,

  try to append in static/css/bootswatch.css this rule:

 .dropdown-menu ul{display:block;}

 I spotted the issue some days ago, but I didn't propose a patch 
 because web2py still has bs 2.0.2

 Let me know if the fix works for you also.

 Il giorno domenica 17 giugno 2012 00:27:18 UTC+2, LightDot ha 
 scritto:
>
> Changes in dev in the last week or so have effect on Bootstrap. 
> 2nd level submenus don't work anymore if using Bootstrap 2.0.4, while 
> bundled 2.0.2 works.
>
> - clean welcome app from latest dev, Bootstrap css and js upgraded 
> to 2.0.4
> - clicking over the yellow "web2py" opens the first submenu level
> - clicking or hovering over e.g. Documentation, does nothing.
>
> Tested in Firefox 13 and Opera 12... Are there plans to update 
> Bootstrap to 2.0.4 in web2py itself?
>
> Regards
>
>
> On Friday, June 15, 2012 4:49:29 PM UTC+2, Paolo Caruccio wrote:
>>
>> Andrew, do you mean the code for old auth_navbar style? If yes, I 
>> think it's better if you open a new thread for asking to the web2py 
>> users 
>> what style they prefer and after we will send a patch to Massimo. 
>> It's 
>> possible that most of w2p users loves the current style (bootstrap 
>> buttons 
>> group).
>>
>> Il giorno giovedì 14 giugno 2012 22:55:38 UTC+2, Andrew ha 
>> scritto:
>>>
>>> Hi Paolo,
>>>
>>> Are you able to send a patch to Massimo for your layout and 
>>> bootswatch files.  The bootstrap menu issue is holdnig up 2.0 and I 
>>> think 
>>> your changes have addressed this.   Would love to see it in trunk.
>>>
>>> If you can't I can have a go at working out what you did.
>>>
>>> Thanks
>>>
>>> Andrew W
>>>
>>>
>>>
>>> On Thursday, June 7, 2012 8:24:44 PM UTC+12, Paolo Caruccio 
>>> wrote:

 I'm afraid you can not do it. The first item in the dropdown 
 menu (having class="dropdown") can not contain an URL. The 
 structure of the 
 dropdown menu is as follows (taken from this page 
 http://twitter.github.com/bootstrap/components.html#navbar):

 Adding dropdown menus

 Adding dropdowns and dropups to the nav is super simple, but 
>>

[web2py] Re: uwsgi enable-thread option and web2py

2012-06-18 Thread Massimo Di Pierro
You need to have some kind of concurrency because if one user is doing, for 
example, a download you do not want other users to wait.

The built-in web server uses threads for concurrency but this reduces 
efficiency. Some servers use lightweight threads with async sockets. They 
are the most efficient but only use one interpreter and therefore one core 
at the time (unless you explicitly use processes). Using processes is the 
best way to take advantage of multiple cores. Which combination you use 
really depends on the architectures.

On languages which are not interpreted things are easier because you just 
use threads and you get scalability and concurrency at the same time. Not 
in Ruby or Python unfortunately.

Massimo

On Monday, 18 June 2012 16:17:39 UTC-5, mrtn wrote:
>
>
> Thanks Massimo. So what're the pros of having multiple threads in the 
> context of web2py, if any? Asynchronous processing?
>
> On Monday, 18 June 2012 15:19:03 UTC-4, Massimo Di Pierro wrote:
>>
>> There are pros and cons. If you use threads in a python program, the more 
>> computing cores you have, the slower - not faster - the program gets. This 
>> is a python feature because even if you have threads, there is only one 
>> interpreted and therefore execution is serialized anyway. For scalability 
>> you should have processes (not threads) one per core.
>>
>> On Monday, 18 June 2012 11:34:39 UTC-5, mrtn wrote:
>>>
>>>
>>> I'm deploying web2py with uwsgi 1.2.3, and upon starting the app, there 
>>> is message in the uwsgi log says;
>>>
>>> *** Python threads support is disabled. You can enable it with 
>>> --enable-threads 
>>> ***
>>>
>>> And in the uwsgi doc, it says the following for option enable-thread:
>>>
>>> Enable threads in the embedded languages. This will allow to spawn 
>>> threads in your app.
>>>
>>> I wonder if I really need this enabled for web2py. If so, what would be 
>>> a common use case for it. Thanks. 
>>>
>>>
>>>

[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-06-18 Thread Massimo Di Pierro
ok. I applied the V2.

Massimo

On Monday, 18 June 2012 16:41:34 UTC-5, Paolo Caruccio wrote:
>
> Massimo,
>
> "bootswatch.css" overwrites some css rules of "bootstrap.min.css" and 
> "web2py.css" to allow layout to comply with bootstrap twitter theme (and 
> consequently with bootswatch themes derived from it).
>
> "bootswatch.css" is a web2py file like "web2py.css", therefore we can edit 
> it. Maybe we should change its name in "bootswatch4w2p.css" to remove any 
> doubt.
> Having two file "bootswatch.css" and "web2py.css" is useful: if someone 
> doesn't like bootstrap and he want apply its own theme, he has only to 
> remove "bootstrap.min.css" and "bootswatch.css" to obtain basic web2py css 
> theme
>
> Instead "bootstrap.min.css" (twitter and bootswatch have the same name) 
> contains the original bootstrap css theme (from twitter site) or modified 
> one (from bootswatch site).
>
>
> Il giorno lunedì 18 giugno 2012 21:06:20 UTC+2, Massimo Di Pierro ha 
> scritto:
>>
>> How is that possible? You edited bootswatch.css?
>>
>> On Monday, 18 June 2012 05:24:36 UTC-5, Paolo Caruccio wrote:
>>>
>>> Massimo,
>>>
>>> actually files with prefix V2_ allow this: download and apply in w2p a 
>>> bootswacth theme without other actions by user.
>>>
>>>
>>> Il giorno lunedì 18 giugno 2012 06:39:23 UTC+2, Massimo Di Pierro ha 
>>> scritto:

 I included your patch but not version V2. That is because we do not 
 want to mantain our own modified bootswatch. People should be able to 
 download a theme and use it without editing. Can this be addressed in 
 web2py.css?

 On Sunday, 17 June 2012 18:42:12 UTC-5, LightDot wrote:
>
> I have tested the V2 versions attached with Issue 856 and they seem to 
> address the issues perfectly.
>
> Regards
>
> On Sunday, June 17, 2012 9:14:33 PM UTC+2, Paolo Caruccio wrote:
>>
>> Patch submitted http://code.google.com/p/web2py/issues/detail?id=856
>>
>> Il giorno domenica 17 giugno 2012 17:32:53 UTC+2, Massimo Di Pierro 
>> ha scritto:
>>>
>>> Can you coordinate with Andrew and Paolo and send me a single fix 
>>> that applies to latest trunk and addresses the outstanding issues?
>>>
>>> On Sunday, 17 June 2012 08:42:50 UTC-5, LightDot wrote:

 I have tried your updated bootswatch.css from another thread here, 
 which also incorporates this fix. I confirm that BS 2.0.4 works now.

 Thanks!

 On Sunday, June 17, 2012 12:33:52 AM UTC+2, Paolo Caruccio wrote:
>
> LightDot,
>
>  try to append in static/css/bootswatch.css this rule:
>
> .dropdown-menu ul{display:block;}
>
> I spotted the issue some days ago, but I didn't propose a patch 
> because web2py still has bs 2.0.2
>
> Let me know if the fix works for you also.
>
> Il giorno domenica 17 giugno 2012 00:27:18 UTC+2, LightDot ha 
> scritto:
>>
>> Changes in dev in the last week or so have effect on Bootstrap. 
>> 2nd level submenus don't work anymore if using Bootstrap 2.0.4, 
>> while 
>> bundled 2.0.2 works.
>>
>> - clean welcome app from latest dev, Bootstrap css and js 
>> upgraded to 2.0.4
>> - clicking over the yellow "web2py" opens the first submenu level
>> - clicking or hovering over e.g. Documentation, does nothing.
>>
>> Tested in Firefox 13 and Opera 12... Are there plans to update 
>> Bootstrap to 2.0.4 in web2py itself?
>>
>> Regards
>>
>>
>> On Friday, June 15, 2012 4:49:29 PM UTC+2, Paolo Caruccio wrote:
>>>
>>> Andrew, do you mean the code for old auth_navbar style? If yes, 
>>> I think it's better if you open a new thread for asking to the 
>>> web2py users 
>>> what style they prefer and after we will send a patch to Massimo. 
>>> It's 
>>> possible that most of w2p users loves the current style (bootstrap 
>>> buttons 
>>> group).
>>>
>>> Il giorno giovedì 14 giugno 2012 22:55:38 UTC+2, Andrew ha 
>>> scritto:

 Hi Paolo,

 Are you able to send a patch to Massimo for your layout and 
 bootswatch files.  The bootstrap menu issue is holdnig up 2.0 and 
 I think 
 your changes have addressed this.   Would love to see it in trunk.

 If you can't I can have a go at working out what you did.

 Thanks

 Andrew W



 On Thursday, June 7, 2012 8:24:44 PM UTC+12, Paolo Caruccio 
 wrote:
>
> I'm afraid you can not do it. The first item in the dropdown 
> menu (having class="dropdown")

[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-06-18 Thread Massimo Di Pierro
But I assume when a new version of bootswatch comes out, we will not be 
able to apply it without "remembering" the changes from the previous 
version. I am still worried about maintenance issues.

Massimo

On Monday, 18 June 2012 17:07:47 UTC-5, Massimo Di Pierro wrote:
>
> ok. I applied the V2.
>
> Massimo
>
> On Monday, 18 June 2012 16:41:34 UTC-5, Paolo Caruccio wrote:
>>
>> Massimo,
>>
>> "bootswatch.css" overwrites some css rules of "bootstrap.min.css" and 
>> "web2py.css" to allow layout to comply with bootstrap twitter theme (and 
>> consequently with bootswatch themes derived from it).
>>
>> "bootswatch.css" is a web2py file like "web2py.css", therefore we can 
>> edit it. Maybe we should change its name in "bootswatch4w2p.css" to remove 
>> any doubt.
>> Having two file "bootswatch.css" and "web2py.css" is useful: if someone 
>> doesn't like bootstrap and he want apply its own theme, he has only to 
>> remove "bootstrap.min.css" and "bootswatch.css" to obtain basic web2py css 
>> theme
>>
>> Instead "bootstrap.min.css" (twitter and bootswatch have the same name) 
>> contains the original bootstrap css theme (from twitter site) or modified 
>> one (from bootswatch site).
>>
>>
>> Il giorno lunedì 18 giugno 2012 21:06:20 UTC+2, Massimo Di Pierro ha 
>> scritto:
>>>
>>> How is that possible? You edited bootswatch.css?
>>>
>>> On Monday, 18 June 2012 05:24:36 UTC-5, Paolo Caruccio wrote:

 Massimo,

 actually files with prefix V2_ allow this: download and apply in w2p a 
 bootswacth theme without other actions by user.


 Il giorno lunedì 18 giugno 2012 06:39:23 UTC+2, Massimo Di Pierro ha 
 scritto:
>
> I included your patch but not version V2. That is because we do not 
> want to mantain our own modified bootswatch. People should be able to 
> download a theme and use it without editing. Can this be addressed in 
> web2py.css?
>
> On Sunday, 17 June 2012 18:42:12 UTC-5, LightDot wrote:
>>
>> I have tested the V2 versions attached with Issue 856 and they seem 
>> to address the issues perfectly.
>>
>> Regards
>>
>> On Sunday, June 17, 2012 9:14:33 PM UTC+2, Paolo Caruccio wrote:
>>>
>>> Patch submitted http://code.google.com/p/web2py/issues/detail?id=856
>>>
>>> Il giorno domenica 17 giugno 2012 17:32:53 UTC+2, Massimo Di Pierro 
>>> ha scritto:

 Can you coordinate with Andrew and Paolo and send me a single fix 
 that applies to latest trunk and addresses the outstanding issues?

 On Sunday, 17 June 2012 08:42:50 UTC-5, LightDot wrote:
>
> I have tried your updated bootswatch.css from another thread here, 
> which also incorporates this fix. I confirm that BS 2.0.4 works now.
>
> Thanks!
>
> On Sunday, June 17, 2012 12:33:52 AM UTC+2, Paolo Caruccio wrote:
>>
>> LightDot,
>>
>>  try to append in static/css/bootswatch.css this rule:
>>
>> .dropdown-menu ul{display:block;}
>>
>> I spotted the issue some days ago, but I didn't propose a patch 
>> because web2py still has bs 2.0.2
>>
>> Let me know if the fix works for you also.
>>
>> Il giorno domenica 17 giugno 2012 00:27:18 UTC+2, LightDot ha 
>> scritto:
>>>
>>> Changes in dev in the last week or so have effect on Bootstrap. 
>>> 2nd level submenus don't work anymore if using Bootstrap 2.0.4, 
>>> while 
>>> bundled 2.0.2 works.
>>>
>>> - clean welcome app from latest dev, Bootstrap css and js 
>>> upgraded to 2.0.4
>>> - clicking over the yellow "web2py" opens the first submenu level
>>> - clicking or hovering over e.g. Documentation, does nothing.
>>>
>>> Tested in Firefox 13 and Opera 12... Are there plans to update 
>>> Bootstrap to 2.0.4 in web2py itself?
>>>
>>> Regards
>>>
>>>
>>> On Friday, June 15, 2012 4:49:29 PM UTC+2, Paolo Caruccio wrote:

 Andrew, do you mean the code for old auth_navbar style? If yes, 
 I think it's better if you open a new thread for asking to the 
 web2py users 
 what style they prefer and after we will send a patch to Massimo. 
 It's 
 possible that most of w2p users loves the current style (bootstrap 
 buttons 
 group).

 Il giorno giovedì 14 giugno 2012 22:55:38 UTC+2, Andrew ha 
 scritto:
>
> Hi Paolo,
>
> Are you able to send a patch to Massimo for your layout and 
> bootswatch files.  The bootstrap menu issue is holdnig up 2.0 and 
> I think 
> your changes have addressed this.   Would love to see it in trunk.
>
>>

Re: [web2py] count current visitors

2012-06-18 Thread ctrlSoft
with page views i understand. but without any analitycs tools, is there a 
method to count active/oline visitors not registered users. 
i want to display on my page:

total visits: 01234...
today:01234..
*online:5*



Re: [web2py] Re: Web2py RAM usage

2012-06-18 Thread Jon Molesa
While  testing webfaction I had launched a very simple app that required login 
to use. No one was registering so no one was using anything other than the 
landing page. However, webfactiion continually killed my process for going over 
it's memory limits. When I asked what was causing this and what I could do to 
keep it under my account limit their reply was that this is a common occurrence 
with web2py apps. I really didn't have the necessary skills to get to the 
bottom of it, or the time to invest in acquiring them. I decided to self-host 
the app on RackSpace Cloud Servers. It was discouraging that a simple running 
app with no users or traffic would exhaust the allowed memory. I had their most 
basic plan which IIRC offers 256 Mb of ram. 

-- 
Jon Molesa


On Monday, June 18, 2012 at 3:08 PM, Massimo Di Pierro wrote:

> Currently there is not built-in way to limit memory usage. You can expire it 
> but does not get deleted, only overwritten. You can explicitly delete an item 
> from the cache using cache.ram.clear(regex) clears all items with ket 
> matching regex.
> 
> On Monday, 18 June 2012 07:42:06 UTC-5, Lucas R. Martins wrote:
> > i'm not using web2py-level caching, but i would like to use, if i can limit 
> > memory usage and expire it when i need.
> > i have compiled app and i'm using sqlite. sqlite is a problem?
> > 
> > 
> > 2012/6/18 Massimo Di Pierro  > (mailto:massimo.dipie...@gmail.com)>
> > > Are you using caching? Are you using sqlite? We should nail down the 
> > > cause of this problem.
> > > Did you try to bytecode compile the app?
> > > 
> > > Massimo
> > > 
> > > 
> > > On Sunday, 17 June 2012 21:17:01 UTC-5, Lucas R. Martins wrote:
> > > > Hi guys,
> > > > 
> > > > I'm running a website with ~ 900 urls and no many daily access in a 
> > > > small vps. I have observed that, when a start the server, this use only 
> > > > 10mb, in my case.
> > > > 
> > > > However, with the time and natural access (specially googlebot), the 
> > > > server memory usage grow and grows indefinitely until use all server 
> > > > memory.
> > > > 
> > > > There is anything to do to limit web2py memory usage and force it to 
> > > > free unused memory? There is any kind of internal ram cache which can 
> > > > be disabled?
> > > > 
> > > > 
> > > > 
> > > > Thanks.
> > 



[web2py] Re: Anyone using BootSwatch with new web2py layout

2012-06-18 Thread Paolo Caruccio
The bootswatch themes are based on bootstrap css files. Your doubt must 
refer to the latter one: for example, the passage from "bootstrap 2.0.2" to 
"bootstrap 2.0.4" caused the issue in web2py menu fixed with ".open > 
.dropdown-menu  ul { display: block;}". In other words, we should worry 
about new version of bootstrap theme (http://twitter.github.com/bootstrap/ 
).

The bootswatch themes (http://bootswatch.com/) are only free customized 
bootstrap themes.

Indeed, on the web, several bootstrap theme generators exist with which you 
can create your own customized theme, alternative to bootswatch themes:
   1) http://twitter.github.com/bootstrap/download.html (original one)
   2) http://stylebootstrap.info/ (simple one)

At last we don't forget that "bootstrap.min.css" included in web2py comes 
from twitter.github.com and not from bootswatch.com
 

Il giorno martedì 19 giugno 2012 00:08:39 UTC+2, Massimo Di Pierro ha 
scritto:
>
> But I assume when a new version of bootswatch comes out, we will not be 
> able to apply it without "remembering" the changes from the previous 
> version. I am still worried about maintenance issues.
>
> Massimo
>
> On Monday, 18 June 2012 17:07:47 UTC-5, Massimo Di Pierro wrote:
>>
>> ok. I applied the V2.
>>
>> Massimo
>>
>> On Monday, 18 June 2012 16:41:34 UTC-5, Paolo Caruccio wrote:
>>>
>>> Massimo,
>>>
>>> "bootswatch.css" overwrites some css rules of "bootstrap.min.css" and 
>>> "web2py.css" to allow layout to comply with bootstrap twitter theme (and 
>>> consequently with bootswatch themes derived from it).
>>>
>>> "bootswatch.css" is a web2py file like "web2py.css", therefore we can 
>>> edit it. Maybe we should change its name in "bootswatch4w2p.css" to remove 
>>> any doubt.
>>> Having two file "bootswatch.css" and "web2py.css" is useful: if someone 
>>> doesn't like bootstrap and he want apply its own theme, he has only to 
>>> remove "bootstrap.min.css" and "bootswatch.css" to obtain basic web2py css 
>>> theme
>>>
>>> Instead "bootstrap.min.css" (twitter and bootswatch have the same name) 
>>> contains the original bootstrap css theme (from twitter site) or modified 
>>> one (from bootswatch site).
>>>
>>>
>>> Il giorno lunedì 18 giugno 2012 21:06:20 UTC+2, Massimo Di Pierro ha 
>>> scritto:

 How is that possible? You edited bootswatch.css?

 On Monday, 18 June 2012 05:24:36 UTC-5, Paolo Caruccio wrote:
>
> Massimo,
>
> actually files with prefix V2_ allow this: download and apply in w2p a 
> bootswacth theme without other actions by user.
>
>
> Il giorno lunedì 18 giugno 2012 06:39:23 UTC+2, Massimo Di Pierro ha 
> scritto:
>>
>> I included your patch but not version V2. That is because we do not 
>> want to mantain our own modified bootswatch. People should be able to 
>> download a theme and use it without editing. Can this be addressed in 
>> web2py.css?
>>
>> On Sunday, 17 June 2012 18:42:12 UTC-5, LightDot wrote:
>>>
>>> I have tested the V2 versions attached with Issue 856 and they seem 
>>> to address the issues perfectly.
>>>
>>> Regards
>>>
>>> On Sunday, June 17, 2012 9:14:33 PM UTC+2, Paolo Caruccio wrote:

 Patch submitted 
 http://code.google.com/p/web2py/issues/detail?id=856

 Il giorno domenica 17 giugno 2012 17:32:53 UTC+2, Massimo Di Pierro 
 ha scritto:
>
> Can you coordinate with Andrew and Paolo and send me a single fix 
> that applies to latest trunk and addresses the outstanding issues?
>
> On Sunday, 17 June 2012 08:42:50 UTC-5, LightDot wrote:
>>
>> I have tried your updated bootswatch.css from another thread 
>> here, which also incorporates this fix. I confirm that BS 2.0.4 
>> works now.
>>
>> Thanks!
>>
>> On Sunday, June 17, 2012 12:33:52 AM UTC+2, Paolo Caruccio wrote:
>>>
>>> LightDot,
>>>
>>>  try to append in static/css/bootswatch.css this rule:
>>>
>>> .dropdown-menu ul{display:block;}
>>>
>>> I spotted the issue some days ago, but I didn't propose a patch 
>>> because web2py still has bs 2.0.2
>>>
>>> Let me know if the fix works for you also.
>>>
>>> Il giorno domenica 17 giugno 2012 00:27:18 UTC+2, LightDot ha 
>>> scritto:

 Changes in dev in the last week or so have effect on Bootstrap. 
 2nd level submenus don't work anymore if using Bootstrap 2.0.4, 
 while 
 bundled 2.0.2 works.

 - clean welcome app from latest dev, Bootstrap css and js 
 upgraded to 2.0.4
 - clicking over the yellow "web2py" opens the first submenu 
 level
 - clicking or hovering over e.g. Documentation, does nothing.

 Tested in Fi

Re: [web2py] Re: Web2py RAM usage

2012-06-18 Thread Vasile Ermicioi
> However, webfactiion continually killed my process for going over it's
> memory limits. When I asked what was causing this and what I could do to
> keep it under my account limit their reply was that this is a common
> occurrence with web2py apps. I really didn't have the necessary skills to
> get to the bottom of it, or the time to invest in acquiring them. I decided
> to self-host the app on RackSpace Cloud Servers. It was discouraging that a
> simple running app with no users or traffic would exhaust the allowed
> memory. I had their most basic plan which IIRC offers 256 Mb of ram.
>
>
I had the same problem with webfaction when I used apache + mod_wsgi,
with uwsgi I managed to run under 80Mb ram,
300-500 unique visitors per day, 1000-2000 page views, 600 registered users
and now they offer 256Mb of RAM

uwsgi is great, ask Roberto how he managed to do that :)


[web2py] Re: I am planning to re-develope my windows applications in python

2012-06-18 Thread Derek
If that's what your application is - define the table in your model, and 
add a smartgrid and you're done. It has crud (create, read, update, delete) 
functionality builtin, and sane defaults.

a default smartgrid has 'add', 'query', sorting, paging, everything shown 
in your screenshots.

It's so easy, I'll show you how to get started.

db.define_table('airports',

Field('airportCode'),

Field('description'),

Field('country'),

Field('embargo')

)


Add the above to your db.py in the models.

form = SQLFORM.smartgrid(db.airports)

return dict(message=T('Hello World'), form=form)

Make the last couple of lines in your "index" function of the "default" 
controller like the above.

and add in {{=form}} to your view.

If you are not logged in, you won't see the "add" or "edit" buttons in the 
grid.

On Thursday, June 14, 2012 6:58:22 AM UTC-7, KarlHeinzF wrote:
>
> Hallo everybody, 
> first of all I am new to python and web2py. 
> I am planning to re-develope some of my windows applications in python for 
> the web. 
> What is best to use, Web2py or Django or some other framework, that is my 
> question. 
>  
>  How can I re-develope them so they look and feel like the application in 
> my attached screenshots?
>   
> Books like „web2py Application Development Cookbook“ don’t realy help!
>  
> What I need is a small application (source code that includes modules like 
> MENUE, MASTER-DETAIL ENTRY, PRINTING etc.) that reduces my learning curve 
> and gets me started fast.   
>  
> Any help is appreciated.
>  
>   
> regards
>  
> Karl
>  
>
> p.s. are there any german web2py developers that can help?  
>


Re: [web2py] Re: Web2py RAM usage

2012-06-18 Thread Jon Molesa
I can't say for certain now, but I'm pretty sure I switched from
apache + mod_wsgi to uwsgi. In any case uwsgi is what I've set up on
my Rackspace server. So far so good. I'm happy with the results. While
I understand webfaction's need to control resource usage I really
didn't appreciate that they kept killing my only process, my web
process. I'm encouraged by your results. Thanks for sharing.

On Mon, Jun 18, 2012 at 7:04 PM, Vasile Ermicioi  wrote:
>
>> However, webfactiion continually killed my process for going over it's
>> memory limits. When I asked what was causing this and what I could do to
>> keep it under my account limit their reply was that this is a common
>> occurrence with web2py apps. I really didn't have the necessary skills to
>> get to the bottom of it, or the time to invest in acquiring them. I decided
>> to self-host the app on RackSpace Cloud Servers. It was discouraging that a
>> simple running app with no users or traffic would exhaust the allowed
>> memory. I had their most basic plan which IIRC offers 256 Mb of ram.
>>
>
> I had the same problem with webfaction when I used apache + mod_wsgi,
> with uwsgi I managed to run under 80Mb ram,
> 300-500 unique visitors per day, 1000-2000 page views, 600 registered users
> and now they offer 256Mb of RAM
>
> uwsgi is great, ask Roberto how he managed to do that :)
>
>



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


Re: [web2py] Re: Problem while using two sqlform.grid in a single form

2012-06-18 Thread Jonathan Lundell
On Jun 18, 2012, at 5:17 PM, Massimo Di Pierro wrote:
> The grid uses the request args to figure out which grid page to visualize. 
> There is only one set of request.args so if you have two grids each of them 
> thinks the args are for them. You may get some un-intuitive behavior like 
> navigating one grid affecting the other grid. The proper way to include two 
> grids it by using LOAD.

In my case the interaction is rather limited. If I switch pages in the 
secondary table, it loses whatever view/edit state the other table might be in, 
but it's not all that common a use case, and only admins use the page, so I can 
live with it.

But yeah, I can see the problem.

> 
> On Monday, 18 June 2012 15:02:31 UTC-5, Jonathan Lundell wrote:
> On Jun 18, 2012, at 3:06 PM, Massimo Di Pierro wrote:
>> You cannot have two grids in the same page.
> 
> I'm using two grids on a page. It seemed all I needed to do was specify 
> different formnames and it seemed to work. The second table is pretty much 
> read-only, but it does have a paging control, and that works. What should I 
> expect to go wrong?
> 
>> 
>> On Monday, 18 June 2012 06:09:24 UTC-5, rahulserver wrote:
>> I tried to use two sqlform.grid in a web2py form. It does work as intended 
>> except for the problem that when I try to edit on of the form's row, other 
>> form's row with same Id also appears to be edited. How should i stop it?
>> my controller:
>> def CommitmentBrowse_rep():
>> rows=db(db.Commitments.Account==session.id).select()
>> commtot=0
>> compen=0
>> comfull=0
>> for row in rows:
>> commtot=commtot+int(row.Amount)
>> if row.pending:
>> compen=compen+int(row.Amount)
>> else:
>> comfull=comfull+int(row.Amount)
>> 
>> rows=db(db.Transaction_Master.Account==session.id).select()
>> netdue=0
>> for row in rows:
>> netdue=netdue+int(row.Net_Due)
>> 
>> pay=0
>> rows=db(db.Payments.Account==session.id).select()
>> for row in rows:
>> pay=pay+int(row.Amount)
>> a=[]
>> b=[]
>> count=0
>> a.append([TH('Due Amount'),TH('Commited Amount'),TH('Commitment 
>> Fulfilled'),TH('Commitment Pending'),TH('Uncommitted Amount'),TH('Payments 
>> Received')])
>> a.append([netdue,commtot,comfull,compen,pay])
>> 
>> COMMITMENTS=SQLFORM.grid(db.Commitments.Account==session.id,user_signature=False)
>> 
>> PAYMENTS=SQLFORM.grid(db.Payments.Account==session.id,user_signature=False)
>> return dict(COMMITMENTS=COMMITMENTS,PAYMENTS=PAYMENTS,SUMMARY=TABLE(a))
> 
> 




Re: [web2py] Re: Web2py RAM usage

2012-06-18 Thread Lucas R. Martins
In my case, i just started web2py server and set up apache2 + proxypass.
I need to change to uwsgi?


2012/6/18 Jon Molesa 

> I can't say for certain now, but I'm pretty sure I switched from
> apache + mod_wsgi to uwsgi. In any case uwsgi is what I've set up on
> my Rackspace server. So far so good. I'm happy with the results. While
> I understand webfaction's need to control resource usage I really
> didn't appreciate that they kept killing my only process, my web
> process. I'm encouraged by your results. Thanks for sharing.
>
> On Mon, Jun 18, 2012 at 7:04 PM, Vasile Ermicioi 
> wrote:
> >
> >> However, webfactiion continually killed my process for going over it's
> >> memory limits. When I asked what was causing this and what I could do to
> >> keep it under my account limit their reply was that this is a common
> >> occurrence with web2py apps. I really didn't have the necessary skills
> to
> >> get to the bottom of it, or the time to invest in acquiring them. I
> decided
> >> to self-host the app on RackSpace Cloud Servers. It was discouraging
> that a
> >> simple running app with no users or traffic would exhaust the allowed
> >> memory. I had their most basic plan which IIRC offers 256 Mb of ram.
> >>
> >
> > I had the same problem with webfaction when I used apache + mod_wsgi,
> > with uwsgi I managed to run under 80Mb ram,
> > 300-500 unique visitors per day, 1000-2000 page views, 600 registered
> users
> > and now they offer 256Mb of RAM
> >
> > uwsgi is great, ask Roberto how he managed to do that :)
> >
> >
>
>
>
> --
> Jon Molesa
> rjmol...@gmail.com
>