[web2py] Re: Database

2015-04-05 Thread Leonel Câmara
I would say postgresql is better than MySQL, not just web2py but for 
everything.

-- 
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.


[web2py] Re: Database

2015-04-05 Thread 黄祥
granma said : 'everything is wonthefull if you know how to appreciate it' 
everything has a good side n bad side, imho better is which database you 
familiar n comfortable with, then please use it.

best regards,
stifan

-- 
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.


[web2py] Re: query in is_in_db is not work

2015-04-05 Thread Anthony
There is an error in you query -- the and should be an . But that is 
not the source of your exception, which comes from the previous line that 
attempts to access the db.employee table. Apparently, at this point in the 
code, that table has not yet been defined (perhaps it is defined in a later 
model file, or defined in a conditional model file).

Anthony

On Sunday, April 5, 2015 at 10:51:46 PM UTC-4, 黄祥 wrote:

 hi,

 i have a query in is_in_db requires but not work properly
 e.g.
 *models/db.py*
 employee = db(db.employee.auth_user == 1).select().first()
 db.booking.room.requires = IS_IN_DB(db((db.room.status == 'Available') and 
 (db.room.branch == employee.branch)), db.room.id, db.room._format) if 
 auth.user else None

 *traceback*
 Traceback

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

 Traceback (most recent call last):
   File C:\web2py\gluon\restricted.py, line 227, in restricted
 exec ccode in environment
   File C:/web2py/applications/hotel/models/db_wizard_4_booking.py 
 https://127.0.0.1/admin/default/edit/hostel/models/db_wizard_4_booking.py, 
 line 3, in module
 employee = db(db.employee.auth_user == 1).select().first()
   File C:\web2py\gluon\packages\dal\pydal\base.py, line 929, in __getattr__
 return ogetattr(self, key)
 AttributeError: 'DAL' object has no attribute 'employee'


 *test on web2py python shell (work fine)*
 print db(db.employee.auth_user == 1).select().first()
 print db(db.room.branch == 1).select().first()

 employee = db(db.employee.auth_user == 1).select().first()
 print employee.branch

 is there related to modular dal?

 thanks and best regards,
 stifan


-- 
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.


[web2py] Re: query in is_in_db is not work

2015-04-05 Thread 黄祥


 There is an error in you query -- the and should be an . But that is 
 not the source of your exception, which comes from the previous line that 
 attempts to access the db.employee table. Apparently, at this point in the 
 code, that table has not yet been defined (perhaps it is defined in a later 
 model file, or defined in a conditional model file).


the employee table already defined before booking table (file name base 
order), what do you mean with conditional model file? is it related with 
show_if?
e.g.
*models/db_wizard_2_employee.py*
# on_define_employee
def on_define_employee(table): 
# requires
table.auth_user.requires = IS_EMPTY_OR(IS_IN_DB(db, db.auth_user.id, 
'%(first_name)s %(last_name)s') )
# show_if
table.auth_user.show_if = (table.is_auth == True)
table.first_name.show_if = (table.is_auth == False)
table.last_name.show_if = (table.is_auth == False)
table.email.show_if = (table.is_auth == False)

# create table : employee
db.define_table('employee', 
Field('is_auth', 'boolean'),
Field('auth_user', 'reference auth_user'),  
Field('first_name'), 
Field('last_name'), 
Field('email', 'list:string'), 
on_define = on_define_employee, 
format = '%(first_name)s %(last_name)s')

*models/db_wizard_4_booking.py*
employee = db(db.employee.auth_user == auth.user_id).select().first()

# on_define_booking
def on_define_booking(table): 
# requires
table.room.requires = IS_IN_DB(db((db.room.status == 'Available')  
(db.room.branch == employee.branch)), db.room.id, db.room._format) if 
auth.user else None

# create table : booking
db.define_table('booking', 
Field('booking_no'), 
Field('room', 'reference room'),
on_define = on_define_booking, 
format = '%(booking_no)s')

thanks and best regards,
stifan

-- 
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.


[web2py] ERROR on clear cash fron admin DB

2015-04-05 Thread Dmitry Ermolaev


I store in cash connection:

# покажем если был вызов а не из кэша
def conn_1(curr, xcurr):
print 'try connect to ',curr.abbrev
# def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, 
connection=None):
cn = ServiceProxy(xcurr.connect_url, None, 40)
#print cn
blk = cn.getblockcount()
print 'connected on block:', blk
return cn

# тут если удача то надолго запомним
def conn_0(curr, xcurr):
try:
cn = cache.ram(curr.abbrev, lambda: conn_1(curr, xcurr), time_expire = 
36000)
except Exception as e:
print curr.abbrev + ' conn except: %s' % 
str(e).decode('cp1251','replace')
cn = None
if not cn:
cache.ram.clear(curr.abbrev)
return cn

# если нет связи то тоже запомним на небольшое время
def conn(curr, xcurr, cn=None):
# пока не подключимся - пробуем
cn = cache.ram(curr.abbrev + '_0', lambda: conn_0(curr, xcurr), time_expire 
= 10)
return cn


Traceback (most recent call last):
  File C:\web2py-m\gluon\restricted.py, line 224, in restricted
exec ccode in environment
  File C:/web2py-m/applications/shop/controllers/appadmin.py 
http://127.0.0.1:8000/admin/default/edit/shop/controllers/appadmin.py, line 
636, in module
  File C:\web2py-m\gluon\globals.py, line 393, in lambda
self._caller = lambda f: f()
  File C:/web2py-m/applications/shop/controllers/appadmin.py 
http://127.0.0.1:8000/admin/default/edit/shop/controllers/appadmin.py, line 
371, in ccache
cache.disk.clear()
  File C:\web2py-m\gluon\cache.py, line 427, in clear
storage.clear()
  File C:\web2py-m\gluon\cache.py, line 364, in clear
for key in self:
  File C:\web2py-m\gluon\cache.py, line 349, in __iter__
yield self.key_filter_out(filename)
  File C:\web2py-m\gluon\cache.py, line 307, in key_filter_out_windows
return base64.b32decode(key)
  File C:\Python27\lib\base64.py, line 198, in b32decode
raise TypeError('Incorrect padding')
TypeError: Incorrect padding

-- 
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.


[web2py] Re: web2py 2.10.3 si OUT

2015-04-05 Thread 黄祥
format record representation is not work in grid (in the drop down select 
form field is work, but in the grid table just shown an id).
e.g.
db.define_table('test0', 
Field('test0'), 
format = '%(test0)s')

db.define_table('test1', 
Field('test0', 'reference test0'),
Field('test1'),
format = '%(test1)s')

def test0():
grid = SQLFORM.grid(db.test0)
return locals()

def test1():
grid = SQLFORM.grid(db.test1)
return locals()

best regards,
stifan

-- 
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.


[web2py] Database

2015-04-05 Thread Wellington Faria
Hi! I would like to know wich is better database to use in web2py? Mysql or 
postgre? 

Thanks. 

-- 
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.


[web2py] BaseAdapter supporting driver selection

2015-04-05 Thread Felipe Augusto Meirelles
Hi,

On pydal/adapters/base.py, on line 170 shouldn't it be:

items = uri.split('://', 1)[0].split('+')

instead of

items = uri.split('://', 1)[0].split(':')?

-- 
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.


[web2py] w2p_clone broke web2py installation

2015-04-05 Thread Gary Cowell

Hello

I installed web2py from pip, I think it's at 2.1.1

Then ran w2p_clone to bring in latest version. On launch I get the 
following error:


Traceb

Traceback (most recent call last):
  File web2py.py, line 18, in module
import gluon.widget
  File /home/gary/python/web2py/web2py/gluon/__init__.py, line 37, in module
from sqlhtml import SQLFORM, SQLTABLE
  File /home/gary/python/web2py/web2py/gluon/sqlhtml.py, line 34, in module
from gluon.dal import _default_validators
ImportError: cannot import name _default_validators



What did I do wrong? I'm working in a virtualenv, wanted to deploy the 
latest version, the pip one is quite the age now it seems.

-- 
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] Drill-down menu with PostgreSQL

2015-04-05 Thread Carlos Zenteno
Thanks for explaining the materialization process.  It will come handy on 
my app...

-- 
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.


[web2py] Re: Design flaw in auth.impersonate ?

2015-04-05 Thread Limedrop
Well the easy answer is to simply open the impersonated user in a different 
browser (eg, have Support Team login in chrome and impersonated user login 
in firefox).

