[web2py] Record Versioning ON, result 'id'

2019-02-11 Thread Ben Lawrence
Hi
Using Python 3.7, anyone has Record Versioning working ok?
http://www.web2py.com/books/default/chapter/29/09/access-control?search=versioning#Record-versioning
Whenever I change a record under versioning, say with SQLFORM.grid(), I 
will get a key error 'id'
thanks for your time,
Ben

Traceback (most recent call last):
File "/home/www-data/web2py/gluon/restricted.py", line 219, in restricted
exec(ccode, environment)
File "/home/www-data/web2py/applications/timecard/controllers/admin.py" 
, line 154, 
in 
File "/home/www-data/web2py/gluon/globals.py", line 421, in 
self._caller = lambda f: f()
File "/home/www-data/web2py/gluon/tools.py", line 3867, in f
return action(*a, **b)
File "/home/www-data/web2py/applications/timecard/controllers/admin.py" 
, line 18, in 
co_accounts
,showbuttontext = False)
File "/home/www-data/web2py/gluon/sqlhtml.py", line 2594, in grid
next=referrer)
File "/home/www-data/web2py/gluon/html.py", line 2302, in process
self.validate(**kwargs)
File "/home/www-data/web2py/gluon/html.py", line 2240, in validate
if self.accepts(**kwargs):
File "/home/www-data/web2py/gluon/sqlhtml.py", line 1973, in accepts
self.id_field_name]).update(**fields)
File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 
2312, in update
if any(f(self, row) for f in table._before_update):
File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 
2312, in 
if any(f(self, row) for f in table._before_update):
File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 433, 
in 
archive_record(qset, fs, db[an], cn))
File "/home/www-data/web2py/gluon/packages/dal/pydal/helpers/methods.py", 
line 132, in archive_record
if fields[k] != v:
KeyError: 'id'


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


[web2py] Record Versioning not working for just one table (?)

2016-09-06 Thread 'maulynvia' via web2py-users
First of all, web2py rocks...I'm amazed how good it is :)

Record versioning is one of the great features and is working perfectly for 
me except for one table. Can anyone see what the problem might be? Thanks 
in advance.
Here is the definition of the table in question:

db.define_table('actions',


Field('priority',required=True,requires=IS_IN_SET(['10_Critical','20_High', 
'30_Medium', '40_Low']), default='30_Medium'),
Field('stage', required=True , 
requires=IS_IN_SET(['10_Backlog','20_Waiting',
'30_Challenged','35_Progressing','70_Done','80_Closed']), 
default='10_Backlog'),
Field('task', requires=IS_NOT_EMPTY() ),
Field('owned_by', db.auth_user, required=True ),
Field('other_contacts'),

Field('category', requires=IS_IN_SET(['PrjExc','OppEff','SalCol',
'DelAcc','HumCap','RevOpt','BusDev','LocStr']), 
default='PrjExc'),
Field('notes','text'),
Field('unit', required=True, requires=IS_IN_SET(['ENERGY','ET','FA', 
'MM', 'OTHER']) , default='OTHER'),
Field('project', db.project, required=True, default='_unknown'),
Field('next_action'),
Field('target_date','date'),
Field('effort', 
requires=IS_IN_SET(['5_vHi','4_Hi','3_Med','2_Lo','1_vLo']), 
default='3_Med'),
Field('impact', 
requires=IS_IN_SET(['9_vHi','7_Hi','5_Med','3_Lo','1_vLo']), 
default='5_Med'),
Field('effort_value',writable=False, compute=calc.impact_value),
Field('tag'),
Field('ext_id'),
Field('current_record','boolean', required=True , default=True),
auth.signature,
format = '%(task)s[:40]',
plural="ACTIONS"
)
...
auth.enable_record_versioning(db)

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


[web2py] Record versioning and list:xxxx field - KeyError on update if I only add a list:xxxx item

2016-01-17 Thread Miquel Fontanals
Hi,

I'm using web2py as a restful api, and model has record_versioning and 
auth.signature enabled.

db.define_table('article',
Field('title', 'string', length=1024, required=True, unique=True),
Field('slug', 'string', length=1024, required=True, unique=True),
Field('body', 'text', required=True),
Field('excerpt', 'text', required=True),
Field('categories', 'list:reference category', required=True),
Field('tags', 'list:reference tag', required=True),
Field('images', 'list:reference image'),
Field('description', 'text', required=True),
Field('keywords', 'list:string', required=True),
Field('is_active','boolean', writable=False, readable=False, default=
True),
auth.signature
, format='%(title)s')

