Re: [web2py] Re: How to use AJAX within a SQLFORM.grid 'add' form

2014-03-31 Thread Keith Edmunds
Thanks Anthony.

 First, take grid out of BEAUTIFY -- not necessary.

Thanks, done.

 Does db.t_dogs happen to have a field called name? If so, change the
 name of your extra input element to something other than name.

No, it doesn't.

 Also, when typing in your input field, open the browser developer tools
 and see if (a) you get any JavaScript errors in the console 

No.

 and (b) an
 Ajax request gets sent to the server.

Yes - but I knew that because I get a change in the display. It just
isn't the change expected. To reiterate, when the Add form is displayed -
in other words, while the grid is *not* displayed - typing in the form
displays the whole grid in the Ajax target area.
-- 
Blog: http://goo.gl/iOwv1w

You can't live a perfect day without doing something for someone 
who will never be able to repay you.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How to use AJAX within a SQLFORM.grid 'add' form

2014-03-31 Thread Keith Edmunds
Really helpful, thanks Anthony.

One suggestion: Chapter 11 of the book, heading The ajax function, has
exactly the code I used (that's where I got it from):

form
   input name=name onkeyup=ajax('echo', ['name'], 'target') /
/form

May I suggest that your comment about URLs be included in that
documentation?

Appreciate the help, thanks.

Keith
-- 
Blog: http://goo.gl/iOwv1w

You can't live a perfect day without doing something for someone 
who will never be able to repay you.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Detect change in sqlform.grid

2013-01-28 Thread Keith Edmunds
Sorry to bump: can anyone give me a pointer on this?

Thanks.

On Sun, 27 Jan 2013 09:02:45 +, k...@midnighthax.com said:

 On Sat, 26 Jan 2013 13:05:50 -0800 (PST), niph...@gmail.com said:
 
  grid takes formargs={}, createargs={}, editargs={}
 
 Thanks. I'm sorry if I'm being a bit slow here, but I *still* can't get
 what I want to work. I've tried:
 
 
grid = SQLFORM.grid(...,editargs={'onvalidation':x},..)
 
 def x(form):
 #dbg.set_trace()
 print in x
 
 
 ...but x is never called when editing items on the grid.
 
 What am I missing?
 
 Thanks.
 




-- 
Love Linux? We want to hear from you!
http://www.tiger-computing.co.uk/jobs/linux-support-consultant/

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Detect change in sqlform.grid

2013-01-27 Thread Keith Edmunds
On Sat, 26 Jan 2013 13:05:50 -0800 (PST), niph...@gmail.com said:

 grid takes formargs={}, createargs={}, editargs={}

Thanks. I'm sorry if I'm being a bit slow here, but I *still* can't get
what I want to work. I've tried:


   grid = SQLFORM.grid(...,editargs={'onvalidation':x},..)

def x(form):
#dbg.set_trace()
print in x


...but x is never called when editing items on the grid.

What am I missing?

Thanks.

-- 





Re: [web2py] web2py cookbook

2013-01-27 Thread Keith Edmunds
On Sun, 27 Jan 2013 09:07:50 -0800 (PST), pythonn...@gmail.com said:

 for learn more about web2py.

That appears to be the Web2py Cookbook, Copyright Packt Publishing.

Is this legitimate to share in this way? It would appear not, given that
the link on the Web2py pages is to purchase this book.
-- 
Love Linux? We want to hear from you!
http://www.tiger-computing.co.uk/jobs/linux-support-consultant/

-- 





Re: [web2py] Re: Detect change in sqlform.grid

2013-01-26 Thread Keith Edmunds
Thanks Massimo, but I'm struggling with how to apply this as I don't ever
process the form.

I'm doing:

grid = SQLFORM.grid(...)
return dict(grid=grid, ...)

How would I hook into the grid's process() function?

 SQLFORM(...).process(...)
 
 takes two callback functions
 
 process(onvalidation=lambda form:, onaccept=lambda form:)
 
 on validation is called when form is submitted, passes validation, and 
 before the database is updated.
 
 
 On Friday, 25 January 2013 17:16:40 UTC-6, backseat wrote:
 
  I have a SQLFORM.grid, and I hook into edits with 'onupdate'. 
 
  Is there an easy way to tell which field(s) have been edited? It seems 
  that by the time onupdate is called, the database has already been 
  updated, so comparing the form record with the db shows no
  differences. 
 
  Thanks. 
  -- 
  We're looking for smart Linux people: 
  http://www.tiger-computing.co.uk/jobs/linux-support-consultant/ 
 
 




-- 
We're looking for smart Linux people:
http://www.tiger-computing.co.uk/jobs/linux-support-consultant/

-- 





[web2py] Detect change in sqlform.grid

2013-01-25 Thread Keith Edmunds
I have a SQLFORM.grid, and I hook into edits with 'onupdate'.

Is there an easy way to tell which field(s) have been edited? It seems
that by the time onupdate is called, the database has already been
updated, so comparing the form record with the db shows no differences.

Thanks.
-- 
We're looking for smart Linux people:
http://www.tiger-computing.co.uk/jobs/linux-support-consultant/

-- 





Re: [web2py] Re: please help us test web2py

2012-07-09 Thread Keith Edmunds
On Sun, 8 Jul 2012 23:31:31 -0700 (PDT), too...@gmail.com said:

 +1 on removing it...
 The internet is covered with too many meaningless share buttons already.

Surely the whole point of the 'welcome' application is to be a scaffolding
to be modified as required? It is much easier for someone new to web2py to
work out how to remove it from their new app than to work out how to add
it if it isn't there.
-- 
We're looking for smart Linux people:
http://www.tiger-computing.co.uk/jobs


Re: [web2py] Re: How much python is needed to learn web2py

2012-07-03 Thread Keith Edmunds
On Tue, 3 Jul 2012 15:11:10 -0700, bruce.w...@gmail.com said:

 So sorry if I find it a little humorous when you think it is still in
 development mode

FWIW, I thought the same when I saw, We welcome all the new commers to
join this incredible site, Please full-fill the following form.

Maybe the tech part is done, and it's time for the copywriters?
-- 
We're looking for good Linux people:
http://www.tiger-computing.co.uk/jobs


Re: [web2py] Re: How much python is needed to learn web2py

2012-07-03 Thread Keith Edmunds
On Tue, 3 Jul 2012 15:17:59 -0700, bruce.w...@gmail.com said:

 The good news is development is becoming a lot faster as we learned from
 a lot of mistakes.

That's nice. I realise you won't have the time right now, but an article
summarising what you've learned would be good one day.
-- 
We're looking for good Linux people:
http://www.tiger-computing.co.uk/jobs


[web2py] How does keepvalues work?

2012-07-01 Thread Keith Edmunds
What is the mechanism that 'keepvalues=True' uses?

I have a form that uses keepvalues=True, and it includes combo box.
Occasionally the values in the combo change, and the previous value is
missing. I want to check for that and reset the default value for the
combo box if it isn't valid.

Thanks,
Keith
-- 
We're looking for good Linux people:
http://www.tiger-computing.co.uk/jobs


[web2py] Need DISTINCT query for combo box

2012-06-22 Thread Keith Edmunds
I have a combo box on a form to select a company name. The list of valid
company names is derived from a query, q, and so I have:

t = db.t_tasks
c = db.t_companies

t.f_company.requires = IS_EMPTY_OR(IS_IN_DB(
db(q), c.id, '%(f_name)s', zero=All))
 
That works, but the query may return more than one row for any given
company, and thus the combo repeats the company name, once for each row. I
need to make the query DISTINCT, but can't see how to do that.

Can anyone help?

Thanks,
Keith
-- 
We're looking for good Linux people:
http://www.tiger-computing.co.uk/jobs

-- 





[web2py] Advice on building a search form

2012-06-14 Thread Keith Edmunds
Hi All

I'd like some advice on the best approach to building a search form. I
don't think crud.search is right, but I'm not sure whether I should
approach this using a SQLFORM or SQLFORM.factory or some other way.

The model includes an 'activities' table that has a date column. There's
also a 'customers' table, and the standard auth_user table. I want to
build a form that has a date selector for 'from date', another for 'to
date', a combo for 'user' (populated from auth_user) and a combo for
'customer' (populated from the customer table).

The resulting query will be fed into a SQLFORM.grid, if that's important.

Any pointers to a good way of doing this?

Thanks,
Keith
-- 
We're looking for good Linux people:
http://www.tiger-computing.co.uk/jobs


Re: [web2py] Advice on building a search form

2012-06-14 Thread Keith Edmunds
On Thu, 14 Jun 2012 13:41:18 -0500, j...@qlf.com said:

 Here is a screen shot of what mine looks like.  I'm using 
 SQLFORM.factory to generate my 'search' form.

Jim, that looks to be exactly what I'm trying to do.

 Again, I'm buried with stuff this week thru Monday.  I can help if 
 Tuesday is soon enough.

Next Tuesday is great: I look forward to learning more then.

Thanks,
Keith
-- 
We're looking for good Linux people:
http://www.tiger-computing.co.uk/jobs


[web2py] SQLFORM.grid: sorting

2012-05-21 Thread Keith Edmunds
Two questions re SQLFORM.grid sorting.

1. Is it possible to specify the initial sort order? 

2. I'm displaying a table that includes a foreign field. When I click on
the header to sort by that field, it sorts by the field id rather than by
the (displayed) foreign field. Can I sort by the displayed field?

Thanks,
Keith
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] SQLFORM.grid: sorting