For us it is important that impersonate is restricted to the user's 
permissions...we have several classes of user and it is essential to see 
what the site looks like from their environment.


On Monday, 6 April 2015 06:51:53 UTC+12, Louis Amon wrote:

 When you impersonate a user in web2py, your whole auth session gets 
 replaced with the user's, and that means you lose access to whatever 
 permissions you used to have (
 http://web2py.readthedocs.org/en/latest/tools.html#gluon.tools.Auth.impersonate
 ) 

 Practically : if you're a staff member (Support Team, not geek) and you're 
 using a permission-locked back-office to impersonate a user, that means you 
 won't be able to access the back-office to check for extra data until you 
 impersonate(0) to go back to your own session and permissions.

 So far I've just asked my team to chew on it and just de-impersonate every 
 time they need to go back to the back-office... but they keep complaining 
 about it and they're quite right.


 I've been thinking about how to improve this, and so far I've only managed 
 to narrow down a few options :

1. Building a second Session() object to manage both sessions 
separately
2. Using session.connect(masterapp=...) to use another application's 
sessions (between main app and back-office app for instance, if those are 
separate... which is a pain in terms of model management)
3. Messing with the permission system to add up permissions (staff 
member's permissions + impersonated user's permissions) before permission 
checks


 I'm really not sure what strategy I should adopt here and how I should go 
 about implementing this.

 Pointers would be very welcome :)


-- 
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.


[web2py] Re: call a function from form.process()

2015-04-05 Thread 黄祥
yes, i know it's lack of parenthesis, pardon me, actually, my real code is 
i put it on module n pass into variable via the controller, the test (app n 
function), is the minimum application that was for dev environment to trace 
back the root cause of the problem. btw, anthony has shown the way, thank 
you so much anthony.
*e.g. in modules works well*
def form_0(table, onvalidation, oncreate, report):
form = SQLFORM(table)
if form.process(onvalidation = onvalidation, onsuccess = oncreate).accepted:
redirect(URL('report', report) )
return dict(form = form)

thanks and best regards,
stifan

-- 
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.


[web2py] Re: AppConfig and Storage

2015-04-05 Thread 黄祥



 Beware: since it's made for speed, once you take out the reload on the 
 initialization, values will be stored indefinitely as they are fetched the 
 first time.


agreed, already tested it. imho, i think is still not stable.
e.g.
private/appconfig.ini
[auth]
actions_disabled   = ['profile', 'register']

[google_analytics_id]
;google_analytics_id = 1
google_analytics_id = None

[meta]
menu = [
(T('Master'), False, URL('master', 'index'), []), 
]

1. the auth using list is work fine define it on appconfig.ini
2. the google analytics can work too, when i change the value (None into 1)
3. the meta is crashed because i made it in python style, so when i cut it 
on the appconfig.ini n paste in menu.py the error is still occured. 
(fetched indefintely)

what i think is not stable, is when i change the value of google analytics, 
it just take a few refresh in view page source on browser (the value 
change). when i cut the meta menu, paste it on menu.py and do a lot of 
refresh, the error is still there.

best regards,
stifan

-- 
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.


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-05 Thread Leonel Câmara
I think it's a weird bug where you have a cookie in your browser that is no 
longer in the server so you get that NoneType, not sure what causes it, I 
think it's probably a weird interaction with your webserver configuration 
(probably apache which seems to create weird problems).  
  
I'll try to investigate.

-- 
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.


[web2py] Re: auth_user table format

2015-04-05 Thread 黄祥
yes, you are right, i defined the custom_auth after auth.define_tables(), 
but the problem is when i put it before auth.define_tables() it return an 
error
*e.g. no error but the result is not expected*
auth = Auth(db)

audit_from = db.Table(db, 'audit_from',
Field('created_from', default = request.client, readable = False, 
writable = False),
Field('modified_from', update = request.client, readable = False, 
writable = False) )

db._common_fields.append(audit_from)

auth.define_tables(username = True, signature = True)

custom_auth_table = db[auth.settings.table_user_name]

custom_auth_table._format = '%(first_name)s %(last_name)s'
custom_auth_table.first_name.label = T('First Name')
custom_auth_table.last_name.label = T('Last Name')
custom_auth_table.email.label = T('Email')

