[web2py] About putting values into database

2020-08-21 Thread Andrea Fae'
Hello, I'm about 1 year that i don't program in web2py and I don't remember 
nothing!

So, easy question

I have this table (I created esplicitally the field is_active, created_on, 
created_by, do not ask me why...it's another question...)

db.define_table('ticket',
Field('asset', 'reference asset'),
Field('fisso', 'boolean'),
Field('anomalia', type='string', 
requires=[IS_NOT_EMPTY(),IS_LENGTH(200)], 
widget=SQLFORM.widgets.text.widget),
Field('chiuso', 'boolean'),
Field('risoluzione', type='string', 
requires=[IS_LENGTH(100)], widget=SQLFORM.widgets.text.widget, default='In 
attesa'),
Field('is_active', 'boolean', default=True),
Field('created_on', 'datetime', default=request.now),
Field('created_by', 'integer', default=auth.user_id),
Field('modified_on', 'datetime', update=request.now),
Field('modified_by', 'integer', update=auth.user_id),
singular="Ticket", plural="Ticket",migrate='ticket.table',
format='%(asset)s')


And I have this function

# crea il ticket per l'asset specificato
@auth.requires_login()
def ticket():
import datetime
# recupero l'asset di cui fare il ticket
asset = db.asset(request.args(0)) or redirect(URL('sedi'))

#verifico se l'asset è già oggetto di un ticket aperto - se lo è 
impedisco l'apertura del ticket
query = (db.ticket.asset == asset) & (db.ticket.chiuso == False)
row = db(query).select().first()
if (row != None):
session.flash = 'Esiste un ticket aperto per questo asset: non è 
possibile aprire un ulteriore ticket'
redirect(URL('index'))

db.ticket.created_by.readable=db.ticket.created_by.writable=True
db.ticket.created_on.readable=db.ticket.created_on.writable=True
db.ticket.asset.default=asset.id
db.ticket.asset.writable=db.ticket.asset.readable=False
db.ticket.fisso.default=True

db.ticket.chiuso.default=db.ticket.chiuso.readable=db.ticket.chiuso.writable=False
db.ticket.risoluzione.readable=db.ticket.risoluzione.writable=False
db.ticket.risoluzione.default="In attesa"
# db.ticket.is_active.default=True
# db.ticket.created_on.default=request.now
# recupero il tipo di asset del ticket
print request.now, auth.user_id
db.ticket.created_by.default = auth.user_id
db.ticket.created_on.default = request.now
tipo_asset = asset.tipo
# definisco la landing_page
landing_page = 'lista_ticket_asset/' + tipo_asset
# print landing_page
# se il form va a buon fine allora va a finire nella lista dei ticket 
aperti di quel tipo asset
form = crud.create(db.ticket, next=landing_page, onaccept=lambda 
form,asset=asset:send_email_ticket(form,asset), message='ticket creato')
# form = crud.create(db.ticket, next='lista_ticket',onaccept=lambda 
form,asset=asset:send_email_ticket(form,asset))
#form.add_button("Annulla",URL('sedi'))
# form[0][-1][1].append(TAG.BUTTON('Annulla', _class='btn btn-default', 
_type='Cancel',_onclick="document.location='%s';return false" % 
URL('lista_ticket_asset',args=tipo_asset)))
form[0][-1][1].append(TAG.BUTTON('Annulla', _class='btn btn-default', 
_type='Cancel',_onclick="document.location='%s';return false" % 
URL('index')))
db.ticket.chiuso.readable=db.ticket.chiuso.writable=True
db.ticket.risoluzione.readable=db.ticket.risoluzione.writable=True

return dict(form=form, asset=asset)

When I create a "ticket" I'm not able to put into fields created_by and 
created_on the right information

This is the result

1 selezionato
ticket.id 

ticket.asset 

ticket.fisso 

ticket.anomalia 

ticket.chiuso 

ticket.risoluzione 

ticket.is_active 

ticket.created_on 

ticket.created_by 

ticket.modified_on 

ticket.modified_by 

24  PC 
CNU411DJR3  
True ooo False In attesa False None 0 None 0





What is wrong? How to correct?
Thank  you

-- 
Resources:
- http://web2py.com
- http://web2py.com/book 

