[web2py] Re: server settings.

2011-12-11 Thread ron_m
I have recorded what might be a similar problem. If I run the application 
using the rocket server where the client browser and server are on the same 
LAN the application works. If I have the client come in from another 
location over a VPN I get partial pages. The Safari archive in the failure 
case is about 100k short of the 400k that a normal page load takes. The 
failed page looks like the jQuery Javascript that places symbols on a map 
did not run at the window.load event. If I take the same server 
configuration to apache/mod_wsgi it works fine in all cases.

An even stranger variable is if I use a different browser such as switching 
from Safari to Firefox it works in both client locations. Possibly 
different browsers have a different load order on resources within the 
page, there are several JS, CSS and image files that make up the page.

It looks to me like a time out on the server cuts short a portion of the 
page in the case the server is rocket and the client is coming on on a VPN 
over the WAN.

I have wireshark captures and Safari save page archives for working and 
failure cases if anyone wants to look. I am going to deploy on apache or 
nginx so the solution was more a matter of interest that I have not got 
around to working on yet.

Ron



[web2py] Re: web2py and FirePHP

2011-11-22 Thread ron_m
I just tried, no problem. Are you behind a proxy?


[web2py] Re: web2py and FirePHP

2011-11-22 Thread ron_m
Ed,

Sorry, I looked at the URL in your second message www.box.com and that 
works. The URL in your first message to a specific shared file gives me a 
404 response too.

This is a file sharing site like dropbox so it appears the file owner has 
removed it.

I tried a few of the web page archives such as wayback machine, a series of 
them are at this URL

http://www.searchengineshowdown.com/others/archive.shtml

but www.box.com has a robots.txt file that prevents crawling when honoured 
so there is nothing in the history.

Ron


[web2py] Re: patch for web2py socket timeout

2011-11-07 Thread ron_m
I am trying to understand why the socket timeout would be set so low at 1 
second as a default. 

I believe this change is the solution to a problem I have been chasing off 
and on time permitting where the pages won't render properly when using the 
rocket server with a browser over the WAN. Local LAN always works. I 
probably won't use rocket for deployment but was testing a prototype. Some 
browsers worked like Firefox but Safari on Snow Leopard failed while Safari 
on Lion worked. On the same LAN they all worked. The failure looked like 
the jQuery Javascript never ran with the page load.

I will see later if this change fixes my problem as well.

Thanks
Ron


[web2py] elfinder integrated into web2py as a plugin?

2011-10-23 Thread ron_m
It looks like elfinder would be a very nice implementation of a file 
manipulation area open to users for an application I am working on.

I found this discussion about elfinder which is over a year old

https://groups.google.com/d/topic/web2py/Ove0jTJn_Vk/discussion

where in the last posting a Massimo is copied in a section that describes 
how to turn this into a plugin. I found the appliance and the hg repository 
on google code.

Was this ever turned into a plugin and if so where is it? Is there any 
interest in someone completing that if it has not been done? Since I will be 
using it I can volunteer.

Thanks,

Ron



[web2py] Re: Menus and Selected Tab

2011-10-17 Thread ron_m
If you are using superfish menus in views/layout.html hee is what I did.

I changed
  script type=text/javascript
jQuery(document).ready(function(){
jQuery('ul.sf-menu').superfish();});
  /script

to be
  script type=text/javascript
jQuery(document).ready(function(){
jQuery('ul.sf-menu').superfish({pathClass: 
'web2py-menu-active'});});
  /script

Really only a parameter addition in third line, extra lines are there to add 
context.

Then look for the superfish.css file for the selector
.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
if you want a different color than the default.

Ron


[web2py] Re: Menus and Selected Tab

2011-10-17 Thread ron_m
Oops sorry forgot a detail, I did this a while back

I have a simple mapping of top level menu item to controller name so this 
works for me because of how it is organized. This allows me to remove 
functions from the application depending on where it is installed. Some 
clients don't use every possible top level menu item.

So to figure out the active path in model/menu.py all i need is

active_path = request.controller

Then the menu items are constructed with a True False in the second item of 
the tuple using logic like this on each item.

response.menu+=[
(MAP, True if active_path == 'map' else False, URL(c='map', 
f='index'), [])
]

MAP = T('Map') to allow translation to fill out a missing part of the above 
code fragment.


I realize this has some limitations such as forcing a top level menu item 
and a controller name to be connected but I was willing to accept that..


[web2py] Re: criticism of web2py

2011-10-05 Thread ron_m
+1 or more

I looked at several Python frameworks 1.5 years ago. Half of them are dead 
projects now glad I wasn't on any of those bandwagons. It came down to 
Web2py and Django and every time I looked at Django I went back to Web2py 
because it felt so well designed and set up for getting things done. The 
true test for a framework for me is how much it helps you. I spent 6 years 
in the Java world and know about things that require a lot of work to 
appease them so they will work for you.

Web2py is clearly my best experience ever for software development in web 
environments. I have been a developer since 1977.

Ron


[web2py] Re: Are we ready to launch 1.99.1?

2011-09-20 Thread ron_m
Ran application I am working on no problems.

The welcome application seems to pull in some adware. Firebug opens in 
Firefox with a problem loading sm6.html saying _gat is not defined. I 
believe this is coming from the Share item in the top menu.

The jQuery team has released 1.6.4 to fix a bug introduced in 1.6.3 which I 
have not seen yet, I believe it manifests on IE. The version in trunk is 
1.6.3 still.

Ron


[web2py] Testing trunk get error in external iframe on Welcome app index page

2011-09-13 Thread ron_m
I was testing trunk, ran the Welcome application and the Firebug debugger 
got a script error

_gat not defined in file http://static.addtoany.com/menu/sm5.html line 1.

Checking the DOM load of the index page I see an iframe

iframe id=a2apage_sm_ifr width=1 height=1 frameborder=0 style=border: 
0pt none; left: 0pt; top: 0pt; position: absolute; z-index: 10; 
transparency=true allowtransparency=true src=
http://static.addtoany.com/menu/sm5.html#page;http://127.0.0.1:8000/welcome/default/index

/iframe

which I see comes from lines 100-102 of layout.html

Not inside web2py ability to fix other than to include or not include, just 
so others know. Most of what I work with is on isolated networks so the 
browser can't reach out to grab external URLs, good for my situation to spot 
this so I can remove it.

Ron



[web2py] Re: Date Picker Widget

2011-09-06 Thread ron_m
I didn't replace the one in web2py, I just use the jQueryUI one by including 
the necessary CSS and JS files and placing the files in static/js and 
static/css after downloading a custom build from jQueryUI

In the view where it is needed I add these lines before the extend 
'layout.html' line

{{response.files.append(URL('static','css/cupertino/jquery-ui-1.8.14.custom.css'))}}
{{response.files.append(URL('static','js/jquery-ui-1.8.14.custom.min.js'))}}



[web2py] Re: migrate=True not creating table ?

2011-08-24 Thread ron_m
In this situation look in the application/databases directory for a file with 
the table name as part of the file name. Remove or move the file somewhere else 
and then restart the web2py server. The table should now reappear and will be 
empty.


[web2py] Re: Understanding Rocket Threads