2012-05-21 Thread Keith Edmunds
Thanks Jim, I somehow missed the 'orderby' parameter to SQLFORM.grid

On Mon, 21 May 2012 13:11:31 -0700 (PDT), massimo.dipie...@gmail.com said:

 foreign key. You can do a join.

Thanks Massimo; however, that's a little cryptic. Could you explain how a
join can be used to determine the sort order when I click on a
SQLFORM.grid header?

Thanks,
Keith
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] cpdb errors

2012-05-17 Thread Keith Edmunds
I'm trying to copy a database from Sqlite to MySQL using the cpdb.py
script. In the manual, it states:

cd web2py
python scripts/cpdb.py \
   -f applications/app/databases \
   -y 'sqlite://storage.sqlite' \
   -Y 'postgresql://username:password@hocalhost/mydb'

However, if I do that I get gluon path not found. The help file suggests
that I can specify the path to dal.py with -d, but:

python scripts/cpdb.py -d gluon/dal.py -f applications/pytrack2/databases
-y 'sqlite://storage.sqlite' -Y
'mysql://pytrack2:pytrack2@localhost/pytrack2' 
gluon path not found
EXCEPTION: could not set DAL 
No module named dal

If I use '-d gluon', it's better but now fails with a MySQL error (which I
think relates to foreign keys), although it still gives the 'gluon path
not found' error:

$ python scripts/cpdb.py -d gluon -f applications/pytrack2/databases -y
'sqlite://storage.sqlite' -Y
'mysql://pytrack2:pytrack2@localhost/pytrack2' 
gluon path not found
creating tables... 
EXCEPTION: could not make a copy of the database
(1005, uCan't create table 'pytrack2.t_companies_archive' (errno: 150))

I'm going to continue by migrating by hand; if I should report this
elsewhere or if you need more details, let me know.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] [noob]html not properly rendered, class=ten columns has no effect on where the elements are positioned.

2012-05-16 Thread Keith Edmunds
On Tue, 15 May 2012 14:28:04 -0700 (PDT), shortempe...@gmail.com said:

 all I get is a page with elements placed on default location

I would start by looking in the browser at the page source, and see what
is wrong, and I'd check that the CSS file is being loaded. Once you know
how the HTML differs from what you expect, you should be able to start
finding out why.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Web-framework+db with the widest scalability?

2012-05-13 Thread Keith Edmunds
On Sun, 13 May 2012 06:21:17 -0700 (PDT), abasta...@gmail.com said:

 I suspect there wouldn't be much difference in performance 
 between the two frameworks (similarly and properly configured).

So long as this is broadly true (which I suspect it is), there are other
considerations to take into account. Suppose (unlikely) that Django is 20%
faster to run code. You also need to consider which is easier to develop
and maintain code. Any web platform, very broadly speaking, can improve
its performance by using faster hardware. That's a one-off cost. If you
determine that web2py is more efficient to develop and maintain code with,
that's a win every time anyone does any development.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] Anyone using flake8 / pyflakes?

2012-05-06 Thread Keith Edmunds
I've just started using flake8 from within vim. Flake8 checks code for
PEP8 conformance and general errors, including undefined names. That means
that running it when editing, say, a web2py controller, lots of warnings
are given:

/path/to/file.py|16| W802 undefined name 'session'

There is an option to suppress reporting of specific errors/warnings,
but that only applies to the PEP8 reporting, not the pyflakes reporting.
Given the implicit import style of web2py (which I'm not complaining
about), this results in lots of spurious errors when checking web2py code,
spoiling an otherwise very useful tool.

Has anyone hacked around with flake8 to suppress the undefined names
warnings?

Notes:
flake8: http://pypi.python.org/pypi/flake8
flake8 vim integration: https://github.com/avidal/flake8.vim
the bug:
https://bitbucket.org/tarek/flake8/issue/14/flake8-fails-to-ignore-errors-warning-from
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Anyone using flake8 / pyflakes?

