[web2py] Re: Cannot insert specific key into table

2012-04-21 Thread haggis
Moved my application to a brand new web2py (latest stable) folder but it 
still doesn't work. I'm wondering about that because I used active_event 
all the time. If I have to use another name for that key, then I have to 
rewrite some code. That would be ok - but as long as I don't know why this 
mysterious thing happens I'm afraid that this will happen later again (in 
production?).

So please, if you don't know the answer, give me some advice where I have 
to look into. Do you need any additional information?


[web2py] Re: Unexpected exception

2012-04-21 Thread haggis
Same here with latest stable:

Table:
db.define_table('variable',
Field('name', type='string', length=255),
Field('value', type='string', length=255),
format='%(name)s',
primarykey=['name'])


Traceback:

Traceback (most recent call last):
  File /home/haggis/tmp/web2py/gluon/restricted.py, line 205, in restricted
exec ccode in environment
  File /home/haggis/tmp/web2py/applications/test/controllers/appadmin.py 
http://127.0.0.1:8000/admin/default/edit/ikum/controllers/appadmin.py, line 
412, in module
  File /home/haggis/tmp/web2py/gluon/globals.py, line 173, in lambda
self._caller = lambda f: f()
  File /home/haggis/tmp/web2py/applications/test/controllers/appadmin.py 
http://127.0.0.1:8000/admin/default/edit/ikum/controllers/appadmin.py, line 
126, in insert
form = SQLFORM(db[table], ignore_rw=ignore_rw)
  File /home/haggis/tmp/web2py/gluon/sqlhtml.py, line 772, in __init__
self.id_field_name = table._id.name
  File /home/haggis/tmp/web2py/gluon/dal.py, line 6774, in __getattr__
return self[key]
  File /home/haggis/tmp/web2py/gluon/dal.py, line 6714, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: '_id'





[web2py] Re: Cannot insert specific key into table

2012-04-21 Thread haggis
*head - desk*

I don't know why...but at any time by any case I wrote the following line 
into db.py:

db(db.variable.name=='active_event').delete()

hahaha, sorry for poluting this list! :(


[web2py] Cannot insert specific key into table

2012-04-20 Thread haggis
Hello,
I've got the following table:

db = DAL('sqlite://storage.sqlite')
db.define_table('variable',
Field('name', type='string', length=255),
Field('value', type='string', length=255),
format='%(name)s',
primarykey=['name'])

This is what happens by adding different name/value pairs via appadmin:

test/foobar: ok
any_name/myValue: ok
active_event/someevent: nothing happens but flash notfier signals 
successfull record

I can insert whatever I want - except active_event as name. It just 
doesn't appear in the table. It looks like that query would be ignored.
As I worked a lot in the database while development so far, I just removed 
the database folder from my applications to begin with a clean database. 
However, the problem still persists.

Do you have any idea?

Regards, haggis



[web2py] Windows Service: No module named gluon.winservice

2012-03-25 Thread haggis
Hello,
I'm trying to start web2py as a Windows (XP) service. After installing the 
pywin32 extension all errors at command line were gone. However, the 
service doesn't start.

This is what happens:

#python web2py.py -W install
- no errors -

#python web2py.py -W start
[...]
Starting hardcron...
Starting service web2py

- cannot access any web2py application!

#python web2py.py -W stop
[...]
Starting hardcron...
Stopping service web2py
Error stopping service: The service was not started. (1062)


Looking at the WinXP EventLog, I see the following:
Python could not import the service's module
ImportError: No module named gluon.winservice


Do you need further information?

Regards, Patrick


[web2py] Re: Windows Service: No module named gluon.winservice

2012-03-25 Thread haggis
Using web2py 1.99.4 stable


[web2py] Re: Windows Service: No module named gluon.winservice

2012-03-25 Thread haggis
Thank you, Massimo!
Here's the ticket: http://code.google.com/p/web2py/issues/detail?id=733

Am Montag, 26. März 2012 01:30:05 UTC+2 schrieb Massimo Di Pierro:

 Looks like it is not finding the gluon folder. Please open a ticket and I 
 will look at it asap.

 Massimo

 On Sunday, 25 March 2012 08:47:41 UTC-5, haggis wrote:

 Hello,
 I'm trying to start web2py as a Windows (XP) service. After installing 
 the pywin32 extension all errors at command line were gone. However, the 
 service doesn't start.

 This is what happens:

 #python web2py.py -W install
 - no errors -

 #python web2py.py -W start
 [...]
 Starting hardcron...
 Starting service web2py

 - cannot access any web2py application!

 #python web2py.py -W stop
 [...]
 Starting hardcron...
 Stopping service web2py
 Error stopping service: The service was not started. (1062)


 Looking at the WinXP EventLog, I see the following:
 Python could not import the service's module
 ImportError: No module named gluon.winservice


 Do you need further information?

 Regards, Patrick



[web2py] Re: web2py with Aptana - optimization required

2012-02-25 Thread haggis
When just using from gluon import * then Aptana shows me many errors
(i.e. dal() and http() not found).
auth = Auth(db) and service = Service() works fine, thank you!

On 24 Feb., 16:20, Anthony abasta...@gmail.com wrote:
  1) At default controller Aptana shows me errors at @auth...
  decorators (Undefined variable auth). Also the service() in the call()-

 function is unknown. You see my actual imports at the end of this

  post.

 You'd have to add the following to your list of dummy
 imports/instantiations:

 auth = Auth(db)
 service = Service()

 Also, note that you no longer need all of those import statements -- the
 entire web2py API is now exposed via from gluon import *. Also, if you're
 using trunk, even the dummy request, response, session, cache, and T
 instantiations are done for you when you import gluon. So, in addition to
 from gluon import *, you should only need to do the imports and
 instantiations for auth, service, and db.

 Anthony