auth.settings.table_user = custom_auth_table

*e.g. error occured*
auth = Auth(db)

audit_from = db.Table(db, 'audit_from',
Field('created_from', default = request.client, readable = False, 
writable = False),
Field('modified_from', update = request.client, readable = False, 
writable = False) )

db._common_fields.append(audit_from)

custom_auth_table = db[auth.settings.table_user_name]

custom_auth_table._format = '%(first_name)s %(last_name)s'
custom_auth_table.first_name.label = T('First Name')
custom_auth_table.last_name.label = T('Last Name')
custom_auth_table.email.label = T('Email')

auth.settings.table_user = custom_auth_table

auth.define_tables(username = True, signature = True)

*error*
Traceback

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

Traceback (most recent call last):
  File C:\web2py\gluon\restricted.py, line 227, in restricted
exec ccode in environment
  File C:/web2py/applications/hostel/models/db.py 
https://127.0.0.1/admin/default/edit/hostel/models/db.py, line 42, in module
custom_auth_table = db[auth.settings.table_user_name]
  File C:\web2py\gluon\packages\dal\pydal\base.py, line 922, in __getitem__
return self.__getattr__(str(key))
  File C:\web2py\gluon\packages\dal\pydal\base.py, line 929, in __getattr__
return ogetattr(self, key)
AttributeError: 'DAL' object has no attribute 'auth_user'


what i want to achieve is the auth_user table format representation can be 
shown in another auth tables (auth_event and auth membership). how can i 
solve this using web2py way?

thanks and best regards,
stifan

-- 
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.


[web2py] Developer network

2015-04-05 Thread 'sasogeek' via web2py-users
Hello,
I'm wondering if there's a social media platform for app developers?
I want to build one as an open source project using web2py... any thoughts, 
ideas, something to look on to start with?

-- 
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] Developer network

2015-04-05 Thread Phyo Arkar
Github?

On Mon, Apr 6, 2015 at 11:10 AM, 'sasogeek' via web2py-users
web2py@googlegroups.com wrote:
 Hello,
 I'm wondering if there's a social media platform for app developers?
 I want to build one as an open source project using web2py... any thoughts,
 ideas, something to look on to start with?

 --
 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.

-- 
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.


[web2py] Re: query in is_in_db is not work

2015-04-05 Thread 黄祥


 There is an error in you query -- the and should be an . But that is 
 not the source of your exception, which comes from the previous line that 
 attempts to access the db.employee table. Apparently, at this point in the 
 code, that table has not yet been defined (perhaps it is defined in a later 
 model file, or defined in a conditional model file).


yes, you are right, it's not defined in a conditional model file 
(response.models_to_run). thank you very much, anthony.

best regards,
stifan

-- 
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.


[web2py] Database

2015-04-05 Thread Ron Chatterjee
I would say u want to start with sqlite n before deployment u can choose 
something more applicableble to ur requirents. There r no right or wrong ans. 
If performance n security is huge use mysql. Otherwise the open source 

-- 
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.


[web2py] query in is_in_db is not work

2015-04-05 Thread 黄祥
hi,

i have a query in is_in_db requires but not work properly
e.g.
*models/db.py*
employee = db(db.employee.auth_user == 1).select().first()
db.booking.room.requires = IS_IN_DB(db((db.room.status == 'Available') and 
(db.room.branch == employee.branch)), db.room.id, db.room._format) if 
auth.user else None

*traceback*
Traceback

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

Traceback (most recent call last):
  File C:\web2py\gluon\restricted.py, line 227, in restricted
exec ccode in environment
  File C:/web2py/applications/hotel/models/db_wizard_4_booking.py 
https://127.0.0.1/admin/default/edit/hostel/models/db_wizard_4_booking.py, 
line 3, in module
employee = db(db.employee.auth_user == 1).select().first()
  File C:\web2py\gluon\packages\dal\pydal\base.py, line 929, in __getattr__
return ogetattr(self, key)
AttributeError: 'DAL' object has no attribute 'employee'


*test on web2py python shell (work fine)*
print db(db.employee.auth_user == 1).select().first()
print db(db.room.branch == 1).select().first()

employee = db(db.employee.auth_user == 1).select().first()
print employee.branch

is there related to modular dal?

thanks and best regards,
stifan