2012-05-06 Thread Keith Edmunds
In case anyone's interested, I've posted a quick and dirty hack to fix
this problem at
https://bitbucket.org/tarek/flake8/issue/14/flake8-fails-to-ignore-errors-warning-from#comment-1385353

-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] request.intargs RFC

2012-05-01 Thread Keith Edmunds
On Sun, 29 Apr 2012 16:54:11 -0700 (PDT), massimo.dipie...@gmail.com said:

 It also takes the optional parameter url_onerror which allows redirect 
 instead of raise HTTP(404).

I kept reading that as url one error, and struggled to understand the
logic. I realise now that it is me that is broken.

For clarity, how about url_on_error?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] Admin of list:string

2012-04-30 Thread Keith Edmunds
In the database admin application, when editing a record from table with a
list:string field, the field is not pre-populated with the current value.

Test model:

db.define_table('t_colours',
Field('f_colour', type='list:string', label=T('Colour')))
db.t_colours.f_colour.requires = IS_IN_SET(('Red','Blue','Black'))

Insert one record. Edit it, and the combo for f_colour has the correct
values in the dropdown, but none is displayed by default.

Is this the expected behaviour?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] SQLFORM.grid edit form

2012-04-30 Thread Keith Edmunds
I have a SQLFORM.grid, and I want to add a button to the form used to edit
records (as called from the grid). Is that possible?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Cookies and Sessions

2012-04-27 Thread Keith Edmunds
On Wed, 25 Apr 2012 15:49:23 -0700 (PDT), varelay...@gmail.com said:

 I'm quite new to web2py and a noob at it. I've been struggling with the 
 difference between cookies and sessions...But I have plenty of questions
 about them and how to use them(in web2py)

I think you should approach them from a different perspective. You are
doing the equivalent of looking at a screwdriver and asking what you can
do with it, whereas you may be better off saying, How can I replace this
hard disk?. In other words, what problem are you trying to solve?

That said, I'll try to offer some guidance. I suggest you ignore cookies
altogether. Web2py uses them, but YOU don't have to. Think of the session
as a temporary store to allow you to pass variables from one place to
another. Given that HTTP[S] is a stateless protocol, it can only tell you
that a user clicked on a link or typed a URL in the browser, not that they
have put 25 widgets in their shopping cart (that's simplifying it a
little, but hopefully you get the point). 

In your code, you can use the session to store the contents of the
shopping cart (for example). So, when they click on 'buy', you might do
something like:

if session.cart:
session.cart.append(dict(item='widget',q=2))
else:
session.cart = [dict(item='widget',q=2)]

Later, when they checkout, you can do:

for orderline in session.cart:
process(orderline['item'],orderline['q'])

There are neater ways to do this, particularly if you use Storage()
objects rather than dictionaries, but the principle is that you can use
the session to give variables persistence between requests.

 *1. What can you store in them? *

In a session: anything than can be pickled (notable NOT user-defined
objects).

 *2. When are they deleted?*

When you do session.forget()

 *3. Could you use cookies as temporary DB?*

What are you trying to achieve?

Hopefully that gives you some idea...
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] How to merge more than one template in web2py

2012-04-27 Thread Keith Edmunds
On Thu, 26 Apr 2012 23:23:06 -0700 (PDT), vibhor.purand...@zero-group.com
said:

 How to merge more than one template in web2py? 

http://web2py.com/books/default/chapter/29/5#Page-layout
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] shared host deployment of my web2py site

2012-04-15 Thread Keith Edmunds
On Sun, 15 Apr 2012 07:36:19 +0100, doncoleon...@gmail.com said:

 So you mean I should just click the 'configure' file?

You need to do this from the command line.

 And how do I add
 the parameters, are u saying

It's you, not u.

You need a open a terminal window and type in the commands you quoted
originally.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Overlapping periods

2012-04-14 Thread Keith Edmunds
On Fri, 13 Apr 2012 11:38:25 -0700 (PDT), sababa.sab...@gmail.com said:

 But the function does not work, and I can't see what's wrong. Any idea?

You don't make it very easy for others to help. The function does not
work - which function doesn't work, and in what way does it not work?
What input, what output, and how does the output differ from what is
expected? Also, your code has no indentation, so it's hard to read.

Help us help you.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Overlapping periods

2012-04-14 Thread Keith Edmunds
On Fri, 13 Apr 2012 11:38:25 -0700 (PDT), sababa.sab...@gmail.com said:

 The 
  function should only add periods that doesn't overlap any of the
 already registered ones. 

Let me try to help (I owe this group a lot of help). I've ignored your
code, and I don't know what schema you're using, but here's the pseudo
and untested code:

def should_this_period_be_inserted(start,end):
# Check that all periods that started before this one
# also finished before this one started
q = ((db.period.begindatestart)(db.period.enddatestart))
if db(query).count():
return False
# Check that no periods started while this one was in progress
q = ((db.period.begindate=start)(db.period.begindate=end))
if db(query).count():
return False
# If we got this far, the period didn't overlap
return True

Have I understood what you're trying to do?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Overlapping periods

2012-04-14 Thread Keith Edmunds
On Sat, 14 Apr 2012 09:44:28 +0100, k...@midnighthax.com said:

   q = ((db.period.begindatestart)(db.period.enddatestart))
   if db(query).count():

Argh. Typos. 'q' and 'query' should refer to the same thing, so change the
second line to 'if db(q).count():' (that change needs to take place twice).
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] shared host deployment of my web2py site

2012-04-14 Thread Keith Edmunds
On Sat, 14 Apr 2012 05:08:01 -0700 (PDT), doncoleon...@gmail.com said:

 but i dont 
 know what the next line of instruction says

It says run this command:

./configure --prefix=$HOME

...from the Python-2.6.5 directory under your home directory. The
'./configure' is the command that will be run (ie, the file
$HOME/Python-2.6.5/configure will be run), and the --prefix=$HOME is a
parameter to that command. In this case, it is telling 'configure' to
build the application as if it were going to be installed in $HOME (which
it will be).

The ./configure, make, make install is a pretty standard way of building
applications. If it still doesn't make sense to you, let me know exactly
what it is you are struggling with.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Vertical lines around database string values

2012-04-14 Thread Keith Edmunds
Are you using Fields of type list:string?

-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: creating a shopping cart using session

2012-04-11 Thread Keith Edmunds
On Wed, 11 Apr 2012 00:11:18 -0700 (PDT), halna...@gardeniatelco.com said:

 i am trying to work with session like you showed me but still when i add 
 somthing it just changes the last element in the session to the element
 i added

Show us the code.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: SQLFORM.grid pagination

2012-04-11 Thread Keith Edmunds
On Tue, 10 Apr 2012 21:38:15 -0700 (PDT), massimo.dipie...@gmail.com said:

 Please open a ticket about this in google code.

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

