[web2py] Re: fake_migration issues

2021-02-12 Thread Dave S

On Sunday, January 31, 2021 at 3:58:21 PM UTC-8 Dave S wrote:

> On Saturday, January 30, 2021 at 3:32:13 PM UTC-8 valq...@gmail.com wrote:
>
>> try to compare db.py from  "fresh" welcome-app with your app. I have had 
>> a migration problem due to imports changes 
>>
>>
> Thanks!  This wasn't the issue, but you got me looking in the right place 
> ... I had missed migrate_enabled.
>
> There's some followup details for when I have time at the keyboard.
>
>
Briefly, I still get an exception but I think I understand why:   sql.log 
shows that the migration lower-cased all field names, which seems to be 
alright with sqlite, but doesn't seem to do that when I use the field in 
SQLTABLE.   This seems to be a broken backwards compatibility issue; I 
don't remember seeing this in the release notes.

/dps

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/ff14c48e-a76c-46f2-845f-abf4227257b6n%40googlegroups.com.


[web2py] auth.signature not working

2021-02-12 Thread António Ramos
hello this is my model
db.define_table(
'entities',
Field('uuid', length=64, default=lambda: str(uuid.uuid4())),
Field('entity', 'string',length=70,required=True, label=T("Entity")),
Field('description', length=100,label=T("Description"), default=""),
Field('status', db.status),
Field('type', 'reference dbentities', label=T("Type")),
Field('sub_type', "reference subtypes", label=T("Type")),
Field('event','string',length=10),
Field('trailevent', 'list:integer'),
Field("last_error", default=""),
Field('extrareaders', 'list:reference auth_user'),
Field('extrafield', db.extrafields, requires=IS_EMPTY_OR(
IS_IN_DB(db, 'extrafields.id', '%(extrafield)s'))),
Field('relatedto', 'reference entities', requires=IS_EMPTY_OR(
IS_IN_DB(db, 'entities.id', '%(entity)s'))),
Field('file', 'upload', label="Ficheiro"),
Field('valstart', 'date', label="Válido de",
  default=datetime.datetime.utcnow()),
Field('valend', 'date', label="Válido até",
  default=datetime.datetime.utcnow()),
Field('orderedat', 'float'),
Field('question','string'),
Field('qt','double'),
Field('units','string',length=5),
Field('readers', 'list:string', default=[""]),#friend uuid
Field('details','json'),
auth.signature,
format='%(type)s %(entity)s',
)


I have auth.signature but  this code

@request.restful()
def uploadInvoice():
import random
import string
response.view = 'generic.json'

def POST(*args, **kw):
try:
user = auth.login_bare("userxxx", "") # so it has a user
uploaded_file = kw['file']
filename =
 db.entities.file.store(uploaded_file, uploaded_file.filename)
id = db.entities.insert(
entity="Invoice",
type=db.dbentities(entity="Invoice")["id"],
status=DBTools().setStatus(db,"Draft", "Invoice"),
file=filename,
created_by=4, # even with this line it saves as None
modified_by=4, # even with this line it saves as None
description="")
if id:
eventid = db.events.insert(
event="Invoice", relatedto=id,  type="Document added",
receipts={},linktodoc=id
)
db.entities[id]=dict(event=eventid)
return "ok"

except Exception as e:
raise Exception('Error on line {}{}{}'.format(
sys.exc_info()[-1].tb_lineno, str(e), request.vars))
return locals()

does not fills the created_by and modified_by field. They have None

Any help ???
Regards

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAEM0BxORXNPK5%3DfkUsCsoqccqnC1RCJ-xNwSu4N%2BwwR5JYEuaQ%40mail.gmail.com.


[web2py] Programatically create Row

2021-02-12 Thread david...@gmail.com
I have a controller that displays confidential data from a table but want 
to be able to show the form publicly with some dummy data. The controller 
makes use of field representation and references so I basically need a Row.

I can create the object I need using the table.insert() methods and then 
db.rollback() to avoid committing the dummy data but is there a better 
method. I've had a look at the internals of Row and suspect that trying to 
create a Row object by hand would be pretty fraught, but is there a better 
way than just using insert() and rollback()? It feels like using a 
sledgehammer to crack a nut.

Cheers,
David

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/068a3914-7560-4edf-a4f1-2071d0fd9749n%40googlegroups.com.