-- 
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.


[web2py] Re: auth_user table format

2015-04-05 Thread Anthony
For the format attribute to affect the represent attribute of linked 
reference fields, it must be set before those reference fields are defined. 
If you are setting the auth_user format attribute after calling 
auth.define_tables(), then the auth_event table has already been defined. 
Instead, you may need to directly change the represent attribute of the 
reference field in auth_event.

Anthony

On Sunday, April 5, 2015 at 6:53:53 PM UTC-4, 黄祥 wrote:

 hi,

 i tried to have auth_user a proper format record representation, but it 
 end with just the id shown on the table.
 e.g.
 *models/db.py*
 custom_auth_table = db[auth.settings.table_user_name]
 custom_auth_table._format = '%(first_name)s %(last_name)s'
 auth.settings.table_user = custom_auth_table

 *controllers/default.py*
 def event():
 grid = SQLFORM.grid(db.auth_event)
 return locals()

 how can i see the user id in auth_event with proper record representation 
 format (first_name, last_name) instead of the id in web2py way?

 thanks and best regards,
 stifan


-- 
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.


[web2py] Re: Is julia going to be the next language of choice, can web2py benefit from its speed?

2015-04-05 Thread david jensen


On Saturday, April 4, 2015 at 1:33:40 AM UTC-4, Ron Chatterjee wrote:

 I recently came across the wonderful programing language call Julia. I 
 used the word wonderful since its resembling to C/MATLAB environment as I 
 am mostly familiar with. Regardless,... people are saying its two times 
 faster than python. Wondering if someone knows more about it than I do, and 
 its relevance to web framework. Can web2py benefit from it in anyway like 
 its speed?



S'il vous plait, monsieur 

-- 
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.


[web2py] Re: Design flaw in auth.impersonate ?

2015-04-05 Thread Massimo Di Pierro
Now I think 3 should be the solution but it should be an option and not 
default behavior. Nowhere we say that impersonate should behave has linux 
sudo permissions. The way it is intended to work is that when you 
impersonate another user you become that other use and you see what the 
other user would see. So by default you only get the same permissions as 
the user you impersonate. this is not by design, and not an oversight. I 
see that sometimes you want something different. I guess the impersonate 
method could have an option that supports your option 3.

On Sunday, 5 April 2015 13:51:53 UTC-5, Louis Amon wrote:

 When you impersonate a user in web2py, your whole auth session gets 
 replaced with the user's, and that means you lose access to whatever 
 permissions you used to have (
 http://web2py.readthedocs.org/en/latest/tools.html#gluon.tools.Auth.impersonate
 ) 

 Practically : if you're a staff member (Support Team, not geek) and you're 
 using a permission-locked back-office to impersonate a user, that means you 
 won't be able to access the back-office to check for extra data until you 
 impersonate(0) to go back to your own session and permissions.

 So far I've just asked my team to chew on it and just de-impersonate every 
 time they need to go back to the back-office... but they keep complaining 
 about it and they're quite right.


 I've been thinking about how to improve this, and so far I've only managed 
 to narrow down a few options :

1. Building a second Session() object to manage both sessions 
separately
2. Using session.connect(masterapp=...) to use another application's 
sessions (between main app and back-office app for instance, if those are 
separate... which is a pain in terms of model management)
3. Messing with the permission system to add up permissions (staff 
member's permissions + impersonated user's permissions) before permission 
checks


 I'm really not sure what strategy I should adopt here and how I should go 
 about implementing this.

 Pointers would be very welcome :)


-- 
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.


[web2py] Re: sorting ip address

2015-04-05 Thread rhardenstein
Try using the netaddr library...

On Tuesday, March 31, 2015 at 3:27:11 PM UTC-7, Matheus Suffi wrote:

 Hello,

 im trying to sort an IP adddres list, this is the only result i getting
 192.168.1.1
 192.168.1.10
 192.168.1.11

 i want to list in that order:
 192.168.1.1
 192.168.1.2
 192.168.1.3
 192.168.1.4

 Any ideias ?


-- 
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] Developer network

2015-04-05 Thread 'sasogeek' via web2py-users
Hmmm, I guess I never saw github as that... never really explored it, just 
have an account there. Will take a look and see what I can learn from it.
Thanks