-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] SQLFORM.grid pagination

2012-04-10 Thread Keith Edmunds
I have a SQLFORM.grid that says 67 records found, and shows the first 20
(as I would expect). At the bottom, there are four buttons for the pages
(1-4). If I click on any of 2, 3 or 4, I get No records found.

Looking deeper, the URL of the first page is

http://127.0.0.1:8000/app/reports/task_report?task_id=5

The URL of the second page, from the '2' link, is

http://127.0.0.1:8000/app/reports/task_report?page=2_signature=22...

Note that the ?task_id=5 is missing; if I add it to the URL manually,
the second page shows.

What do I need to do to ensure that the URL for pages after page 1 include
the 'task_id' parameter?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Multiple target by using the Ajax

2012-04-09 Thread Keith Edmunds
On Sun, 8 Apr 2012 23:32:31 -0700 (PDT), sanjeet.ro...@gmail.com said:

 How to call the multiple function or set the multiple target via Ajax 

In the view:

form
   input name=name onkeyup=ajax('echo', ['name'], ':eval') /
/form

h3Start of target1/h3
div id=target1/div
h3End of target1/h3
h3Start of target2/h3
div id=target2/div
h3End of target2/h3

In the controller:

def echo():
return jQuery('#target1').html(%s);jQuery('#target1').html(%s); \
% (repr(request.vars.name.upper()),repr(request.vars.name.lower()))

When you type characters into the form, they will be inserted as uppercase
in target1 and lowercase in target2.

NB: I've not tested the code above, but the principle is sound; if it
doesn't work, let me know and I'll test and fix.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Multiple target by using the Ajax

2012-04-09 Thread Keith Edmunds
On Mon, 9 Apr 2012 12:28:23 +0100, k...@midnighthax.com said:

 def echo():
 return jQuery('#target1').html(%s);jQuery('#target1').html(%s); \
   %
 (repr(request.vars.name.upper()),repr(request.vars.name.lower()))

Sorry, the second '#target1' above should be '#target2'
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] Unit testing and faking authentication

2012-04-07 Thread Keith Edmunds
I've been looking that the unit testing page
(http://www.web2py.com/AlterEgo/default/show/260), which is very helpful.
However, most of my controller functions are decorated with
'@auth.requires_login()', and thus if I call them from the test suite,
they fail (issuing a redirect):

  File /home/kae/hg/kae/web2py/gluon/tools.py, line 934, in lambda
settings.on_failed_authentication = lambda x: redirect(x)
  File /home/kae/hg/kae/web2py/gluon/http.py, line 128, in redirect
Location=location)
HTTP: 303 SEE OTHER

One could argue that's a correct failure because the test suite isn't
authenticated, but I'd like to use unit tests to test functions that need
authentication. I don't want to test the authentication mechanism itself.

Is there a way to fake authentication to allow unit testing? Do others
have a better way of doing this?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] Hiding columns in SQLFORM.grid

2012-04-07 Thread Keith Edmunds
Is it possible to hide columns in a SQLFORM.grid?

I need to retrieve some columns in the query to build some custom links,
but I don't want those columns displayed. I've tried setting maxtextlength
for those columns to zero, but they still display.

Thanks.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: Hiding columns in SQLFORM.grid

2012-04-07 Thread Keith Edmunds
On Sat, 7 Apr 2012 07:41:16 -0700 (PDT), abasta...@gmail.com said:

 Before constructing the grid, try db.mytable.myfield.readable = False.

Anthony, very neat, and it works: thank you.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] Stopping a timer from an Ajax call (Clienttools)

2012-04-07 Thread Keith Edmunds
I'm using clienttools.py to put a timer on a page; the timer calls a
controller function (imaginatively called 'tick') every second, which in
turn updates a div on the page via Ajax. So far, so good.

I want the 'tick' controller function to be able to stop/disable the timer
under certain circumstances. I can do this interactively from a link that
results in the whole page being refreshed, but not from the tick function;
I think that's because the clienttools page.ready() function is only called
on initial page load, not from when an Ajax update completes.

Bits of code: to set up the timer:

callback = js.call_function(tick)
page.ready(js.timer(callback,1000))

...which works. Calling this from 'tick':

page.ready(js.stop_timer(request.var.timer_id))

...doesn't stop the timer (the request.vars.timer_id is valid).

Is there a way of stopping the js timer from an Ajax call? Alternatively,
is there a better way of calling 'tick' to update a page every second?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: DAL or SQL?

2012-03-27 Thread Keith Edmunds
On Sun, 25 Mar 2012 16:41:09 -0700 (PDT), niph...@gmail.com said:

 Doh, you're right. All the datetime api on fields are extracting, not 
 converting the actual value

Yes, and I've also found that, with Sqlite at least, web2py doesn't
carry out datetime arithmetic correctly within the DAL (not entirely
Web2py's fault).

Rather than have another field in the table for duration, which could
easily get out of sync with start/stop times, I created a view instead:

CREATE VIEW v_durations as select
id,f_date,f_start,f_end,strftime('%s',t_periods.f_end)-strftime('%s',t_periods.f_start)
as f_duration,f_category,f_task,f_user from t_periods;

I use that view, rather than the t_periods table, for reporting. It's
defined in the model as migrate=false, and it works really well. If I move
to another database (probably MySQL for production), I only need to create
one new view. This way, edits to the table are no problem, and the
duration from the view is always correct.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] Documentation suggestion

2012-03-25 Thread Keith Edmunds
If something like this has already been suggested, please point me at the
earlier discussion.

I've read the Web2py manual (and bought three of them) since v1, and the
quality of both web2py and the manual has improved hugely.

To my mind, however, the manual tries to fulfil two roles currently: it is
a howto manual with lots of developed examples, and it is a reference
manual. I think the two functions should be split to two documents.

Rationale: the current format requires that the reference material be
spread throughout the book. A simple example: look up the 'URL' helper
function. The helper functions are listed in Views chapter, and indeed
the URL function is included in the list under HTML helpers. However, it
is actually defined in the previous chapter (Core). The tutorial nature
of the manual requires it be discussed in core, but the reference nature
of the manual suggests it should be under HTML helpers.

This isn't the only example. It also isn't a criticism: as a single
document, the manual is about as good as it could be. My question is
simply: is it time to split it up?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: DAL or SQL?

2012-03-25 Thread Keith Edmunds
On Mon, 19 Mar 2012 14:45:51 -0700 (PDT), niph...@gmail.com said:

 for every period, duration is calculated as:
 duration = db.periods.end_time.seconds() -
 db.periods.start_time.seconds()

This is wrong.

I reworked my data model so that the period start and stop fields were of
type datetime. I then found the flaw in your logic above: the seconds()
method returns the value of the seconds part of the datetime rather than
the number of seconds of the duration.