db.article.categories.requires=IS_IN_DB(db, db.category.id, db.category.
_format, multiple=True)
db.article.tags.requires=IS_IN_DB(db, db.tag.id, db.tag._format, multiple=
True)
db.article.images.requires=IS_EMPTY_OR(IS_IN_DB(db, db.image.id, db.image.
_format, multiple=True))



db.article._enable_record_versioning()

And in my restful PUT method I'm updating record this way.

def PUT(table_name,record_id,**vars):
...
result = db(db[table_name]._id==record_id).update(**vars)
...



Its working well so far if I modify all fields, or if I modify one list:xxx 
field type plus any other "plain" field. However if I only add one item to 
any list: field types, for example adding new keyword to the list, the 
update crashes with the following exception:

Traceback (most recent call last):
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/applications/coders/controllers/api.py"
, line 79, in PUT
result = db(db[tbn]._id==record_id).update(**vars)
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/gluon/packages/dal/pydal/objects.py"
, line 2054, in update
if any(f(self,update_fields) for f in table._before_update):
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/gluon/packages/dal/pydal/objects.py"
, line 2054, in 
if any(f(self,update_fields) for f in table._before_update):
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/gluon/packages/dal/pydal/objects.py"
, line 393, in 
archive_record(qset, fs, db[an], cn))
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/gluon/packages/dal/pydal/helpers/methods.py"
, line 95, in archive_record
if fields[k] != v:
KeyError: 'id'



I don't know if it's a bug or if I'm doing something wrong or missed 
something, etc... Can you give me some light please?

Thank you! (and sorry for my english...)

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


[web2py] record versioning

2015-11-30 Thread Fabiano Almeida
Hi All!

I need create a report with record versioning. How to union table with
table_archive?

Thanks!

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


[web2py] record versioning on auth tables

2015-06-26 Thread 黄祥
hi,

just wondering about record versioning on auth tables, why the table auth 
events and auth cas don't have archives table when i use record versioning 
on auth tables?

thanks and best regards,
stifan

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


[web2py] Record versioning without duplicate archive records?

2014-08-12 Thread Jack Kuan
Hi,

just starting out with web2py. Given a table with record versioning 
enabled, I find that for every successful update operation a row will be 
inserted in the archive table.
I'm using update_or_insert(), is it possible to make web2py only copy an 
old row into the archive table when there's a difference between the old 
row and the new row?


Thanks
Jack

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


[web2py] record versioning and standalone DAL

2013-09-30 Thread JaapP
Hi,

i've build a (very small) standalone side project (so, running without 
Web2Py) that uses the Web2Py DAL, and all goes well.

Now i'm trying to enable record versioning. but this seems not to be 
working  (thread._local object has no attribute 'request')

Has anybody succeeded in using record versioning in a standalone project?

Any hints greatly appreciated!

Jaap

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


[web2py] Record versioning on delete CASCADE

2013-02-01 Thread Felipe Meirelles
The cascade feature should work for record versioning enabled tables?

Thanks.

-- 

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




[web2py] record versioning: what if tables are manually changed with migrate=False?

2013-01-15 Thread Rick Ree
Hi,

I would like to enable record versioning on an existing MySQL database in 
which all tables are managed manually (migrate=False). I am concerned about 
what happens if the structure of a table changes in db.define_table( ... ). 
Is the associated archive table changed to match accordingly?

thanks,
-Rick

-- 





[web2py] Record versioning

2012-10-23 Thread tomt
Hi,

I'm using auth.signature and db.my_table._enable_record_versioning()
to enable record versioning on a table.

