[web2py] Re: web2py 2.0.8 login_next, register_next ignored

2012-09-12 Thread Anthony
That is by design. The _next variable in the URL takes precedence over 
those settings, which are intended to be defaults. If you don't want the 
navbar to include the _next variable, you can do:

auth.navbar(..., referrer_actions=['list', 'of', 'actions'])

Just make sure 'login' and 'register' are not in that list.

Anthony

On Wednesday, September 12, 2012 2:39:11 AM UTC-4, Alexei Vinidiktov wrote:
>
> Hello,
>
> I have auth.settings.login_next and auth.settings.register_next defined in 
> db.py.
>
> Both appear to be ignored.
>
> I need the user to go to a specific page after he logs in or registers.
>
> In web2py 1.99.7 auth.settings.login_next defined in db.py was respected, 
> auth.settings.register_next wasn't. 
>
> Now neither is respected. The menus show the next links that point to the 
> page that the user came from to the registration or log in page not the 
> page that I want them to go to.
>
> -- 
> Alexei Vinidiktov
>  

-- 





[web2py] Re: web2py default layout.html

2012-09-12 Thread Annet


> missing some  s for the first "span12"s ?
>

You're right, it should be:


  

 
   

 

Kind regards,

Annet.

-- 





[web2py] Re: response.stream and web2py_component

2012-09-12 Thread maverick
Anthony,
Thanks for the explanation.

I tried cacheable=True in my select(), like: 
rows = db().select(db.vmt_weekly.ALL, cacheable=True)

 but it is met with internal error:  invalid 
select attribute: cacheable

Is there something I'm missing?

mave


On Tuesday, September 11, 2012 10:17:48 PM UTC-7, Anthony wrote:
>
> Can you show me how I could modify form_query() to embed JS (if I've 
>> understood your second option correctly) in order to trigger the download? 
>>
>
> You're not going to be able to have a single call to form_query both 
> return HTML content and stream a file at the same time -- those are two 
> separate HTTP responses, so you need two separate requests. Return the HTML 
> first, and then request the file separately. If you don't want to repeat 
> the query to re-generate the rows object again, in your select(), add 
> cacheable=True. That will allow you to store rows in the session when 
> form_query is called. Your subsequent call to fetch the file can then 
> retrieve rows from the session, convert to csv, and then stream.
>
> Anthony
>

-- 





[web2py] Error: DAL object has no attribute custom_auth_table

2012-09-12 Thread Annet
I defined a custom auth_user table:

db.define_table(
auth.settings.table_user_name,
Field('title',length=8,requires=IS_IN_SET(['de 
heer','mevrouw'],zero=T('Select a value')),label='Aanheft * '),

Field('firstName',length=32,requires=IS_LENGTH(32,error_message=T('length 
exceeds 32 characters')),label='Voornaam'),

Field('lastName',length=64,default='',requires=[IS_LENGTH(64,error_message=T('length
 
exceeds 64 charactrer')),IS_NOT_EMPTY()],notnull=True,label='Achternaam * 
'),

Field('shortname',default='',requires=[IS_LENGTH(128,error_message=T('length 
exceeds 128 
characters')),IS_EMPTY_OR(IS_NOT_IN_DB(db,'custom_auth_table.shortname',error_message=T('shortname
 
already in database')))],notnull=True,unique=True),
Field('phone',length=16,requires=IS_LENGTH(16,error_message='length 
exceeds 16 characters'),label='Telefoon'),

Field('email',length=128,default='',requires=[IS_LENGTH(128,error_message=T('length
 
exceeds 128 characters')),IS_EMAIL(error_message=T('invalid 
email')),IS_NOT_IN_DB(db,'custom_auth_table.email',error_message=T('email 
already in database'))],notnull=True,unique=True,label='E-mail * '),

Field('username',length=32,default='',requires=[IS_LENGTH(32,error_message=T('length
 
exceeds 32 
charactrer')),IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'custom_auth_table.username',error_message=T('username
 
already in 
database'))],notnull=True,unique=True,writable=False,readable=False,label='Gebruikersnaam
 
* '),
Field('password', 
type='password',length=512,requires=[IS_STRONG(),CRYPT()],readable=False,label='Wachtwoord
 
* '),
Field('nodeID','reference 
node',default='',requires=[IS_IN_DB(db,'node.id','%(id)s',zero=T('Select a 
value'))],ondelete='CASCADE',notnull=True,label='NodeID * 
',writable=False,readable=False),

Field('comment',type='text',requires=IS_LENGTH(512,error_message=T('length 
exceeds 512 characters'))),

Field('registration_key',length=512,default='',writable=False,readable=False),

Field('reset_password_key',length=512,default='',writable=False,readable=False),

Field('registration_id',length=512,default='',writable=False,readable=False),
Field('createdOn',type='datetime',default=request.now),

Field('modifiedOn',type='datetime',default=request.now,update=request.now))

## get the custom_auth_table
custom_auth_table = db[auth.settings.table_user_name]
## tell auth to use custom_auth_table
 auth.settings.table_user = custom_auth_table
## to prevent the auth_cas table from being created
auth.settings.cas_domains = None
## create all tables needed by auth if not custom tables
auth.define_tables(migrate=True,username=True,signature=False)



When I enter a user I get the following error:


Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/web2py/gluon/restricted.py", line 
209, in restricted
exec ccode in environment
  File 
"/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
 , line 
444, in 
  File "/Library/Python/2.6/site-packages/web2py/gluon/globals.py", line 185, 
in 
self._caller = lambda f: f()
  File 
"/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
 , line 
129, in insert
if form.accepts(request.vars, session):
  File "/Library/Python/2.6/site-packages/web2py/gluon/sqlhtml.py", line 1223, 
in accepts
hideerror=hideerror,
  File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 1952, in 
accepts
status = self._traverse(status,hideerror)
  File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, in 
_traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, in 
_traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, in 
_traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, in 
_traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 827, in 
_traverse
newstatus = self._validate()
  File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 1706, in 
_validate
(value, errors) = validator(value)
  File "/Library/Python/2.6/site-packages/web2py/gluon/validators.py", line 
2505, in __call__
return self.other(value)
  File "/Library/Python/2.6/site-packages/web2py/gluon/validators.py", line 
558, in __call__
table = self.dbset.db[tablename]
  File "/Library/Python/2.6/site-packages/web2py/gluon/dal.py", line 7136, in 
__getitem__
return self.__getattr__(str(key))
  File "/Library/Python/2.6/site-packages/web2py/gluon/dal.py", line 7143, in 
__getattr__
retur

[web2py] Re: denormalizing a list:reference -- need a bit of help

2012-09-12 Thread Pepe Araya
Hi,
a question: how do you display the entities related to a user in a View 
which displays a list of users with their related entities??

for example:

Name: user 1
Entities: one, two

--

Name: user 2
Entities: one

--
...

Thanks.

On Friday, May 11, 2012 12:16:32 PM UTC-4, Niphlod wrote:
>
> If you need to fetch all entities knowing the user in advance there is a 
> ultra-simple way to fetch entities in a single query
> Actually I don't think anyone will come up with a solution involving more 
> than 1 additional query to the one required for "selecting" the user.
>
> user = db.auth_user(auth.user_id)
> entities = db(db.entity.id.belongs(user.entity)).select(db.entity.name) 
>
> Mind that the auth_user line is copied into session, so if that is always 
> available you can skip the first query and do
>
> entities = db(db.entity.id.belongs(auth.user.entity)).select(
> db.entity.name)
>
>
>
> Il giorno venerdì 11 maggio 2012 17:28:38 UTC+2, weheh ha scritto:
>>
>> db.define_table('entity', Field('name'), format='%(name)s')
>> auth_user_table = db.define_table(
>> auth.settings.table_user_name,
>> ... 
>> Field('entity', 'list:reference db.entity',
>>requires=IS_IN_DB(db, 'entity.id','%(name)s', multiple=True),
>>...
>> )
>>
>> Later, I want to get a list of entities by name from the list: reference 
>> entry for the current user.
>>
>> I would think I could do this:
>> user = db(db.auth_user.id == auth.user_id).select().first()
>> entities = db.auth_user.entity.represent(user.entity)
>> but I get a ticket:
>>   File "N:/web2py/applications/myapp/controllers/mycontroller.py", line 
>> 15, in myfunc
>> return dict(etext=db.auth_user.entity.represent(user.entity))
>> TypeError: 'NoneType' object is not callable
>>
>>
>> I've tried a few different variations on the theme, but none working so 
>> far. Any help would be appreciated.
>>
>> There are obvious slower ways to do this, but inelegant. I want the 
>> fastest, tightest solution.
>>
>>
>>

-- 





[web2py] Re: denormalizing a list:reference -- need a bit of help

2012-09-12 Thread Niphlod
more or less

{{for user in db(db.auth_user).select():}}
 Name : {{=user.name}}
 {{entities = db(db.entity.id.belongs(user.entity)).select(db.entity.
name)}}
 Entities : {{', '.join(ent.name for ent in entities)}}
{{pass}}
--

of course you should probably fetch the result in the controller and show 
only them in the view.

BTW: this is pretty simple and standard for web2py. If you were asking for 
something else please post more details...

Il giorno mercoledì 12 settembre 2012 11:10:33 UTC+2, Pepe Araya ha scritto:
>
> Hi,
> a question: how do you display the entities related to a user in a View 
> which displays a list of users with their related entities??
>
> for example:
>
> Name: user 1
> Entities: one, two
>
> --
>
> Name: user 2
> Entities: one
>
> --
> ...
>
> Thanks.
>
> On Friday, May 11, 2012 12:16:32 PM UTC-4, Niphlod wrote:
>>
>> If you need to fetch all entities knowing the user in advance there is a 
>> ultra-simple way to fetch entities in a single query
>> Actually I don't think anyone will come up with a solution involving more 
>> than 1 additional query to the one required for "selecting" the user.
>>
>> user = db.auth_user(auth.user_id)
>> entities = db(db.entity.id.belongs(user.entity)).select(db.entity.name) 
>>
>> Mind that the auth_user line is copied into session, so if that is always 
>> available you can skip the first query and do
>>
>> entities = db(db.entity.id.belongs(auth.user.entity)).select(
>> db.entity.name)
>>
>>
>>
>> Il giorno venerdì 11 maggio 2012 17:28:38 UTC+2, weheh ha scritto:
>>>
>>> db.define_table('entity', Field('name'), format='%(name)s')
>>> auth_user_table = db.define_table(
>>> auth.settings.table_user_name,
>>> ... 
>>> Field('entity', 'list:reference db.entity',
>>>requires=IS_IN_DB(db, 'entity.id','%(name)s', multiple=True),
>>>...
>>> )
>>>
>>> Later, I want to get a list of entities by name from the list: reference 
>>> entry for the current user.
>>>
>>> I would think I could do this:
>>> user = db(db.auth_user.id == auth.user_id).select().first()
>>> entities = db.auth_user.entity.represent(user.entity)
>>> but I get a ticket:
>>>   File "N:/web2py/applications/myapp/controllers/mycontroller.py", line 
>>> 15, in myfunc
>>> return dict(etext=db.auth_user.entity.represent(user.entity))
>>> TypeError: 'NoneType' object is not callable
>>>
>>>
>>> I've tried a few different variations on the theme, but none working so 
>>> far. Any help would be appreciated.
>>>
>>> There are obvious slower ways to do this, but inelegant. I want the 
>>> fastest, tightest solution.
>>>
>>>
>>>

-- 





Re: [web2py] Re: internal error crash with newest 2.0.6 and old 1.99.2

2012-09-12 Thread LightDot
I'd just rebuild the source RPM if I was you. Way simpler... besides you'll 
need to take care of the updates all by yourself now, same as for your 
postgres. Just taking Red Hat (or CentOS) updates and rebuilding them 
(couple of seconds of work) really simplifies things. Your postges RPMs are 
from the upstream, I guess?

Regards,
Ales


On Wednesday, September 12, 2012 6:23:25 AM UTC+2, lucas wrote:
>
> ok, i am working on installing the psycopg2 from source, i got it to 
> compile and it looked like it was installed under the python site_packages, 
> but when i just try to import it into python i get
>
> >>> import psycopg2
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/usr/lib/python2.6/site-packages/psycopg2-2.4.5-py2.6-linux-i686.egg/psycopg2/__init__.py",
>  
> line 67, in 
> from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
> ImportError: 
> /usr/lib/python2.6/site-packages/psycopg2-2.4.5-py2.6-linux-i686.egg/psycopg2/_psycopg.so:
>  
> undefined symbol: GSS_C_NT_HOSTBASED_SERVICE
>
> is there a good forum for psycopg2 anywhere?  lucas
>

-- 





[web2py] Re: denormalizing a list:reference -- need a bit of help

2012-09-12 Thread Pepe Araya
Thanks very much! it works!

if I have the user query in the controller like this:

def user_list():
 users = db(db.auth_user).select()
 entities =  db(db.entity.id.belongs(user.entity)).select(db.entity.name)
 return dict(users = users, entities = entities )

will work?

---

Another related question is: why this don't work?
entities = db.auth_user.entity.represent(user.entity)

on the book appears as the way to get the work done, but it doesn't 


On Wednesday, September 12, 2012 6:32:44 AM UTC-3, Niphlod wrote:
>
> more or less
>
> {{for user in db(db.auth_user).select():}}
>  Name : {{=user.name}}
>  {{entities = db(db.entity.id.belongs(user.entity)).select(db.entity.
> name)}}
>  Entities : {{', '.join(ent.name for ent in entities)}}
> {{pass}}
> --
>
> of course you should probably fetch the result in the controller and show 
> only them in the view.
>
> BTW: this is pretty simple and standard for web2py. If you were asking for 
> something else please post more details...
>
> Il giorno mercoledì 12 settembre 2012 11:10:33 UTC+2, Pepe Araya ha 
> scritto:
>>
>> Hi,
>> a question: how do you display the entities related to a user in a View 
>> which displays a list of users with their related entities??
>>
>> for example:
>>
>> Name: user 1
>> Entities: one, two
>>
>> --
>>
>> Name: user 2
>> Entities: one
>>
>> --
>> ...
>>
>> Thanks.
>>
>> On Friday, May 11, 2012 12:16:32 PM UTC-4, Niphlod wrote:
>>>
>>> If you need to fetch all entities knowing the user in advance there is a 
>>> ultra-simple way to fetch entities in a single query
>>> Actually I don't think anyone will come up with a solution involving 
>>> more than 1 additional query to the one required for "selecting" the user.
>>>
>>> user = db.auth_user(auth.user_id)
>>> entities = db(db.entity.id.belongs(user.entity)).select(db.entity.name) 
>>>
>>> Mind that the auth_user line is copied into session, so if that is 
>>> always available you can skip the first query and do
>>>
>>> entities = db(db.entity.id.belongs(auth.user.entity)).select(
>>> db.entity.name)
>>>
>>>
>>>
>>> Il giorno venerdì 11 maggio 2012 17:28:38 UTC+2, weheh ha scritto:

 db.define_table('entity', Field('name'), format='%(name)s')
 auth_user_table = db.define_table(
 auth.settings.table_user_name,
 ... 
 Field('entity', 'list:reference db.entity',
requires=IS_IN_DB(db, 'entity.id','%(name)s', multiple=True
 ),
...
 )

 Later, I want to get a list of entities by name from the list: 
 reference entry for the current user.

 I would think I could do this:
 user = db(db.auth_user.id == auth.user_id).select().first()
 entities = db.auth_user.entity.represent(user.entity)
 but I get a ticket:
   File "N:/web2py/applications/myapp/controllers/mycontroller.py",line 
 15, in myfunc
 return dict(etext=db.auth_user.entity.represent(user.entity))
 TypeError: 'NoneType' object is not callable


 I've tried a few different variations on the theme, but none working so 
 far. Any help would be appreciated.

 There are obvious slower ways to do this, but inelegant. I want the 
 fastest, tightest solution.




-- 





[web2py] Re: denormalizing a list:reference -- need a bit of help

2012-09-12 Thread Niphlod
no, it wont.
users is a "list" of users.
you need to fetch the "list of entities" separately for every "item" of the 
"list of the users".

Il giorno mercoledì 12 settembre 2012 11:46:32 UTC+2, Pepe Araya ha scritto:
>
> Thanks very much! it works!
>
> if I have the user query in the controller like this:
>
> def user_list():
>  users = db(db.auth_user).select()
>  entities =  db(db.entity.id.belongs(user.entity)).select(db.entity.name)
>  return dict(users = users, entities = entities )
>
> will work?
>
> ---
>
> Another related question is: why this don't work?
> entities = db.auth_user.entity.represent(user.entity)
>
> on the book appears as the way to get the work done, but it doesn't 
>
>
> On Wednesday, September 12, 2012 6:32:44 AM UTC-3, Niphlod wrote:
>>
>> more or less
>>
>> {{for user in db(db.auth_user).select():}}
>>  Name : {{=user.name}}
>>  {{entities = db(db.entity.id.belongs(user.entity)).select(db.entity.
>> name)}}
>>  Entities : {{', '.join(ent.name for ent in entities)}}
>> {{pass}}
>> --
>>
>> of course you should probably fetch the result in the controller and show 
>> only them in the view.
>>
>> BTW: this is pretty simple and standard for web2py. If you were asking 
>> for something else please post more details...
>>
>> Il giorno mercoledì 12 settembre 2012 11:10:33 UTC+2, Pepe Araya ha 
>> scritto:
>>>
>>> Hi,
>>> a question: how do you display the entities related to a user in a View 
>>> which displays a list of users with their related entities??
>>>
>>> for example:
>>>
>>> Name: user 1
>>> Entities: one, two
>>>
>>> --
>>>
>>> Name: user 2
>>> Entities: one
>>>
>>> --
>>> ...
>>>
>>> Thanks.
>>>
>>> On Friday, May 11, 2012 12:16:32 PM UTC-4, Niphlod wrote:

 If you need to fetch all entities knowing the user in advance there is 
 a ultra-simple way to fetch entities in a single query
 Actually I don't think anyone will come up with a solution involving 
 more than 1 additional query to the one required for "selecting" the user.

 user = db.auth_user(auth.user_id)
 entities = db(db.entity.id.belongs(user.entity)).select(db.entity.name) 


 Mind that the auth_user line is copied into session, so if that is 
 always available you can skip the first query and do

 entities = db(db.entity.id.belongs(auth.user.entity)).select(
 db.entity.name)



 Il giorno venerdì 11 maggio 2012 17:28:38 UTC+2, weheh ha scritto:
>
> db.define_table('entity', Field('name'), format='%(name)s')
> auth_user_table = db.define_table(
> auth.settings.table_user_name,
> ... 
> Field('entity', 'list:reference db.entity',
>requires=IS_IN_DB(db, 'entity.id','%(name)s', multiple=True
> ),
>...
> )
>
> Later, I want to get a list of entities by name from the list: 
> reference entry for the current user.
>
> I would think I could do this:
> user = db(db.auth_user.id == auth.user_id).select().first()
> entities = db.auth_user.entity.represent(user.entity)
> but I get a ticket:
>   File "N:/web2py/applications/myapp/controllers/mycontroller.py",line 
> 15, in myfunc
> return dict(etext=db.auth_user.entity.represent(user.entity))
> TypeError: 'NoneType' object is not callable
>
>
> I've tried a few different variations on the theme, but none working 
> so far. Any help would be appreciated.
>
> There are obvious slower ways to do this, but inelegant. I want the 
> fastest, tightest solution.
>
>
>

-- 





[web2py] Receiving error when exporting to TSV with SQLFORM.grid (V2.0.8)

2012-09-12 Thread Gerd
Hi!

First: This is my first try to build a "real" application in web2py and 
python, i'm new to both but like it very much (i'm coming from bash/awk/sed)

I receive following error when trying to export a SQLFORM.grid to TSV 
(Excel compatible), but CSV works

Traceback (most recent call last):
  File "/home/gniemetz/webapps/web2py/web2py/gluon/restricted.py", line 209, in 
restricted
exec ccode in environment
  File 
"/home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py"
 
,
 line 78, in 
  File "/home/gniemetz/webapps/web2py/web2py/gluon/globals.py", line 185, in 

self._caller = lambda f: f()
  File "/home/gniemetz/webapps/web2py/web2py/gluon/tools.py", line 2783, in f
return action(*a, **b)
  File 
"/home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py"
 
,
 line 22, in index
grid = 
SQLFORM.grid(db.Logbuch,fields=[db.Logbuch.Datum,db.Logbuch.Kurs,db.Logbuch.Thema,db.Logbuch.Kommentar],maxtextlength=50)
  File "/home/gniemetz/webapps/web2py/web2py/gluon/sqlhtml.py", line 1858, in 
grid
raise HTTP(200, oExp.export(),**response.headers)
  File "/home/gniemetz/webapps/web2py/web2py/gluon/sqlhtml.py", line 2627, in 
export
records = self.represented()
  File "/home/gniemetz/webapps/web2py/web2py/gluon/sqlhtml.py", line 2594, in 
represented
value = field.represent(value, record)
TypeError: () takes exactly 1 argument (2 given)


This is my model (a bit complicated, maybe there's room for improvement)

db.define_table('KFZ', 
Field 
('Auto','string',length=30,label=T
 ('Car')), 
Field 
('Kennzeichen','string',length=10,label=T
 ('License plate')), 
Field 
('KM','integer',label=T 
('Mileage')), 
Field 
('gueltig_bis','date',label=T
 ('Expired')), 
format='%(Auto)s %(Kennzeichen)s'
)

db.define_table('Themen', 
Field 
('Thema','string',length=30,label=T
 ('Topic')), 
Field 
('gueltig_bis','date',label=T
 ('Expired')), 
format='%(Thema)s'
)

db.define_table('KM_Gelder', 
Field 
('Tarif','decimal(3,2)',requires=IS_DECIMAL_IN_RANGE
 
(dot=','),label=T
 ('Mileage Cost')), 
Field 
('gueltig_bis','date',label=T
 ('Expired')), 
format=lambda row: str('%(Tarif)s' % row if row else 
'').replace('.',',').replace(',00',',-')
)

from datetime import datetime, date
query = ((db.KM_Gelder.gueltig_bis == None))
db.define_table('Logbuch', 
Field 
('Datum','date',requires=IS_DATE
 
(format='%Y-%m-%d'),label=T
 ('Date')), 
Field 
('Kurs','string',length=50,label=T
 ('Course')), 
Field 
('Beginn','time',requires=IS_TIME
 (),label=T 
('Start'),represent=lambda 
row: row.strftime('%H:%M')), 
Field 
('Ende','time',requires=IS_TIME
 (),label=T 
('End'),represent=lambda row: 
row.strftime('%H:%M')), 
Field 
('Thema',db.Themen,label=T
 ('Topic')), 
Field 
('Teilnehmer','integer',label=T
 ('Number of participants')), 
Field 
('Kosten','decimal(7,2)',requires=IS_DECIMAL_IN_RANGE
 
(dot=','),label=T
 

Re: [web2py] Somewhere between 1.97 and 2.0.8 I lost translations.

2012-09-12 Thread Marin Pranjić
Hi Jason,

I just tried few things... It is working in nightly build but not in 2.0.8.

Marin

On Wed, Sep 12, 2012 at 7:54 AM, Jason Brower  wrote:

> It seems that our production system stoped serving translated versions of
> our website.  Even when our browsers are on the correct settings it doesn't
> switch to our Finnish translations.
> Any way I could resolve this?  Something you need to know?
> BR,
> Jason
> http://interestid.com
>
> --
>
>
>
>

-- 





[web2py] Re: HTML truncate

2012-09-12 Thread villas
oops yes,  there was a typo with the tipo!  :)

On Tuesday, September 11, 2012 3:33:18 PM UTC+1, Massimo Di Pierro wrote:
>
> {{=db.publicaciones.descripcion.represent(tipo_3.descripcion,tipo_3}}
>
> I do not think you want the extra =.
>
> On Tuesday, 11 September 2012 08:47:00 UTC-5, villas wrote:
>>
>> I end up doing something like this:
>>
>> {{=db.publicaciones.descripcion.represent(=tipo_3.descripcion,tipo_3)}}
>>
>> I hope that helps,  but maybe there is a better way?
>>
>>
>>
>> On Tuesday, September 11, 2012 1:48:59 PM UTC+1, Pepe Araya wrote:
>>>
>>> Hi Massimo,
>>>
>>> Sorry for my poor explanation.
>>>
>>> What I don't get is in the view when i call the field value 
>>> {{=tipo_3.descripcion}}  I get the whole text and not the truncated one 
>>> like in the SQLFORM.grid case.
>>>
>>>
>>>
>>>
>>> On Tuesday, September 11, 2012 9:32:18 AM UTC-3, Massimo Di Pierro wrote:

 What does it mean it does not work? Can you import it? Can you import 
 it from python?

 On Tuesday, 11 September 2012 00:55:03 UTC-5, Pepe Araya wrote:
>
> Hello,
>
> I need to truncate a field that contains HTML content. 
>
> Now i'm using htmltruncate in 
> a controller that return a SQLFORM.smartgrid and it works perfect:
>  
> def noticias():
> 
> db.noticias.cuerpo.represent = lambda field,row: 
> XML(htmltruncate.truncate(field, 100))
> grid = SQLFORM.smartgrid(db.noticias, 
> linked_tables=['adjuntos_noticia'])
>
> return dict(grid =grid)
>
>
> But when I try to implement a in a controller in this way:
>
> def index():
> db.publicaciones.descripcion.represent = lambda field, row: 
> XML(htmltruncate.truncate(field, 10))
> tipo_3 = db(db.publicaciones.tipo == 3).select().last()
>
> return dict(tipo_3 = tipo_3)
>
>
> It doesn't work
>
>
> The module is inside the "modules" folder of the app and it's imported 
> via:
> import htmltruncate
>
>
> any help is welcome!
>
> Best!
>


-- 





[web2py] Re: When/how is 'format' used?

2012-09-12 Thread MichaelF
Thanks. I didn't realize that SQLFORM was used by default to display a Row 
object; that makes sense. And the presence/invocation of those 'format' 
expressions is what's causing the various 'additional' SELECT statements I 
see in the "db stats" display, yes. By 'additional' I mean they're SELECT 
statements I didn't explicitly code. They're repetitive, but that makes 
sense if they're applying the 'format'.

On using represent or _format: thanks. I saw the 'represent' attribute and 
assumed (not good!) that that was 'automatically' called, and the results 
of that were stored in the Row object. I see now that, as you say, if it's 
not the entire Row then I can explicitly call the function, passing in the 
field value.

Thanks.

On Tuesday, September 11, 2012 11:27:32 PM UTC-6, Anthony wrote:
>
> Three questions:
>>
>>1. What's the 'magic' going on that tells the display code for 
>>meetTeams to use the 'format' expression (but not to use it when 
>> displaying 
>>'message')? Does it realize it's a row, and the row knows how to display 
>>using the format?
>>
>> When you create a reference field, if you don't give it any validator, it 
> will automatically get an IS_IN_DB validator, and its "represent" attribute 
> will automatically be set to the "format" attribute of the referenced 
> table. The "represent" attribute is only used by SQLTABLE (i.e., when you 
> include an entire Rows object in a view), SQLFORM, and SQLFORM.grid. If you 
> simply display a single value from a Row object, the "represent" attribute 
> is not used. 
>
>>
>>1. Are the results of that 'format' expression stored in the row, 
>>available to me to use? As you can see I can explicitly join with the 
>>Institution to get the name. But if there's an easier way, then I'll do 
>> it.
>>
>> You can access the format expression either via db.Institution._format or 
> db.Team.Institution.represent (the latter is actually a function that will 
> reference the former).
>
> Anthony
>

-- 





[web2py] Re: "MENU helper" and "Server-side DOM" work together?

2012-09-12 Thread amphisia pui
Hi Antony,

I followed your suggestion and it works. 
I paste the code snippet in case someone else needs it.

{{ 

smenu = mmenu.serialize(mmenu.data)
mmenu = MENU(response.menu, _class='nav' )
lis = 
smenu.elements('li.web2py-menu-expand')  
for i in lis: i[0] = H4(i[0].flatten(), 
_class="mfoot")
=smenu 

}} 

Everything is in the main layout view, after, I will think where is the 
best place to manipulate the footer menu,
I do not want to put much python code in a view.

In the trunk web2py version at Revision: 17a0b1bbf2f6 (rif *)
I saw that Massimo added empty components in the MENU helper constructor,
this solve my first post traceback but your workaround is needed yet.

Many thanks both

AP


(rif *) 
http://code.google.com/p/web2py/source/detail?r=17a0b1bbf2f691edecdd90adbeb6777e7ff1e7c6
   



Il giorno martedì 11 settembre 2012 17:29:02 UTC+2, Anthony ha scritto:
>
> Looks like MENU doesn't generate a DOM structure until its .serialize() 
> method is called. You could do:
>
> mmenu = mmenu.serialize(mmenu.data)
> mmenu.elements('a')
>
> I'm not sure why it was done this way as opposed to generating the DOM 
> upon initialization. Massimo?
>
> Anthony
>
> On Tuesday, September 11, 2012 10:49:59 AM UTC-4, amphisia pui wrote:
>>
>> Hi to all 
>>
>> I want to use the html helper MENU to have in the page footer a menu 
>> totally exploded without sliding items.
>> I changed the css classes and everything looks fine but I don't want the 
>> first level menu items to be clickable
>>
>>  so the first thing I tried was the server-side parsing to remove 
>> unnecessary tags but in a web2py shell I got
>>
>> mlist = ... well formatted web2py menu list
>>
>> In [40]: mmenu = MENU(mlist)
>>
>>  In [41]: mitems = mmenu.elements('a')
>>
>> ---
>> AttributeErrorTraceback (most recent call 
>> last)
>> /opt/web2py/applications/happy/models/menu.py in ()
>> > 1 mmenu.elements('a')
>>
>> /opt/web2py/gluon/html.pyc in elements(self, *args, **kargs)
>>1079 # loop the components
>>
>>1080 if find_text or find_components:
>> -> 1081 for i, c in enumerate(self.components):
>>1082 if check and find_text and isinstance(c, str) and 
>> \
>>1083((is_regex and find_text.search(c)) or 
>> (str(find_text) in c)):
>>
>> AttributeError: 'MENU' object has no attribute 'components'
>>
>> Is MENU helper supposed to work with sever side DOM parsing? Is web2py 
>> ipython Shell fault?   
>> Can you suggest something better to try to have first level items menu 
>> seem like simple labels?
>>
>> Thanks to all
>>
>> AP
>>
>> Sys info
>> Python 2.7.3
>> web2py 2.0.8
>>
>>

-- 





[web2py] creating breadcrumbs in the application

2012-09-12 Thread Mandar Vaze
I found a discussion on this group and this 
http://www.web2pyslices.com/slice/show/1374/full-breadcrumbs
But both of them seem to be from 2009 - almost 2.5-3 yrs old. web2py has 
changed a lot since 2009.

I also found gluon.tools.Expose.breadcrumbs() - But there are no examples 
or documentation

There seems to be breadcrumbs for smartgrid - I'm not looking for this. 
Rather breadcrumbs implementation for the application.

Are there latest examples of implementing breadcrumbs ? 
Is the web2pyslice listed above accurate after @3 yrs ?

Thanks,
-Mandar

-- 





Re: [web2py] Re: web2py 2.0.8 login_next, register_next ignored

2012-09-12 Thread Alexei Vinidiktov
Thanks, Anthony.

I've tried it and it worked. I just passed an empty referrer_actions list.

The bahavior has changed for navbar since 1.99.7 though. In 1.99.7
login_next defined in db.py was not ignored.

On Wed, Sep 12, 2012 at 2:03 PM, Anthony  wrote:

> That is by design. The _next variable in the URL takes precedence over
> those settings, which are intended to be defaults. If you don't want the
> navbar to include the _next variable, you can do:
>
> auth.navbar(..., referrer_actions=['list', 'of', 'actions'])
>
> Just make sure 'login' and 'register' are not in that list.
>
> Anthony
>
>
> On Wednesday, September 12, 2012 2:39:11 AM UTC-4, Alexei Vinidiktov wrote:
>>
>> Hello,
>>
>> I have auth.settings.login_next and auth.settings.register_**next
>> defined in db.py.
>>
>> Both appear to be ignored.
>>
>> I need the user to go to a specific page after he logs in or registers.
>>
>> In web2py 1.99.7 auth.settings.login_next defined in db.py was respected,
>> auth.settings.register_next wasn't.
>>
>> Now neither is respected. The menus show the next links that point to the
>> page that the user came from to the registration or log in page not the
>> page that I want them to go to.
>>
>> --
>> Alexei Vinidiktov
>>
>  --
>
>
>
>



-- 
Alexei Vinidiktov

-- 





[web2py] How to login to Web2Py-app by providing username and password in URL?

2012-09-12 Thread Remco K
Hello everyone,

I'm not a big fan of asking questions rather than find solutions by myself 
but i need a little help on this one so i hope someone can help me a bit.

What i need is 'very simple'. I have a Web2Py application running and i 
need other applications (PHP or something) to be able to successfully login 
users to this app by providing the username and password via the URL.

When doing this in PHP i would think of something like: 

/index.php?username=blabla&password=dfgfdjkldfgjk

I've already looked at basic auth but i can't get the user to login.

All of my controllers/functions use 
@auth.requires_login()
to check whether the user has the permission to execute the functions.

I hope someone can help me out on this.

Thanks in advance!
Remco

-- 





[web2py] Re: response.stream and web2py_component

2012-09-12 Thread Anthony
Are you using the latest version of web2py? That's a new option.

On Wednesday, September 12, 2012 4:43:50 AM UTC-4, maverick wrote:
>
> Anthony,
> Thanks for the explanation.
>
> I tried cacheable=True in my select(), like: 
> rows = db().select(db.vmt_weekly.ALL, cacheable=True)
>
>  but it is met with internal error:  
> invalid select attribute: cacheable
>
> Is there something I'm missing?
>
> mave
>
>
> On Tuesday, September 11, 2012 10:17:48 PM UTC-7, Anthony wrote:
>>
>> Can you show me how I could modify form_query() to embed JS (if I've 
>>> understood your second option correctly) in order to trigger the download? 
>>>
>>
>> You're not going to be able to have a single call to form_query both 
>> return HTML content and stream a file at the same time -- those are two 
>> separate HTTP responses, so you need two separate requests. Return the HTML 
>> first, and then request the file separately. If you don't want to repeat 
>> the query to re-generate the rows object again, in your select(), add 
>> cacheable=True. That will allow you to store rows in the session when 
>> form_query is called. Your subsequent call to fetch the file can then 
>> retrieve rows from the session, convert to csv, and then stream.
>>
>> Anthony
>>
>

-- 





[web2py] Re: modified_by and modified_on not updating

2012-09-12 Thread Joel Carrier
I was calling auth.define_tables() after defining auth_user manually.
My mistake.

On Saturday, September 8, 2012 1:56:37 PM UTC-4, Joel Carrier wrote:
>
> Hmmm... i never call auth.define_tables I guess because I wanted to 
> customize the auth_user table.
> And yet the following tables all get created:
>
> | auth_cas |
> | auth_cas_archive |
> | auth_event   |
> | auth_event_archive   |
> | auth_group   |
> | auth_group_archive   |
> | auth_membership  |
> | auth_membership_archive  |
> | auth_permission  |
> | auth_permission_archive  |
> | auth_user|
> | auth_user_archive  
>
> Could that be why?
>
> On Saturday, September 8, 2012 1:51:24 PM UTC-4, Massimo Di Pierro wrote:
>>
>> works for me
>>
>> >>> db= DAL()
>> >>> from gluon.tools import Auth
>> >>> auth = Auth(db)
>> >>> auth.define_tables()
>> >>> db._common_fields.append(auth.signature)
>> >>> db.define_table('thing',
>> Field('name'),
>> Field('name2',
>>   writable=False,
>>   compute=lambda r: r.name+'xxx'))
>> >>> auth.enable_record_versioning(db)
>> >>> print db.thing(2).modified_on
>> 2012-09-08 09:22:28
>> >>> db.thing(2).update_record(name='test4')
>> >>> print db.thing(2).modified_on
>> 2012-09-08 12:49:01
>>
>> Massimo
>>
>> On Saturday, 8 September 2012 12:48:14 UTC-5, Massimo Di Pierro wrote:
>>>
>>> Supposed to work any update_record but let me give it a try.
>>>
>>> On Saturday, 8 September 2012 12:39:20 UTC-5, Joel Carrier wrote:

 At first I thought it was related to running on a windows machine using 
 the development server.
 Then I deployed to a linux machine using the setup-web2py-ubuntu.sh 
 script

 Yes, the version is: Version 2.0.8 (2012-09-07 03:47:51) stable

 db.py:

 # -*- coding: utf-8 -*-
 if 0:
 from gluon.sql import *
 from gluon.validators import *
 from gluon import T


 from gluon import current


 db = SQLDB('mysql://'+settings.sql_user+':'+settings.sql_password+'@'+
 settings.db_host+'/'+settings.db_name,migrate=settings.migrate,
 pool_size=10)


 response.generic_patterns = ['*'] #if request.is_local else []


 current.db = db
 current.T = T


 from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
 auth = Auth(db, hmac_key=settings.hmac_key, salt=True)
 crud, service, plugins = Crud(db), Service(), PluginManager()


 current.auth = auth


 auth.settings.registration_requires_verification = True
 auth.settings.registration_requires_approval = False
 auth.settings.reset_password_requires_verification = True


 db._common_fields.append(auth.signature)


 db.define_table('auth_user',
 Field('id','id'),
 Field('first_name', type='string',
 label=T('First Name')),
 Field('last_name', type='string',
 label=T('Last Name')),
 Field('email', type='string',
 label=T('Email')),
 Field('password', type='password',
 readable=False,
 label=T('Password')),
 Field('date_of_birth', type='date',
 label=T('Date of Birth')),
 Field('birth_country','integer'),
 Field('birth_city'),
 Field('registration_key',default='',
 writable=False,readable=False),
 Field('reset_password_key',default='',
 writable=False,readable=False),
 Field('registration_id',default='',
 writable=False,readable=False),
 format='[%(id)s] %(first_name)s %(last_name)s',
 )


 db.auth_user.first_name.requires = IS_UPPER()
 db.auth_user.last_name.requires = IS_UPPER()
 db.auth_user.password.requires = CRYPT(key=auth.settings.hmac_key)
 db.auth_user.registration_id.requires = IS_NOT_IN_DB(db, db.auth_user.
 registration_id)
 db.auth_user.email.requires = (
 IS_EMAIL(error_message=auth.messages.invalid_email),
 IS_NOT_IN_DB(db, db.auth_user.email),
 IS_UPPER()
 )


 and in models directory i also have a z.py

 auth.enable_record_versioning(db)

 Do I have to update my entities using SQLForms only?  Or is it suppose 
 to work with any .update_record()?

 Thanks for your help!


 On Saturday, September 8, 2012 10:23:05 AM UTC-4, Massimo Di Pierro 
 wrote:
>
> I am trying to reproduce the problem but I cannot. Are you running 
> 2.0.8?
>
> On Saturday, 8 September 2012 07:34:19 UTC-5, Joel Carrier wrote:
>>
>> I want to maintain an audit history of all my objects.
>>
>> So near the beginning of my model

[web2py] Re: You don't have permission to access /admin/default/index on this server.

2012-09-12 Thread Vladimir Drobnjak
Thank you very much. Now I can access the admin pages.



Dne ponedeljek, 10. september 2012 14:45:19 UTC+2 je oseba Massimo Di 
Pierro napisala:
>
> For security reasons you cannot access admin remotely using port 80. You 
> either setup https, or a ssh tunnel, or access it from localhost.
>
> On Monday, 10 September 2012 04:17:20 UTC-5, Vladimir wrote:
>>
>> Hello!
>> I'd like to try web2py, but I can not open administrative pages. I'm 
>> getting this error:
>>
>> Forbidden
>>
>> You don't have permission to access /admin/default/index on this server.
>> --
>> Apache/2.2.16 (Debian) Server at localhost Port 80
>> My operating system is Debian 6.04 with the last stable version of 
>> web2py. At installation process I've choosed web2py to be installed as 
>> apache2 module. Web2py is working - only admin interface is not acceptable. 
>> I've controled the ownership of web directories (/home/www-data): the owner 
>> is www-data (apache server).
>> Thanks for any help.
>>
>

-- 





Re: [web2py] Pynes notify

2012-09-12 Thread David Sorrentino
Impressive.

On 12 September 2012 08:40, Bruno Rocha  wrote:

> This plugin for Bootstrap looks very nice for response.flash
>
> http://pinesframework.org/pnotify/
>
>
>  --
>
>
>
>

-- 





[web2py] Re: denormalizing a list:reference -- need a bit of help

2012-09-12 Thread Pepe Araya
Thanks you!

On Wednesday, September 12, 2012 6:51:56 AM UTC-3, Niphlod wrote:
>
> no, it wont.
> users is a "list" of users.
> you need to fetch the "list of entities" separately for every "item" of 
> the "list of the users".
>
> Il giorno mercoledì 12 settembre 2012 11:46:32 UTC+2, Pepe Araya ha 
> scritto:
>>
>> Thanks very much! it works!
>>
>> if I have the user query in the controller like this:
>>
>> def user_list():
>>  users = db(db.auth_user).select()
>>  entities =  db(db.entity.id.belongs(user.entity)).select(db.entity.name)
>>  return dict(users = users, entities = entities )
>>
>> will work?
>>
>> ---
>>
>> Another related question is: why this don't work?
>> entities = db.auth_user.entity.represent(user.entity)
>>
>> on the book appears as the way to get the work done, but it doesn't 
>>
>>
>> On Wednesday, September 12, 2012 6:32:44 AM UTC-3, Niphlod wrote:
>>>
>>> more or less
>>>
>>> {{for user in db(db.auth_user).select():}}
>>>  Name : {{=user.name}}
>>>  {{entities = db(db.entity.id.belongs(user.entity)).select(db.entity
>>> .name)}}
>>>  Entities : {{', '.join(ent.name for ent in entities)}}
>>> {{pass}}
>>> --
>>>
>>> of course you should probably fetch the result in the controller and 
>>> show only them in the view.
>>>
>>> BTW: this is pretty simple and standard for web2py. If you were asking 
>>> for something else please post more details...
>>>
>>> Il giorno mercoledì 12 settembre 2012 11:10:33 UTC+2, Pepe Araya ha 
>>> scritto:

 Hi,
 a question: how do you display the entities related to a user in a View 
 which displays a list of users with their related entities??

 for example:

 Name: user 1
 Entities: one, two

 --

 Name: user 2
 Entities: one

 --
 ...

 Thanks.

 On Friday, May 11, 2012 12:16:32 PM UTC-4, Niphlod wrote:
>
> If you need to fetch all entities knowing the user in advance there is 
> a ultra-simple way to fetch entities in a single query
> Actually I don't think anyone will come up with a solution involving 
> more than 1 additional query to the one required for "selecting" the user.
>
> user = db.auth_user(auth.user_id)
> entities = db(db.entity.id.belongs(user.entity)).select(db.entity.name) 
>
>
> Mind that the auth_user line is copied into session, so if that is 
> always available you can skip the first query and do
>
> entities = db(db.entity.id.belongs(auth.user.entity)).select(
> db.entity.name)
>
>
>
> Il giorno venerdì 11 maggio 2012 17:28:38 UTC+2, weheh ha scritto:
>>
>> db.define_table('entity', Field('name'), format='%(name)s')
>> auth_user_table = db.define_table(
>> auth.settings.table_user_name,
>> ... 
>> Field('entity', 'list:reference db.entity',
>>requires=IS_IN_DB(db, 'entity.id','%(name)s', multiple=
>> True),
>>...
>> )
>>
>> Later, I want to get a list of entities by name from the list: 
>> reference entry for the current user.
>>
>> I would think I could do this:
>> user = db(db.auth_user.id == auth.user_id).select().first()
>> entities = db.auth_user.entity.represent(user.entity)
>> but I get a ticket:
>>   File "N:/web2py/applications/myapp/controllers/mycontroller.py",line 
>> 15, in myfunc
>> return dict(etext=db.auth_user.entity.represent(user.entity))
>> TypeError: 'NoneType' object is not callable
>>
>>
>> I've tried a few different variations on the theme, but none working 
>> so far. Any help would be appreciated.
>>
>> There are obvious slower ways to do this, but inelegant. I want the 
>> fastest, tightest solution.
>>
>>
>>

-- 





[web2py] web2py 2.0.8 Firebird driver fdb error

2012-09-12 Thread Alexei Vinidiktov
I'm trying to use the new fdb driver for Firebird with web2py 2.0.8 but I'm
getting this error when I load a page:

(Transaction object is not active)

TRACEBACK


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.


Traceback (most recent call last):
  File "C:\Users\alexei\Dev\web2py\vocabilis.net-2.0.8\gluon\main.py",
line 538, in wsgibase

BaseAdapter.close_all_instances('commit')

  File "C:\Users\alexei\Dev\web2py\vocabilis.net-2.0.8\gluon\dal.py",
line 510, in close_all_instances

getattr(instance, action)()

  File "C:\Users\alexei\Dev\web2py\vocabilis.net-2.0.8\gluon\dal.py",
line 1618, in commit

return self.connection.commit()

  File "C:\Python27\lib\site-packages\fdb\fbcore.py", line 1084, in commit

self._main_transaction.commit(retaining)

  File "C:\Python27\lib\site-packages\fdb\fbcore.py", line 2385, in commit

self.__check_active()

  File "C:\Python27\lib\site-packages\fdb\fbcore.py", line 2316, in
__check_active

raise ProgrammingError("Transaction object is not active")
ProgrammingError: Transaction object is not active

 Code listing

2311.
2312.

2313.
2314.
2315.
2316.

2317.
2318.
2319.
2320.

self._cursors.remove(cursor_ref)

def __get_closed(self):

return self._tr_handle == None

def __check_active(self):

if self._tr_handle == None:
raise ProgrammingError("Transaction object is not active")

def __con_in_list(self,connection):

for con in self._connections:

if con() == connection:

return True


I have Python 2.7.2 and fdb 0.8.5 on Windows 8 RC.

-- 
Alexei Vinidiktov

-- 





[web2py] Re: How to login to Web2Py-app by providing username and password in URL?

2012-09-12 Thread villas
Security is clearly not at the top of your agenda :)  
Something like this might work:

def logmein():
# minimal, insecure login function
auth.login_bare(request.vars['username'],request.vars['password']) 

yoursite.com/yourapp/default/logmein?username=abc&password=xyz




On Wednesday, September 12, 2012 12:40:13 PM UTC+1, Remco K wrote:
>
> Hello everyone,
>
> I'm not a big fan of asking questions rather than find solutions by myself 
> but i need a little help on this one so i hope someone can help me a bit.
>
> What i need is 'very simple'. I have a Web2Py application running and i 
> need other applications (PHP or something) to be able to successfully login 
> users to this app by providing the username and password via the URL.
>
> When doing this in PHP i would think of something like: 
>
> /index.php?username=blabla&password=dfgfdjkldfgjk
>
> I've already looked at basic auth but i can't get the user to login.
>
> All of my controllers/functions use 
> @auth.requires_login()
> to check whether the user has the permission to execute the functions.
>
> I hope someone can help me out on this.
>
> Thanks in advance!
> Remco
>
>

-- 





[web2py] Re: HTML truncate

2012-09-12 Thread Pepe Araya
Thanks you both!

One more help request: I have a "represent" related question in this 
topic https://groups.google.com/d/topic/web2py/9R9iQT_BVyU/discussion

please, can you help me to understand what I'm doing wrong? 

On Tuesday, September 11, 2012 11:33:18 AM UTC-3, Massimo Di Pierro wrote:
>
> {{=db.publicaciones.descripcion.represent(tipo_3.descripcion,tipo_3}}
>
> I do not think you want the extra =.
>
> On Tuesday, 11 September 2012 08:47:00 UTC-5, villas wrote:
>>
>> I end up doing something like this:
>>
>> {{=db.publicaciones.descripcion.represent(=tipo_3.descripcion,tipo_3)}}
>>
>> I hope that helps,  but maybe there is a better way?
>>
>>
>>
>> On Tuesday, September 11, 2012 1:48:59 PM UTC+1, Pepe Araya wrote:
>>>
>>> Hi Massimo,
>>>
>>> Sorry for my poor explanation.
>>>
>>> What I don't get is in the view when i call the field value 
>>> {{=tipo_3.descripcion}}  I get the whole text and not the truncated one 
>>> like in the SQLFORM.grid case.
>>>
>>>
>>>
>>>
>>> On Tuesday, September 11, 2012 9:32:18 AM UTC-3, Massimo Di Pierro wrote:

 What does it mean it does not work? Can you import it? Can you import 
 it from python?

 On Tuesday, 11 September 2012 00:55:03 UTC-5, Pepe Araya wrote:
>
> Hello,
>
> I need to truncate a field that contains HTML content. 
>
> Now i'm using htmltruncate in 
> a controller that return a SQLFORM.smartgrid and it works perfect:
>  
> def noticias():
> 
> db.noticias.cuerpo.represent = lambda field,row: 
> XML(htmltruncate.truncate(field, 100))
> grid = SQLFORM.smartgrid(db.noticias, 
> linked_tables=['adjuntos_noticia'])
>
> return dict(grid =grid)
>
>
> But when I try to implement a in a controller in this way:
>
> def index():
> db.publicaciones.descripcion.represent = lambda field, row: 
> XML(htmltruncate.truncate(field, 10))
> tipo_3 = db(db.publicaciones.tipo == 3).select().last()
>
> return dict(tipo_3 = tipo_3)
>
>
> It doesn't work
>
>
> The module is inside the "modules" folder of the app and it's imported 
> via:
> import htmltruncate
>
>
> any help is welcome!
>
> Best!
>


-- 





Re: [web2py] Re: How to login to Web2Py-app by providing username and password in URL?

2012-09-12 Thread David Sorrentino
>
> Security is clearly not at the top of your agenda :)
>

LoL


On 12 September 2012 14:09, villas  wrote:

> Security is clearly not at the top of your agenda :)
> Something like this might work:
>
> def logmein():
> # minimal, insecure login function
> auth.login_bare(request.vars['username'],request.vars['password'])
>
> yoursite.com/yourapp/default/logmein?username=abc&password=xyz
>
>
>
>
> On Wednesday, September 12, 2012 12:40:13 PM UTC+1, Remco K wrote:
>>
>> Hello everyone,
>>
>> I'm not a big fan of asking questions rather than find solutions by
>> myself but i need a little help on this one so i hope someone can help me a
>> bit.
>>
>> What i need is 'very simple'. I have a Web2Py application running and i
>> need other applications (PHP or something) to be able to successfully login
>> users to this app by providing the username and password via the URL.
>>
>> When doing this in PHP i would think of something like:
>>
>> /index.php?username=blabla&pas**sword=dfgfdjkldfgjk
>>
>> I've already looked at basic auth but i can't get the user to login.
>>
>> All of my controllers/functions use
>> @auth.requires_login()
>> to check whether the user has the permission to execute the functions.
>>
>> I hope someone can help me out on this.
>>
>> Thanks in advance!
>> Remco
>>
>>  --
>
>
>
>

-- 





[web2py] Re: How to login to Web2Py-app by providing username and password in URL?

2012-09-12 Thread Remco K
Thanks villas!

This function isn't for the 'whole wide world' but for an other internal 
application which needs to connect to my web2py application, so for me this 
isn't a insecure solution.

If you or someone else knows how this can be achieved in 'the' secure way, 
please let me know! My example i just only a suggestion to make clear what 
i want. I think that there are a lot more people that are looking for a 
good solution.

Thanks! :-)


-- 





[web2py] Not authorized! ??

2012-09-12 Thread Johann Spies
This is old code - it worked without a problem before.  I suspect recent 
upgrades broke it.

I have a SQLDFORM.grid using the following links:

links = [lambda row: A(B(T('View')), _target = "_blank",
   _href = URL(r = request, c = 'articles',
   f = 'show_akb_article',
   args = 
str(row[db.akb_articles.id])))]

if auth.has_membership(role = 'kb_ed'):
links.append(lambda row: A(B(T('Edit')), _target = "_blank",
   _href = URL(r = request, c = 'articles',
   f = 'edit_akb_article',
   args = 
str(row[db.akb_articles.id]

links.append(lambda row: A(B(T('Link to Institute')), _target = 
"_blank",
   _href = URL(r = request, c = 'articles',
   f = 'art_research',
   args = 
str(row[db.akb_articles.id]


I use any of those links in the grid even if I am logged in as a member of 
the 'kb_ed' group.  I get the error:  "not authorized" even when I try to 
use 'view'.

I have experimented by removing the following decorator 

@auth.requires(lambda:auth.has_membership('kb_ed'))
def edit_akb_article():

but even without the decorator I cannot edit the article.

What is causing this?

Regards
Johann


BTW the syntax highlighting is not working for me today in the web 
interface to the group.

-- 





[web2py] Re: web2py DAL one-to-one relation

2012-09-12 Thread martzi
Thanks to all members that shared their ideas with me:
I was able to the solve my problem  after setting foreign_keys attribute to 
on :

sqlite> PRAGMA foreign_keys;
0
sqlite> PRAGMA foreign_keys = ON;
sqlite> PRAGMA foreign_keys;
1


On Monday, September 10, 2012 12:45:28 PM UTC+2, martzi wrote:
>
> Hi,
> I wonder if there's a way to enforce a one to one relationship with 
> Cascade via web2py  DAL API. ???
>

-- 





[web2py] Re: custom auth clarification

2012-09-12 Thread Massimo Di Pierro
yes.

On Tuesday, 11 September 2012 18:49:29 UTC-5, Dave wrote:
>
> I am working on my own external authentication.
>
> From reading the source of gluon.tools and gluon.contrib.login_methods it 
> appears I need a class that implements the following methods to do my own 
> authentication:
>
> get_user()
> login_form()
>
> Then in my db.py just do an auth.settings.login_form = [myclass()]
>
> Is that a correct oversimplification?
>
> Thanks!
>

-- 





[web2py] Re: bug in 2.0.8

2012-09-12 Thread Massimo Di Pierro


On Tuesday, 11 September 2012 21:43:10 UTC-5, Matt wrote:
>
> Hi Massimo,
>
> I've switched to trunk and yes the fields are now being created as 
> expected.
>
> As a suggestion could the auto migration have an extra check added to 
> ensure that "upload" columns - if on non filesystem environments like GAE - 
> alway create the equivalent _blob column?
>

Can you provide an example. I think that's what it does already by default, 
no?
 

>
> Thankfully even though the original columns have been dropped from the 
> schema (along with my data) it's only currently running on my on local 
> development machine so the loss isn't too much of a problem as I can 
> recreate the data again.
>
 

>
> Thanks again for your fast response and fix.
>
> Kind regards,
> Matt
>
> On Wednesday, September 12, 2012 2:28:09 AM UTC+12, Massimo Di Pierro 
> wrote:
>>
>> I found the web2py bug that caused this problem. It was an indentation 
>> issue. Took the occasion to rewrite the logic a little better.
>>
>> Can you please check this works now? You should be able to update to 
>> trunk and your missing fields should re-appear (they will be hidden, 
>> writable=False, readable=False) but web2py should be able to use them as 
>> intended.
>>
>> Please let me know asap.
>>
>> Massimo
>>
>> On Tuesday, 11 September 2012 03:44:46 UTC-5, Matt wrote:
>>>
>>> Hi there,
>>>
>>> First off thanks for all of the fantastic work putting 2.0 together. 
>>> Looking forward to trying the new features.
>>>
>>> I've just upgraded from 1.99.7 -> 2.0.8 and I've discovered a serious 
>>> bug which has resulted in the loss of my data.
>>>
>>> [I'm using both GAE with CloudSQL and dal(migrate_enabled = True)]
>>>
>>> The automatically created image_blob references for GAE fields like:
>>>
>>> Field('image', 'upload', required = True, length = 100)
>>>
>>> Have vanished and with them the data contained in the image_blob fields.
>>>
>>> It seems to have happened fairly randomly i.e. some tables are fine but 
>>> others are affected. Out of about 6 tables using uploads only two still 
>>> have the extra blob columns.
>>>
>>> I've had some of these table definitions around for a long time and they 
>>> haven't changed. Whereas some others have been edited more recently.
>>>
>>> Any help or suggestions would be appreciated. Happy to give mere 
>>> information if possible.
>>>
>>> Thanks in advance,
>>> Matt
>>>
>>> BTW: Also had this problem occur prior to the above:
>>>
>>>  self.db.executesql("CREATE TABLE IF NOT EXISTS web2py_filesystem (path 
>>> VARCHAR(512), content LONGTEXT, PRIMARY KEY(path) ) ENGINE=InnoDB;")
>>>   File "/Projects/www/gluon/dal.py", line 7234, in executesql
>>> adapter.execute(query)
>>>   File "/Projects/www/gluon/dal.py", line 4002, in execute
>>> return self.log_execute(a.decode('utf8'))
>>>   File "/Projects/www/gluon/dal.py", line 1653, in log_execute
>>> ret = self.cursor.execute(*a, **b)
>>>   File "/Library/Python/2.7/site-packages/MySQLdb/cursors.py", line 174, 
>>> in execute
>>>   File "/Library/Python/2.7/site-packages/MySQLdb/connections.py", line 
>>> 36, in defaulterrorhandler
>>> OperationalError: (1071, 'Specified key was too long; max key length is 
>>> 767 bytes')
>>>
>>> Temporary fix was to change from True to False.
>>>
>>> class DatabaseStoredFile:
>>>
>>> web2py_filesystem = True
>>>
>>> (I did already have the web2py_filesystem table of course)
>>>
>>

-- 





[web2py] Re: Not authorized! ??

2012-09-12 Thread Niphlod
I think the problem you are facing is that all links pointing to a grid 
should include the user signature, that's a default requirement for grids 
(asuming that your show_akb_artcle and edit_akb_article are using grids as 
well).
 
You can switch them off with user_signature=False in grid but you'd be more 
safer signing the urls you are generating.

Il giorno mercoledì 12 settembre 2012 14:28:16 UTC+2, Johann Spies ha 
scritto:
>
> This is old code - it worked without a problem before.  I suspect recent 
> upgrades broke it.
>
> I have a SQLDFORM.grid using the following links:
>
> links = [lambda row: A(B(T('View')), _target = "_blank",
>_href = URL(r = request, c = 'articles',
>f = 'show_akb_article',
>args = str(row[db.akb_articles.id
> ])))]
>
> if auth.has_membership(role = 'kb_ed'):
> links.append(lambda row: A(B(T('Edit')), _target = "_blank",
>_href = URL(r = request, c = 'articles',
>f = 'edit_akb_article',
>args = str(row[
> db.akb_articles.id]
>
> links.append(lambda row: A(B(T('Link to Institute')), _target = 
> "_blank",
>_href = URL(r = request, c = 'articles',
>f = 'art_research',
>args = str(row[
> db.akb_articles.id]
>
>
> I use any of those links in the grid even if I am logged in as a member of 
> the 'kb_ed' group.  I get the error:  "not authorized" even when I try to 
> use 'view'.
>
> I have experimented by removing the following decorator 
>
> @auth.requires(lambda:auth.has_membership('kb_ed'))
> def edit_akb_article():
>
> but even without the decorator I cannot edit the article.
>
> What is causing this?
>
> Regards
> Johann
>
>
> BTW the syntax highlighting is not working for me today in the web 
> interface to the group.
>

-- 





[web2py] Re: Receiving error when exporting to TSV with SQLFORM.grid (V2.0.8)

2012-09-12 Thread Massimo Di Pierro
represent takes always two values. You have

represent=lambda row: row.strftime('%H:%M')),


but you should have

represent=lambda value,row: value.strftime('%H:%M')),


On Wednesday, 12 September 2012 05:02:28 UTC-5, Gerd wrote:
>
> Hi!
>
> First: This is my first try to build a "real" application in web2py and 
> python, i'm new to both but like it very much (i'm coming from bash/awk/sed)
>
> I receive following error when trying to export a SQLFORM.grid to TSV 
> (Excel compatible), but CSV works
>
> Traceback (most recent call last):
>   File "/home/gniemetz/webapps/web2py/web2py/gluon/restricted.py", line 209, 
> in restricted
> exec ccode in environment
>   File 
> "/home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py"
>  
> ,
>  line 78, in 
>   File "/home/gniemetz/webapps/web2py/web2py/gluon/globals.py", line 185, in 
> 
> self._caller = lambda f: f()
>   File "/home/gniemetz/webapps/web2py/web2py/gluon/tools.py", line 2783, in f
> return action(*a, **b)
>   File 
> "/home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py"
>  
> ,
>  line 22, in index
> grid = 
> SQLFORM.grid(db.Logbuch,fields=[db.Logbuch.Datum,db.Logbuch.Kurs,db.Logbuch.Thema,db.Logbuch.Kommentar],maxtextlength=50)
>   File "/home/gniemetz/webapps/web2py/web2py/gluon/sqlhtml.py", line 1858, in 
> grid
> raise HTTP(200, oExp.export(),**response.headers)
>   File "/home/gniemetz/webapps/web2py/web2py/gluon/sqlhtml.py", line 2627, in 
> export
> records = self.represented()
>   File "/home/gniemetz/webapps/web2py/web2py/gluon/sqlhtml.py", line 2594, in 
> represented
> value = field.represent(value, record)
> TypeError: () takes exactly 1 argument (2 given)
>
>
> This is my model (a bit complicated, maybe there's room for improvement)
>
> db.define_table('KFZ', 
> Field 
> ('Auto','string',length=30,label=T
>  ('Car')), 
> Field 
> ('Kennzeichen','string',length=10,label=T
>  ('License plate')), 
> Field 
> ('KM','integer',label=T 
> ('Mileage')), 
> Field 
> ('gueltig_bis','date',label=T
>  ('Expired')), 
> format='%(Auto)s %(Kennzeichen)s'
> )
>
> db.define_table('Themen', 
> Field 
> ('Thema','string',length=30,label=T
>  ('Topic')), 
> Field 
> ('gueltig_bis','date',label=T
>  ('Expired')), 
> format='%(Thema)s'
> )
>
> db.define_table('KM_Gelder', 
> Field 
> ('Tarif','decimal(3,2)',requires=IS_DECIMAL_IN_RANGE
>  
> (dot=','),label=T
>  ('Mileage Cost')), 
> Field 
> ('gueltig_bis','date',label=T
>  ('Expired')), 
> format=lambda row: str('%(Tarif)s' % row if row else 
> '').replace('.',',').replace(',00',',-')
> )
> 
> from datetime import datetime, date
> query = ((db.KM_Gelder.gueltig_bis == None))
> db.define_table('Logbuch', 
> Field 
> ('Datum','date',requires=IS_DATE
>  
> (format='%Y-%m-%d'),label=T
>  ('Date')), 
> Field 
> ('Kurs','string',length=50,label=T
>  ('Course')), 
> Field 
> ('Beginn','time',requires=IS_TIME
>  (),label=T 
> ('Start'),represent=lambda 
> row: row.strftime('%H:%M')), 
> Field 
> ('Ende','time',requires=IS_TIME
>  (),label=T 
> ('End'),represent=lambda 
> row: row.strftime('%H:%M')), 
> Field 
> ('Thema',db.Themen,label=T
>  

[web2py] Re: web2py 2.0.8 Firebird driver fdb error

2012-09-12 Thread Massimo Di Pierro
Please open a ticket about this.

On Wednesday, 12 September 2012 07:06:33 UTC-5, Alexei Vinidiktov wrote:
>
> I'm trying to use the new fdb driver for Firebird with web2py 2.0.8 but 
> I'm getting this error when I load a page:
>
> (Transaction object is not active) 
>
> TRACEBACK
>  
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
>
> Traceback (most recent call last):
>   File "C:\Users\alexei\Dev\web2py\vocabilis.net-2.0.8\gluon\main.py", line 
> 538, in wsgibase
>
>
> BaseAdapter.close_all_instances('commit')
>
>
>   File "C:\Users\alexei\Dev\web2py\vocabilis.net-2.0.8\gluon\dal.py", line 
> 510, in close_all_instances
>
>
> getattr(instance, action)()
>
>
>   File "C:\Users\alexei\Dev\web2py\vocabilis.net-2.0.8\gluon\dal.py", line 
> 1618, in commit
>
>
> return self.connection.commit()
>
>
>   File "C:\Python27\lib\site-packages\fdb\fbcore.py", line 1084, in commit
>
>
> self._main_transaction.commit(retaining)
>
>
>   File "C:\Python27\lib\site-packages\fdb\fbcore.py", line 2385, in commit
>
>
> self.__check_active()
>
>
>   File "C:\Python27\lib\site-packages\fdb\fbcore.py", line 2316, in 
> __check_active
>
>
> raise ProgrammingError("Transaction object is not active")
>
> ProgrammingError: Transaction object is not active
>
>  Code listing
>
>
>
> 2311.
> 2312.
>
>
> 2313.
> 2314.
> 2315.
> 2316.
>
> 2317.
> 2318.
> 2319.
> 2320.
>
> self._cursors.remove(cursor_ref)
>
>
> def __get_closed(self):
>
>
> return self._tr_handle == None
>
>
> def __check_active(self):
>
>
> if self._tr_handle == None:
>
> raise ProgrammingError("Transaction object is not active")
>
>
> def __con_in_list(self,connection):
>
>
> for con in self._connections:
>
>
> if con() == connection:
>
>
> return True
>
>
> I have Python 2.7.2 and fdb 0.8.5 on Windows 8 RC.
>
> -- 
> Alexei Vinidiktov
>  

-- 





[web2py] Re: How to login to Web2Py-app by providing username and password in URL?

2012-09-12 Thread Massimo Di Pierro
Nope.

auth.settings.allow_basic_login = True

https://username:passw...@yoursite.com/yourapp/default/index

http://en.wikipedia.org/wiki/Basic_access_authentication



On Wednesday, 12 September 2012 07:09:23 UTC-5, villas wrote:
>
> Security is clearly not at the top of your agenda :)  
> Something like this might work:
>
> def logmein():
> # minimal, insecure login function
> auth.login_bare(request.vars['username'],request.vars['password']) 
>
> yoursite.com/yourapp/default/logmein?username=abc&password=xyz
>
>
>
>
> On Wednesday, September 12, 2012 12:40:13 PM UTC+1, Remco K wrote:
>>
>> Hello everyone,
>>
>> I'm not a big fan of asking questions rather than find solutions by 
>> myself but i need a little help on this one so i hope someone can help me a 
>> bit.
>>
>> What i need is 'very simple'. I have a Web2Py application running and i 
>> need other applications (PHP or something) to be able to successfully login 
>> users to this app by providing the username and password via the URL.
>>
>> When doing this in PHP i would think of something like: 
>>
>> /index.php?username=blabla&password=dfgfdjkldfgjk
>>
>> I've already looked at basic auth but i can't get the user to login.
>>
>> All of my controllers/functions use 
>> @auth.requires_login()
>> to check whether the user has the permission to execute the functions.
>>
>> I hope someone can help me out on this.
>>
>> Thanks in advance!
>> Remco
>>
>>

-- 





Re: [web2py] Pynes notify

2012-09-12 Thread António Ramos
Also
http://www.jeasyui.com/demo/index.php

has some flash message also

2012/9/12 David Sorrentino 

> Impressive.
>
>
> On 12 September 2012 08:40, Bruno Rocha  wrote:
>
>> This plugin for Bootstrap looks very nice for response.flash
>>
>> http://pinesframework.org/pnotify/
>>
>>
>> --
>>
>>
>>
>>
>
>  --
>
>
>
>

-- 





[web2py] How to select only 10 last rows in a table?

2012-09-12 Thread Vladimir Makarov
So, I need to select data from the table but the only ten last rows (with 
highest id).
I have already tried with select all records and then use while statement 
but I think there is another way.
Any ideas? Thanks!

-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Massimo Di Pierro
if you have a SQL db then you can order them by reverse id

db().select(orderby=~db.tablename.id,limitby=(0,10))

otherwise you should have some timestamp field (as created_on in 
auth.signature) and use that field.

On Wednesday, 12 September 2012 08:09:07 UTC-5, Vladimir Makarov wrote:
>
> So, I need to select data from the table but the only ten last rows (with 
> highest id).
> I have already tried with select all records and then use while statement 
> but I think there is another way.
> Any ideas? Thanks!
>

-- 





[web2py] Re: Error: DAL object has no attribute custom_auth_table

2012-09-12 Thread Massimo Di Pierro
You cannot do:

IS_NOT_IN_DB(db,'custom_auth_table.shortname',...

custom_auth_table is not the table name, it is a variable. Try

IS_NOT_IN_DB(db,'auth_user.shortname',

You have the same problem in many places.



On Wednesday, 12 September 2012 03:46:06 UTC-5, Annet wrote:
>
> I defined a custom auth_user table:
>
> db.define_table(
> auth.settings.table_user_name,
> Field('title',length=8,requires=IS_IN_SET(['de 
> heer','mevrouw'],zero=T('Select a value')),label='Aanheft * '),
> 
> Field('firstName',length=32,requires=IS_LENGTH(32,error_message=T('length 
> exceeds 32 characters')),label='Voornaam'),
> 
> Field('lastName',length=64,default='',requires=[IS_LENGTH(64,error_message=T('length
>  
> exceeds 64 charactrer')),IS_NOT_EMPTY()],notnull=True,label='Achternaam * 
> '),
> 
> Field('shortname',default='',requires=[IS_LENGTH(128,error_message=T('length 
> exceeds 128 
> characters')),IS_EMPTY_OR(IS_NOT_IN_DB(db,'custom_auth_table.shortname',error_message=T('shortname
>  
> already in database')))],notnull=True,unique=True),
> Field('phone',length=16,requires=IS_LENGTH(16,error_message='length 
> exceeds 16 characters'),label='Telefoon'),
> 
> Field('email',length=128,default='',requires=[IS_LENGTH(128,error_message=T('length
>  
> exceeds 128 characters')),IS_EMAIL(error_message=T('invalid 
> email')),IS_NOT_IN_DB(db,'custom_auth_table.email',error_message=T('email 
> already in database'))],notnull=True,unique=True,label='E-mail * '),
> 
> Field('username',length=32,default='',requires=[IS_LENGTH(32,error_message=T('length
>  
> exceeds 32 
> charactrer')),IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'custom_auth_table.username',error_message=T('username
>  
> already in 
> database'))],notnull=True,unique=True,writable=False,readable=False,label='Gebruikersnaam
>  
> * '),
> Field('password', 
> type='password',length=512,requires=[IS_STRONG(),CRYPT()],readable=False,label='Wachtwoord
>  
> * '),
> Field('nodeID','reference node',default='',requires=[IS_IN_DB(db,'
> node.id','%(id)s',zero=T('Select a 
> value'))],ondelete='CASCADE',notnull=True,label='NodeID * 
> ',writable=False,readable=False),
> 
> Field('comment',type='text',requires=IS_LENGTH(512,error_message=T('length 
> exceeds 512 characters'))),
> 
> Field('registration_key',length=512,default='',writable=False,readable=False),
> 
> Field('reset_password_key',length=512,default='',writable=False,readable=False),
> 
> Field('registration_id',length=512,default='',writable=False,readable=False),
> Field('createdOn',type='datetime',default=request.now),
> 
> Field('modifiedOn',type='datetime',default=request.now,update=request.now))
>
> ## get the custom_auth_table
> custom_auth_table = db[auth.settings.table_user_name]
> ## tell auth to use custom_auth_table
>  auth.settings.table_user = custom_auth_table
> ## to prevent the auth_cas table from being created
> auth.settings.cas_domains = None
> ## create all tables needed by auth if not custom tables
> auth.define_tables(migrate=True,username=True,signature=False)
>
>
>
> When I enter a user I get the following error:
>
>
> Traceback (most recent call last):
>   File "/Library/Python/2.6/site-packages/web2py/gluon/restricted.py", line 
> 209, in restricted
> exec ccode in environment
>   File 
> "/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
>  , 
> line 444, in 
>   File "/Library/Python/2.6/site-packages/web2py/gluon/globals.py", line 185, 
> in 
> self._caller = lambda f: f()
>   File 
> "/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
>  , 
> line 129, in insert
> if form.accepts(request.vars, session):
>   File "/Library/Python/2.6/site-packages/web2py/gluon/sqlhtml.py", line 
> 1223, in accepts
> hideerror=hideerror,
>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 1952, 
> in accepts
> status = self._traverse(status,hideerror)
>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, in 
> _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, in 
> _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, in 
> _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, in 
> _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 827, in 
> _traverse
> newstatus = self._validate()
>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 1706, 
> in _validate
> (value, errors) =

Re: [web2py] Re: Not authorized! ??

2012-09-12 Thread Johann Spies
On 12 September 2012 14:36, Niphlod  wrote:

> I think the problem you are facing is that all links pointing to a grid
> should include the user signature, that's a default requirement for grids
> (asuming that your show_akb_artcle and edit_akb_article are using grids as
> well).
>

Correct assumption.

Thanks.  I have not previously seen the part in the book on how to sign
url's - only now saw it after your email.



Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] Re: Error: DAL object has no attribute custom_auth_table

2012-09-12 Thread Niphlod
PS: this auth_table (and others) is giving nightmares both to Annet and 
everyone reading this forum when the app is finished I want to see the 
code behind! :P

Il giorno mercoledì 12 settembre 2012 15:17:14 UTC+2, Massimo Di Pierro ha 
scritto:
>
> You cannot do:
>
> IS_NOT_IN_DB(db,'custom_auth_table.shortname',...
>
> custom_auth_table is not the table name, it is a variable. Try
>
> IS_NOT_IN_DB(db,'auth_user.shortname',
>
> You have the same problem in many places.
>
>
>
> On Wednesday, 12 September 2012 03:46:06 UTC-5, Annet wrote:
>>
>> I defined a custom auth_user table:
>>
>> db.define_table(
>> auth.settings.table_user_name,
>> Field('title',length=8,requires=IS_IN_SET(['de 
>> heer','mevrouw'],zero=T('Select a value')),label='Aanheft * '),
>> 
>> Field('firstName',length=32,requires=IS_LENGTH(32,error_message=T('length 
>> exceeds 32 characters')),label='Voornaam'),
>> 
>> Field('lastName',length=64,default='',requires=[IS_LENGTH(64,error_message=T('length
>>  
>> exceeds 64 charactrer')),IS_NOT_EMPTY()],notnull=True,label='Achternaam * 
>> '),
>> 
>> Field('shortname',default='',requires=[IS_LENGTH(128,error_message=T('length 
>> exceeds 128 
>> characters')),IS_EMPTY_OR(IS_NOT_IN_DB(db,'custom_auth_table.shortname',error_message=T('shortname
>>  
>> already in database')))],notnull=True,unique=True),
>> Field('phone',length=16,requires=IS_LENGTH(16,error_message='length 
>> exceeds 16 characters'),label='Telefoon'),
>> 
>> Field('email',length=128,default='',requires=[IS_LENGTH(128,error_message=T('length
>>  
>> exceeds 128 characters')),IS_EMAIL(error_message=T('invalid 
>> email')),IS_NOT_IN_DB(db,'custom_auth_table.email',error_message=T('email 
>> already in database'))],notnull=True,unique=True,label='E-mail * '),
>> 
>> Field('username',length=32,default='',requires=[IS_LENGTH(32,error_message=T('length
>>  
>> exceeds 32 
>> charactrer')),IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'custom_auth_table.username',error_message=T('username
>>  
>> already in 
>> database'))],notnull=True,unique=True,writable=False,readable=False,label='Gebruikersnaam
>>  
>> * '),
>> Field('password', 
>> type='password',length=512,requires=[IS_STRONG(),CRYPT()],readable=False,label='Wachtwoord
>>  
>> * '),
>> Field('nodeID','reference node',default='',requires=[IS_IN_DB(db,'
>> node.id','%(id)s',zero=T('Select a 
>> value'))],ondelete='CASCADE',notnull=True,label='NodeID * 
>> ',writable=False,readable=False),
>> 
>> Field('comment',type='text',requires=IS_LENGTH(512,error_message=T('length 
>> exceeds 512 characters'))),
>> 
>> Field('registration_key',length=512,default='',writable=False,readable=False),
>> 
>> Field('reset_password_key',length=512,default='',writable=False,readable=False),
>> 
>> Field('registration_id',length=512,default='',writable=False,readable=False),
>> Field('createdOn',type='datetime',default=request.now),
>> 
>> Field('modifiedOn',type='datetime',default=request.now,update=request.now))
>>
>> ## get the custom_auth_table
>> custom_auth_table = db[auth.settings.table_user_name]
>> ## tell auth to use custom_auth_table
>>  auth.settings.table_user = custom_auth_table
>> ## to prevent the auth_cas table from being created
>> auth.settings.cas_domains = None
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(migrate=True,username=True,signature=False)
>>
>>
>>
>> When I enter a user I get the following error:
>>
>>
>> Traceback (most recent call last):
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/restricted.py", line 
>> 209, in restricted
>> exec ccode in environment
>>   File 
>> "/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
>>  , 
>> line 444, in 
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/globals.py", line 
>> 185, in 
>> self._caller = lambda f: f()
>>   File 
>> "/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
>>  , 
>> line 129, in insert
>> if form.accepts(request.vars, session):
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/sqlhtml.py", line 
>> 1223, in accepts
>> hideerror=hideerror,
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 1952, 
>> in accepts
>> status = self._traverse(status,hideerror)
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>> newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>> newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>> newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Library/Pyt

[web2py] Re: Centos 5 script for Nginx with Uwsgi and Web2py

2012-09-12 Thread Alan Etkin

>
> I'm trying step to step now...and only was needed an little changes
>

 Answered in web2py-usuarios

-- 





[web2py] Re: Upload from git repro - GitCommandError

2012-09-12 Thread Nico Zanferrari
Well, I think that you mean *gitpython *and not python-git, isn't it? Can 
you kindly correct the warning message?

Thank you,
Nico

-- 





Re: [web2py] Re: web2py default layout.html

2012-09-12 Thread Kevin Miller
Yes definitely that span12 is causing the problem. Thanks guys. Now I have
to add some extra padding now.

On Wed, Sep 12, 2012 at 2:35 AM, Annet  wrote:

>
> missing some  s for the first "span12"s ?
>>
>
> You're right, it should be:
>
>
> 
>   
> 
>  
>
> 
>
>
> Kind regards,
>
> Annet.
>
> --
>
>
>
>

-- 





[web2py] Re: Upload from git repro - GitCommandError

2012-09-12 Thread dhmorgan
the pypi package is 'gitpython' --  http://pypi.python.org/pypi/GitPython

"sudo pip install gitpython" worked for me

note: there is a 'gitpython' on github but that is different and useless in 
this case


I originally tried "sudo  apt-get install python-git" and this did not work 
for my Ubuntu 12.04 machine; despite the debian package name, it is 
'gitpython' -- unfortunately it's not the current version and so fails 
because it doesn't have 'clone_from' attribute


On Wednesday, September 12, 2012 8:52:16 AM UTC-5, Nico Zanferrari wrote:
>
> Well, I think that you mean *gitpython *and not python-git, isn't it? Can 
> you kindly correct the warning message?
>
> Thank you,
> Nico
>

-- 





[web2py] Timezone

2012-09-12 Thread Rod Watkins
I have a question about timezones. What is the best way to handle datetimes 
entered by users. Since they will enter a datetime in their local timezone, 
what is the best way to transform that to a UTC datetime value before 
inserting it into the database?

Thanks
Rod

-- 





[web2py] Re: Receiving error when exporting to TSV with SQLFORM.grid (V2.0.8)

2012-09-12 Thread Gerd
Thank you Massimo, it worked

Am Mittwoch, 12. September 2012 14:38:43 UTC+2 schrieb Massimo Di Pierro:
>
> represent takes always two values. You have
>
> represent=lambda row: row.strftime('%H:%M')),
>
>
> but you should have
>
> represent=lambda value,row: value.strftime('%H:%M')),
>
>
> On Wednesday, 12 September 2012 05:02:28 UTC-5, Gerd wrote:
>>
>> Hi!
>>
>> First: This is my first try to build a "real" application in web2py and 
>> python, i'm new to both but like it very much (i'm coming from bash/awk/sed)
>>
>> I receive following error when trying to export a SQLFORM.grid to TSV 
>> (Excel compatible), but CSV works
>>
>> Traceback (most recent call last):
>>   File "/home/gniemetz/webapps/web2py/web2py/gluon/restricted.py", line 209, 
>> in restricted
>> exec ccode in environment
>>   File 
>> "/home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py"
>>  
>> ,
>>  line 78, in 
>>   File "/home/gniemetz/webapps/web2py/web2py/gluon/globals.py", line 185, in 
>> 
>> self._caller = lambda f: f()
>>   File "/home/gniemetz/webapps/web2py/web2py/gluon/tools.py", line 2783, in f
>> return action(*a, **b)
>>   File 
>> "/home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py"
>>  
>> ,
>>  line 22, in index
>> grid = 
>> SQLFORM.grid(db.Logbuch,fields=[db.Logbuch.Datum,db.Logbuch.Kurs,db.Logbuch.Thema,db.Logbuch.Kommentar],maxtextlength=50)
>>   File "/home/gniemetz/webapps/web2py/web2py/gluon/sqlhtml.py", line 1858, 
>> in grid
>> raise HTTP(200, oExp.export(),**response.headers)
>>   File "/home/gniemetz/webapps/web2py/web2py/gluon/sqlhtml.py", line 2627, 
>> in export
>> records = self.represented()
>>   File "/home/gniemetz/webapps/web2py/web2py/gluon/sqlhtml.py", line 2594, 
>> in represented
>> value = field.represent(value, record)
>> TypeError: () takes exactly 1 argument (2 given)
>>
>>
>> This is my model (a bit complicated, maybe there's room for improvement)
>>
>> db.define_table('KFZ', 
>> Field 
>> ('Auto','string',length=30,label=T
>>  ('Car')), 
>> Field 
>> ('Kennzeichen','string',length=10,label=T
>>  ('License plate')), 
>> Field 
>> ('KM','integer',label=T
>>  ('Mileage')), 
>> Field 
>> ('gueltig_bis','date',label=T
>>  ('Expired')), 
>> format='%(Auto)s %(Kennzeichen)s'
>> )
>>
>> db.define_table('Themen', 
>> Field 
>> ('Thema','string',length=30,label=T
>>  ('Topic')), 
>> Field 
>> ('gueltig_bis','date',label=T
>>  ('Expired')), 
>> format='%(Thema)s'
>> )
>>
>> db.define_table('KM_Gelder', 
>> Field 
>> ('Tarif','decimal(3,2)',requires=IS_DECIMAL_IN_RANGE
>>  
>> (dot=','),label=T
>>  ('Mileage Cost')), 
>> Field 
>> ('gueltig_bis','date',label=T
>>  ('Expired')), 
>> format=lambda row: str('%(Tarif)s' % row if row else 
>> '').replace('.',',').replace(',00',',-')
>> )
>> 
>> from datetime import datetime, date
>> query = ((db.KM_Gelder.gueltig_bis == None))
>> db.define_table('Logbuch', 
>> Field 
>> ('Datum','date',requires=IS_DATE
>>  
>> (format='%Y-%m-%d'),label=T
>>  ('Date')), 
>> Field 
>> ('Kurs','string',length=50,label=T
>>  ('Course')), 
>> Field 
>> ('Beginn','time',requires=IS_TIME
>>  (),label=T 
>> ('Start'),represent=lambda 
>> row: row.strftime('%H:%M')), 
>> Field 
>> ('Ende','time',requires=IS_TIME
>>  (),label=T 
>> 

[web2py] [FYI] Pyodel is now a plugin

2012-09-12 Thread Alan Etkin
 Pyodel demo is now available on Google appspot with new features:

- Mode plugin (all functionalities can be deployed in web2py apps by 
individual components)
- Course admission/attendees with CRUD
- Course and lecture managing and presentation for students and teachers
- Gradebooks with ajax update, formula fields with abbreviated instance 
names and read/write permissions (with contrib.spreadsheet)
- Grade CRUD per student/course/instance
- Educational document edition and presentation with the new auth.wiki 
built-in and markmin
- Streaming service and managing for couses and lectures with restricted 
access for attendees
- Automated course admission interface for electronic payment services
- Customized panels for students or teachers
- Managing and access for student works, exams and quiz (sort of trivias 
with multiple or single options)
- Simplified syntax for quiz submission

The (incomplete) docs can be read the project's wiki at 
http://code.google.com/p/pyodel
For using the plugin demo, go to http://pyodel.appspot.com (registration is 
requisite)

It features an example course, with some documents, lectures, video streams 
and a quiz

For enhancements or errors please open an issue at 
http://code.google.com/p/pyodel/issues

Quizzes about web2py are welcome (there's a quiz submission form in the 
demo page)

-- 





[web2py] Re: Upload from git repro - GitCommandError

2012-09-12 Thread Andrew
Also just fyi, I haven't had much time to work on the Git support to make 
it more friendly. 

If you're using a smart http url for a r/w repo, you won't be able to push 
unless you modify the url as 
https://user:passw...@github.com/user/project.git

Right now if you don't do that it prompts you for user / pass and stdin 
which you'll never see unless you're running locally and appears to be 
broken. If you're using git ssh and have ssh keys setup correctly it should 
be fine.

On Wednesday, September 12, 2012 9:44:02 AM UTC-5, dhmorgan wrote:
>
> the pypi package is 'gitpython' --  http://pypi.python.org/pypi/GitPython
>
> "sudo pip install gitpython" worked for me
>
> note: there is a 'gitpython' on github but that is different and useless 
> in this case
>
>
> I originally tried "sudo  apt-get install python-git" and this did not 
> work for my Ubuntu 12.04 machine; despite the debian package name, it is 
> 'gitpython' -- unfortunately it's not the current version and so fails 
> because it doesn't have 'clone_from' attribute
>
>
> On Wednesday, September 12, 2012 8:52:16 AM UTC-5, Nico Zanferrari wrote:
>>
>> Well, I think that you mean *gitpython *and not python-git, isn't it? 
>> Can you kindly correct the warning message?
>>
>> Thank you,
>> Nico
>>
>

-- 





Re: [web2py] [FYI] Pyodel is now a plugin

2012-09-12 Thread Tito Garrido
Hey Alan,

I was about to test it but it requested access to my google account, is it
expected?

On Wed, Sep 12, 2012 at 12:00 PM, Alan Etkin  wrote:

> Pyodel demo is now available on Google appspot with new features:
>
> - Mode plugin (all functionalities can be deployed in web2py apps by
> individual components)
> - Course admission/attendees with CRUD
> - Course and lecture managing and presentation for students and teachers
> - Gradebooks with ajax update, formula fields with abbreviated instance
> names and read/write permissions (with contrib.spreadsheet)
> - Grade CRUD per student/course/instance
> - Educational document edition and presentation with the new auth.wiki
> built-in and markmin
> - Streaming service and managing for couses and lectures with restricted
> access for attendees
> - Automated course admission interface for electronic payment services
> - Customized panels for students or teachers
> - Managing and access for student works, exams and quiz (sort of trivias
> with multiple or single options)
> - Simplified syntax for quiz submission
>
> The (incomplete) docs can be read the project's wiki at
> http://code.google.com/p/pyodel
> For using the plugin demo, go to http://pyodel.appspot.com (registration
> is requisite)
>
> It features an example course, with some documents, lectures, video
> streams and a quiz
>
> For enhancements or errors please open an issue at
> http://code.google.com/p/pyodel/issues
>
> Quizzes about web2py are welcome (there's a quiz submission form in the
> demo page)
>
> --
>
>
>
>



-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 





Re: [web2py] [FYI] Pyodel is now a plugin

2012-09-12 Thread Alan Etkin
Oops, I's not. Let me see how do I get rid of that

2012/9/12 Tito Garrido :
> Hey Alan,
>
> I was about to test it but it requested access to my google account, is it
> expected?
>
>
> On Wed, Sep 12, 2012 at 12:00 PM, Alan Etkin  wrote:
>>
>> Pyodel demo is now available on Google appspot with new features:
>>
>> - Mode plugin (all functionalities can be deployed in web2py apps by
>> individual components)
>> - Course admission/attendees with CRUD
>> - Course and lecture managing and presentation for students and teachers
>> - Gradebooks with ajax update, formula fields with abbreviated instance
>> names and read/write permissions (with contrib.spreadsheet)
>> - Grade CRUD per student/course/instance
>> - Educational document edition and presentation with the new auth.wiki
>> built-in and markmin
>> - Streaming service and managing for couses and lectures with restricted
>> access for attendees
>> - Automated course admission interface for electronic payment services
>> - Customized panels for students or teachers
>> - Managing and access for student works, exams and quiz (sort of trivias
>> with multiple or single options)
>> - Simplified syntax for quiz submission
>>
>> The (incomplete) docs can be read the project's wiki at
>> http://code.google.com/p/pyodel
>> For using the plugin demo, go to http://pyodel.appspot.com (registration
>> is requisite)
>>
>> It features an example course, with some documents, lectures, video
>> streams and a quiz
>>
>> For enhancements or errors please open an issue at
>> http://code.google.com/p/pyodel/issues
>>
>> Quizzes about web2py are welcome (there's a quiz submission form in the
>> demo page)
>>
>> --
>>
>>
>>
>
>
>
>
> --
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>
> --
>
>
>

-- 





[web2py] Re: Appadmin not showing default widgets for plugin tables

2012-09-12 Thread scausten
I'm having the same trouble with the following table definition (version 
2.0.8)

db.define_table('clients',
Field('name'))

db.define_table('promotions',
Field('client', 'reference clients'),
Field('name'),
Field('starts_on', 'datetime'),
Field('ends_on', 'datetime'))

I'm not getting a dropdown for promotions.client in appadmin or other 
SQLFORMs without explicitly specifying requires=IS_IN_DB(...)

Thanks in advance!

On Sunday, 19 August 2012 21:02:41 UTC+1, Massimo Di Pierro wrote:
>
> Thanks. Fixed.
>
> On Sunday, 19 August 2012 14:16:47 UTC-5, Alan Etkin wrote:
>>
>> Can you make a more concrete example?
>>>
>>>
>> A table definition
>>
>> db.define_table("plugin_pyodel_attendance",
>>  Field ("student", 
>> "reference auth_user",
>>  default=auth.user_id),
>>  Field ("course", 
>> "reference plugin_pyodel_course"),
>>  Field ("paid", "double", 
>> default=0.0),
>>  Field ("allowed", 
>> "boolean", default=False),
>>  Field ("passed", 
>> default=False),
>>  Field ("score", "double"),
>>  format="%(student)s"
>>  )
>>
>> I have previously inserted two users with the registration feature.
>> I attached a screenshot with the appadmin insert form view output.
>> For my understanding, the form should by default present a combo widget for 
>> the student field
>>
>> Perhaps I could look for validators defined elsewhere but I'm pretty sure 
>> I'm not using them.
>> No big deal if the problem is only for appadmin but would'n there be similar 
>> problems with default forms when using crud, etc?
>>
>>

-- 





[web2py] Re: How to login to Web2Py-app by providing username and password in URL?

2012-09-12 Thread Remco K
I've tried this but i cant get this to work.

in db.py i have 

auth.settings.allow_basic_login = True

And in the controller:

@auth.requires_login()

When i use:

http://:@127.0.0.1:8000///

I get redirected to the login page. My app uses email as username but i 
also tried to use the default username. Still no luck.

I think i miss something.


Op woensdag 12 september 2012 14:45:23 UTC+2 schreef Massimo Di Pierro het 
volgende:
>
> Nope.
>
> auth.settings.allow_basic_login = True
>
> https://username:passw...@yoursite.com/yourapp/default/index
>
> http://en.wikipedia.org/wiki/Basic_access_authentication
>
>
>
> On Wednesday, 12 September 2012 07:09:23 UTC-5, villas wrote:
>>
>> Security is clearly not at the top of your agenda :)  
>> Something like this might work:
>>
>> def logmein():
>> # minimal, insecure login function
>> auth.login_bare(request.vars['username'],request.vars['password']) 
>>
>> yoursite.com/yourapp/default/logmein?username=abc&password=xyz
>>
>>
>>
>>
>> On Wednesday, September 12, 2012 12:40:13 PM UTC+1, Remco K wrote:
>>>
>>> Hello everyone,
>>>
>>> I'm not a big fan of asking questions rather than find solutions by 
>>> myself but i need a little help on this one so i hope someone can help me a 
>>> bit.
>>>
>>> What i need is 'very simple'. I have a Web2Py application running and i 
>>> need other applications (PHP or something) to be able to successfully login 
>>> users to this app by providing the username and password via the URL.
>>>
>>> When doing this in PHP i would think of something like: 
>>>
>>> /index.php?username=blabla&password=dfgfdjkldfgjk
>>>
>>> I've already looked at basic auth but i can't get the user to login.
>>>
>>> All of my controllers/functions use 
>>> @auth.requires_login()
>>> to check whether the user has the permission to execute the functions.
>>>
>>> I hope someone can help me out on this.
>>>
>>> Thanks in advance!
>>> Remco
>>>
>>>

-- 





[web2py] Re: web2py default layout.html

2012-09-12 Thread Massimo Di Pierro
aha! Thanks Annet, this fixes a long standing problem.

massimo

On Wednesday, 12 September 2012 00:42:29 UTC-5, Annet wrote:
>
> Anthony is right, it's the span12 that's causing the problem. I had the 
> same problem, and solved it by following the bootstrap pattern more 
> strictly.
>
> 
>   
> 
> 
>
> 
> 
>   
> 
>  
> 
>  
>
> 
> 
>   
> 
>  
>
> 
>
> Furthermore I defined the css selectors .pad and .pad-vertical and 
> .pad-horizontal which I add to the class="span*" divs to create extra 
> padding when needed.
>
> Kind regads,
>
> Annet
>

-- 





Re: [web2py] [ANN] Started development on web2admin

2012-09-12 Thread rif
Added plugin configuration options (inspired by sramana's instant-admin):

   - items per page
   - extra links in sidebar

Every day when I get some free time I am adding some new features. If you 
have requests or bug reports please don't hesitate :)

Thanks,
-rif

-- 





Re: [web2py] [ANN] Started development on web2admin

2012-09-12 Thread rif
There was a problem with the installation from master tip tar gz. Created 
plugin archive for download 
here
.

miercuri, 12 septembrie 2012, 18:50:20 UTC+3, rif a scris:
>
> Added plugin configuration options (inspired by sramana's instant-admin):
>
>- items per page
>- extra links in sidebar
>
> Every day when I get some free time I am adding some new features. If you 
> have requests or bug reports please don't hesitate :)
>
> Thanks,
> -rif
>

-- 





[web2py] Re: Appadmin not showing default widgets for plugin tables

2012-09-12 Thread Niphlod
format is missing for the clients table . 

how should web2py show the clients records in the dropdown of the 
"newly/currently editing" record of promotions ?

Il giorno mercoledì 12 settembre 2012 17:28:50 UTC+2, scausten ha scritto:
>
> I'm having the same trouble with the following table definition (version 
> 2.0.8)
>
> db.define_table('clients',
> Field('name'))
> 
> db.define_table('promotions',
> Field('client', 'reference clients'),
> Field('name'),
> Field('starts_on', 'datetime'),
> Field('ends_on', 'datetime'))
>
> I'm not getting a dropdown for promotions.client in appadmin or other 
> SQLFORMs without explicitly specifying requires=IS_IN_DB(...)
>
> Thanks in advance!
>
> On Sunday, 19 August 2012 21:02:41 UTC+1, Massimo Di Pierro wrote:
>>
>> Thanks. Fixed.
>>
>> On Sunday, 19 August 2012 14:16:47 UTC-5, Alan Etkin wrote:
>>>
>>> Can you make a more concrete example?


>>> A table definition
>>>
>>> db.define_table("plugin_pyodel_attendance",
>>>  Field ("student", 
>>> "reference auth_user",
>>>  default=auth.user_id),
>>>  Field ("course", 
>>> "reference plugin_pyodel_course"),
>>>  Field ("paid", "double", 
>>> default=0.0),
>>>  Field ("allowed", 
>>> "boolean", default=False),
>>>  Field ("passed", 
>>> default=False),
>>>  Field ("score", 
>>> "double"),
>>>  format="%(student)s"
>>>  )
>>>
>>> I have previously inserted two users with the registration feature.
>>> I attached a screenshot with the appadmin insert form view output.
>>> For my understanding, the form should by default present a combo widget for 
>>> the student field
>>>
>>> Perhaps I could look for validators defined elsewhere but I'm pretty sure 
>>> I'm not using them.
>>> No big deal if the problem is only for appadmin but would'n there be 
>>> similar problems with default forms when using crud, etc?
>>>
>>>

-- 





[web2py] Re: web2py default layout.html

2012-09-12 Thread Annet
@Massimo,

aha! Thanks Annet, this fixes a long standing problem.


Well, Anthony already mentioned the span12, I just provided my solution to 
the problem.

@Dundee

In an external style sheet I defined:

.pad {padding: 18px;}
.pad-hor {padding: 0px 18px;}
.pad-vert {padding: 18px 0px;}


I use these selectors in the following way:


  

 
   



Kind regards,

Annet.

-- 





[web2py] Re: problem adding members to group

2012-09-12 Thread greaneym
I think most of what I need is in ch. 3 about the DAL, but using this, I 
don't think there are any records with "manager" in them, so I am puzzled 
why I am locked out.  
python web2py.py -a 'your password' -i 127.0.0.1 -p 8000  gets in without 
gui

>>> myrecord = db(db.auth_group.id==0).select().first()
>>> print myrecord
None

>>> myrecord = db(db.auth_group.id==0).select().first()
>>> print myrecord
None
>>> myrecord = db(db.auth_membership.id==0).select().first()
>>> print myrecord
None


In any case, I had a backup of my app, so I can try again to add the 
manager group to a restored copy.



On Tuesday, September 11, 2012 3:53:56 PM UTC-5, greaneym wrote:
>
> Got farther but still stuck. I got locked out of the database and am 
> trying to get back in with "admin".
>
> cd to directory that contains "web2py.py"
>
> python web2py.py -S appname
>
> >>>
> >>> db = DAL('sqlite://storage.sqlite', auto_import=True)
> >>> print db.tables
> ['auth_cas', 'auth_event', 'auth_group', 'auth_membership', 
> 'auth_permission', 'auth_user', 'plugin_google_checkout_message', 
> 'plugin_google_checkout_order', 'plugin_google_checkout_purchase', 
> 'product', 'sale']
>
>
> if you leave out "auto_import=True" you will see [] as the result of
> print db.tables.
>
> >>> print db.auth_cas.fields
> ['id', 'user_id', 'created_on', 'service', 'ticket', 'renew']
>
> print db.auth_membership.fields
>
> ['id', 'user_id', 'group_id']]
>
>
> I need help with the finding the rest.
>
> >>> rows = db(db.auth_membership.group_id).select()
> >>> print rows
> auth_membership.id,auth_membership.user_id,auth_membership.group_id
>
>
>  = db(db.auth_group).select()
> >>> print rows
> auth_group.id,auth_group.role,auth_group.description
>
> >>> rows = db(db.auth_group.role).select()
> >>> print rows
> auth_group.id,auth_group.role,auth_group.description
>
>
> How do I find out where the "manager" group is, and can/should I add 
> "admin"
> to it, and how is this done?
>
> thanks for any assistance.
>
>
> On Tuesday, September 11, 2012 10:32:47 AM UTC-5, Massimo Di Pierro wrote:
>>
>> I do not understand this line:
>>
>> python web2py.py -S app -M -N -R applications/myapp -A
>>
>> -R should specify a script, not an app
>> -A should be followed by command line arguments for the script but you do 
>> not have any
>>
>> This is probably not the cause of your problem anyway.
>>
>>
>>
>> On Tuesday, 11 September 2012 09:48:48 UTC-5, greaneym wrote:
>>>
>>> Dear all,
>>>
>>> I'm testing the pos plugin and have it mostly set up, but I'm stuck. I 
>>> had commented all the auth statements and have now uncommented them, and 
>>> was adding the group called manager and before I could add members was 
>>> interrupted.  My session ended, and after that I could not use the admin 
>>> interface to access the database from appadmin.  So I'm now trying to add 
>>> members through the shell, but
>>> I'm getting an error:
>>>
>>> python web2py.py -S app -M -N -R applications/myapp -A 
>>> Traceback (most recent call last):
>>>   File "web2py.py", line 16, in 
>>> import gluon.widget
>>> ImportError: No module named gluon.widget
>>>
>>>
>>> I upgraded from version 1.99 to 2.06 and just added the web2py.app.
>>>
>>> Do I need something else? Or how can I modify the shell command please?
>>>
>>> thanks,
>>> Margaret
>>>
>>>

-- 





[web2py] virtual fields book example

2012-09-12 Thread KMax

Hello,
I was looking the book  http://www.web2py.com/books/default/chapter/29/06
And intrested with:

New style virtual fields (experimental)


Create model.db with:

db.define_table('item',
   Field('unit_price','double'),
   Field('quantity','integer'))
db.item.total_price = Field.Virtual(lambda row: row.unit_price*row.quantity)

Open database admin and insert some numbers
but the table view gives only flash with:

'Row' object has no attribute 'unit_price'

and no data.

Please correct my mistake, 
I think I missed something.

Thanks,
Maxim

-- 





[web2py] Happy Programmers' Day

2012-09-12 Thread Massimo Di Pierro
https://en.wikipedia.org/wiki/Programmers'_Day

-- 





[web2py] Re: virtual fields book example

2012-09-12 Thread Massimo Di Pierro
I think it should be

db.item.total_price = Field.Virtual(lambda row: row.item.unit_price*row
.item.quantity)

This was an experimental feature and it may be wrong in the book.


On Wednesday, 12 September 2012 11:21:10 UTC-5, KMax wrote:
>
>
> Hello,
> I was looking the book  http://www.web2py.com/books/default/chapter/29/06
> And intrested with:
>
> New style virtual fields (experimental)
>
>
> Create model.db with:
>
> db.define_table('item',
>Field('unit_price','double'),
>Field('quantity','integer'))
> db.item.total_price = Field.Virtual(lambda row: row.unit_price*row.quantity)
>
> Open database admin and insert some numbers
> but the table view gives only flash with:
>
> 'Row' object has no attribute 'unit_price'
>
> and no data.
>
> Please correct my mistake, 
> I think I missed something.
>
> Thanks,
> Maxim
>

-- 





Re: [web2py] virtual fields book example

2012-09-12 Thread Marin Pranjić
Should be:

Row.item.unit_price
Row.item.quantity

On Sep 12, 2012 6:21 PM, "KMax"  wrote:


Hello,
I was looking the book  http://www.web2py.com/books/default/chapter/29/06
And intrested with:

New style virtual fields (experimental)


Create model.db with:

db.define_table('item',
   Field('unit_price','double'),
   Field('quantity','integer'))
db.item.total_price = Field.Virtual(lambda row: row.unit_price*row.quantity)

Open database admin and insert some numbers
but the table view gives only flash with:

'Row' object has no attribute 'unit_price'

and no data.

Please correct my mistake,
I think I missed something.

Thanks,
Maxim

--

-- 





[web2py] Re: Error: DAL object has no attribute custom_auth_table

2012-09-12 Thread Annet
Massimo,

Thanks for your reply.

I used to define a custom auth_user table the following way:

auth.settings.table_user=db.define_table('auth_user',
Field())

Are there any disadvantages to doing it this way?



You cannot do:
>
> IS_NOT_IN_DB(db,'custom_auth_table.shortname',...
>
> custom_auth_table is not the table name, it is a variable. Try
>
> IS_NOT_IN_DB(db,'auth_user.shortname',
>
>
Problem solved!


Kind regards,

Annet 

> You have the same problem in many places.
>
>
>
> On Wednesday, 12 September 2012 03:46:06 UTC-5, Annet wrote:
>>
>> I defined a custom auth_user table:
>>
>> db.define_table(
>> auth.settings.table_user_name,
>> Field('title',length=8,requires=IS_IN_SET(['de 
>> heer','mevrouw'],zero=T('Select a value')),label='Aanheft * '),
>> 
>> Field('firstName',length=32,requires=IS_LENGTH(32,error_message=T('length 
>> exceeds 32 characters')),label='Voornaam'),
>> 
>> Field('lastName',length=64,default='',requires=[IS_LENGTH(64,error_message=T('length
>>  
>> exceeds 64 charactrer')),IS_NOT_EMPTY()],notnull=True,label='Achternaam * 
>> '),
>> 
>> Field('shortname',default='',requires=[IS_LENGTH(128,error_message=T('length 
>> exceeds 128 
>> characters')),IS_EMPTY_OR(IS_NOT_IN_DB(db,'custom_auth_table.shortname',error_message=T('shortname
>>  
>> already in database')))],notnull=True,unique=True),
>> Field('phone',length=16,requires=IS_LENGTH(16,error_message='length 
>> exceeds 16 characters'),label='Telefoon'),
>> 
>> Field('email',length=128,default='',requires=[IS_LENGTH(128,error_message=T('length
>>  
>> exceeds 128 characters')),IS_EMAIL(error_message=T('invalid 
>> email')),IS_NOT_IN_DB(db,'custom_auth_table.email',error_message=T('email 
>> already in database'))],notnull=True,unique=True,label='E-mail * '),
>> 
>> Field('username',length=32,default='',requires=[IS_LENGTH(32,error_message=T('length
>>  
>> exceeds 32 
>> charactrer')),IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'custom_auth_table.username',error_message=T('username
>>  
>> already in 
>> database'))],notnull=True,unique=True,writable=False,readable=False,label='Gebruikersnaam
>>  
>> * '),
>> Field('password', 
>> type='password',length=512,requires=[IS_STRONG(),CRYPT()],readable=False,label='Wachtwoord
>>  
>> * '),
>> Field('nodeID','reference node',default='',requires=[IS_IN_DB(db,'
>> node.id','%(id)s',zero=T('Select a 
>> value'))],ondelete='CASCADE',notnull=True,label='NodeID * 
>> ',writable=False,readable=False),
>> 
>> Field('comment',type='text',requires=IS_LENGTH(512,error_message=T('length 
>> exceeds 512 characters'))),
>> 
>> Field('registration_key',length=512,default='',writable=False,readable=False),
>> 
>> Field('reset_password_key',length=512,default='',writable=False,readable=False),
>> 
>> Field('registration_id',length=512,default='',writable=False,readable=False),
>> Field('createdOn',type='datetime',default=request.now),
>> 
>> Field('modifiedOn',type='datetime',default=request.now,update=request.now))
>>
>> ## get the custom_auth_table
>> custom_auth_table = db[auth.settings.table_user_name]
>> ## tell auth to use custom_auth_table
>>  auth.settings.table_user = custom_auth_table
>> ## to prevent the auth_cas table from being created
>> auth.settings.cas_domains = None
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(migrate=True,username=True,signature=False)
>>
>>
>>
>> When I enter a user I get the following error:
>>
>>
>> Traceback (most recent call last):
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/restricted.py", line 
>> 209, in restricted
>> exec ccode in environment
>>   File 
>> "/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
>>  , 
>> line 444, in 
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/globals.py", line 
>> 185, in 
>> self._caller = lambda f: f()
>>   File 
>> "/Library/Python/2.6/site-packages/web2py/applications/init/controllers/appadmin.py"
>>  , 
>> line 129, in insert
>> if form.accepts(request.vars, session):
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/sqlhtml.py", line 
>> 1223, in accepts
>> hideerror=hideerror,
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 1952, 
>> in accepts
>> status = self._traverse(status,hideerror)
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>> newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>> newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Library/Python/2.6/site-packages/web2py/gluon/html.py", line 820, 
>> in _traverse
>> newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/Li

[web2py] Re: virtual fields book example

2012-09-12 Thread KMax
Thanks,
That works!

среда, 12 сентября 2012 г., 23:24:01 UTC+7 пользователь Massimo Di Pierro 
написал:
>
> I think it should be
>
> db.item.total_price = Field.Virtual(lambda row: row.item.unit_price*row
> .item.quantity)
>
> This was an experimental feature and it may be wrong in the book.
>
>
> On Wednesday, 12 September 2012 11:21:10 UTC-5, KMax wrote:
>>
>>
>> Hello,
>> I was looking the book  http://www.web2py.com/books/default/chapter/29/06
>> And intrested with:
>>
>> New style virtual fields (experimental)
>>
>>
>> Create model.db with:
>>
>> db.define_table('item',
>>Field('unit_price','double'),
>>Field('quantity','integer'))
>> db.item.total_price = Field.Virtual(lambda row: row.unit_price*row.quantity)
>>
>> Open database admin and insert some numbers
>> but the table view gives only flash with:
>>
>> 'Row' object has no attribute 'unit_price'
>>
>> and no data.
>>
>> Please correct my mistake, 
>> I think I missed something.
>>
>> Thanks,
>> Maxim
>>
>

-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Annet
Hi Vladimir,

Some time ago Anthony provided me with the following solution:

maxID=db(db.node).select(db.node.id.max()).first()['MAX(node.id)']
rows=db(db.node.id>=maxID-10).select(db.node.id,db.node.computedName,orderby=~db.node.id)


Kind regards,

Annet

-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Massimo Di Pierro
Instead of this

maxID=db(db.node).select(db.node.id.max()).first()['MAX(node.id)']

I would do

maxID=db(db.node).select(db.node.id.max()).first()[db.node.id.max()]

to make sure it will continue work in the future. The former is 
implementation dependent.

On Wednesday, 12 September 2012 11:29:04 UTC-5, Annet wrote:
>
> Hi Vladimir,
>
> Some time ago Anthony provided me with the following solution:
>
> maxID=db(db.node).select(db.node.id.max()).first()['MAX(node.id)']
> rows=db(db.node.id>=maxID-10).select(db.node.id
> ,db.node.computedName,orderby=~db.node.id)
>
>
> Kind regards,
>
> Annet
>

-- 





Re: [web2py] Pynes notify

2012-09-12 Thread lyn2py
Very very nice. :D

On Wednesday, September 12, 2012 3:22:02 PM UTC+8, David Sorrentino wrote:
>
> Impressive.
>
> On 12 September 2012 08:40, Bruno Rocha  >wrote:
>
>> This plugin for Bootstrap looks very nice for response.flash
>>
>> http://pinesframework.org/pnotify/
>>
>>
>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] [FYI] Pyodel is now a plugin

2012-09-12 Thread Alan Etkin
El miércoles, 12 de septiembre de 2012 12:19:02 UTC-3, Tito Garrido 
escribió:
>
> Hey Alan,
>
> I was about to test it but it requested access to my google account, is it 
> expected?
>
>
The Google account login activates if you register with an active google 
user session. For now you can avoid the extra authentication by closing 
your google user session before registration. Anyway, clicking the "... 
google account" gives you normal access to the app too.
 

-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Anthony
On Wednesday, September 12, 2012 12:35:41 PM UTC-4, Massimo Di Pierro wrote:
>
> Instead of this
>
> maxID=db(db.node).select(db.node.id.max()).first()['MAX(node.id)']
>
> I would do
>
> maxID=db(db.node).select(db.node.id.max()).first()[db.node.id.max()]
>

Well, that's what I really recommended: 
https://groups.google.com/d/msg/web2py/VY71mF2cl-4/oNE00OduXQ0J. :-)
 

-- 





Re: [web2py] Happy Programmers' Day

2012-09-12 Thread Martín Mulone
+1

2012/9/12 Massimo Di Pierro 

> https://en.wikipedia.org/wiki/Programmers'_Day
>
> --
>
>
>
>



-- 
http://martinmulone.com.ar

-- 





Re: [web2py] Removing labels from forms

2012-09-12 Thread Richard Vézina
I will try, but Bruno's code was :

for input in form.elements("input[type='text']"):
input["_placeholder"] = placeholders.get(input["_name"], "")

And it didn't catch anything...

input[] return all the input...

Anyway, I try and I report.

Richard

On Wed, Sep 12, 2012 at 1:11 AM, Anthony  wrote:

> The proper code I come up with :
>>
>> {{{
>> for input_elem in form.elements("input[]"):
>> if input_elem.attributes['_type']**=='text':
>> input_elem["_placeholder"] = YOURPLACEHOLDERTEXT
>> }}}
>>
>>
> Why not just form.elements('input[type=text]') or form.elements('input',
> _type='text')?
>
> Anthony
>
> --
>
>
>
>

-- 





Re: [web2py] Happy Programmers' Day

2012-09-12 Thread Richard Vézina
+1

On Wed, Sep 12, 2012 at 1:10 PM, Martín Mulone wrote:

> +1
>
> 2012/9/12 Massimo Di Pierro 
>
>> https://en.wikipedia.org/wiki/Programmers'_Day
>>
>> --
>>
>>
>>
>>
>
>
>
> --
> http://martinmulone.com.ar
>
> --
>
>
>
>

-- 





Re: [web2py] Removing labels from forms

2012-09-12 Thread Anthony
It should be 'input[type=text]' instead of "input[type='text']" (i.e., no 
quotes around "text" when using that syntax).

Anthony

On Wednesday, September 12, 2012 1:59:57 PM UTC-4, Richard wrote:
>
> I will try, but Bruno's code was : 
>
> for input in form.elements("input[type='text']"):
> input["_placeholder"] = placeholders.get(input["_name"], "")
>
> And it didn't catch anything...
>
> input[] return all the input...
>
> Anyway, I try and I report.
>
> Richard
>
> On Wed, Sep 12, 2012 at 1:11 AM, Anthony  >wrote:
>
>> The proper code I come up with :
>>>
>>> {{{
>>> for input_elem in form.elements("input[]"):
>>> if input_elem.attributes['_type']**=='text':
>>> input_elem["_placeholder"] = YOURPLACEHOLDERTEXT
>>> }}}
>>>
>>>
>> Why not just form.elements('input[type=text]') or form.elements('input', 
>> _type='text')?
>>
>> Anthony
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] How to modify the Multi Select Form in SQLFORM

2012-09-12 Thread A E
I have defined three tables

db.define_table('category_cat',
Field('userinfo',db.auth_user,default=auth.user_id,
writable=False,readable=False),
Field('name', requires=IS_NOT_EMPTY()))

db.define_table('category',
Field('userinfo',db.auth_user,default=auth.user_id,
writable=False,readable=False),
Field('category_cat',db.category_cat,requires=IS_IN_DB(db,
db.category_cat.id,'%(name)s')),
Field('name', label='Sub Category', requires=IS_NOT_EMPTY()),
Field('description', 'text'))

db.define_table('listing',
Field('userinfo',db.auth_user,default=auth.user_id,
writable=False,readable=False),
Field('category', db.category, label='Category * ~can select
multiple~', requires=IS_IN_DB(db,db.category.id,'%(name)s',multiple=True)),


I would like to display the category_cat entries in the Multi Select Form
Field (for the listings table) make them unselectable and group the
category entries under each one is this even possible? If so how can I
achieve this result

So for example in the Multi Select Form (listing table) I would like to have

category_cat 1 (not selectable)
   category 1
   category 2
category_cat 2 (not selectable)
   category 3
   category 4

but displaying the name value :-)

I hope I made sense and some one can help me :-)

Thank you

-- 





[web2py] Re: How to display Users who are not admins

2012-09-12 Thread Frederick Yankowski
I haven't noticed the _select() nested-select method before.  Interesting.


On Tuesday, September 11, 2012 4:45:04 PM UTC-5, Massimo Di Pierro wrote:
>
> rows = 
> db(~db.auth_user.id.belongs(db(db.auth_membership.group_id==auth.id_group('admins'))._select(db.auth_membership.user_id,distinct=True))).select(db.auth_user.ALL)
>
>>
>>

-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Niphlod
ps: methods are NOT equivalent. They are if you have "continous" ids. 
But, e.g., you remove some rows. You end up with 
1,2,3,4,5,6,7,8,9,10,11,13,15,17,20.
Second method (i.e. calc max and go back by ten) leaves you with 
20,17,15,13,11,10 (and takes two queries)
First method (i.e. orderby + limitby) correctly returns 
20,17,15,13,11,10,9,8,7,6.

On Wednesday, September 12, 2012 7:09:39 PM UTC+2, Anthony wrote:
>
> On Wednesday, September 12, 2012 12:35:41 PM UTC-4, Massimo Di Pierro 
> wrote:
>>
>> Instead of this
>>
>> maxID=db(db.node).select(db.node.id.max()).first()['MAX(node.id)']
>>
>> I would do
>>
>> maxID=db(db.node).select(db.node.id.max()).first()[db.node.id.max()]
>>
>
> Well, that's what I really recommended: 
> https://groups.google.com/d/msg/web2py/VY71mF2cl-4/oNE00OduXQ0J. :-)
>  
>

-- 





[web2py] Re: Remember to delete examples application or become a spam farm

2012-09-12 Thread Frederick Yankowski
I had been removing the welcome and examples apps. They returned when I 
updated web2py to a new release so I created a routes.py that stubs off 
those apps.

routes_in = (
('/welcome/?$anything', '/nothing'),
('/examples/?$anything', '/nothing'),
)

I don't have a "nothing" app. :)

-- 





Re: [web2py] Re: web2py default layout.html

2012-09-12 Thread Kevin Miller
Thanks again Annet and all the others who took the time to respond to my
question.

On Wed, Sep 12, 2012 at 11:11 AM, Annet  wrote:

> @Massimo,
>
>
> aha! Thanks Annet, this fixes a long standing problem.
>
>
> Well, Anthony already mentioned the span12, I just provided my solution to
> the problem.
>
> @Dundee
>
> In an external style sheet I defined:
>
> .pad {padding: 18px;}
> .pad-hor {padding: 0px 18px;}
> .pad-vert {padding: 18px 0px;}
>
>
> I use these selectors in the following way:
>
>
> 
>   
> 
>  
>
> 
>
>
> Kind regards,
>
> Annet.
>
> --
>
>
>
>

-- 





[web2py] Re: How to modify the Multi Select Form in SQLFORM

2012-09-12 Thread A E
I did this which should suffice

If only I could display the name of the category_cat though :-?

Any ideas

 Field('category', db.category, requires=IS_IN_DB(db,db.category.id,'%(name)s
- %(category_cat)s',multiple=True)),





On Wed, Sep 12, 2012 at 11:29 AM, A E  wrote:

> I have defined three tables
>
> db.define_table('category_cat',
> Field('userinfo',db.auth_user,default=auth.user_id,
> writable=False,readable=False),
> Field('name', requires=IS_NOT_EMPTY()))
>
> db.define_table('category',
> Field('userinfo',db.auth_user,default=auth.user_id,
> writable=False,readable=False),
> Field('category_cat',db.category_cat,requires=IS_IN_DB(db,
> db.category_cat.id,'%(name)s')),
> Field('name', label='Sub Category', requires=IS_NOT_EMPTY()),
> Field('description', 'text'))
>
> db.define_table('listing',
> Field('userinfo',db.auth_user,default=auth.user_id,
> writable=False,readable=False),
> Field('category', db.category, label='Category * ~can select
> multiple~', requires=IS_IN_DB(db,db.category.id
> ,'%(name)s',multiple=True)),
>
>
> I would like to display the category_cat entries in the Multi Select Form
> Field (for the listings table) make them unselectable and group the
> category entries under each one is this even possible? If so how can I
> achieve this result
>
> So for example in the Multi Select Form (listing table) I would like to
> have
>
> category_cat 1 (not selectable)
>category 1
>category 2
> category_cat 2 (not selectable)
>category 3
>category 4
>
> but displaying the name value :-)
>
> I hope I made sense and some one can help me :-)
>
> Thank you
>
>
>

-- 





[web2py] DAL format and represent outside of SQLFORM

2012-09-12 Thread Jim S
Given the following tables:

formulaImport = db.define_table('formulaImport', 
 Field('formulaImportId', 'id', readable=False),
 Field('fileName', length=256, required=True, label='File'),
 Field('sweptOn', 'date', required=True, label='Swept', 
 default=datetime.datetime.today()),
 Field('importedOn', 'date', label='Imported'),
 Field('brillPlant', length=5, required=True, label='Plant'),
 Field('productNumber', length=30, required=True, 
 label='Product'),
 Field('productName', length=75, required=True, 
 label='Name'),
 format = '%(productNumber)s')
formulaImport._plural = 'Formula Imports'

formulaImport.fileName.requires = IS_NOT_EMPTY()
formulaImport.brillPlant.requires = IS_NOT_EMPTY()
formulaImport.sweptOn.requires = IS_DATE('%m/%d/%Y')
formulaImport.productNumber.requires = IS_NOT_EMPTY()
formulaImport.productName.requires = IS_NOT_EMPTY()
formulaImport.importedOn.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))

formulaImportLine = db.define_table('formulaImportLine',
 Field('formulaImportLineId', 'id', readable=False),
 Field('formulaImportId', db.formulaImport, required=True,
 label='Formula Import'),
 Field('sequence', 'integer', required=True),
 Field('productNumber', length=30, required=True, label='Product Number'),
 Field('quantity', 'decimal(13,5)', required=True),
 format=('%(productNumber)s'))
formulaImportLine.formulaImportId.required = IS_IN_DB(db, db.formulaImport,
 '$(fileName)s',
 '.choose.')
formulaImportLine.sequence.requires = [IS_INT_IN_RANGE(0,999), 
 IS_NOT_EMPTY()]
formulaImportLine.productNumber.requires = IS_NOT_EMPTY()
formulaImportLine.quantity.requires = [IS_FLOAT_IN_RANGE(0,2000), 
 IS_NOT_EMPTY()]
db.formulaImportLine.formulaImportId.represent = lambda p, r: r.
productNumber


Given a specific formulaImportLine I want to be able to display the 
associate formulaLine.productNumber.

Running this code:
for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
 print x.formulaImportId.represent()

...I get the following traceback:

Traceback (most recent call last):
 File "C:\dev\miscellaneous\playground\dalOutside.py", line 26, in 
 print x.formulaImportId.represent()
TypeError: 'NoneType' object is not callable

Is there a way for me to reference a 'parent' record and display either for 
'format' for the table or the 'represent' for the specific field?


-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Anthony
Yes, the "max" solution was originally for a different problem that only 
needed the single max value and involved only one query. In this case, the 
orderby/limitby solution is the way to go.

Anthony

On Wednesday, September 12, 2012 2:36:37 PM UTC-4, Niphlod wrote:
>
> ps: methods are NOT equivalent. They are if you have "continous" ids. 
> But, e.g., you remove some rows. You end up with 
> 1,2,3,4,5,6,7,8,9,10,11,13,15,17,20.
> Second method (i.e. calc max and go back by ten) leaves you with 
> 20,17,15,13,11,10 (and takes two queries)
> First method (i.e. orderby + limitby) correctly returns 
> 20,17,15,13,11,10,9,8,7,6.
>
> On Wednesday, September 12, 2012 7:09:39 PM UTC+2, Anthony wrote:
>>
>> On Wednesday, September 12, 2012 12:35:41 PM UTC-4, Massimo Di Pierro 
>> wrote:
>>>
>>> Instead of this
>>>
>>> maxID=db(db.node).select(db.node.id.max()).first()['MAX(node.id)']
>>>
>>> I would do
>>>
>>> maxID=db(db.node).select(db.node.id.max()).first()[db.node.id.max()]
>>>
>>
>> Well, that's what I really recommended: 
>> https://groups.google.com/d/msg/web2py/VY71mF2cl-4/oNE00OduXQ0J. :-)
>>  
>>
>

-- 





[web2py] Re: How to display Users who are not admins

2012-09-12 Thread Anthony
On Wednesday, September 12, 2012 2:34:28 PM UTC-4, Frederick Yankowski 
wrote:
>
> I haven't noticed the _select() nested-select method before.  Interesting.


http://web2py.com/books/default/chapter/29/06#belongs

-- 





[web2py] Re: DAL format and represent outside of SQLFORM

2012-09-12 Thread Massimo Di Pierro
Given your model you can do:

for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
 print db.formulaImportLine.formulaImportId.represent(x.formulaImportLineId)

or more simply

for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
 print x.productNumber

On Wednesday, 12 September 2012 14:10:50 UTC-5, Jim S wrote:
>
> Given the following tables:
>
> formulaImport = db.define_table('formulaImport', 
>  Field('formulaImportId', 'id', readable=False),
>  Field('fileName', length=256, required=True, label='File'),
>  Field('sweptOn', 'date', required=True, label='Swept', 
>  default=datetime.datetime.today()),
>  Field('importedOn', 'date', label='Imported'),
>  Field('brillPlant', length=5, required=True, label='Plant'),
>  Field('productNumber', length=30, required=True, 
>  label='Product'),
>  Field('productName', length=75, required=True, 
>  label='Name'),
>  format = '%(productNumber)s')
> formulaImport._plural = 'Formula Imports'
>
> formulaImport.fileName.requires = IS_NOT_EMPTY()
> formulaImport.brillPlant.requires = IS_NOT_EMPTY()
> formulaImport.sweptOn.requires = IS_DATE('%m/%d/%Y')
> formulaImport.productNumber.requires = IS_NOT_EMPTY()
> formulaImport.productName.requires = IS_NOT_EMPTY()
> formulaImport.importedOn.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
>
> formulaImportLine = db.define_table('formulaImportLine',
>  Field('formulaImportLineId', 'id', readable=False),
>  Field('formulaImportId', db.formulaImport, required=True,
>  label='Formula Import'),
>  Field('sequence', 'integer', required=True),
>  Field('productNumber', length=30, required=True, label='Product Number'),
>  Field('quantity', 'decimal(13,5)', required=True),
>  format=('%(productNumber)s'))
> formulaImportLine.formulaImportId.required = IS_IN_DB(db, db.formulaImport
> ,
>  '$(fileName)s',
>  '.choose.')
> formulaImportLine.sequence.requires = [IS_INT_IN_RANGE(0,999), 
>  IS_NOT_EMPTY()]
> formulaImportLine.productNumber.requires = IS_NOT_EMPTY()
> formulaImportLine.quantity.requires = [IS_FLOAT_IN_RANGE(0,2000), 
>  IS_NOT_EMPTY()]
> db.formulaImportLine.formulaImportId.represent = lambda p, r: r.
> productNumber
>
>
> Given a specific formulaImportLine I want to be able to display the 
> associate formulaLine.productNumber.
>
> Running this code:
> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
>  print x.formulaImportId.represent()
>
> ...I get the following traceback:
>
> Traceback (most recent call last):
>  File "C:\dev\miscellaneous\playground\dalOutside.py", line 26, in 
> 
>  print x.formulaImportId.represent()
> TypeError: 'NoneType' object is not callable
>
> Is there a way for me to reference a 'parent' record and display either 
> for 'format' for the table or the 'represent' for the specific field?
>
>
>

-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Massimo Di Pierro
On a second look this assumes that no record was deleted. It does not 
always select the last 10 records.

On Wednesday, 12 September 2012 11:29:04 UTC-5, Annet wrote:
>
> Hi Vladimir,
>
> Some time ago Anthony provided me with the following solution:
>
> maxID=db(db.node).select(db.node.id.max()).first()['MAX(node.id)']
> rows=db(db.node.id>=maxID-10).select(db.node.id
> ,db.node.computedName,orderby=~db.node.id)
>
>
> Kind regards,
>
> Annet
>

-- 





[web2py] Re: DAL format and represent outside of SQLFORM

2012-09-12 Thread Jim S
Massimo

Thanks for the reply.  Yes, I know I can do it the second way, I'm trying 
to a generic function working that will work with any field with the 
represent value set.  When I try the first suggestion I get the following:

Traceback (most recent call last):
 File "C:\dev\miscellaneous\playground\dalOutside.py", line 28, in 
 print db.formulaImportLine.formulaImportId.represent(x.formulaImportLineId)
TypeError: () takes exactly 2 arguments (1 given)

I'm kinda lost here now...

-Jim

On Wednesday, September 12, 2012 3:02:44 PM UTC-5, Massimo Di Pierro wrote:
>
> Given your model you can do:
>
> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
>  print db.formulaImportLine.formulaImportId.represent(x.formul
> aImportLineId)
>
> or more simply
>
> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
>  print x.productNumber
>
> On Wednesday, 12 September 2012 14:10:50 UTC-5, Jim S wrote:
>>
>> Given the following tables:
>>
>> formulaImport = db.define_table('formulaImport', 
>>  Field('formulaImportId', 'id', readable=False),
>>  Field('fileName', length=256, required=True, label='File'),
>>  Field('sweptOn', 'date', required=True, label='Swept', 
>>  default=datetime.datetime.today()),
>>  Field('importedOn', 'date', label='Imported'),
>>  Field('brillPlant', length=5, required=True, label='Plant'),
>>  Field('productNumber', length=30, required=True, 
>>  label='Product'),
>>  Field('productName', length=75, required=True, 
>>  label='Name'),
>>  format = '%(productNumber)s')
>> formulaImport._plural = 'Formula Imports'
>>
>> formulaImport.fileName.requires = IS_NOT_EMPTY()
>> formulaImport.brillPlant.requires = IS_NOT_EMPTY()
>> formulaImport.sweptOn.requires = IS_DATE('%m/%d/%Y')
>> formulaImport.productNumber.requires = IS_NOT_EMPTY()
>> formulaImport.productName.requires = IS_NOT_EMPTY()
>> formulaImport.importedOn.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
>>
>> formulaImportLine = db.define_table('formulaImportLine',
>>  Field('formulaImportLineId', 'id', readable=False),
>>  Field('formulaImportId', db.formulaImport, required=True,
>>  label='Formula Import'),
>>  Field('sequence', 'integer', required=True),
>>  Field('productNumber', length=30, required=True, label='Product Number'
>> ),
>>  Field('quantity', 'decimal(13,5)', required=True),
>>  format=('%(productNumber)s'))
>> formulaImportLine.formulaImportId.required = IS_IN_DB(db, db.
>> formulaImport,
>>  '$(fileName)s',
>>  '.choose.')
>> formulaImportLine.sequence.requires = [IS_INT_IN_RANGE(0,999), 
>>  IS_NOT_EMPTY()]
>> formulaImportLine.productNumber.requires = IS_NOT_EMPTY()
>> formulaImportLine.quantity.requires = [IS_FLOAT_IN_RANGE(0,2000), 
>>  IS_NOT_EMPTY()]
>> db.formulaImportLine.formulaImportId.represent = lambda p, r: r.
>> productNumber
>>
>>
>> Given a specific formulaImportLine I want to be able to display the 
>> associate formulaLine.productNumber.
>>
>> Running this code:
>> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
>>  print x.formulaImportId.represent()
>>
>> ...I get the following traceback:
>>
>> Traceback (most recent call last):
>>  File "C:\dev\miscellaneous\playground\dalOutside.py", line 26, in 
>> 
>>  print x.formulaImportId.represent()
>> TypeError: 'NoneType' object is not callable
>>
>> Is there a way for me to reference a 'parent' record and display either 
>> for 'format' for the table or the 'represent' for the specific field?
>>
>>
>>

-- 





[web2py] Re: DAL format and represent outside of SQLFORM

2012-09-12 Thread Massimo Di Pierro
My bad.

print db.formulaImportLine.formulaImportId.represent(x.formulaImportLineId,x
)

because you have:

... represent = lambda p, r: ...

Here p is the value of the db.formulaImportLine.formulaImportId and r is 
the row.


On Wednesday, 12 September 2012 15:59:02 UTC-5, Jim S wrote:
>
> Massimo
>
> Thanks for the reply.  Yes, I know I can do it the second way, I'm trying 
> to a generic function working that will work with any field with the 
> represent value set.  When I try the first suggestion I get the following:
>
> Traceback (most recent call last):
>  File "C:\dev\miscellaneous\playground\dalOutside.py", line 28, in 
> 
>  print db.formulaImportLine.formulaImportId.represent(x.
> formulaImportLineId)
> TypeError: () takes exactly 2 arguments (1 given)
>
> I'm kinda lost here now...
>
> -Jim
>
> On Wednesday, September 12, 2012 3:02:44 PM UTC-5, Massimo Di Pierro wrote:
>>
>> Given your model you can do:
>>
>> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
>>  print db.formulaImportLine.formulaImportId.represent(x.formul
>> aImportLineId)
>>
>> or more simply
>>
>> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
>>  print x.productNumber
>>
>> On Wednesday, 12 September 2012 14:10:50 UTC-5, Jim S wrote:
>>>
>>> Given the following tables:
>>>
>>> formulaImport = db.define_table('formulaImport', 
>>>  Field('formulaImportId', 'id', readable=False),
>>>  Field('fileName', length=256, required=True, label='File'),
>>>  Field('sweptOn', 'date', required=True, label='Swept', 
>>>  default=datetime.datetime.today()),
>>>  Field('importedOn', 'date', label='Imported'),
>>>  Field('brillPlant', length=5, required=True, label='Plant'),
>>>  Field('productNumber', length=30, required=True, 
>>>  label='Product'),
>>>  Field('productName', length=75, required=True, 
>>>  label='Name'),
>>>  format = '%(productNumber)s')
>>> formulaImport._plural = 'Formula Imports'
>>>
>>> formulaImport.fileName.requires = IS_NOT_EMPTY()
>>> formulaImport.brillPlant.requires = IS_NOT_EMPTY()
>>> formulaImport.sweptOn.requires = IS_DATE('%m/%d/%Y')
>>> formulaImport.productNumber.requires = IS_NOT_EMPTY()
>>> formulaImport.productName.requires = IS_NOT_EMPTY()
>>> formulaImport.importedOn.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
>>>
>>> formulaImportLine = db.define_table('formulaImportLine',
>>>  Field('formulaImportLineId', 'id', readable=False),
>>>  Field('formulaImportId', db.formulaImport, required=True,
>>>  label='Formula Import'),
>>>  Field('sequence', 'integer', required=True),
>>>  Field('productNumber', length=30, required=True, label='Product Number'
>>> ),
>>>  Field('quantity', 'decimal(13,5)', required=True),
>>>  format=('%(productNumber)s'))
>>> formulaImportLine.formulaImportId.required = IS_IN_DB(db, db.
>>> formulaImport,
>>>  '$(fileName)s',
>>>  '.choose.')
>>> formulaImportLine.sequence.requires = [IS_INT_IN_RANGE(0,999), 
>>>  IS_NOT_EMPTY()]
>>> formulaImportLine.productNumber.requires = IS_NOT_EMPTY()
>>> formulaImportLine.quantity.requires = [IS_FLOAT_IN_RANGE(0,2000), 
>>>  IS_NOT_EMPTY()]
>>> db.formulaImportLine.formulaImportId.represent = lambda p, r: r.
>>> productNumber
>>>
>>>
>>> Given a specific formulaImportLine I want to be able to display the 
>>> associate formulaLine.productNumber.
>>>
>>> Running this code:
>>> for x in db(db.formulaImportLine.formulaImportLineId==63901).select():
>>>  print x.formulaImportId.represent()
>>>
>>> ...I get the following traceback:
>>>
>>> Traceback (most recent call last):
>>>  File "C:\dev\miscellaneous\playground\dalOutside.py", line 26, in 
>>> 
>>>  print x.formulaImportId.represent()
>>> TypeError: 'NoneType' object is not callable
>>>
>>> Is there a way for me to reference a 'parent' record and display either 
>>> for 'format' for the table or the 'represent' for the specific field?
>>>
>>>
>>>

-- 





[web2py] comprehensive cheetsheet

2012-09-12 Thread Massimo Di Pierro
Assembled this for myself perhaps can be useful to others:
https://dl.dropbox.com/u/18065445/Tmp/cheetsheets.pdf

-- 





Re: [web2py] Modelless app no longer works with web2py 2.0.x ???

2012-09-12 Thread BlueShadow
So if I understand you correctly you lighten the server load and get 
quicker sites when you add change db=DAL(...) to 
db=DAL(...,lazy_tables=True)
I like the everything gets better option :)

On Monday, September 10, 2012 3:15:32 AM UTC+2, rochacbruno wrote:
>
> On Sun, Sep 9, 2012 at 9:27 PM, Andrew W 
> > wrote:
>
>> (although I still don't quite really understand what a lazy table is).
>
>
> imagine you have
>
> models/db.py
>
> db = DAL(...)
> db.define_table("table1".)
> db.define_table("table2".)
> ...
> ...
> db.define_table("table30".)
>
> So, for each request (I mean every time user hits an url or click on 
> something) all that 30 tables will be imeddiatelly instantiated even if the 
> requested page does not need to all the 30 tables.
>
> The process of table definition involves some logic such as instantiate a 
> new Table object, check all the fields, do migrations, check reserved 
> keywords, check the tablename atc...
>
> Now if you turn
>
> db = DAL(... lazy_tables=True)
>
> for each request web2py will just store some data in a dictionary 
> {"tablename": {"fields": ., "options":}, no table will be 
> instantiated ultil needed.
>
> So when in your program you do 
>
> db(db.table1),select() # in this time web2py will fire the table 
> instantiation and all the process, so it will happen only for the table you 
> need and you saved 29.
>
> Thats it.  
>
>
>

-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Niphlod
@anthony, massimo: I surely trust that you know what are you doing.
My reply was only a specification for "future references" as the title of 
the post could be found by some users and may come handy.

-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Anthony
Yes, I'm glad you pointed it out.

On Wednesday, September 12, 2012 5:44:58 PM UTC-4, Niphlod wrote:
>
> @anthony, massimo: I surely trust that you know what are you doing.
> My reply was only a specification for "future references" as the title of 
> the post could be found by some users and may come handy.
>
>

-- 





[web2py] Bug? crud.settings.auth NOT set. Forces login and all crud urls yield insuficient priveleges message

2012-09-12 Thread JoeCodeswell
Dear web2py Group,

I am running 2.0.8 on win xp.
I created a new simple app named forms.
I added some tables to models/db.py
I added the following lines to controllers/default.py
from gluon.tools import Crud
crud = Crud(db)

def data(): return dict(form=crud())

When I navigate to http://127.0.0.1:8000/forms/default/data/tables
A. I was forced to login which i didn't expect.
B. Once logged in, i got sent to 
http://127.0.0.1:8000/forms/default/user/not_authorized

I searched the entire applications/forms subdirectory structure for files 
containing "crud.settings.auth". I got "no results to display". As i read 
the book 
[http://web2py.com/books/default/chapter/29/9#Authorization-and-CRUD], 
 crud.settings.auth must be set to auth to make this behavior happen. Am i 
misinterpreting the book or is this a bug?

Thanks for the help.

Love and peace,

Joe

-- 





[web2py] Re: comprehensive cheetsheet

2012-09-12 Thread Andrew W
Thankyou, an excellent resource.

If I could suggest one more, and I'd be happy to attempt this.   I don't 
know about others, but before I can make any sense of a page's layout and 
what other people are saying about css ids and classes (this happened with 
the menu bar), is that I have to draw a picture of the page's box model 
with all the elements and selectors, particularly with nested elements.  
It's only then that I can make sense of comments around margin/padding/etc 
and what impact it might have.   Maybe more experienced designers don't 
need this.

Would this help for the Welcome App's layout, and use of bootstrap 
selectors,  and web2py specific selectors (forms ?).

   



On Thursday, September 13, 2012 9:29:46 AM UTC+12, Massimo Di Pierro wrote:
>
> Assembled this for myself perhaps can be useful to others:
> https://dl.dropbox.com/u/18065445/Tmp/cheetsheets.pdf
>

-- 





[web2py] Redis: RedisCache error

2012-09-12 Thread devrunner
Any idea guys what's the problem in this error:

>>> from gluon.contrib.redis_cache import RedisCache
>>> cache.redis = RedisCache('localhost:6379', db=None, debug=True)
Traceback (most recent call last):
  File "", line 1, in 
  File "gluon/contrib/redis_cache.py", line 39, in RedisCache
RedisCache.redis_instance = RedisClient(*args, **vars)
  File "gluon/contrib/redis_cache.py", line 55, in __init__
self.request = current.request
AttributeError: 'thread._local' object has no attribute 'request'


-- 





[web2py] Howto? Host 2 or more applications in a single web2py folder to google app engine

2012-09-12 Thread Pystar
I have one web2py installation on my system containing 2 applications. I 
want to upload both to google app engine. How do I specify that in the 
app.yaml file? is it even legal? or are there some pitfalls I have to look 
out for?

-- 





[web2py] Re: How to select only 10 last rows in a table?

2012-09-12 Thread Vladimir Makarov
Thank you all for your hints!!!
The easiest way, of course, is to use *orderby *and *limitby*. It works 
fine.
But the MAX method is usefull too. I'll use it in my projects.


On Wednesday, September 12, 2012 5:09:07 PM UTC+4, Vladimir Makarov wrote:
>
> So, I need to select data from the table but the only ten last rows (with 
> highest id).
> I have already tried with select all records and then use while statement 
> but I think there is another way.
> Any ideas? Thanks!
>

-- 





Re: [web2py] Re: internal error crash with newest 2.0.6 and old 1.99.2

2012-09-12 Thread lucas
it took a while to figure this out, but with the postgres repository that i 
am using for 9.1, the python-psycopg2 rpm that is installed on my system is 
from the pgdg91 repository.  so i would have to conclude that the psycopg2 
driver from that repository is for postgresql-9.1 and not the centos 
6.x/postgres-8.4.  so hopefully that is sound logic now.

-- 





[web2py] Is there an easy way to do this?

2012-09-12 Thread lyn2py
I am writing an app where the user can make some settings. 

So I create a configuration table like so:
Field('key'),
Field('value')
Field('label'),
Field('requires'),
Where each db entry is a setting or configuration. 

I would like to create a form whereby the User can view all the different 
settings and edit the 'value' field of each setting. 

Is there a way to create this form easily in web2py or is it better to create 1 
table with many columns but have only 1 db entry?

Also, how will performance differ if I used either table format? Thank you!

-- 





[web2py] Re: Timezone

2012-09-12 Thread Peter Etchells
You could try the following (not tested!), which defines custom validators 
for date and datetime that convert the date/time data entered by a user to 
UTC, assuming the time offset is known. In the validator below, this offset 
is session.tz_offset. the validator should convert the input datetime to 
UTC, and convert back to the user's local time when displayed. The time 
offset should ideally come from the user browser session.

usage is:

define_table('mytable',
..
 Field('updated_on', 'datetime', requires=IS_DATETIME_UTC, ...),
)

code:
import time
class IS_DATETIME_UTC(object):
def __init__(self, format='%Y-%m-%d %H:%M:%S', error_message='invalid 
datetime format - must be -MM-DD HH:MM:SS!'):
self.format = format
self.error_message = error_message
def __call__(self, value):
try:
y, m, d, hh, mm, ss, t0, t1, t2 = time.strptime(value, 
str(self.format))
value = datetime.datetime(y, m, d, hh,mm)-session.tz_offset 
#subtract offset here
return (value, None)
except:
return (value, self.error_message)
def formatter(self, value):
return (value+session.tz_offset).strftime('%Y-%m-%d %H:%M') #add 
offset here


class IS_DATE_UTC(object):
def __init__(self, format='%Y-%m-%d', error_message='invalid date 
format - must be -MM-DD!'):
self.format = format
self.error_message = error_message
def __call__(self, value):
try:
y, m, d, hh, mm, ss, t0, t1, t2 = time.strptime(value, 
str(self.format))
value = (datetime.datetime(y, m, d, 
hh,mm)-session.tz_offset).date() #subtract offset here
return (value, None)
except:
return (value, self.error_message)
def formatter(self, value):
return (value+session.tz_offset).strftime('%Y-%m-%d') #add offset 
here

--