You can see this below. For one row (id==257), these are the values:

Row {'f_start': datetime.datetime(2012, 3, 25, 18, 18, 54), 'f_end':
datetime.datetime(2012, 3, 25, 18, 19, 1)}

So, start at 18:18:54 today, stop at 18:19:01, so the duration should be 6
seconds. However:

 duration = db.t_periods.f_end.seconds() -
 db.t_periods.f_start.seconds()
result = db(db.t_periods.id==257).select(db.t_periods.id,duration)
 for r in result:
...  print r
... 
Row {'t_periods': Row {'update_record': function lambda at
0xa15e1b4, 't_periods_archive': gluon.dal.Set object at 0xa0dcf8c,
0xa15e1b4'id': 257, 'delete_record': function lambda at 0xa15e10c},
0xa15e1b4'_extra': Row {(web2py_extract('second',t_periods.f_end) -
0xa15e1b4web2py_extract('second',t_periods.f_start)): -53}}

...giving -53 seconds. In other words, it is the difference in the value
of seconds rather than the duration.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: DAL or SQL?

2012-03-22 Thread Keith Edmunds
On Mon, 19 Mar 2012 14:45:51 -0700 (PDT), niph...@gmail.com said:

 for every period, duration is calculated as:
 duration = db.periods.end_time.seconds() -
 db.periods.start_time.seconds()
 
 now, get a list of all durations...
 
 result = db(db.periods.id0).select(db.periods.id, duration)

This does not work: every 'duration' is None:

 duration = db.t_periods.f_period_end.seconds() -
 db.t_periods.f_period_start.seconds() 
 result = db(db.t_periods.id0).select(db.t_periods.id, duration)
 result[0]
Row {'t_periods': Row {'update_record': function lambda at
0x923479c, 't_periods_archive': gluon.dal.Set object at 0x923924c,
0x923479c'id': 40, 'delete_record': function lambda at 0x9234764},
0x923479c'_extra': Row
0x923479c{(web2py_extract('second',t_periods.f_period_end) -
0x923479cweb2py_extract('second',t_periods.f_period_start)): None}}
 

All rows give the same result (None).

I can see that what I need to be doing is calculating the end time in
seconds and subtracting the start time in seconds, but I can't see how to
do that via the DAL.

Back to my original question: is the only way to do this to use
hand-crafted SQL?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: DAL or SQL?

2012-03-22 Thread Keith Edmunds
 Perhaps you could add the seconds as a virtual lazy field.

That sounds worth investigating, thanks.

 We shall come to an agreement when you explain plainly what is your real
 model... it seems that your start and end columns are time and not
 datetime... Time fields don't have a seconds() method, only datetime!

In my original posting, I said: the periods table has id, date,
start_time, end_time (and other fields). I suppose I assumed that the
presence of a 'date' field implied that the *_time fields were indeed of
type time, but I'm sorry if that wasn't clear. For clarity:

db.define_table('t_periods',
Field('f_date', type='date',
  label=T('Date')),
Field('f_period_start', type='time',
  label=T('Period Start')),
Field('f_period_end', type='time',
  label=T('Period End')),
...

-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] Bug(?) using list:string in 1.99.7

2012-03-21 Thread Keith Edmunds
My application has broken moving from 1.99.4 to 1.99.7.

I have a field of type list:string (using Sqlite). In 1.99.7, dal.py
breaks at line 1405 (marked with ):

return str(obj)
if fieldtype.startswith('list:'):
if not obj:
obj = []
elif not isinstance(obj, (list, tuple)):
obj = [int(obj)]

elif fieldtype.startswith('list:string'):
obj = [str(item) for item in obj]
else:
obj = [int(item) for item in obj]

Because my field is type list:string, startswith('list:') is True and thus
the startswith('list:string') line is never reached.

This patch appears to fix the problem, although I've not tested it
thoroughly:

--- dal.py.old  2012-03-21 07:19:12.0 +
+++ dal.py  2012-03-21 07:20:38.0 +
@@ -1398,13 +1398,13 @@
 return fieldtype.encoder(obj)
 if isinstance(obj, (Expression, Field)):
 return str(obj)
-if fieldtype.startswith('list:'):
+if fieldtype.startswith('list:string'):
+obj = [str(item) for item in obj]
+elif fieldtype.startswith('list:'):
 if not obj:
 obj = []
 elif not isinstance(obj, (list, tuple)):
 obj = [int(obj)]
-elif fieldtype.startswith('list:string'):
-obj = [str(item) for item in obj]
 else:
 obj = [int(item) for item in obj]
 if isinstance(obj, (list, tuple)):

-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: DAL or SQL?

2012-03-21 Thread Keith Edmunds
I'm having problems getting a valid value for seconds() from a time field
under Sqlite. I can extract a time:

 for row in db(db.t_periods.id==40).select(db.t_periods.f_period_end):
...  print row
... 
Row {'f_period_end': datetime.time(17, 50, 51)}

However, if I try to get the seconds(), it returns None:

 for row in
 db(db.t_periods.id==40).select(db.t_periods.f_period_end.seconds()):
...  print row
... 
Row {'_extra': Row {web2py_extract('second',t_periods.f_period_end):
None}}

Both Niphlod's examples and the manual suggest that this should give the
time in seconds, but I'm getting None. Have I misunderstood?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: DAL or SQL?

2012-03-21 Thread Keith Edmunds
On Wed, 21 Mar 2012 14:43:42 -0700 (PDT), niph...@gmail.com said:

 rows = db(db.t_periods.id==40).select(db.t_periods.f_period_end)
 for row in rows:
 print row.f_period_end.seconds()

No, that gives an error:

 rows = db(db.t_periods.id==40).select(db.t_periods.f_period_end)
 for row in rows:
... print row.f_period_end.seconds()
... 
Traceback (most recent call last):
  File console, line 2, in module
AttributeError: 'datetime.time' object has no attribute 'seconds'

I arrived at this point because your earlier examples were giving None as
the duration, and I was trying to narrow down where the problem lay.

By the way, thank you for your continuing help, it is very much
appreciated.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: DAL or SQL?

2012-03-20 Thread Keith Edmunds
Thanks Niphlod, that looks good and I will try it soon.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: DAL or SQL?

2012-03-20 Thread Keith Edmunds
I've hit an error (web2py bug?) in Niphlod's well-explained example. 

I *was* running web2py.1.99.4, which gave this:

 duration=(db.t_periods.f_period_end.seconds() -
 db.t_periods.f_period_start.seconds()).sum()
 result=db(db.t_periods0).select(db.t_periods.id,duration,groupby=db.t_periods.f_task_id)