2011-08-24 Thread ron_m
You also need to consider the database type used by the application for the 
model. The SQLite database has a transaction lock which will cause the 
application to look like it is single threaded if the database is held in a 
transaction pending state while the background work is performed.


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

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


Re: [web2py] Re: Getting a reproducible web2py internal error

2011-07-17 Thread ron_m
You should probably check permissions and ACLs all the way up the directory 
tree to the root of the drive. It is possible to apply an ACL in an upper 
level directory and with a check box option cause that permission to apply 
recursively to the whole file tree below.


Re: [web2py] Thanks for the awesome framework/setting up PostgreSQL

2011-07-13 Thread ron_m
I use PostgreSQL as well with great success. Another thing to keep in mind 
is if you restart the database server and are using apache with web2py then 
you should restart apache as well. The reason is the connection pool if used 
as a number  0 in the DAL() connection statement will have stale 
connections resulting in errors.


[web2py] Re: Passing JavaScript variable to web2py session variable?

2011-07-08 Thread ron_m
You need to have the AJAX URL formed in a way that invokes a controller.

eg /application_name/controller_name/function_name/arg0/arg1 .

and include the variable(s) you want to send back. The variables can be 
either addition items after the function as above where they show up as args 
or if they are part of a form POST then the variables would be in the vars 
dict.

The controller will then validate the variables if need be and store what it 
needs to in the session. You don't need a view for this.


Re: [web2py] cron Too many open files regression?

2011-07-07 Thread ron_m
The code running this is in gluon/newcron.py
From your stack trace you are using hard cron which is a class at line 44. 
It runs launch once a minute
This runs crondance which puts a wrapper on the tasks that should be run 
adding web2py run line parameters if * or ** is at the beginning of the 
command. The crondance function then uses class cronlauncher which in turn 
uses subprocess.Popen to launch the task.

If you have web2py like processes building up do these processes have other 
processes with the web2py process pid listed as the parent process. You 
should be able to do a ps -ef pick the pid of one of the web2py processes 
and run another ps -ef with grep pid to filter. The process started with the 
Popen will have to close the pipe usually by exiting to release the thread 
from cronlauncher.

Do these cron tasks run okay if you just launch them from the shell. That is 
a good test to determine that there are no problems outside the cron 
environment.

Do you use a SQLite database? This database performs a global lock to 
protect from multiple access.

Do the cron tasks take more than their scheduling interval to complete. The 
launcher will run another copy without regard for an existing copy still 
running.

Do any of the tasks have locking code such as a file lock that other tasks 
depend on gaining access to. Two file locks shared by two processes with 
crossed access, one process locks a then b, other locks b then a will 
deadlock if the timing is right.

Do any tasks read stdin, the subprocess.Popen call opens the stdin of the 
process to the launcher but will never write to it so a read on stdin would 
hang preventing exit.

I hope this is some help, looks like a difficult one to find but likely 
something fairly simple to fix once you find it.

Could you post your crontab file, it would be a start of something to look 
at.




Re: [web2py] Re: cron Too many open files regression?

2011-07-06 Thread ron_m
Sounds like some kind of race condition between the cron scripts because it 
doesn't happen every time. Is there any chance the 3 cron scripts are 
dependent on each other in some way such as a file passed between or sharing 
a database. If there is any relationship between the cron scripts would it 
be possible to make a single script that just runs the 3 scripts 
sequentially and use that as your cron script. Do the scripts access the 
database and the database happens to be SQLite which locks for the duration 
of an access/

Without seeing some code and more details determining the cause is a guess.

Ron


Re: [web2py] Re: cron Too many open files regression?

2011-07-06 Thread ron_m
Maybe one possibility is if your code has classes with a __del__ method in 
them, Massimo would have better perspective on if this is a possibility. If 
a class with this method is involved in a circular reference the garbage 
collector cannot clean it up because of uncertainty of execution of the 
__del__ method. This was discussed a lot on the group a few months back. I 
believe exec also has to be involved. Do a search for __del__ in the group 
to see what was said. There were also some tools mentioned in those threads 
that help with tracking down this sort of problem.

I find in Python as soon as a file variable binding produced by open goes 
out of scope it is closed, you don't have to specifically call close on it. 
Normally objects are dropped as soon as the reference count reaches 0. The 
garbage collector was added to clean up the circular referenced objects that 
will never get a count down to 0 without some outside help. It searches the 
heap looking for objects that have no references except other objects also 
in the garbage and marks those as candidates to clean out. The fact that 
these file objects are piling up means something is holding the file 
reference which also cannot be cleaned up.

Are you running on Linux? If so the /proc/pid_of_web2py/fd directory using 
ls -l will show you what files by name are open to the process which might 
provide some clues to which part of your code.


[web2py] Re: Check

2011-07-06 Thread ron_m
If you started with a copy of the Welcome app did you change the database 
name? If both apps have the same database URL originally defined in the 
Welcome app in file models/db.py they will share tables.


[web2py] Question on menu active rendering

2011-07-01 Thread ron_m
In response.menu each item of the list is a 4 element tuple. The second 
element of tuple can be True or False to represent that item is active. This 
causes teh MENU class in gluon/html.py to attach class=web2py-menu-active 
to the li tag associated with that menu item.

That class is not represented anywhere in the .css files included with the 
example. I am using the superfish menus form the default welcome 
application.

Here is what I added to my own application css file

.web2py-menu-active {
background-color: #275B90;
}

but it doesn't get picked up by the rendering of the menu. I am thinking 
maybe the superfish menu styling is over riding this or I don't have it 
right somehow. CSS is not one of my stronger areas.

I looked at the example which the web2py.com site actually is and it uses a 
PNG image file with style sheet animation to change the button look for each 
state idle, hover, pressed and active. I saw something from Bruno recently 
as well in another thread. I am still using the superfish menus, if I need 
to replace them I will. It is not that difficult for a user to know where 
they are in the application but it would be nice to show which of the top 
menu items is active with a visual cue.

Thanks
Ron



[web2py] Re: Question on menu active rendering

2011-07-01 Thread ron_m
Oops I found it, simple once you know how. In layout.html do the following

Change
jQuery('ul.sf-menu').superfish();});

To
jQuery('ul.sf-menu').superfish({pathClass: 
'web2py-menu-active'});});

This will allow suckerfish to use the class added to the active menu item by 
the web2py MENU class as a way to highlight the active path. I hope this 
isn't obvious, looked in the archives of the group and the manual.

Ron


[web2py] Re: pound sign display

2011-06-24 Thread ron_m
I would have great difficulty recommending Word as an editor for working 
with HTML because of all the things it does under the covers. Not trying to 
stir up flames, just trying to make your life easier. As a word processor 
Word is okay.


[web2py] Re: Broken pipe with mysql

2011-06-15 Thread ron_m
Unless step 6 is reached and completed if the client closed then I would 
expect the database server to detect the closed connection and rollback on 
its own since there is no way to recover the state built on that connection 
or if the database server is restarted then the database server should 
perform startup recovery and rollback anything that isn't completed but the 
client still needs to clean up.

What this smells like is a connection pool will hold open connections for 
reuse, the database server is restarted because of a maintenance script and 
now the pool has stale connections. When one of these pooled connections is 
given to a user task the connection should be detected as stale in the pool 
logic and a reconnect attempted before handing it over to the user.