[web2py] web2py with Aptana - optimization required

2012-02-24 Thread haggis
Hello,
after a couple of hours I finally got web2py development (with
debugging) working in Aptana Studio.

Helpful links for this:
http://pierrethibault.posterous.com/2010/10/web2py-eclipse-pydev-recipe.html
http://code.google.com/p/neo-web2py2eclipse/

However, there a two minor issues I want to resolve:

1) At default controller Aptana shows me errors at @auth...
decorators (Undefined variable auth). Also the service() in the call()-
function is unknown. You see my actual imports at the end of this
post.

2) Normally, I'm starting web2py manually from bash with python2.7
web2py.py. But this way debugging does not work. If I want to start
debugging, I have to stop web2py and let it start from Aptana debug-
mode. Is there a way to make this more comfortable?


Imports in default.py:
code
if 0:
  None
  from gluon import *
  from gluon.tools import *
  from gluon.globals import *
  from gluon.html import *
  from gluon.validators import *
  from gluon.sql import *
  import gluon.fileutils
  from gluon.contrib.gql import GQLDB
  from gluon.sql import SQLDB
  from gluon.sqlhtml import SQLFORM
  from gluon.sql import SQLField
  from gluon.sqlhtml import SQLTABLE
  from gluon.http import redirect
  import gluon.languages.translator as T
  import gluon.compileapp.local_import_aux as local_import

  global cache; cache = gluon.cache.Cache()
  global request; request = gluon.globals.Request()
  global response; response = gluon.globals.Response()
  global session; session = gluon.globals.Session()
  global DAL; DAL = gluon.dal()
  global HTTP; HTTP = gluon.http()
  global LOAD; LOAD = gluon.compileapp.LoadFactory()
  db = DAL('sqlite://storage.sqlite')

from gluon import *
import sys, datetime
/code

Regards, haggis


[web2py] ajax redirect after @auth.requires_login() failed

2011-11-02 Thread haggis
Hello,
is it possible to return json to the calling jQuery.ajax() function
after access was denied by decorator @auth.requires_login()?

I know there is a possibility to specify a function when authorization/
authentication failed with
auth.settings.on_failed_authentication = myFunc and
auth.settings.on_failed_authorization = myFunc

I put this two lines in model db.py. However, I don't know how to just
return json containing a url to which the user should be redirected.

Any suggestions are welcome!
Thanks, haggis


[web2py] Re: ajax redirect after @auth.requires_login() failed

2011-11-02 Thread haggis
As I wrote Massimo directly by accident, he answered me via mail: it's
not possible.
That's a pity. May this be possible in a future release? Otherwise
it's difficult to develope an application that works with ajax only.
In this case the only way I see to redirect a user after his session
timed out is to resign the decorators and check access in each
callback function.
Are there other ways I don't know?



On 2 Nov., 19:36, haggis patr...@mindf.org wrote:
 Hello,
 is it possible to return json to the calling jQuery.ajax() function
 after access was denied by decorator @auth.requires_login()?

 I know there is a possibility to specify a function when authorization/
 authentication failed with
 auth.settings.on_failed_authentication = myFunc and
 auth.settings.on_failed_authorization = myFunc

 I put this two lines in model db.py. However, I don't know how to just
 return json containing a url to which the user should be redirected.

 Any suggestions are welcome!
 Thanks, haggis


[web2py] Dynamic modules