On Monday, 6 April 2015 06:07:21 UTC+1, Phyo Arkar wrote:

 Github? 

 On Mon, Apr 6, 2015 at 11:10 AM, 'sasogeek' via web2py-users 
 web...@googlegroups.com javascript: wrote: 
  Hello, 
  I'm wondering if there's a social media platform for app developers? 
  I want to build one as an open source project using web2py... any 
 thoughts, 
  ideas, something to look on to start with? 
  
  -- 
  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+un...@googlegroups.com javascript:. 
  For more options, visit https://groups.google.com/d/optout. 


-- 
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.


[web2py] auth_user table format

2015-04-05 Thread 黄祥
hi,

i tried to have auth_user a proper format record representation, but it end 
with just the id shown on the table.
e.g.
*models/db.py*
custom_auth_table = db[auth.settings.table_user_name]
custom_auth_table._format = '%(first_name)s %(last_name)s'
auth.settings.table_user = custom_auth_table

*controllers/default.py*
def event():
grid = SQLFORM.grid(db.auth_event)
return locals()

how can i see the user id in auth_event with proper record representation 
format (first_name, last_name) instead of the id in web2py way?

thanks and best regards,
stifan

-- 
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.


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-05 Thread 'sasogeek' via web2py-users
Thanks Leonel
Somehow that worked! But I have no idea why it worked... seeing as you 
suggested it, can you explain to me please?
Thanks again though.

On Sunday, April 5, 2015 at 9:15:56 AM UTC+1, Leonel Câmara wrote:

 If you clear your browser cookies (you can try using a private browsing 
 window) does it work?


-- 
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.


[web2py] Re: Facing problem of settingup web2py project in Eclipse.

2015-04-05 Thread flagist0
Hello Amit!
Web2py executes your code in a special environment populated with 
predefined objects (like request, response, T etc, 
http://web2py.com/books/default/chapter/29/04/the-core#API)
Also web2py has special places where it looks for modules (/gluon, 
applications/your application/modules, /site-packages). These folders are 
not in PYTHONPATH, so your IDE cannot find them and shows errors.
But web2py can find them and everything works, so this is an error only for 
your IDE code analyzer.
This is a common problem, and there are many workarounds for different 
IDEs, including eclipse. Maybe this post will help you: 
http://www.web2py.com/AlterEgo/default/show/37


On Friday, July 20, 2012 at 9:19:29 AM UTC+4, Amit wrote:

 Hi,
 I followed below link to configure Web2py project in eclipse:

 http://allisterx.blogspot.in/2009/06/using-web2py-framework-on-eclipse.html

 but after setting up when i open my application which is there inside 
 application folder of web2py_src folder, I saw so many errors on the module.
 once i open default.py module, it showing error on import modules which 
 are inside Modules folder(for e.g.: i have userconf.py module inside 
 modules but when i import it in default.controller it giving error saying 
 Unresolved import:userconf) , similar problem with when i am trying to 
 use function of db.py, its giving error undefined variable.

 can anyone please help me to figure out what wrong i did?


-- 
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.


[web2py] Re: call a function from form.process()

2015-04-05 Thread Anthony
There's no reason you can't use a function in your first example:

if form.process().accepted:
oncreate_event(form)

You can also use the onsuccess argument:

form.process(onsuccess=oncreate_event)

The above will mainly be useful when you have also specified a next 
argument and need to do something before the redirect to next.

Anthony

On Sunday, April 5, 2015 at 1:08:47 AM UTC-4, 黄祥 wrote:

 pardon me, i mean is i would like to have something like oncreate in 
 SQLFORM.grid using SQLFORM.
 so i think if i have more than a function to record the activity of user 
 input using SQLFORM, it will efficient to put it on the function, so that 
 another function can use my custom oncreate function during form.process().
 about onvalidation, i already use it to assign another job (specific 
 document no format), can't be used in another function.
 well i think the option are either to put the custom oncreate function 
 under the onvalidation (like your recommendation), or using the first 
 example that work.

 thanks and best regards,
 stifan


-- 
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.


[web2py] Re: unknown error on production server! I need help fixing it asap ['NoneType' object is not callable]

2015-04-05 Thread Leonel Câmara
If you clear your browser cookies (you can try using a private browsing 
window) does it work?

-- 
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.


[web2py] Design flaw in auth.impersonate ?

2015-04-05 Thread Louis Amon
When you impersonate a user in web2py, your whole auth session gets 
replaced with the user's, and that means you lose access to whatever 
permissions you used to have (
http://web2py.readthedocs.org/en/latest/tools.html#gluon.tools.Auth.impersonate
) 

Practically : if you're a staff member (Support Team, not geek) and you're 
using a permission-locked back-office to impersonate a user, that means you 
won't be able to access the back-office to check for extra data until you 
impersonate(0) to go back to your own session and permissions.

So far I've just asked my team to chew on it and just de-impersonate every 
time they need to go back to the back-office... but they keep complaining 
about it and they're quite right.


I've been thinking about how to improve this, and so far I've only managed 
to narrow down a few options :

   1. Building a second Session() object to manage both sessions separately
   2. Using session.connect(masterapp=...) to use another application's 
   sessions (between main app and back-office app for instance, if those are 
   separate... which is a pain in terms of model management)
   3. Messing with the permission system to add up permissions (staff 
   member's permissions + impersonated user's permissions) before permission 
   checks


I'm really not sure what strategy I should adopt here and how I should go 
about implementing this.

Pointers would be very welcome :)