Re: [web2py] Re: How to debug "lost password"

2020-08-21 Thread Jim S
Hey Jon, I should have been more specific.  What I was looking for was the 
actual server and port you're accessing for the mail server.  Looks like it 
is stored in your config.  Is that mail server accessible from you 
workstation?  Can you telnet to it using the settings in the config file?

-Jim

On Friday, August 21, 2020 at 4:51:55 AM UTC-5, Jonsubs wrote:
>
> Hi everyone,
> Whe I run my web2py app locally (in my desktop in 127.0.0.1:8000) I get 
> the following message:
>
> '08/21/2020 11:48:56 AM' - web2py - WARNING - Mail.send failure:please run 
> connect() first
>
> What does it mean?
> Thanks, Jon.
>
> On Fri, Aug 21, 2020 at 11:45 AM Jon Subscripted  > wrote:
>
>> Hi Jim,
>> It looks like this (see below):
>>
>> # 
>> -
>> # configure email
>> # 
>> -
>> mail = auth.settings.mailer
>> mail.settings.server = configuration.get('smtp.server') #'logging' if 
>> request.is_local else configuration.get('smtp.server')
>> mail.settings.sender = configuration.get('smtp.sender')
>> mail.settings.login = configuration.get('smtp.login')
>> mail.settings.tls = configuration.get('smtp.tls') or False
>> mail.settings.ssl = configuration.get('smtp.ssl') or False
>>
>> Thanks, Jon.
>>
>> On Fri, Aug 21, 2020 at 1:56 AM Jim S > 
>> wrote:
>>
>>> What does your mail setup in db.py look like?
>>>
>>> -Jim
>>>
>>>
>>> On Thursday, August 20, 2020 at 9:47:11 AM UTC-5, Jonsubs wrote:

 Any suggestions on how to debug "password lost" email not being sent.
 Thanks, Jon.

 On Wed, Aug 19, 2020 at 7:49 PM Jon Subscripted  
 wrote:

> Hi everyone,
> I'm having some trouble sending "lost password" emails to my users. 
> Whenever I test it I get an "Unable to send email" message.
>
> But I do not really know the reason. I tried with a standalone python 
> script with the same configuration and it works.
>
> I'd like to know how to debug this problem or where to look at. 
>
> In which log are email related errors written?
> Regards, Jon.
>
> -- 
>>> 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 web...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/web2py/a61e3de4-f288-4968-9001-d21741f881f2o%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
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/d6644977-e184-4612-98e6-7556ef88e230o%40googlegroups.com.


Re: [web2py] Re: How to debug "lost password"

2020-08-21 Thread Jon Subscripted
Hi everyone,
Whe I run my web2py app locally (in my desktop in 127.0.0.1:8000) I get the
following message:

'08/21/2020 11:48:56 AM' - web2py - WARNING - Mail.send failure:please run
connect() first

What does it mean?
Thanks, Jon.

On Fri, Aug 21, 2020 at 11:45 AM Jon Subscripted 
wrote:

> Hi Jim,
> It looks like this (see below):
>
> # -
> # configure email
> # -
> mail = auth.settings.mailer
> mail.settings.server = configuration.get('smtp.server') #'logging' if
> request.is_local else configuration.get('smtp.server')
> mail.settings.sender = configuration.get('smtp.sender')
> mail.settings.login = configuration.get('smtp.login')
> mail.settings.tls = configuration.get('smtp.tls') or False
> mail.settings.ssl = configuration.get('smtp.ssl') or False
>
> Thanks, Jon.
>
> On Fri, Aug 21, 2020 at 1:56 AM Jim S  wrote:
>
>> What does your mail setup in db.py look like?
>>
>> -Jim
>>
>>
>> On Thursday, August 20, 2020 at 9:47:11 AM UTC-5, Jonsubs wrote:
>>>
>>> Any suggestions on how to debug "password lost" email not being sent.
>>> Thanks, Jon.
>>>
>>> On Wed, Aug 19, 2020 at 7:49 PM Jon Subscripted 
>>> wrote:
>>>
 Hi everyone,
 I'm having some trouble sending "lost password" emails to my users.
 Whenever I test it I get an "Unable to send email" message.

 But I do not really know the reason. I tried with a standalone python
 script with the same configuration and it works.

 I'd like to know how to debug this problem or where to look at.

 In which log are email related errors written?
 Regards, Jon.

 --