Traceback (most recent call last):
  File console, line 1, in module
  File /home/kae/hg/kae/web2py.1.99.4.pytrack2/gluon/dal.py, line 6333,
in select return self.db._adapter.select(self.query,fields,attributes)
  File /home/kae/hg/kae/web2py.1.99.4.pytrack2/gluon/dal.py, line 1274,
in select sql = self._select(query, fields, attributes)
  File /home/kae/hg/kae/web2py.1.99.4.pytrack2/gluon/dal.py, line 1672,
in _select sql = super(SQLiteAdapter, self)._select(query, fields,
attributes) File /home/kae/hg/kae/web2py.1.99.4.pytrack2/gluon/dal.py,
line 1155, in _select if query and not query.ignore_common_filters:
AttributeError: 'bool' object has no attribute 'ignore_common_filters'
 

Some Googling suggested this problem was fixed after 1.99.4 was released,
so I've just downloaded 1.99.7, which gives:

 durations=(db.t_periods.f_period_end.seconds() 
 -db.t_periods.f_period_start.seconds()).sum()

 result=db(db.t_periods0).select(db.t_periods.id,durations,groupby=db.t_periods.f_task_id)
Traceback (most recent call last):
  File console, line 1, in module
  File /home/kae/hg/kae/web2py.1.99.7.pytrack2/gluon/dal.py, line 7578,
in select return adapter.select(self.query,fields,attributes)
  File /home/kae/hg/kae/web2py.1.99.7.pytrack2/gluon/dal.py, line 1315,
in select rows = response(sql)
  File /home/kae/hg/kae/web2py.1.99.7.pytrack2/gluon/dal.py, line 1305,
in response self.execute(sql)
  File /home/kae/hg/kae/web2py.1.99.7.pytrack2/gluon/dal.py, line 1392,
in execute return self.log_execute(*a, **b)
  File /home/kae/hg/kae/web2py.1.99.7.pytrack2/gluon/dal.py, line 1386,
in log_execute ret = self.cursor.execute(*a, **b)
OperationalError: no such column: True
 

Is this a web2py bug, or am I doing something wrong?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: DAL or SQL?

2012-03-20 Thread Keith Edmunds
I'm using sqlite, and I'm embarrassed about my errors. Thanks for your
help.

-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] DAL or SQL?

2012-03-19 Thread Keith Edmunds
I need to run a reasonably complex query, and I'm wondering whether it
would be better to code it in SQL, or should I try to get the DAL to
provide the data (or maybe there's another way). There's no right or wrong
answer, but I'd welcome opinion on the best approach.

Simply put, consider two tables, tasks and periods. As well as an id
field, tasks has a 'name' field too. Each task has multiple periods (of
work) associated with it, and the periods table has id, date, start_time,
end_time (and other fields). What I want to do is produce a summary that
lists:

task_name   total_time

...for each task. That is, for each period, find the duration by
subtracting the start_time from the end_time, and total all durations for
each task in turn.

I can write this in SQL, but then I lose the advantages of the DAL, as
well as potentially losing database portability. I'm not even sure if this
is doable in the DAL.

What would be the best approach?
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: Odd auth problem

2012-03-18 Thread Keith Edmunds
On Sat, 17 Mar 2012 15:03:39 -0700 (PDT), abasta...@gmail.com said:

 Instead, you can use auth.user_id, which 
 will simply return None when the user isn't logged in rather than an
 error. 

Thanks, that's fixed the problem.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


[web2py] Odd auth problem

2012-03-17 Thread Keith Edmunds
I have a function whose definition starts as follows:

@auth.requires_login()
def rbb_time(category_id, from_date, to_date, user_id=auth.user.id):

It works fine. I'll leave the development of this application for a few
days, come back, run it, and get:

Traceback (most recent call last):
  File /home/kae/hg/kae/web2py.1.99.4.pytrack2/gluon/restricted.py, line
  204, in restricted exec ccode in environment
File [...]/controllers/default.py, line 100, in module 
  def rbb_time(category_id, from_date, to_date, user_id=auth.user.id): 
AttributeError: 'NoneType' object has no attribute 'id'

The only way to fix it (and this isn't 100% reliable) is to comment out
all of the @auth.requires_login() lines, hard-code the above function
definition to end user_id=11 (the UID I was logged in as), and then
call /default/user/logout.

Can anyone offer any suggestions as to what is going on here?

Thanks,
Keith


[web2py] Representing foreign field with image (format/represent)

2012-02-12 Thread Keith Edmunds
I have a form based on a table which includes foreign fields. By default,
the foreign fields are displayed as the name from the foreign table
as expected.

I want to have an image displayed rather than the name from the foreign
table.

Not having used 'format' before, I changed the format of the foreign table
to:

format=xyz

As expected, every row now displayed xyz. I then changed to:

format=URL('static','images/red.jpg')

and again, as expected, the URL string appears in every row. Then I did:

format=IMG(_src=URL('static','images/red.jpg'))

and now no foreign key lookup seems to occur at all: I just get the id
value showing in the table.

I have two questions:

Why does that happen and
How can I display an image for a foreign key value?

Thanks for pointers or help!
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: Representing foreign field with image (format/represent)

2012-02-12 Thread Keith Edmunds
Thanks Alan, that has enabled me to do what I want.
-- 
You can have everything in life you want if you help enough other people
get what they want - Zig Ziglar. 

Who did you help today?


Re: [web2py] Re: Using LOAD from a controller?

2010-05-13 Thread Keith Edmunds
It's always a conundrum: does one thank people for helping, and thus
contribute an otherwise content-free mail to the list? Or should one thank
those who helped with a personal mail, thus suggesting to everyone else
that you are ungrateful?

Iceberg, Selecta: thanks for your valuable help. I'm going to monitor the
list more and see if I can help others.

Keith


[web2py] Using LOAD from a controller?

2010-05-11 Thread Keith Edmunds
I was to display a form using Ajax in response to a click on a link on the
page. I have tried putting this in the view:

a href=# onclick=ajax(
'{{=URL(request.application, 
'todo', 
'new')}}',
[], 'DetailArea') /New todo
/a

with this in the controller:

def new():

return = LOAD('todo','todo_form',ajax=True)

def todo_form():
form = SQLFORM(db.tasks,fields=['priority','subject','duedate'])
if form.accepts(request.vars,session):
session.flash = 'record inserted'
redirect(URL(request.application,'default','index'))
return form

...but that doesn't work.

I don't think I've fully understood how LOAD works - can someone point me
in the right direction, please?


Re: [web2py] Using LOAD from a controller?

2010-05-11 Thread Keith Edmunds
On Tue, 11 May 2010 21:16:45 +0100, k...@midnighthax.com said:

 return = LOAD('todo','todo_form',ajax=True)

Typo in my mail: that is actually