What Alvaro describes is similar but it looks like the DAL won't initiate a 
new connection after a server restart unless a ping is performed. Is it 
possible there is state being held in the DAL or the mysqldb driver that 
says there is a connection but is not cleared to allow an attempt to get a 
fresh open on the database?




Re: [web2py] Re: what's up in DAL?

2011-06-14 Thread ron_m
Are you returning enough data to cause the system to go into paging - check 
the system monitoring tools, not sure what you are running on, to see if 
there is a large amount of VM activity involving paging to disk while this 
is running. That would really kill performance. The entire data returned by 
the query will be turned into a Rows object so it all has to live in memory 
at the same time.

Another odd clue is the second time takes longer than the first time. 
Normally it should take less time because the caching in the system such as 
in the database engine is warmed up. If VM activity is high, caching will be 
defeated because those assumed high speed memory caches saved in case the 
are needed again in a short time might have been rolled out onto the disk.

Ron


[web2py] Re: Discussion: Thoughts about including jQuery UI in core web2py?

2011-06-14 Thread ron_m
I agree jQueryUI should not be included as a default. I use jQueryUI but 
only pull it in for the views that need it. It is one css and one js.
The other thing to remember is if you go to the jQueryUI download page the 
form allows you to build a custom version specific to the features in use 
with the particular application. Some of the components are large enough 
that I wouldn't want to load them if I don't need them.


[web2py] Re: How to implement flags?

2011-06-09 Thread ron_m
IMHO it depends on a number of things.

Using groups and memberships is good if the flags are meant to indicate an 
ability to do something on the system because there are decorators and 
functions to test for having the attribute. You can then decorate a function 
or use a has_ test to determine ability in the code.

If all you want to do is test something in code and there are a fixed and 
small number of these flags then an extension to the user table might be the 
easiest using a binary column per flag type. One problem is a new flag 
causes a schema change. It would be the most efficient, reading the user 
table could pull these in at the same time but that would be premature 
optimization.

The relations in the auth_* tables look like this in ascii

auth_user - auth_membership -- auth_group  auth_permission   
where  indicates a one to many relation.

Therefore auth_membership is an intermediate or join table that realizes the 
many to many between auth_user and auth_group.

The auth_permission table can be used to hold capabilities and not be 
associated with tables at all by means of a settings tweak. Then a 
permission can be assigned to only one group but a group can have several 
permissions. Then users can be assigned to multiple groups to collect the 
capabilities assigned by the admin. By using the group you can lump several 
flags that belong together. This works for me to define a hierarchy of users 
for the application I am working on. I am able to customize the permission 
items to whatever group type the installation needs to allow or disallow a 
group to have a certain capability without having to change what groups the 
users belong to, something like a policy editor as in this group can do 
these things.

If all the flags are single purpose and are not grouped then I would think 
you could collapse this to a flag = group item.

I am not certain of lists in columns. It is used with GAE to get around the 
lack of functionality in their DB but many db admins call it an anti-pattern 
called jay walking. The main difficulty is searching for a particular 
attribute in the list from a SQL perspective.



[web2py] Re: web2py 1.96.4 is OUT

2011-06-08 Thread ron_m
My application is working with model files under a subdirectory == the 
controller name.


[web2py] Re: web2py 1.96.4 is OUT

2011-06-08 Thread ron_m
I should have said using version 1.96.4 as verification requested by Jay. 
BTW controller specific models were not introduced until 1.96.1

On Wednesday, 8 June 2011 13:37:11 UTC-7, ron_m wrote:

 My application is working with model files under a subdirectory == the 
 controller name.



[web2py] Re: webfaction: Internal Server Error after upgrade to 1.96.2

2011-06-04 Thread ron_m
On my Ubuntu 10.04 system /dev/urandom has mode 666 which means read and 
write for everyone. If it is not writeable on Webfaction for others then it 
is either a policy for a different Linux distribution or a policy of 
Webfaction.

The idea behind writing to /dev/urandom is to seed the random number 
generator so the output read from the generator is less likely to be guessed 
which increases security.


[web2py] Re: webfaction: Internal Server Error after upgrade to 1.96.2

2011-06-04 Thread ron_m
To add some more, on Ubuntu and according to man urandom all major Linux 
distributions since 2000 the file /etc/init.d/urandom saves the random 
number pool into a seed file and restores it on startup by writing it back 
to /dev/urandom.


[web2py] Re: LOAD: ajax_trap errors... (still in 1.96.1)

2011-06-03 Thread ron_m
Verified fixed in 1.96.2


[web2py] Re: databases and the shell

2011-06-02 Thread ron_m
You need to put the define_table in a model file or type it in again. You 
are probably better off using a command line shell, see teh link

https://groups.google.com/d/topic/web2py/AzCFS8X7oLc/discussion


[web2py] Re: databases and the shell

2011-06-02 Thread ron_m
The post by Yarko is the one you want to look at, sorry


[web2py] Re: LOAD: ajax_trap errors... (still in 1.96.1)

2011-06-02 Thread ron_m
I figured out the problem. The Javascript generated looks like this:

web2py_trap_form('('/app/default/testajax.load',)','c831268503949');

which is illegal because the single quotes around the URL terminate the 
single quotes of the first parameter for web2py_trap_form

It looks like a string '(' then /app/default. is no longer inside 
quotes.

Line 148 of compileapp.py in version 1.96.1 has the line

   js = web2py_trap_form('%s','%s'); % (link, target)

I traded the quotes around in the Python code like so

   js = 'web2py_trap_form(%s,%s);' % (link, target)

so the output would change to look like

web2py_trap_form(('/app/default/testajax.load',),c831268503949);

which is legal Javascript and now I get no errors.

A second question is why the link is a set, the output formating seems to 
indicate that. I don't know enough to know whether the first element should 
be dereferenced e.g. link[0] instead of just link. Then there would not be 2 
sets of single quotes atcked in the output.

Ron







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

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

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

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

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


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

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

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


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

2011-05-30 Thread ron_m
Good for you on the course completion. There is a lot to learn especially if 
you have never done web development before of this type. For web development 
many people do HTML/CSS and to a lesser degree Javascript only so the server 
only pushes pages that are pre-canned. I worked with Java for many years 
doing server development and by comparison web2py is a dream. Part of the 
comparative ease of use is Python but much of it is the organization and 
integration of web2py. At first it looks like magic, then you learn a little 
because magic is an uneasy feeling but as you gain experience you learn some 
more and start to realize how well put together it all is.

Java in it's own way is okay, just so much boiler plate code and some of the 
frameworks have you writing pages of XML that has no equivalent in web2py 
mainly because it follows a philosophy similar to Ruby on Rails (convention 
not configuration).

Maybe see you back if you do more with web2py.


[web2py] Re: can't use admin, can't see tickets with localhost google appengine SDK

2011-05-26 Thread ron_m
Glad to help, wish you success on your project.


[web2py] Re: os.path.exists thread safety?

2011-05-26 Thread ron_m
os.path.join takes into account the path separation character - UNIX = '/' 
Windows = '\' which is why you should use it for when you want to run on 
both system types even if you don't expect to right now.