>> 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/a61e3de4-f288-4968-9001-d21741f881f2o%40googlegroups.com
>> 
>> .
>>
>

-- 
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/CAK8tz33D07eqgkDbQjfTbPnxCLWmYFvakP2gVGevx79-_vWPmQ%40mail.gmail.com.


Re: [web2py] Re: How to debug "lost password"

2020-08-21 Thread Jon Subscripted
Hi Jim,
It looks like this (see below):

# -
# configure email
# -
mail = auth.settings.mailer
mail.settings.server = configuration.get('smtp.server') #'logging' if
request.is_local else configuration.get('smtp.server')
mail.settings.sender = configuration.get('smtp.sender')
mail.settings.login = configuration.get('smtp.login')
mail.settings.tls = configuration.get('smtp.tls') or False
mail.settings.ssl = configuration.get('smtp.ssl') or False

Thanks, Jon.

On Fri, Aug 21, 2020 at 1:56 AM Jim S  wrote:

> What does your mail setup in db.py look like?
>
> -Jim
>
>
> On Thursday, August 20, 2020 at 9:47:11 AM UTC-5, Jonsubs wrote:
>>
>> Any suggestions on how to debug "password lost" email not being sent.
>> Thanks, Jon.
>>
>> On Wed, Aug 19, 2020 at 7:49 PM Jon Subscripted 
>> wrote:
>>
>>> Hi everyone,
>>> I'm having some trouble sending "lost password" emails to my users.
>>> Whenever I test it I get an "Unable to send email" message.
>>>
>>> But I do not really know the reason. I tried with a standalone python
>>> script with the same configuration and it works.
>>>
>>> I'd like to know how to debug this problem or where to look at.
>>>
>>> In which log are email related errors written?
>>> Regards, Jon.
>>>
>>> --
> 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/a61e3de4-f288-4968-9001-d21741f881f2o%40googlegroups.com
> 
> .
>

-- 
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/CAK8tz314DOQmcCxDimzWZT3XiReasMsq2es%3Dy%2BwtHyjfbvzrYQ%40mail.gmail.com.


[web2py] MS SQL and searchable=true

2020-08-21 Thread Andrea Fae'
Using search standard widget with MS SQL server and trying to search only 
typing a string causes this error

for example when I search simply "202h719" it appears this

Query Not Supported: ('42000', u'[42000] [Microsoft][ODBC SQL Server 
Driver][SQL Server]Argument data type text is invalid for argument 1 of 
lower function. (8116) (SQLExecDirectW)')

if I search typing asset.nome = "202H719" it works.


-- 
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/b18f65b0-d5a5-4d94-9fbf-8460684762aeo%40googlegroups.com.


[web2py] Developers

2020-08-21 Thread Anthony Smith
Hi are there any programmers in Australia looking for work 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/157d048d-99b9-4ff4-bae0-38c1712e4aaen%40googlegroups.com.


[web2py] Re: DAL Could not create constraint or index

2020-08-21 Thread Andrea Fae'
...but this error is not clear with me

Error ticket for "ITAsset"Ticket ID

127.0.0.1.2020-08-21.09-54-23.77579ea3-20b8-49ca-aed5-76c10960c92f
 ('23000', u"[23000] [Microsoft][ODBC SQL 
Server Driver][SQL Server]Cannot insert the value NULL into column 'id', 
table 'itassetdb.dbo.asset_archive'; column does not allow nulls. INSERT 
fails. (515) (SQLExecDirectW); [23000] [Microsoft][ODBC SQL Server 
Driver][SQL Server]The statement has been terminated. (3621)")

insert a NULL value into culumn'id' on table asset_archive? Why?