return LOAD('todo','todo_form',ajax=True)


Re: [web2py] Re: Using LOAD from a controller?

2010-05-11 Thread Keith Edmunds
Sorry, Iceburg, I appreciate your attempt to help, but you've lost me
completely! Can you explain?

Thanks


Re: [web2py] Debugging with GAE and Eclipse/Aptana?

2010-05-01 Thread Keith Edmunds
I don't run web2py.py under the debugger. I just put the following where I
want the first breakpoint:

import pydb
pydb.debugger()

...which drops into the debugger when encountered. No GUI, but I believe
you can hook up DDD to pydb if you are so inclined. Whether that works on
GAE or not, I don't know.


Re: [web2py] Re: Application logging

2010-04-29 Thread Keith Edmunds
Hi Iceberg

 But I would recommend you use a later version, quoted already in
 Omicron's post. It uses RotatingFileHandler to avoid unstoppable log
 file size

Thanks for providing it. I can see the sense of your suggestion; however,
I want the logging to be to the standard syslog files (which are
logrotated independently).

Massimo: I would have thought that application logging was an integral
part of an enterprise application, much as authentication is, and should
be in the scaffolding. It really isn't very big.

Keith


Re: [web2py] Re: Application logging

2010-04-27 Thread Keith Edmunds
On Tue, 27 Apr 2010 09:31:50 -0700 (PDT), minkto...@gmail.com said:

 I'd be interested in a step by step guide to setting up this kind of
 logging.

I found some older posts that helped in the end. I now have a
modules/logging.py file that looks like:

def _init_log():

From http://article.gmane.org/gmane.comp.python.web2py/11091


import logging
from logging.handlers import SysLogHandler

logger = logging.getLogger(request.application)
logger.setLevel(logging.DEBUG)
handler = SysLogHandler(address='/dev/log')
handler.setLevel(logging.DEBUG)
handler.setFormatter(logging.Formatter(
'%s' % request.application + '[%(process)d]: %(levelname)s:
%(filename)s at line %(lineno)d: %(message)s'))
logger.addHandler(handler) return logger

logging=cache.ram('once',lambda:_init_log(),time_expire=)

Then, when I want to log something, I do:

logging.debug(blah)

.debug can be the other standard values including .exception,
.error, .info, etc

I don't claim originality for the above: I adapted it slightly from the
URL quoted.

Given the unexpected challenges in implementing this in web2py, I think it
would make sense to include it in the scaffolding (but I'm probably wrong).


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Silent errors

2010-04-27 Thread Keith Edmunds
I've just found a stupid programming error of mine. Code:


task_rows = db(db.tasks.ref==request.vars.number).select()
if len(task_rows):
rows[0].update_record(status = request.vars.new)


At some point, I'd renamed the variable 'rows' to 'task_rows', but
omitted to change the last line quoted above. Blindingly obvious once you
see it, and there are 101 reasons why I shouldn't have made that mistake.

However, it fails in Web2py without any indication. It wasn't until I ran
it under pydb that I saw this:

(Pydb) n
NameError:global name 'rows' is not defined

My question: is there any way Web2py can catch and notify me of errors
like that?

Thanks


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en


Re: [web2py] Re: showing errors from loaded web2py components

2010-04-25 Thread Keith Edmunds
On Wed, 21 Apr 2010 16:59:04 +0200, kuba.kuchar...@gmail.com said:

 Is it possible to have this as a trigger/checkbox in admin as an
 OPTIONAL behaviour for all errors(not only LOAD components)?

Seconded.

Firebug is fine for those using Firefox, but not for the rest of us.


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en


Re: [web2py] Ajax from menu item?

2010-04-23 Thread Keith Edmunds
Am I trying to do something stupid or impossible?

 Does anyone have any sample code showing how to call the Web2py 'ajax'
 function from a menu? I currently have this as a link on a page, and I'd
 like to move it to a menu item:
 
 a href=# onclick=ajax(
   '{{=URL(request.application, 'dopy', 'new')}}',[], 'DetailArea'
 ) /New/a

-- 
|Keith Edmunds
|Tiger Computing Ltd
|The Linux Specialists
|
|Tel: 033 0088 1511
|Web: http://www.tiger-computing.co.uk
|
|Registered in England. Company number: 3389961
|Registered address: Wyastone Business Park,
| Wyastone Leys, Monmouth, NP25 3SR


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Ajax from menu item?

2010-04-22 Thread Keith Edmunds
Does anyone have any sample code showing how to call the Web2py 'ajax'
function from a menu? I currently have this as a link on a page, and I'd
like to move it to a menu item:

a href=# onclick=ajax(
'{{=URL(request.application, 'dopy', 'new')}}',[], 'DetailArea'
) /New/a

Thanks


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Application logging

2010-04-17 Thread Keith Edmunds
What are others doing for application logging? I'm not referring to the
HTTP logs, but program-generated logs.

I've recently been looking at the Python 'logging' module, which I've not
used before. I initiate logging from a file in the 'modules' directory
which does this:


import logging
from logging.handlers import SysLogHandler

logger = logging.getLogger(MyApp)
logger.setLevel(logging.DEBUG)
hdlr = SysLogHandler(address='/dev/log')
formatter = logging.Formatter('tigerpy[%(process)d]: %(levelname)s:
%(filename)s at line %(lineno)d: %(message)s') hdlr.setFormatter(formatter)
logger.addHandler(hdlr)


Then each file that I want to log from does this:


import logging

logger = logging.getLogger(MyApp)
.
.
logger.info(Something interesting happened)


This logs to syslog: the only problem is that each logging message is
written to syslog many (20-40) times(!). This isn't just in one place in
my code, but throughout. I don't think the code is being executed multiple
times, so I'm not sure why I'm getting so many log entries.

So, I'm interested in what others do to log application events.


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] sqlite and 'unique'

2010-04-15 Thread Keith Edmunds
I have the following (sqlite) table definition:

db.define_table('companies',
Field('name', length=512, default='', unique=True),
Field('oncontract', 'boolean', default=False)
)

From the admin app, I am prevented from adding duplicate company names.
However, from the shell, a sequence of:

db.companies.insert(name=test)
db.commit()
db.companies.insert(name=test)
db.commit()

...gives no errors and does insert duplicates.

The book says, section 6.4, unique=True translates into the UNIQUE SQL
statement. It asks the database to make sure that values of this field are
unique within the table.

That doesn't appear to match the behaviour I'm seeing. Bug, feature,
misunderstanding on my part?

Thanks,
Keith


-- 
To unsubscribe, reply using remove me as the subject.


Re: [web2py] sqlite and 'unique'

2010-04-15 Thread Keith Edmunds
On Thu, 15 Apr 2010 15:25:56 -0500, thade...@thadeusb.com said:

 sqlite does not enforce types/length, or uniqueness.

I understand about types/lengths, but the uniqueness part doesn't
match with what I'm seeing:

$ sqlite3 /dev/shm/test.db
SQLite version 3.5.9
Enter .help for instructions
sqlite create table mytable(text unique);
sqlite insert into mytable values(mystring);
sqlite insert into mytable values(mystring);
SQL error: column text is not unique
sqlite   

Keith


-- 
To unsubscribe, reply using remove me as the subject.


Re: [web2py] Re: sqlite and 'unique'

2010-04-15 Thread Keith Edmunds
On Thu, 15 Apr 2010 13:56:19 -0700 (PDT), mdipie...@cs.depaul.edu said:

 Is it possible you did not have unique=True when you created the table
 and added that later?

Yes, that is the case - thanks for clearing that up, much appreciated.

Keith


-- 
To unsubscribe, reply using remove me as the subject.


Re: [web2py] Re: sqlite and 'unique'

2010-04-15 Thread Keith Edmunds
On Thu, 15 Apr 2010 15:06:57 -0700 (PDT), mdipie...@cs.depaul.edu said:

 Try on a fresh database it should work.

I have, it did, thank you again.

Perhaps a note in the V3 book about this?

Keith


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en


Re: [web2py] Re: Authentication: form just refreshes, won't validate login

2010-04-11 Thread Keith Edmunds
On Sat, 10 Apr 2010 15:35:05 -0700 (PDT), hamdy.a.fa...@inbox.com said:

 This's most likely to happen if you've more than one form in the same
 page so the question is , do you've another form inside the page ?

Thanks for the suggestion, but I don't have any other forms there. I'm
using the authentication page that comes with Web2py, unmodified. I've
checked the source of the page and there is only one form there.

That authentication page has 

form action=

so which URL is the form submitted to? I could then put the debugger on
that function and check what is going on.

Thanks


-- 
To unsubscribe, reply using remove me as the subject.


Re: [web2py] Authentication: form just refreshes, won't validate login

2010-04-11 Thread Keith Edmunds
Problem solved. For the sake of others searching on this: some of the
distribution files under applications/my_app were from an earlier version
of web2py.


-- 
To unsubscribe, reply using remove me as the subject.


[web2py] Using Ajax to display detail from a list

2010-04-01 Thread Keith Edmunds
What I want to do: have a list of items displayed; when one is clicked,
more detail is shown (via an Ajax call) in a defined detail area.

Problem: the web2py ajax call takes three parameters: a controller action,
one or more field ids, and a target DIV. My controller action needs to
identify which row has been clicked on, so I need a hidden field per row
that holds the row number. Because all field ids need to be unique, I
actually have to build a dynamic name for the row id (eg,
id=row_{{=row.number}}, name=row_{{=row.number}}), and - even worse - my
controller action doesn't know the name of the field passed, so it has to
parse response.vars to find it.

Web2py and Python in general are so well architected that I know there
must be a better way. Could someone point it out, please?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py:22915] Re: true or false?