2011-10-18 Thread haggis
Hello,
I want an intranet application which is extendable by dynamic modules.
That is, it should be possible to copy i.e. a statistic module into
a module directory and the module will be automatically implemented
without changing the applications source or doing anything in
appadmin.
So with next start of the application (not necessary during runtime)
the example statistic module would provide an additional menu button
for authorized users.

Web2py provides a plugin system which doesn't fit that needs, does it?
I would try it in a way as discussed here:
http://stackoverflow.com/questions/301134/dynamic-module-import-in-python

Or is there a specific web2py way?


Cheers, haggis


[web2py] Fetching password field from auth_user table

2011-10-08 Thread haggis
I'm trying to fetch the password field in a simple query like this:

row = db(db.auth_user.id == uid).select(db.auth_user.password)
eturn row

This is returned:
auth_user.password
auth_user.password generator object genexpr at 0xa313a2c

What's so special with the password field that I can query every field
but password? How would you query the salted hash of an user?

Thanks in advance,
haggis


[web2py] Getting form via ajax/json returns JSON serialization error

2011-10-05 Thread haggis
When I try to access my action via myapp/statusbar/userEdit I see the
form as expected. However, when I try it at myapp/statusbar/
userEdit.json I get a JSON serialization error.

This is my controller:

def user_widget():
# return table of all users incl. their roles
output = T('No users found')

rows = db().select(db.auth_user.id, db.auth_user.username,
db.auth_membership.id, db.auth_membership.group_id,
left=db.auth_membership.on(db.auth_membership.user_id==db.auth_user.id))
if len(rows)  0:
table_rows = []
for row in rows:
table_rows.append([row.auth_user.username,
row.auth_membership.id, row.auth_membership.group_id, A(T('edit'),
_href='#', _id='edit-user-' + str(row.auth_user.id), _class='edit-
user')])
output = TABLE(THEAD(TR(TH(T('Username')), TH(T('Membership
ID')), TH(T('Group ID')), TH(T('Edit', *[TR(*myrows) for myrows in
table_rows], _id='user-widget-users-table')
script = SCRIPT('$(function() { \
$(#user-widget-users-table a.edit-
user).click(function() { \
jQuery.ajax({ \
type: POST, \
url: '+
URL(r=request,c='statusbar',f='userEdit') +', \
data: id= +  $(this).attr(id),
\
success: function(msg){ \
$(#settings-
content).html(msg.html); \
$(#settings-
title).html(msg.title); \
} \
}); \
}); \
});', _language='javascript')
output.append(script)

return {'html':str(output), 'title':T('User settings')}

def userEdit():
# simplified - should return edit form a specific user later
form=SQLFORM.factory(db.auth_user,db.auth_membership)
return {'html':form, 'title':'test'}


The form contains two textfields and two selection fields and a submit
button. My statusbar/userEdit.json view ist the default one.

Any suggestions?


[web2py] Re: Getting form via ajax/json returns JSON serialization error

2011-10-05 Thread haggis
The str() function helped:

return {'html':str(form), 'title':'test'}


[web2py] Re: Login form error KeyError: 'email' after customizing db.auth_user table

2011-05-22 Thread haggis
Thanks both of you! This helped me understanding a little bit more of
what happens inside.
As Anthony suggested I just renamed the 'name' field to 'username' and
everything is fine now.

Next step is to figure out how to disable the reset password actions.


[web2py] Login form error KeyError: 'email' after customizing db.auth_user table

2011-05-20 Thread haggis
Hi,
since I doesn't need any email adresses associated with my users, I
changed the schema of the auth_user table like this:

file: db.py

snip
db.define_table(
auth.settings.table_user_name,
Field('name', length=32, default='', label='Name'),
Field('password', 'password', length=512, readable=False,
label='Passwort'),
Field('registration_key', length=512, writable=False,
readable=False, default=''),
Field('reset_password_key', length=512, writable=False,
readable=False, default=''),
Field('registration_id', length=512, writable=False,
readable=False, default=''))

custom_auth_table = db[auth.settings.table_user_name]
custom_auth_table.name.requires =
[IS_NOT_EMPTY(error_message=auth.messages.is_empty),
   IS_NOT_IN_DB(db,
custom_auth_table.name)]
custom_auth_table.password.requires =
CRYPT(key=auth.settings.hmac_key)

auth.settings.table_user = custom_auth_table

auth.define_tables(username=True)
/snap

I also managed to get the registration form working. However, if I try
to show the login form (http://localhost:8000/myapp/default/user/
login) I get the following error: KeyError: 'email'

It seems as web2py tries to generate the login form based on the
original auth_user schema. How can I change this? I didn't find
anything.

Please forgive me if this is a fiddling question - I'm still very new
to python and web2py.

Regards,
haggis