os.path.exists internally does a stat() of the file to determine if it 
exists. There are cases listed in the docs where it returns false such as 
broken symbolic links. If another thread removes the file right after you 
get a true return then your next operation will fail. The best option is to 
use try except blocks and gracefully handle the file went away errors in the 
except section and re-raise errors you can't handle there. On UNIX once you 
get the file open the file will remain accessible through that open file 
descriptor even if another thread removes the file which is actually 
completed by just removing the directory name-inode pair. No other process 
will ever open the file again once all the directory links are gone and the 
final close will clean up the contents and release the resources back to the 
free pool on the file system. Conversely, on Windows you can't remove a file 
open to a process is my understanding from using that system.

I digress but one of the hardest things to find on a UNIX system is a 
process writing blocks to a file which has been already removed from all 
directories. That file will continue to grow as long as the process writes 
to it and the blocks remain allocated as long as the process stays alive. 
The sys admin can see the file system free space disappearing but will have 
trouble finding out why because this file won't show up on du reports. In 
this case your friend is lsof. This isn't a bash of UNIX, I much prefer that 
system type, just one of the things that many people using it don't realize.



[web2py] Re: Create an email queing feature...

2011-05-26 Thread ron_m
A possible idea, each email insert into a table. When the cron job wakes up 
have it read X number of emails with the smallest ID value from the table 
and process them. Delete the row as each one is completed. 


[web2py] Re: can't use admin, can't see tickets with localhost google appengine SDK

2011-05-25 Thread ron_m
I run the same version of Ubuntu, no problems with seeing or generating 
tickets when I don't get it quite right in the code. Check the permissions 
on the errors directory for you app?

The errors in views are from when the Python code runs which is after 
extend, include and translation of HTML etc. into response.write statements. 
There should be enough in the content of the generated Python to get you 
close to the right place in the original view code.


[web2py] Re: ATTENTION trunk users!!!!

2011-05-25 Thread ron_m
I backed up my database, made a copy of the application databases directory, 
hg pull and hg update on trunk.

Got this traceback right away

Traceback (most recent call last):
  File /home/camcentral/Dev/web2py-hg/gluon/restricted.py, line 184, in 
restricted
exec ccode in environment
  File /home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py 
http://127.0.0.1:8000/admin/default/edit/ccims/models/A_db.py, line 49, in 
module
auth.define_tables(username=True)  # creates all needed tables
  File /home/camcentral/Dev/web2py-hg/gluon/tools.py, line 1148, in 
define_tables
format='%(username)s')
  File /home/camcentral/Dev/web2py-hg/gluon/dal.py, line 4175, in define_table
polymodel=polymodel)
  File /home/camcentral/Dev/web2py-hg/gluon/dal.py, line 633, in create_table
fake_migrate=fake_migrate)
  File /home/camcentral/Dev/web2py-hg/gluon/dal.py, line 716, in migrate_table
if query:
UnboundLocalError: local variable 'query' referenced before assignment

Did I miss a step? In development I default migrate=True fake_migrate=False

Ron




[web2py] Re: ATTENTION trunk users!!!!

2011-05-25 Thread ron_m
query isn't set in the last elif branch before the else


[web2py] Re: ATTENTION trunk users!!!!

2011-05-25 Thread ron_m
I added query = None after line 668 which is the line containing

for key in keys:

just before the line

if not key in sql_fields_old:

and got rid of all the query = None statements in the if elif branches plus 
got rid of the else branch.

I am happy to report this allowed the application to run completely without 
error.

I don't use all the features of web2py but then I am sure very few of us do.

Ron


[web2py] Re: can't use admin, can't see tickets with localhost google appengine SDK

2011-05-25 Thread ron_m
Looks like you get a ticket trying to display the application error ticket. 
I had that once but I was debugging something in trunk that was broken at 
the time.

You mentioned you have a fully and properly working debain version. I 
believe it is legit to move the files under errors in your application to 
the system that works and look at them there using the admin interface. That 
might help get a handle on it.

Also when the admin system gets an error you will find the ticket file under 
applications/admin/errors.

You are using stable from web2py currently 1.95.1?

I would be tempted to download the zip file, unpack it and slide it into 
place where the existing one is now after you rename the top directory of 
the old one. Then you can run a diff to see if something got changed 
somehow.

Is there a requirement to run GAE on python 2.5? What version of Python is 
on your debian system where everything is working? I run standalone or under 
apache with wsgi on Python 2.6.5 without issues. Have a look at 
web2py/scripts/setup-web2py-ubuntu.sh and you can see the packages that get 
loaded in there. I wouldn't load in matplotlib or reportlab unless you need 
them.

Ron



[web2py] Re: Consuming a web2py web service in C#?

2011-05-24 Thread ron_m
If you go to the web2py server admin app e.g. http://127.0.0.1:8000/admin 
and login you should see the name of the app containing the service and an 
errors link after the name. Click that and you will see the errors page and 
be able to see the stack trace.

When running as a Python process you can put print statements in your 
controller to get an idea of what the parameters look like coming into the 
request. The output should go out on the terminal you ran python web2py.py 
from. Be sure to comment out the print statements before embedding in a web 
server such as apache with WSGI or you will get tickets from the print 
statement.


[web2py] Re: Problem with Ubuntu init script

2011-05-24 Thread ron_m
I found out the DAEMON_ARGS change should not be applied. The start branch 
of the script needs both pid file options.

The --pidfile option prevents start-stop-daemon from behaving like killall 
as mentioned in the Description section of the start-stop-daemon man page. 
This will allow start-stop-daemon to run python if it finds another copy of 
python on the system doing some other task.

The --pid_filename option to web2py is needed to actually get the 
/var/run/web2py/web2py.pid file written otherwise the service web2py stop 
command or the init state change will fail to find the copy of python 
running web2py and kill it.

Please use only the line 65 patch from above. I sent Massimo the correct 
patch file so he is looking at it.

Ron


Re: [web2py] get last visited page

2011-05-24 Thread ron_m
a href=javascript:void(history.go(-1))img src={{URL('static', 
)}}/a

puts an image link that simulates the back button on the page. You could 
convert it to button and use the jQuery alternative

Too much of a hack? The web2py framework is very good with history 
integration.


[web2py] Re: How to make a constant for list of fields in select()?

2011-05-24 Thread ron_m
Ah C, pointers and pointers to pointers for **
I used to like pointers in C but then I used to work on operating systems 
written in assembler during my early years in computers (70s, early 80s).
Results in a different mindset.


Re: [web2py] Re: how to adjust timezone for request.now ?

2011-05-23 Thread ron_m
I was thinking of the values you would ultimately store in the database and 
what you might use them for eventually. If you want to use these times in a 
SQL expression in the WHERE clause through direct SQL or through DAL 
expressions and search across multiple users for something created between 
time X and Y then they should all be resolved and then stored to the same 
time zone not different ones. In that case you would want to work in UTC on 
the server and then convert using Javascript in the user's browser since the 
user's workstation should have the proper setting for the time zone they are 
in which will trickle down through the browser and the Javascript code to 
convert between UTC and local time for each particular user.

However, since there is no real background for what you want to do with the 
time values from the application perspective it is difficult to advise you 
without some speculation. :-)