Il giorno venerdì 21 agosto 2020 10:04:15 UTC+2, Andrea Fae' ha scritto:
>
> I think the problem with archiving is when I defined archive table in 
> mssql I defined a field named 'current_record" type int. Maybe type int is 
> not correct, isn't it?
> Thank you
>
> Il giorno venerdì 21 agosto 2020 09:43:14 UTC+2, Andrea Fae' ha scritto:
>>
>> Hello, some updates.
>> In the databases I can see only this (see attachment).
>> I'm trying to manage record versionin (table archiving). I create for 
>> example asset.archive in mssql but web2py doesn't "see" the table. In fact 
>> the table is not listend in the appadmin page.
>> The question is that tables definitions are not created in the databases 
>> folder, even if I put migrate=false in appconfig.ini and in db.py I typed 
>> migrate_fake=true... ???
>>
>>
>>
>> Il giorno giovedì 20 agosto 2020 16:57:26 UTC+2, Andrea Fae' ha scritto:
>>>
>>> UPDATES
>>>
>>> in appconfig.ini I changed from migrate= true to migrate=false.
>>>
>>> tha system doesn't create me the sql.log and .table file definitions in 
>>> the folder databases, but the application seems start to work! How is 
>>> posisble?
>>>
>>>
>>> Il giorno giovedì 20 agosto 2020 16:45:35 UTC+2, Andrea Fae' ha scritto:

 Hello Villas, first al all...thank  you thank you thank you! But I 
 didn't arrived to the end of the game yet. but I think I'm near with your 
 suggestions.

 I followed the "easier solution" and, with a lot of effort, now I have 
 my MSSQL database filled of my data.
 But when I start tha application web2py I have this error:

 Error ticket for "ITAsset"Ticket ID

 127.0.0.1.2020-08-20.16-37-26.91c5b362-833d-4bdc-afef-3b727fde37a8
  ('42S01', u"[42S01] [Microsoft][ODBC 
 SQL Server Driver][SQL Server]There is already an object named 'sede' in 
 the database. (2714) (SQLExecDirectW)")Versione
 web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
 Python Python 2.7.15: C:\Python27\python.exe (prefix: C:\Python27)
 Traceback

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

 Traceback (most recent call last):
   File "C:\web2py\gluon\restricted.py", line 227, in restricted
 exec ccode in environment
   File "c:/web2py/applications/ITAsset/models/db_asset.py" 
 , 
 line 12, in 
 format='%(nome)s')
   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 834, in 
 define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 873, in 
 lazy_define_table
 polymodel=polymodel)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 482, in 
 create_table
 self.create_sequence_and_triggers(query, table)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1369, 
 in create_sequence_and_triggers
 self.execute(query)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1388, 
 in execute
 return self.log_execute(*a, **b)
   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1382, 
 in log_execute
 ret = self.get_cursor().execute(command, *a[1:], **b)
 ProgrammingError: ('42S01', u"[42S01] [Microsoft][ODBC SQL Server 
 Driver][SQL Server]There is already an object named 'sede' in the 
 database. (2714) (SQLExecDirectW)")


 I will attach you db.py and dbasset.py, my models and the sql.log 
 generated...
 I tested with all combination of "migrate" and "fake_migrate" but 
 web2py try every time to create the table "sede and so the error.
 Can you have another suggestion? when I will finish I inveted you yo a 
 dinner in the restaurant! :-)

 thank you


 Il giorno mercoledì 19 agosto 2020 12:32:20 UTC+2, villas ha scritto:
>
> *An easier solution for you could be this!*
> Simply specify your created_by/modified_by as extra fields (which 
> should side-step self-referencing probem).
> I didn't test it, but it seems like a good idea to me. You can then 
> use normal migrations etc.
>
> auth.settings.extra_fields['auth_user']= [
>
> 

[web2py] Re: DAL Could not create constraint or index

2020-08-21 Thread Andrea Fae'
I think the problem with archiving is when I defined archive table in mssql 
I defined a field named 'current_record" type int. Maybe type int is not 
correct, isn't it?
Thank you

Il giorno venerdì 21 agosto 2020 09:43:14 UTC+2, Andrea Fae' ha scritto:
>
> Hello, some updates.
> In the databases I can see only this (see attachment).
> I'm trying to manage record versionin (table archiving). I create for 
> example asset.archive in mssql but web2py doesn't "see" the table. In fact 
> the table is not listend in the appadmin page.
> The question is that tables definitions are not created in the databases 
> folder, even if I put migrate=false in appconfig.ini and in db.py I typed 
> migrate_fake=true... ???
>
>
>
> Il giorno giovedì 20 agosto 2020 16:57:26 UTC+2, Andrea Fae' ha scritto:
>>
>> UPDATES
>>
>> in appconfig.ini I changed from migrate= true to migrate=false.
>>
>> tha system doesn't create me the sql.log and .table file definitions in 
>> the folder databases, but the application seems start to work! How is 
>> posisble?
>>
>>
>> Il giorno giovedì 20 agosto 2020 16:45:35 UTC+2, Andrea Fae' ha scritto:
>>>
>>> Hello Villas, first al all...thank  you thank you thank you! But I 
>>> didn't arrived to the end of the game yet. but I think I'm near with your 
>>> suggestions.
>>>
>>> I followed the "easier solution" and, with a lot of effort, now I have 
>>> my MSSQL database filled of my data.
>>> But when I start tha application web2py I have this error:
>>>
>>> Error ticket for "ITAsset"Ticket ID
>>>
>>> 127.0.0.1.2020-08-20.16-37-26.91c5b362-833d-4bdc-afef-3b727fde37a8
>>>  ('42S01', u"[42S01] [Microsoft][ODBC 
>>> SQL Server Driver][SQL Server]There is already an object named 'sede' in 
>>> the database. (2714) (SQLExecDirectW)")Versione
>>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
>>> Python Python 2.7.15: C:\Python27\python.exe (prefix: C:\Python27)
>>> Traceback
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>> 13.
>>> 14.
>>> 15.
>>> 16.
>>> 17.
>>> 18.
>>> 19.
>>>
>>> Traceback (most recent call last):
>>>   File "C:\web2py\gluon\restricted.py", line 227, in restricted
>>> exec ccode in environment
>>>   File "c:/web2py/applications/ITAsset/models/db_asset.py" 
>>> , line 
>>> 12, in 
>>> format='%(nome)s')
>>>   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 834, in 
>>> define_table
>>> table = self.lazy_define_table(tablename,*fields,**args)
>>>   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 873, in 
>>> lazy_define_table
>>> polymodel=polymodel)
>>>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 482, in 
>>> create_table
>>> self.create_sequence_and_triggers(query, table)
>>>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1369, in 
>>> create_sequence_and_triggers
>>> self.execute(query)
>>>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1388, in 
>>> execute
>>> return self.log_execute(*a, **b)
>>>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1382, in 
>>> log_execute
>>> ret = self.get_cursor().execute(command, *a[1:], **b)
>>> ProgrammingError: ('42S01', u"[42S01] [Microsoft][ODBC SQL Server 
>>> Driver][SQL Server]There is already an object named 'sede' in the database. 
>>> (2714) (SQLExecDirectW)")
>>>
>>>
>>> I will attach you db.py and dbasset.py, my models and the sql.log 
>>> generated...
>>> I tested with all combination of "migrate" and "fake_migrate" but web2py 
>>> try every time to create the table "sede and so the error.
>>> Can you have another suggestion? when I will finish I inveted you yo a 
>>> dinner in the restaurant! :-)
>>>
>>> thank you
>>>
>>>
>>> Il giorno mercoledì 19 agosto 2020 12:32:20 UTC+2, villas ha scritto:

 *An easier solution for you could be this!*
 Simply specify your created_by/modified_by as extra fields (which 
 should side-step self-referencing probem).
 I didn't test it, but it seems like a good idea to me. You can then use 
 normal migrations etc.

 auth.settings.extra_fields['auth_user']= [

  Field('is_active', 'boolean', default=True),
  Field('created_on', 'datetime', default=request.now),
  Field('created_by', 'integer', default=auth.user_id),
  Field('modified_on', 'datetime', update=request.now),
  Field('modified_by', 'integer', update=auth.user_id)

 ]

 auth.define_tables(... signature=False )

 *Otherwise, in answer to your questions...*
 migrate='asset_archive.table'
 Personally, I do not specify the table definition name as the one given 
 automatically by web2py is very good.  I just use migrate=True/False.
 If you use migrate='asset_archive.table',  you are 

[web2py] Re: DAL Could not create constraint or index

2020-08-21 Thread Andrea Fae'
Hello, some updates.
In the databases I can see only this (see attachment).
I'm trying to manage record versionin (table archiving). I create for 
example asset.archive in mssql but web2py doesn't "see" the table. In fact 
the table is not listend in the appadmin page.
The question is that tables definitions are not created in the databases 
folder, even if I put migrate=false in appconfig.ini and in db.py I typed 
migrate_fake=true... ???