-- 
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.


[web2py] Re: call a function from form.process()

2015-04-05 Thread JorgeH

are you aware that you are not calling the function ? or is that semicode.


def test():
 form = SQLFORM(db.test)
 if form.process().accepted:
 oncreate_event ()   - you lack the parenthesis here, and the argument
 return dict(form = form)






On Saturday, April 4, 2015 at 10:51:02 PM UTC-5, 黄祥 wrote:

 hi,

 is it possible to call a function from form.process()?
 e.g. 
 *work*
 def test():
 form = SQLFORM(db.test)
 if form.process().accepted:
 db.auth_event.insert(time_stamp = request.now, client_ip = request.client, 
  user_id = auth.user_id, origin = '%s' % (request.function), 
  description = 'ID created')
 return dict(form = form)

 *not work*
 def oncreate_event(form):
 db.auth_event.insert(time_stamp = request.now, client_ip = request.client, 
  user_id = auth.user_id, origin = '%s' % (request.function), 
  description = 'ID created')

 def test():
 form = SQLFORM(db.test)
 if form.process().accepted:
 oncreate_event
 return dict(form = form)

 why i can't call a function from form.process()? what is the correct way 
 in web2py to call a function in form.process()?

 thanks and best regards,
 stifan


-- 
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.


[web2py] Re: Difference between response.files.insert() and URL(), and congratulations on v2.10

2015-04-05 Thread Louis Amon
Unless... you have response.optimize_css set somewhere in your code as well.

In which case, some pre-processing and caching would be applied to your CSS 
file before it is injected in the view.

More doc here : 
http://www.web2py.com/books/default/chapter/29/04/the-core#response

On Thursday, April 2, 2015 at 5:17:25 AM UTC+2, Anthony wrote:

 On Wednesday, April 1, 2015 at 7:45:10 PM UTC-4, Tom Campbell wrote:

 (First--congrats on v2.10 and thanks to all you contributors for an 
 incredible framework.)

 What's the difference between these two lines of code?


 response.files.insert(1,URL('static','adminlte/bootstrap/css/bootstrap.min.css'))

 link 
 href={{=URL('static','adminlte/bootstrap/css/bootstrap.min.css')}} 
 rel=stylesheet type=text/css /

 Assuming the first line is at some point followed by 
 response.include_files(), there is no difference.

 Anthony
  


-- 
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] Drill-down menu with PostgreSQL

2015-04-05 Thread Louis Amon
That's an interesting approach indeed. Thanks Niphlod :)

Well, in the end my company hired a SEO consultant and our conclusion was 
that we need to build a drill-down navigation instead of one page 
containing the whole tree.

E.g. :

*country*

   - administrative_area_level_1
   - administrative_area_level_1
   - ...

Then if you click on any of the leaves :

*administrative_area_level_1*

   - administrative_area_level_2
   - administrative_area_level_2
   - ...

And so forth.
As you said a webpage holding 200 locations and requiring 800 queries is 
not a webpage a user would need.