Massimo's comment is spot on. The default in the server is to generate the 
time as the local time of the server when the request comes in which again 
would be consistent if all your servers are in the same timezone. To get UTC 
just assign request.now = datetime.utcnow() and use the value consistently.

If you never intend to use the times for comparison across multiple users 
then you can store in the user's local time but I think you will also need 
to store the user's timezone as well to be able to render it back out to the 
user later for display.


[web2py] Problem with Ubuntu init script

2011-05-23 Thread ron_m
scripts/web2py.ubuntu.sh has a problem with starting web2py sometimes. The 
symptom is the init script is run with a start option but web2py does not 
start. 

The cause is if the start-stop-daemon program used to start python sees 
another copy of python running it will refuse to start the copy of python 
required to run web2py. This can be corrected by having the --pidfile option 
on start-stop-daemon --start, then start-stop-daemon will allow another copy 
of python to run. In the current script the pid file writing option is the 
responsibility of the web2py command as set in DAEMON_ARGS. It should be 
moved to be an option of start-stop-daemon.

Here is the output from diff from trunk after I made the changes

$ diff ../web2py-hg/scripts/web2py.ubuntu.sh web2py.ubuntu.sh 
30c30
 DAEMON_ARGS=web2py.py --password=recycle --pid_filename=$PIDFILE
---
 DAEMON_ARGS=web2py.py --password=recycle
65c65
 start-stop-daemon --start --quiet \
---
 start-stop-daemon --start --quiet --pidfile $PIDFILE \



[web2py] Re: script to clone a database

2011-05-23 Thread ron_m
Great, I was doing this manually, this really helps codify the procedure.

The export_to_csv_file and import_from_csv_file routines are the magic with 
how they fix up all the foreign keys to match the new primary key values. 



[web2py] Re: how to adjust timezone for request.now ?

2011-05-20 Thread ron_m
Actually it isn't that obvious. In Python the datetime class by default is 
not time zone aware. If you have users coming from multiple time zones the 
best universal way to handle this is store the time in UTC which the 
datetime class has a method for datetime.utcnow(). This is how UNIX does it 
internally and then warps the time to the local time of the user based on 
their environment variable setting. If you don't do this then time 
comparisons across users become a real bear to deal with. If you have all 
the users on one server it will be the server time that is used to fill the 
database fields if you use datetime.now() instead so you might be able to 
manage it that way. The browser client through Javascript knows the timezone 
of the client and without being specific I believe there is a way to get 
from UTC to local time in Javascript. So again it comes back to using UTC on 
the server for the least effort over all.

Hope that helps
Ron




[web2py] Re: Static file caching problem?

2011-05-19 Thread ron_m
I examined the TCP traffic with Wireshark and could not see the actual 
requests go out to the server. I am beginning to believe this is a Firebug 
instrumentation problem. I would believe the Wireshark trace, it had no 
filters and I removed as much traffic as possible on the interface and all I 
got was a GET to the controller for the page. Sorry for the noise.

Ron


Re: [web2py] Re: Static file caching problem?

2011-05-19 Thread ron_m
Martin,
Thanks for the suggestion, the analyze function shows 200 for the status but 
that it loaded from cache which is consistent with observation using 
Wireshark. This tool is also a much more direct approach to increasing 
performance. It also pointed out that the items getting the 200 do not have 
an expires setting. Now I see why the browser would reload a JPG an hour 
later that has not changed in months.
Ron


[web2py] Static file caching problem?

2011-05-18 Thread ron_m
Host is Ubuntu 10.04, web2py is 1.95.1
I use Firefox 3.6.17 from the Ubuntu distribution
Added the Firebug plugin.

Running on the rocket built in server port 8000 if I enable the Net tab of 
Firebug

Clicking around on the application buttons all the static CSS and Javascript 
resources such as jQuery and jQueryUI and anything else the response loads 
is always 200 OK and the CSS and Javascript is downloaded. Even pushing the 
same top level menu item twice in a row yields the same load every time.

If I hit the refresh button in the browser toolbar then the response for the 
CSS and Javascript files is 304 Not Modified.

Images are not affected and only show up as 304 Not Modified responses.

I then went to the Apache WSGI installation running on port 80 and get the 
same result.

This could be a serious drag on performance depending on the network 
connection. I probably didn't notice because the browser and server are on 
the same machine for development work.

The files that avoid caching are the ones added to the response.files 
collection in the view from what I have seen so far.

Anyone else seeing this?

Thanks,
Ron


[web2py] Re: differntial of request.args[0] and request.args(0)

2011-05-15 Thread ron_m
In the core chapter of the book I found this:

In the above example, both request.args[i] and request.args(i) can be used 
to retrieve the i-th element of the request.args, but while the former 
raises an exception if the list does not have such an index, the latter 
returns None in this case.

I would use request.args(0) and test for None if it is legal for the arg to 
not to be there on some requests. Conversely, if arg 0 is always supposed to 
be part of the request then request.args[0] would generate an exception and 
a ticket indicating a failure condition when it is missing.



Re: [web2py] Re: Weird Error in modules files...

2011-05-15 Thread ron_m
If the second parameter on local_import is True it will reload each time the 
statement is executed. Otherwise it retains the first local_import until 
server restart.


Re: [web2py] Re: Gigya - Janrain alternative

2011-05-13 Thread ron_m
Pricing by an accountant, no offence to accountants - hmm 1000 people that's 
only $15/year per person I am sure is someone's way of thinking. I might see 
a mid size company going for it if they wanted to outsource authentication. 
Too much for my pockets. :-)


[web2py] Handy HTTP traffic examination and interaction tool

2011-05-11 Thread ron_m
Ran across this in a blog, written in Python, 

http://mitmproxy.org/

from the web page:

*mitmproxy* is an SSL-capable, intercepting HTTP proxy. It provides a 
console interface that allows traffic flows to be inspected and edited on 
the fly. 

*mitmdump* is the command-line version of mitmproxy, with the same 
functionality but without the frills. Think tcpdump for HTTP.




[web2py] Re: how do you put a JavaScript variable in a python variable

2011-05-06 Thread ron_m
In a typical view file you have to think about where the execution will 
occur.

The Python code in the view will run on the server as part of the page 
generation process, the page is shipped out to the user's browser as the 
response and will be HTML and Javascript and the Javascript that possibly is 
embedded in that page is run by the user's browser. Given that situation 
there is no longer any Python code for the Javascript to assign a variable 
into.

Your only hope is to generate an AJAX request from the Javascript which will 
send a new request to the server as a way to interact back with the Python 
code on the server.


[web2py] Re: python/javascript

2011-05-06 Thread ron_m
Please don't multiple post the same question. I have seen this question 
posed 3 times in the last day and it has been answered by several people in 
the different instances of the question. If you don't get an answer right 
away it is because:

1) Everyone that might want to answer is getting 3 or 4 hours of sleep
2) Nobody understands the question
3) Most (all) of the people on this message board are volunteers and have 
other jobs, some very demanding.

Thanks for your consideration of us, I think I can speak collectively for 
all on the group, we really do try to help.
Not intended to scare you away.

Ron


[web2py] Re: Unknown auth_user injected in 1.95.1