2009-05-29 Thread Keith Edmunds

I think you could get some good exposure from LWN - it's one of the more
professional Linux sites (imo, the /most/ professional).

Keith aka BackSeat

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:19408] Re: The official Web2py Book by Massimo....for free?

2009-04-07 Thread Keith Edmunds

On Sun, 5 Apr 2009 17:08:31 -0700 (PDT), richar...@gmail.com said:

 And my version is
 fast becoming out of date with all the new features.

This is not a complaint - I do not expect the book to be free - but the
above point is valid. I too have the printed book, but a lot has changed
since it was written. Some projects (the Claws Mail project springs to
mind) include a list of new features with each release. Would that be
something that web2py could do?

Keith

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:18008] Deleted record returning

2009-03-13 Thread Keith Edmunds

I'm returning to web2py after a bit of a break, so maybe things have
changed in the intervening six months or so (well, I'm sure they have).

Version 1.58 (2009-03-10 10:51:30)

I have a SQLite database with a number of rows in it. I had been
retrieving the rows with:

todos_ds = db(db.todos.rt != 0).select(db.todos.ALL)

I then edited one of the rows from the dba page. When I now run the above
line, the returned dataset has the modified row in it and, right at the
end, the original row with a new id. The dba page doesn't show the phantom
row. I exited web2py altogether and examined the table with sqlite3: the
row isn't there. I start up web2py, run the app to the above line, and the
phantom row is in the dataset.

I would struggle to believe what I've written above if I read it, but it
is definitely true! Happy to make screenshots if you want.

Can anyone explain what is going on?

Thanks,
Keith

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:11697] Re: Proposal: MVC separation - son of custom views

2008-11-11 Thread Keith Edmunds

On Tue, 11 Nov 2008 11:56:12 -0800 (PST), [EMAIL PROTECTED]
said:

 Can achipa or Keith or
 anyone who gets the problem try storing the source locally (if they
 can access it at all!) and see if they still get the problem?

The problem (for me, at least) is NOT the page itself, but the DNS entry
for www.wellbehavedsystems.co.uk - I can fix the problem by flushing the
local DNS cache here.

If I get time, I'll try to see why it's happening.

Keith

-- 
Keith Edmunds

+-+
|Tiger Computing Ltd|  Helping businesses make the most of Linux  |
|  The Linux Specialists  |   http://www.tiger-computing.co.uk  |
+-+

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:10760] The Book

2008-10-28 Thread Keith Edmunds

Received the web2py book yesterday (I'm in the UK and I had to buy it from
Amazon in the US, and it took a while to ship). Good job, Massimo: I'm
up to page 66 and it reads very well. Much better than the earlier
versions posted on the website, although they were helpful too.

I do have a couple of suggestions for the book: are you still interested
in feedback (I'll send via PM when I've finished the book if you are).

Keith

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:10638] Re: Multiple Threading

2008-10-26 Thread Keith Edmunds

On Sun, 26 Oct 2008 11:55:08 -0700 (PDT), [EMAIL PROTECTED]
said:

 1) what other background tasks do people envisage?

A regular display update via Ajax (but that could probably be demanded by
the client rather than pushed)

 2) how should you do it in web2py?

Pass.

-- 
Keith Edmunds

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:10544] Re: Lost some work tonite

2008-10-23 Thread Keith Edmunds

On Wed, 22 Oct 2008 23:12:24 -0700 (PDT), [EMAIL PROTECTED] said:

 This is one reason
 why many people don't trust web editors -- they are too prone to lose
 work.

Whilst I agree with the basic point you make about somehow saving the
context of the editing if possible, if you don't trust web editors then
why are you using one?? None of my web2py editing is done via the web
interface for a number of reasons, not least of which is that there is no
recovery journal.

Keith

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---