Search engines know that and disregard pages holding more than 200 links, 
so a clean routing and drill-down navigation is the right answer for this 
SEO issue 

Hope this helps other people :)


On Thursday, February 12, 2015 at 5:26:01 PM UTC+1, Niphlod wrote:

 mind that there's even another angle: given that usually a city resides 
 in the same place (same goes for regions, countries, etc etc etc) you can 
 carefully cache the computationally expensive resultset and update it 
 once a week (or once modifications are made). 
 That's what we - dba - call as materialization process: something huge 
 to compute, read often, modified rarely...can be computed rarely and stored 
 somewhere with the most correct structure that is read-safe.

 On Thursday, February 12, 2015 at 1:27:29 PM UTC+1, Louis Amon wrote:

 a webpage holding 200 locations and requiring 800 queries is not a 
 webpage a user would need. 


 That’s actually a very good point !

 This page is actually designed for SEO, but even SEO doesn’t go well with 
 hundreds of links.

 I think I should build a navigation architecture that maps the drill down 
 I want to build.
 This way I solve both problems : the DAL query will be much simpler  the 
 result in terms of SEO will also improve !

 Thanks Niphlod for helping me clear that up. Not all answers need to be 
 technical :)




-- 
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.


[web2py] Re: Project: Heroku Buildpack for Web2py

2015-04-05 Thread Louis Amon
After much thought, and based on the fact that I've been using the 
Heroku/Web2py stack for more than a year now, I think I'll try to build a 
scaffolding app dedicated to Heroku in order to demonstrate exactly how one 
should go about building a web2py-based application on a PaaS cloud with no 
persistent filesystem.
I could also contribute the doc section on Heroku but I'm not quite sure 
I'm senior enough just yet.

That being said, the most difficult issue I've been having so far with 
web2py on Heroku (and still haven't solved yet) is *how to handle migration 
files*.

If you guys can help me do that then it's pretty much all clear down the 
road ;)


So, basically, there are 4 approaches to storing data on cloud systems :

   1. Use a remote bucket (e.g. Amazon S3)
   2. Store data in the database
   3. Postdeploy hooks
   4. CVS (Git/Mercurial...)

Let's go over those :

*1. Bucket*

If you use a library like pyfs, you can replace the filesystem used to 
access local files with a remote system (a bucket). That's very handy for 
instance if you want to manage uploads (e.g. pictures) in web2py using a 
remote storage service like Amazon S3.

HOWEVER, migration files being files you need to access a lot and very fast 
in web2py, any latency you add in the loading of those files would 
drastically impact your app's responsivity.
Even using a CDN service like Cloudfront, I would highly recommend not 
going for that option.

*2. Database*

That is the preferred option so far, and the only one offered in web2py's 
doc.
gluon/contrib/heroku.py uses the UseDatabaseStoredFiles class to do most of 
the heavy lifting here.

Problem is : this class was built with GAE in consideration and you can 
find many explicit implementations dedicated to GAE (e.g. if gae : ...)
I'm sure this can be improved to solve inconsistencies when this class is 
used with Heroku (for example this issue 
https://groups.google.com/forum/#!topic/web2py/w2RJBqKIwRE)

Using the database is a solid option when using an ephemeral filesystem.

*3. Postdeploy hook*

This option hasn't been explored at all so far.

Based on Heroku's doc https://devcenter.heroku.com/articles/buildpack-api, 
one can specify explicitely when shell commands to run when building an app.

If there was python script that could run the migrations (migrate_enabled = 
True, fake_migrate_all = False, lazy_tables = False), you could run it at 
postdeploy-time then basically disable migrations consistently throught 
your project without having to worry about how this model change will 
affect your production DB.

*4. CVS*

Including .table files in my Git changesets if the solution I'm currently 
using.
It makes sure your local and production environment are on the same page 
migration-wise, and it's a good way to remind you that your changeset may 
trigger migrations.

I'm not 100% sure it's the best way to do things, and there are times when 
it breaks : if you don't specify explicit names for your migration files 
then you'll end up with tons of .table files in your changesets due to the 
hashed prefix being changed (why is it changed all the time anyway ??).


These are the only options I know of, and none of them is fully 
satisfactory so far.

What do you think ? What's the best way to handle migrations on a git-based 
deploy system that has an ephemeral filesystem ?

-- 
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.