2011-04-29 Thread ron_m
I just did with 1.95.1 and the auth_user table is empty. I am not using 
powerpac tools, it is a plain install from the web2py_src.zip file download.


[web2py] Re: Unknown auth_user injected in 1.95.1

2011-04-29 Thread ron_m
I would just download the web2py_src.zip and unpack it in a different 
directory and then run it from that directory

python web2py.py

do the simple app in admin and check the result.

I believe the simple app builder is just an unpack and rename of the welcome 
app - the w2p file in the base of your web2py install is teh basis for that 
application construction. I would guess that user is somehow embedded in the 
welcome app sqlite database. Maybe this person found you machine and 
registered when you were in early stages of installation using the welcome 
app?


Re: [web2py] Re: password encrypt during insert

2011-04-28 Thread ron_m
email of a.a.com is not a valid email address according to your code.
I am not sure if there is any validation during login


[web2py] Re: Deploying DB

2011-04-27 Thread ron_m
The duplicate .table files from what I can tell come from using different 
database connection strings. I haven't looked for the code but I do know if 
I change the database type, user name etc in the DAL() connection string 
parameter it appears to generate a hash code from the string and prefix that 
onto the table name and then .table as the extension. 

If you were to look in your development environment I am guessing one of the 
prefixes in your production set matches and if the production db connection 
string is different I am reasonably sure it will be using the other set of 
.table files. Except for SQLite I have found it only makes sense to preserve 
the database directory across installation instances if you use the exact 
same database connection string in both installations. Then I copy the 
database across using the database specific dump restore. If I get the 
tables already created error because I changed something I drop the 
database, clear out the databases directory, create an empty database, run 
the application up once to create an empty table and relations set and then 
load the data using the import from cvs file method. Now that I know what 
fake_migrate does I might try that next time by just deleting the .table 
files.

My db is small containing configuration data for the application mostly so 
it isn't much of a hardship to toss these around. When the db is large it is 
a totally different matter that requires a lot more effort and time.


[web2py] Re: Menus in the model don't update at the right time...

2011-04-27 Thread ron_m
The web2py request work flow runs the model files first, then the 
controller, then renders the view. I had a similar problem, the only way I 
could figure out how to change the menu after the model files have run was 
to add a menu update function to the model and call it from the controller 
when necessary.


[web2py] Re: Variables in javascript function.

2011-04-22 Thread ron_m
Try changing

name=window.open(url,name,'toolbar=yes,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=width,height=height');
 


to have the variables width and height not inside the string literal quotes, 
something like this

name=window.open(url,name,'toolbar=yes,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height);
 




[web2py] Re: new web2py version

2011-04-21 Thread ron_m
I ran my application and did not see any problems. I am over a PostgreSQL 
database. I likely did not exercise any new features, I have not touched the 
code in a week or more - working on other things right now.


[web2py] Re: Netbeans

2011-04-15 Thread ron_m
Doesn't look good for Python support in Netbeans 7 according to this

https://groups.google.com/forum/#!topic/comp.lang.python/JQQWJCARh9U




Re: [web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-13 Thread ron_m
The _select is a nested select - the one in the second half of the WHERE 
clause that Christian wrote out for the SQL equivalent.

But the _select needs to return exactly one column, try changing _select() 
to _select(db.user_tags.tag)

There is some discussion in the manual under the belongs topic

Ron


[web2py] Re: Change IPython to BPython in shell mode

2011-04-10 Thread ron_m
First item on Blender page you reference, big discussion on auto import bpy. 
All the arguments look familiar. :-)


[web2py] Re: please help: owned by windows way of doing things

2011-04-10 Thread ron_m
In UNIX for text mode output the default setting in the serial driver is to 
map the standard UNIX EOL which is \n to \r\n
Unix input also maps \r to \n
The Linux man page is 
man 4 tty_ioctl
for more than you will likely will want to know

In Windows the file must contain the \r\n which is the standard EOL sequence 
for that system.

This is why programs such as ftp in ascii transfer mode do the conversion 
for you.

The Linux mcopy program from Mtools might help you otherwise (part of my 
Ubuntu install)


Re: [web2py] main menu z-index

2011-04-04 Thread ron_m
Are you using IE as the browser? I had a similar problem show up with video 
displayed in an ActiveX control but it worked fine in anything but IE. In 
the end it was presumed this was an IE issue with CSS based menu posting so 
I went away from pull down submenus with having to support IE8.


[web2py] Re: FAQ topic(s) on typical Web2py FUD

2011-04-04 Thread ron_m
Agreed, I looked at all the usual suspects for a Python framework and came 
to the conclusion web2py was the best integrated of any and represented the 
path of least resistance to getting work done with well chosen defaults in 
the design and a well defined way of implementing applications. The admin 
functions helped a lot as well. Nothing since starting to work with web2py 
has changed my mind on the choice I made. I spent years in the land of Java 
before this so am familiar with working with databases from using an ORM 
down to writing my own SQL in JDBC. I like the DAL, close enough to the 
database that you don't lose sight of it in a slew of object mappings but 
far enough away from the drudgery of doing it all by yourself. The layering 
of the controllers and views over top is icing on the cake as they say, no 
reference to CakePHP intended. :-)


[web2py] Re: Issues with python in the menu.py

2011-04-03 Thread ron_m
Hi Jason

This line
response.menu += [(T('My Conferences'), False, 
URL('default','my_conferences'), [
users_conferences_list
])]
I think should be
response.menu += [(T('My Conferences'), False, 
URL('default','my_conferences'), 
users_conferences_list
)]

users_conferences is already a list, wrapping it in [] makes a one element 
list containing the users_conferences list which is not what menu expects.

Ron


[web2py] Re: cannot import name DateTime

2011-04-02 Thread ron_m
Something is odd, looking at your traceback dal.py line 3357 in my copy of 
trunk updated a minute ago is in the last line of the initializer code for 
ADAPTERS


[web2py] Re: Garbaginator

2011-04-01 Thread ron_m
Hmm didn't know Rails was a Python web framework, according to Garbaginator 
it is. :-)
Check out gmail motion on Google home page


[web2py] Re: discounted books

2011-03-25 Thread ron_m
I would like one, location Vancouver Canada for the postage calculation. Can 
use Paypal if you like.


[web2py] Re: DAL not working in shell

2011-03-25 Thread ron_m
It is in web2py-developers


[web2py] Re: DAL not working in shell

2011-03-25 Thread ron_m
Sorry should have put in link for interest of others, the post on the DAL 
shell by Kevin is in web2py-developers at

https://groups.google.com/forum/?pli=1#!topic/web2py-developers/AbBiV8hoLIw


[web2py] Re: reddit again

2011-03-22 Thread ron_m
Maybe they are just jealous they never thought of what you have done before 
you made it a reality with web2py.


[web2py] Re: File Upload and save to DB

2011-03-22 Thread ron_m
I presume you know enough Python to be able to open these files, read and 
parse the content and come up with a data structure such as a dict of the 
name value pairs in the file.

In your own standalone program you can use the DAL by itself

from gluon/dal import DAL, Field

then you can connect to your database and define your model as per chapter 6 
of the book. Look at Chapter 4 first to get a good overview of web2py.

The data from the file can be driven into the appropriate table with 
db.insert(...)