db.define_table('mytable',
 Field('staffid','string'),
 Field('date','datetime',requires=IS_DATETIME(format='%Y-%m-%d 
%H:%M:%S'), default=request.now),
 Field('comment','string'),
 auth.signature 
)
db.mytable._enable_record_versioning()

This works great. I can delete or modify records and I have a full 
historical record in mytable_archive.

I can see all the details with the appadmin function, but I haven't 
been able to figure out how to display this info with SQLFORM.grid
I thought I could disable the common_filter with:
db.mytable._common_filter = None
but this didn't work.

Any pointers?

-- 





[web2py] Record versioning in web2py 2.0

2012-08-12 Thread apps in tables
Hi,

The feature of record versioning is very important to know the history of 
the record.

is it possible to go back and forward (in the history)?

is it possible to merge two histories of the same (logical data), and end 
up with one record ?

is it possible to have an offline application that will synch later, by 
merging the revisions?

Regards,

Ashraf


-- 





[web2py] Record Versioning

2012-01-31 Thread Johann Spies
The book describe record versioning in the Forms section (SQLFORM and Crud).

How can I get the same when updating/deleting records through queries that
do not use forms?

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


Re: [web2py] Record Versioning

2012-01-31 Thread Bruno Rocha
something like this http://www.web2pyslices.com/slices/take_slice/35

On Tue, Jan 31, 2012 at 10:31 AM, Johann Spies johann.sp...@gmail.comwrote:

 The book describe record versioning in the Forms section (SQLFORM and
 Crud).

 How can I get the same when updating/deleting records through queries that
 do not use forms?

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




-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Record Versioning

2011-12-17 Thread Ron McOuat
Might not be a problem but the table mpn has a field with the same name mpn and 
the problem goes away if the archive portion of onaccept is removed.


[web2py] Record Versioning

2011-12-16 Thread JF
Hi,
 
I'm trying the error versioning but I'm stuck with a curious error message 
and I don't see the link between what I did and this error.
 
A part of my Model goes like this:

db.define_table('item',
Field('ipn', 'string'),
Field('desc', 'string'))
 
db.define_table('business',
Field('name', 'string'))
 
db.define_table('mpn',
Field('iditm', db.item),
Field('idbsn', db.business),
Field('mpn', 'string'))
 
db.define_table('mpn_archive',
Field('current_record', db.mpn), db.mpn)
 
 
A part of my Controller goes like this:
 
 form = crud.update(db.mpn, thispage, onaccept=auth.archive, 
  next = URL(r=request, f='edit', args=request.args))

 
If I do remove the onaccept=auth.archive, everything works as expected, 
but if I keep it, I get the following error message:
 
type 'exceptions.ValueError'(invalid literal for int() with base 10: 
'2134-123456789-00')
 
 
This '2134-123456789-00' is from the field ipn in table item.  But I 
don't see why it is not considered as a string correctly.
 
Thanks,
 
JF


[web2py] Record Versioning findings

2010-10-29 Thread baloan
First of all, CRUD is the hell of a productivity tool. Some findings:

1. Definiton of the archive table like given in the book:

db.define_table('mytable_arcvhive',
   Field('current_record',db.mytable),
   db.mytable)

breaks deletion of records in db.mytable. The foreign key constraint
in db.mytable_archive prevents a deletion. Untested workaround
proposal:

db.define_table('mytable_arcvhive',
   Field('current_record', integer),
   db.mytable)

2. Any unique constraint on db.mytable breaks archiving on modifying
the record without changing the unique constraint column. Unique
constraints have to be manually removed from db.mytable_archive
currently. Any plans to automate?

3. In the documentation the archive table is defined like

db.define_table('mytable_history',
   Field('current_record',db.mytable),
   db.mytable)

while in the current version it is defined like

db.define_table('mytable_arcvhive',
   Field('current_record',db.mytable),
   db.mytable)

Just a typo correction needed in the documentation.

Regards, Andreas
balo...@gmail.com


[web2py] Record Versioning

2010-10-27 Thread baloan
I am trying to use versioning in an authenticated section of a
website. Instead of this:

db.define_table('my_table',
Field('saved_by',auth.user,
default=auth.user_id,update=auth.user_id,writable=False)

I was trying this:

db.define_table('my_table',
Field('saved_by','string',
default=auth.user.username,update=auth.user.username, writable=False)

Whenever I try to visit the website's home page  (as an
unauthenticated user) web2py chokes on the table definition in models/
db.py. See below for the traceback.

Any idea how to solve this?
Maybe I should use a decorator with the define_table statement?

Regards, Andreas
balo...@gmail.com

--

Error traceback

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



Traceback (most recent call last):
  File D:\Home\web\web2py\gluon\restricted.py, line 188, in
restricted
exec ccode in environment
  File D:/Home/web/web2py/applications/invest/models/db.py, line
159, in module
Field('change_user', 'string', default=auth.user.username,
update=auth.user.username, writable=False),
AttributeError: 'NoneType' object has no attribute 'username'

Error snapshot
Detailed traceback description

* Exception: type 'exceptions.AttributeError'('NoneType' object
has no attribute 'username')
  Exception instance attributes
  o args: ('NoneType' object has no attribute 'username',)
  o __setattr__: method-wrapper '__setattr__' of
exceptions.AttributeError object
  o __reduce_ex__: built-in method __reduce_ex__ of
exceptions.AttributeError object
  o __getslice__: method-wrapper '__getslice__' of
exceptions.AttributeError object
  o __getitem__: method-wrapper '__getitem__' of
exceptions.AttributeError object
  o __setstate__: built-in method __setstate__ of
exceptions.AttributeError object
  o __getattribute__: method-wrapper '__getattribute__' of
exceptions.AttributeError object
  o __str__: method-wrapper '__str__' of
exceptions.AttributeError object
  o __format__: built-in method __format__ of
exceptions.AttributeError object
  o __reduce__: built-in method __reduce__ of
exceptions.AttributeError object
  o __class__: type 'exceptions.AttributeError'
  o __dict__: {}
  o __delattr__: method-wrapper '__delattr__' of
exceptions.AttributeError object
  o __subclasshook__: built-in method __subclasshook__ of
type object
  o __repr__: method-wrapper '__repr__' of
exceptions.AttributeError object
  o __init__: method-wrapper '__init__' of
exceptions.AttributeError object
  o __hash__: method-wrapper '__hash__' of
exceptions.AttributeError object
  o __sizeof__: built-in method __sizeof__ of
exceptions.AttributeError object
  o __doc__: 'Attribute not found.'
  o __unicode__: built-in method __unicode__ of
exceptions.AttributeError object
  o __new__: built-in method __new__ of type object
* Python 2.6.5: C:\Program Files\Apache2.2\bin\httpd.exe

File D:\Home\web\web2py\gluon\restricted.py in restricted at line 188
[ code | arguments | variables ]
Function argument list: (code='# coding: utf8\n\nimport datetime as dt
\n\n#...ail),\n db.email)\n \n', environment={'A': class
'gluon.html.A', 'Auth': class 'gluon.tools.Auth', 'B': class
'gluon.html.B', 'BEAUTIFY': class 'gluon.html.BEAUTIFY', 'BODY':
class 'gluon.html.BODY', 'BR': class 'gluon.html.BR', 'CENTER':
class 'gluon.html.CENTER', 'CLEANUP': class
'gluon.validators.CLEANUP', 'CODE': class 'gluon.html.CODE',
'CRYPT': class 'gluon.validators.CRYPT', ...}, layer=r'D:\Home\web
\web2py\applications\invest/models/db.py')

183.
184.
185.
186.
187.
188.

189.
190.
191.
192.



if type(code) == types.CodeType:
ccode = code
else:
ccode = compile2(code,layer)

exec ccode in environment

except HTTP:
raise
except Exception:
# XXX Show exception in Wing IDE if running in debugger

* environment: {'A': class 'gluon.html.A', 'Auth': class
'gluon.tools.Auth', 'B': class 'gluon.html.B', 'BEAUTIFY': class
'gluon.html.BEAUTIFY', 'BODY': class 'gluon.html.BODY', 'BR':
class 'gluon.html.BR', 'CENTER': class 'gluon.html.CENTER',
'CLEANUP': class 'gluon.validators.CLEANUP', 'CODE': class
'gluon.html.CODE', 'CRYPT': class 'gluon.validators.CRYPT', ...}
* ccode: code object module at 03DB9BA8, file D:\Home...web2py
\applications\invest/models/db.py, line 3

File D:\Home\web\web2py\applications\invest\models\db.py in module
at line 159
[ code | arguments | variables ]
Function argument list: ()

154.
155.
156.
157.
158.
159.

160.
161.
162.
163.




db.define_table('email',
Field('email', 'string', length=40, notnull=False,
unique=True, represent=lambda s: s),
Field('active', 'boolean', default=True),
Field('expires', 'date', default=None,
represent=lambda s: s or 'Never'),