Il giorno giovedì 20 agosto 2020 16:57:26 UTC+2, Andrea Fae' ha scritto:
>
> UPDATES
>
> in appconfig.ini I changed from migrate= true to migrate=false.
>
> tha system doesn't create me the sql.log and .table file definitions in 
> the folder databases, but the application seems start to work! How is 
> posisble?
>
>
> Il giorno giovedì 20 agosto 2020 16:45:35 UTC+2, Andrea Fae' ha scritto:
>>
>> Hello Villas, first al all...thank  you thank you thank you! But I didn't 
>> arrived to the end of the game yet. but I think I'm near with your 
>> suggestions.
>>
>> I followed the "easier solution" and, with a lot of effort, now I have my 
>> MSSQL database filled of my data.
>> But when I start tha application web2py I have this error:
>>
>> Error ticket for "ITAsset"Ticket ID
>>
>> 127.0.0.1.2020-08-20.16-37-26.91c5b362-833d-4bdc-afef-3b727fde37a8
>>  ('42S01', u"[42S01] [Microsoft][ODBC 
>> SQL Server Driver][SQL Server]There is already an object named 'sede' in 
>> the database. (2714) (SQLExecDirectW)")Versione
>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
>> Python Python 2.7.15: C:\Python27\python.exe (prefix: C:\Python27)
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File "c:/web2py/applications/ITAsset/models/db_asset.py" 
>> , line 
>> 12, in 
>> format='%(nome)s')
>>   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 834, in 
>> define_table
>> table = self.lazy_define_table(tablename,*fields,**args)
>>   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 873, in 
>> lazy_define_table
>> polymodel=polymodel)
>>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 482, in 
>> create_table
>> self.create_sequence_and_triggers(query, table)
>>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1369, in 
>> create_sequence_and_triggers
>> self.execute(query)
>>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1388, in 
>> execute
>> return self.log_execute(*a, **b)
>>   File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1382, in 
>> log_execute
>> ret = self.get_cursor().execute(command, *a[1:], **b)
>> ProgrammingError: ('42S01', u"[42S01] [Microsoft][ODBC SQL Server 
>> Driver][SQL Server]There is already an object named 'sede' in the database. 
>> (2714) (SQLExecDirectW)")
>>
>>
>> I will attach you db.py and dbasset.py, my models and the sql.log 
>> generated...
>> I tested with all combination of "migrate" and "fake_migrate" but web2py 
>> try every time to create the table "sede and so the error.
>> Can you have another suggestion? when I will finish I inveted you yo a 
>> dinner in the restaurant! :-)
>>
>> thank you
>>
>>
>> Il giorno mercoledì 19 agosto 2020 12:32:20 UTC+2, villas ha scritto:
>>>
>>> *An easier solution for you could be this!*
>>> Simply specify your created_by/modified_by as extra fields (which should 
>>> side-step self-referencing probem).
>>> I didn't test it, but it seems like a good idea to me. You can then use 
>>> normal migrations etc.
>>>
>>> auth.settings.extra_fields['auth_user']= [
>>>
>>>  Field('is_active', 'boolean', default=True),
>>>  Field('created_on', 'datetime', default=request.now),
>>>  Field('created_by', 'integer', default=auth.user_id),
>>>  Field('modified_on', 'datetime', update=request.now),
>>>  Field('modified_by', 'integer', update=auth.user_id)
>>>
>>> ]
>>>
>>> auth.define_tables(... signature=False )
>>>
>>> *Otherwise, in answer to your questions...*
>>> migrate='asset_archive.table'
>>> Personally, I do not specify the table definition name as the one given 
>>> automatically by web2py is very good.  I just use migrate=True/False.
>>> If you use migrate='asset_archive.table',  you are also specifying 
>>> migrate=True
>>>
>>> fake_migrate=True
>>> This is used to recreate the .table file without touching your DB.
>>> If you manually create and edit the fields in your DB,  you may wish to 
>>> recreate the .table definition file (hence fake_migrate).
>>>
>>> I am not sure how you are using the archiving etc,  but I do know this:  
>>>
>>>- you can manually create