Unlike the web applications you need to db.commit() at the end if everything 
succeeds or db.rollback() if you want to back out, this is done 
automatically for you in the web request-response cycle.


Another option is you could write a normal web app that has a controller 
that will take the ini file key value pairs as keyword args and then either 
fire the URL at the origin or a standalone program that reads the ini files 
and fires the URLs in using urllib2.


[web2py] Re: Converting legacy MySQL databases to web2py DAL

2011-03-21 Thread ron_m
Looks great, thanks for the addition. I worked on this a bit when it first 
was added but since I don't use mysql any more in the application I am 
working on and have a high workload I never got any further.


[web2py] Re: Export DB from admin?

2011-03-21 Thread ron_m
I moved from MySQL to PostgreSQL a few months ago with a small database but 
with a significant number of many to many relations as well as one to many. 
Here is what I did:

Exported the data from MySQL using the export_to_csv_file call from the 
shell with the model activated which pushes all the data out to one CSV.

Copied the application directory under web2py/applications, removed all the 
files under databases, changed the connection string in the model.

Created the database in PostgreSQL, left the DB empty.

Ran the application which ran the model and created all the tables and 
relations but no data.

Ran the import_from_csv_file in a shell with the model activated using the 
file from the export step. Don't forget the db.commit() at the end.

The import_from_csv_file does a fantastic job of mapping the old ids to new 
ids in the foreign key relations. I didn't find any breakage in the data. 
This allows the import to not use tricks like turning off the auto increment 
keys such as what happens when using a mysqldump to a file followed by 
reading it in with mysql. Any database that has been used for a while will 
usually have holes in the id sequence of records caused by deletion of 
records. The import_from_csv_file will pack all the ids into a continuous 
sequence and then fix the foreign key references by maintaining the old to 
new id mapping. If your application depends on knowing specific ids this is 
a problem but then I would argue this is an application design issue.

I tested the application and only found one DAL statement that worked in 
MySQL that would not in PostgreSQL. By changing the group by field in the 
query to the field on the other side of the join it worked in both versions.

By copying the application temporarily you are preserving the 
application/databases directory and since you are not touching the MySQL 
database exporting to CSV there isn't much danger in losing the data.

If the database were very large I am not sure how well this would work 
because the IDs from original to new database mapping must be kept in 
memory.

For regular backups by all means use the designated utility provided by the 
database.


[web2py] Re: Bug? Opening session files from multiple processes

2011-03-11 Thread ron_m
You should only get a portalocker.LockException if the no blocking option is 
set on the lock attempt which it is not the case in the original web2py 
code.

However, the exception handler inside portalocker.lock will re-raise any 
exception if it is not IOError for Errno 11

It would be very helpful if you posted the stack trace that shows the 
exception type and details.


Re: [web2py] Re: Dotcloud hosting great tutorial but stuck

2011-03-10 Thread ron_m
Type in the terminal window

echo $PATH

upper lower case is important. It should have /bin between colon characters 
somewhere

or try

/bin/ls

as a command.

Either you PATH environment is messed up or some important command files are 
missing from the /bin directory.


[web2py] Re: No login possible in Firefox, but in chrome

2011-03-09 Thread ron_m
The symptoms look exactly like a user I had a problem with logging into my 
application but for them cookies were disabled, re-enabling cookies fixed 
it.

Firefox cookie settings are a little obscure, here is a web reference

http://support.mozilla.com/en-US/kb/Websites%20say%20cookies%20are%20blocked

there are 2 flags, accept and accept third party cookies.

You say you have cookies enabled but I run the same configuration as you and 
have no trouble logging in on my applications. The fact that it works in 
Chrome would indicate to me that your application is in working order for 
the most part. Are there any Javascript errors reported?


[web2py] Re: conditionally include in view

2011-03-09 Thread ron_m
I use this in a portion of the views coded for what I am working on and it 
works for me. I just ran the page with the test true and again with the test 
false and I get the include file content inside the {{if condition:}} branch 
if the condition is True and the html in the {{else:} branch if the 
condition is False. I verified with a View Source in the browser, the code 
from the include file is not there when the condition is False. I am on 
1.93.2 but this has been consistent for several months now.

Here is a chunk of code

{{site_names =  session.user_access['site_names']}}
{{if len(site_names)  1:}}
{{include 'common/site_switcher.html'}}
hr /
{{else:}}
{{=B(header)}}
{{pass}}
{{include 'live/display_mode_switcher.html'}}
hr/

I think the include is indeed expanded out unconditionally but when the 
Python logic runs the response.write is not executed for that portion of the 
code if condition is False.

Replace someData in your example with True and then with False and refresh 
the page to see what you get in each case. The truthness or falseness of a 
variable can be deceiving. Also the include file name should be the path 
portion past views.


[web2py] Re: Dotcloud hosting great tutorial but stuck

2011-03-09 Thread ron_m
That is a symlink creation so the assumption if using that command is 
wsgihandler.py exists in the current directory and you are creating a 
symbolic link named wsgi.py which points to wsgihandler.py.

If you use ls while logged in on the server do you see wsgihandler.py, run 
the ls command. If not then you need to be in the web2py install directory

$ ls -l wsgihandler.py

should show you the file. The ln command is a standard UNIX command. Do you 
get an error message?


Re: [web2py] Basic authentication user id

2011-03-07 Thread ron_m
In the file gluon/tools.py line 808 in trunk the Auth class __init__ method 
you will find these lines

if auth and auth.last_visit and auth.last_visit\
 + datetime.timedelta(days=0, seconds=auth.expiration)\
  request.now:
self.user = auth.user
self.user_id = self.user.id
auth.last_visit = request.now

I am guessing this branch does not run when used in a standalone environment 
and the else branch not shown above runs instead which sets the 3 values to 
None.


Re: [web2py] Basic authentication user id

2011-03-07 Thread ron_m
I am guessing some more because I didn't trace the code but I think 
auth.user eventually gets set in login_bare without setting auth.user_id but 
then do standalone apps actually login?
I could only find 3 places where self.user_id is used in the class, the 2 
places in the if else and as a test to see which of the nav bars (login or 
logout) should be placed at the top of the page. I could not see anywhere 
else that auth.user_id is set outside the class.

I guess bottom line is Alexei has a solution. :-)


[web2py] Re: DAL new syntax RFC

2011-03-07 Thread ron_m
+1


[web2py] Re: Error in trunk opening PostgreSQL database

2011-03-04 Thread ron_m
Thanks, it is easy to see how the default parameter gets changed with that 
example since the binding passes back outside the function through the 
return value, gets assigned to another variable and then the container 
contents modified through that assignment.


[web2py] Re: potential memory leak???

2011-03-04 Thread ron_m
RSS (Resident Set Size) is a closer approximation of actual physical memory 
consumed by a process. VSZ includes shared libraries and anything else 
required to be mapped in to make the process complete but shared libraries 
are not in physical memory more than once for all processes except the 
writeable data area they may contain.

Presuming Linux or UNIX like system and CPython memory allocation ultimately 
comes down to the library function malloc which is layered over the system 
call sbreak. The malloc library call manages allocation of memory to 
whatever is requesting it such as the CPython interpreter but works from a 
pool for performance efficiency. If it runs out of room it calls the system 
using sbreak to get another chunk. It is possible to reduce the size by 
calling sbreak with a smaller size but malloc must be sure the area given 
back is completely free from use by objects. This was typically never done 
in the past. If malloc frees a lot of space then it will just reuse it on 
the next allocation request. I admit I have not dug into the CPython use of 
malloc reading code to see what it does. What I am saying is the numbers 
reported by system utilities can be misleading specifically if sbreak size 
reduction is not exercised.


[web2py] Re: potential memory leak???

2011-03-04 Thread ron_m
Depending on the system type the memory doesn't get released. It is rare 
that a malloc implementation calls sbreak with a smaller number than the 
previous call which is what you are looking for. If you have a program that 
consumes say 100 MB to do some initialization and then frees all those 
memory objects the program size does not shrink. However malloc will keep 
track of what is free and reuse it so if the growth goes up to a certain 
level and stays constant after that as you continue to use the application 
then you don't have a leak. A leak is where the memory is not freed but the 
references to it are lost so it keeps going for more memory from the system. 
In that case the memory growth will not hit a levelling off point like your 
application seems to have reached and instead continues to grow and either 
hit system imposed limits or consume all physical memory on the system and 
force swapping.

My web2py application starts at 22 MB of RSS and if I hit every page in a 
test run it grows to 48 MB and I only have configuration data in the 
database so small tables. I can run the server for weeks after that and will 
not see any further growth. If you see behaviour like that while users are 
still using the application you don't have a memory leak.


[web2py] Error in trunk opening PostgreSQL database

2011-03-03 Thread ron_m
I tested my app with version 1.92.1 and it works. I then copied it to trunk 
and I can no longer connect to the PostgreSQL database I use.

I looked at the code in dal.py for the PostgreSQL adapter and driver_args 
defaults to empty dict {}, adding some debug print code shows it is set on 
the class construction to be {'check_same_thread': False} and when this is 
passed to the driver an invalid keyword argument error occurs

Here is a traceback from the ticket.

web2py™ Version 1.92.1 (2011-03-03 08:26:32)  Python Python 2.6.5: 
/usr/bin/python  Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Traceback (most recent call last):
  File /home/camcentral/Dev/web2py-hg/gluon/restricted.py, line 188, in 
restricted
exec ccode in environment
  File /home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py 
http://127.0.0.1:8000/admin/default/edit/ccims/models/A_db.py, line 22, in 
module
db = DAL('postgres://user:password@localhost/cc_ims', POOL_SIZE, 
check_reserved=check_reserved_value)
  File /home/camcentral/Dev/web2py-hg/gluon/dal.py, line 3529, in __init__
raise RuntimeError, Failure to connect, tried 5 times:\n%s % error
RuntimeError: Failure to connect, tried 5 times:
'check_same_thread' is an invalid keyword argument for this function

 Error snapshot [image: help] Detailed traceback description 

type 'exceptions.RuntimeError'(Failure to connect, tried 5 times: 
'check_same_thread' is an invalid keyword argument for this function) 
Frames

   -  
   
   *File /home/camcentral/Dev/web2py-hg/gluon/restricted.py in restricted at 
   line 188* code arguments variables 
Function argument list 
   
   (code='# -*- coding: utf-8 -*- \n# this file is 
   released...sion.table_name.requires = IS_IN_SET(db.tables)\n\n', 
   environment={'A': class 'gluon.html.A', 'B': class 'gluon.html.B', 
   'BEAUTIFY': class 'gluon.html.BEAUTIFY', 'BODY': class 
   'gluon.html.BODY', 'BR': class 'gluon.html.BR', 'CENTER': class 
   'gluon.html.CENTER', 'CLEANUP': class 'gluon.validators.CLEANUP', 'CODE': 
   class 'gluon.html.CODE', 'COUPLE_MENUS': True, 'CRYPT': class 
   'gluon.validators.CRYPT', ...}, 
   layer='/home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py')
Code listing 
   
   183.
   184.
   185.
   186.
   187.
   188.
   
   189.
   190.
   191.
   192.
   
   if type(code) == types.CodeType:
   ccode = code
   else:
   ccode = compile2(code,layer)
   
   exec ccode in environment
   
   except HTTP:
   raise
   except Exception:
   # XXX Show exception in Wing IDE if running in debugger
   
Variables  environment {'A': class 'gluon.html.A', 'B': class 
   'gluon.html.B', 'BEAUTIFY': class 'gluon.html.BEAUTIFY', 'BODY': class 
   'gluon.html.BODY', 'BR': class 'gluon.html.BR', 'CENTER': class 
   'gluon.html.CENTER', 'CLEANUP': class 'gluon.validators.CLEANUP', 'CODE': 
   class 'gluon.html.CODE', 'COUPLE_MENUS': True, 'CRYPT': class 
   'gluon.validators.CRYPT', ...}  ccode code object module at 
   0x30bda08, file /home/...py-hg/applications/ccims/models/A_db.py, line 8  
-  
   
   *File /home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py in 
   module at line 22* code arguments variables 
Function argument list 
   
   ()
Code listing 
   
   17.
   18.
   19.
   20.
   21.
   22.
   
   23.
   24.
   25.
   26.
   
   # else use a normal relational database
   #*** Add customization
   #   db = DAL('sqlite://storage.sqlite')   # if not, use SQLite or other 
DB
   # CamCentral IMS configuration database
   #   db = DAL('mysql://root:pass@localhost/cc_ims', POOL_SIZE, 
check_reserved=check_reserved_value)
   db = DAL('postgres://user:password@localhost/cc_ims', POOL_SIZE, 
check_reserved=check_reserved_value)
   
   ## if no need for session
   # session.forget()
   
   #
   
Variables  DAL class 'gluon.dal.DAL'  check_reserved undefined  
   POOL_SIZE 0  db undefined  check_reserved_value ['all']  
-  
   
   *File /home/camcentral/Dev/web2py-hg/gluon/dal.py in __init__ at line 
   3529* code arguments variables 
Function argument list 
   
   (self=DAL {'_lastsql': '', '_db_codec': 'UTF-8', '_ur...cc_ims', 
   '_pool_size': 0, '_dbname': 'postgres'}, 
   uri='postgres://user:password@localhost/cc_ims', pool_size=0, folder=None, 
   db_codec='UTF-8', check_reserved=['all'], migrate=True, fake_migrate=False, 
   decode_credentials=False, driver_args={'check_same_thread': False})
   



[web2py] FYI jQuery 1.5.1 breaks jQueryUI buttonsets

2011-03-03 Thread ron_m
The latest web2py trunk jQuery is 1.5.1

If using a buttonset from the jQueryUI Button widget the Javascript trips on 
the label tag 'for' attribute and throws an error leaving the buttonset as a 
set of radio boxes instead of making them into buttons. This can be seen in 
the jQueryUI Button Toolbar demo as an example 
(http://jqueryui.com/demos/button/).

I haven't figured it out yet and I am not discouraging web2py from moving 
forward to 1.5.1, I am just mentioning this to document it. I can keep my 
application at jQuery 1.4.4 until this is fixed by the jQuery/jQueryUI 
group.


  1   2   3   >