Thank you for your suggestions...Like this (see attaached files)?
but, no way, no .tables created...I don't know why...

Il giorno mercoledì 26 agosto 2020 14:46:05 UTC+2, Jim S ha scritto:
>
> Did you remove the apostrophe at the bottom as well?
>
> I haven't used migrate / fake migrate in the past the way that you are 
> implementing.
>
> Are you intentionally trying to set it by table?
>
> For me, on my DAL statement I'd include:
>
> migrate_enabled=myconf.get('db.migrate')
> fake_migrate_all=myconf.get('db.fake_migrate_all')
>
>
> then in appconfig.ini I'd have:
>
> [db]
> uri = mssql4://sa/Web2PyPassword@TS-SQL2016R2/itassetdb
> migrate = True
> fake_migrate_all = True
>
>
>
> Can you try that and see if it helps?
>
> Also, I'd remove all the migrate stuff from auth and all the individual 
> tables.  I just set it globally, but that may be a personal preference kind 
> of thing.
>
> -Jim
>
> On Wednesday, August 26, 2020 at 1:32:13 AM UTC-5, Andrea Fae' wrote:
>>
>> Hello, thank you for your answer.
>> I deleted the character but nothing changes.
>> Best regards 
>> Andrea
>>
>> Il giorno lunedì 24 agosto 2020 12:39:47 UTC+2, Clemens ha scritto:
>>>
>>> Hi,
>>>
>>> I'm not very deep in your issue. But opening your appconfig.ini with my 
>>> default editor shows that the apostrophe in your authors value could be a 
>>> problem:
>>>
>>> [image: Untitled.jpg]
>>>
>>> Thus, just delete it and have try. If it doesn't change anything, please 
>>> let me know and I will have a closer look.
>>>
>>> Best regards
>>> Clemens
>>>
>>>
>>>
>>>
>>> On Monday, August 24, 2020 at 11:18:32 AM UTC+2 and...@gmail.com wrote:
>>>
>>>> Hello, if I chose migrate= False and fake_migrate=True the .tables in 
>>>> databases folder are not created.
>>>> Why?
>>>> I'm attaching appconfig.ini and py.db and my custom db db_asset.py
>>>> Thank you
>>>>
>>>

-- 
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/e1702e2a-1c5f-4d0b-a27b-67cece00d923o%40googlegroups.com.
# -*- coding: utf-8 -*-

# -------------------------------------------------------------------------
# This scaffolding model makes your app work on Google App Engine too
# File is released under public domain and you can use without limitations
# -------------------------------------------------------------------------

if request.global_settings.web2py_version < "2.14.1":
    raise HTTP(500, "Requires web2py 2.13.3 or newer")

# -------------------------------------------------------------------------
# if SSL/HTTPS is properly configured and you want all HTTP requests to
# be redirected to HTTPS, uncomment the line below:
# -------------------------------------------------------------------------
# request.requires_https()

# -------------------------------------------------------------------------
# app configuration made easy. Look inside private/appconfig.ini
# -------------------------------------------------------------------------
from gluon.contrib.appconfig import AppConfig

# -------------------------------------------------------------------------
# once in production, remove reload=True to gain full speed
# -------------------------------------------------------------------------
myconf = AppConfig(reload=True)

if not request.env.web2py_runtime_gae:
    # ---------------------------------------------------------------------
    # if NOT running on Google App Engine use SQLite or other DB
    # ---------------------------------------------------------------------
    db = DAL(myconf.get('db.uri'),
             pool_size=myconf.get('db.pool_size'),
             migrate_enabled=myconf.get('db.migrate'),
             fake_migrate_all=myconf.get('db.fake_migrate_all'),
             check_reserved=['all'])
else:
    # ---------------------------------------------------------------------
    # connect to Google BigTable (optional 'google:datastore://namespace')
    # ---------------------------------------------------------------------
    db = DAL('google:datastore+ndb')
    # ---------------------------------------------------------------------
    # store sessions and tickets there
    # ---------------------------------------------------------------------
    session.connect(request, response, db=db)
    # ---------------------------------------------------------------------
    # or store session in Memcache, Redis, etc.
    # from gluon.contrib.memdb import MEMDB
    # from google.appengine.api.memcache import Client
    # session.connect(request, response, db = MEMDB(Client()))
    # ---------------------------------------------------------------------

# -------------------------------------------------------------------------
# by default give a view/generic.extension to all actions from localhost
# none otherwise. a pattern can be 'controller/function.extension'
# -------------------------------------------------------------------------
response.generic_patterns = ['*'] if request.is_local else []
# -------------------------------------------------------------------------
# choose a style for forms
# -------------------------------------------------------------------------
response.formstyle = myconf.get('forms.formstyle')  # or 'bootstrap3_stacked' or 'bootstrap2' or other
response.form_label_separator = myconf.get('forms.separator') or ''

# -------------------------------------------------------------------------
# (optional) optimize handling of static files
# -------------------------------------------------------------------------
# response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 'concat,minify,inline'

# -------------------------------------------------------------------------
# (optional) static assets folder versioning
# -------------------------------------------------------------------------
# response.static_version = '0.0.0'

# -------------------------------------------------------------------------
# Here is sample code if you need for
# - email capabilities
# - authentication (registration, login, logout, ... )
# - authorization (role based authorization)
# - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
# - old style crud actions
# (more options discussed in gluon/tools.py)
# -------------------------------------------------------------------------

from gluon.tools import Auth, Service, PluginManager, Crud

# host names must be a list of allowed host names (glob syntax allowed)
auth = Auth(db, host_names=myconf.get('host.names'))
service = Service()
plugins = PluginManager()

#personalizzazione lunghezza password
#auth.settings.password_min_length = 8

# -------------------------------------------------------------------------
# create all tables needed by auth if not custom tables
# -------------------------------------------------------------------------
# personalizzazione  Fae' : username = True per gestire lo username mentre signature = true per gestire i log
auth.settings.extra_fields['auth_cas']= [
                     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.settings.extra_fields['auth_event']= [
                     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.settings.extra_fields['auth_group']= [
                     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.settings.extra_fields['auth_membership']= [
                     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.settings.extra_fields['auth_permission']= [
                     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.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(username=True, signature=False, migrate=False, fake_migrate=True)
auth.define_tables(username=True, signature=False)

# in model db.py after auth.define_tables
# questo passaggio serve per definire la lunghezza minima della password per gli utenti
default_password_validators = [def_val for def_val in db.auth_user.password.requires]
added_password_validators = [IS_LENGTH(minsize=8,error_message=T('Password non valida'))]
password_validators = added_password_validators + default_password_validators
db.auth_user.password.requires = password_validators
#print db.auth_user.password.requires

# -------------------------------------------------------------------------
# configure email
# -------------------------------------------------------------------------
mail = auth.settings.mailer
# personalizzazioni per utilizzo posta elettronica interna
"""mail.settings.server = 'logging' if request.is_local else myconf.get('smtp.server')
mail.settings.sender = myconf.get('smtp.sender')
mail.settings.login = myconf.get('smtp.login')
mail.settings.tls = myconf.get('smtp.tls') or False
mail.settings.ssl = myconf.get('smtp.ssl') or False"""
mail.settings.server = 'smtp.bccsi.bcc.it:25'
mail.settings.sender = 'as...@bccpm.it'
mail.settings.login = None
mail.settings.tls = False

# -------------------------------------------------------------------------
# configure auth policy
# -------------------------------------------------------------------------
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

# -------------------------------------------------------------------------
# Define your tables below (or better in another model file) for example
#
# >>> db.define_table('mytable', Field('myfield', 'string'))
#
# Fields can be 'string','text','password','integer','double','boolean'
#       'date','time','datetime','blob','upload', 'reference TABLENAME'
# There is an implicit 'id integer autoincrement' field
# Consult manual for more options, validators, etc.
#
# More API examples for controllers:
#
# >>> db.mytable.insert(myfield='value')
# >>> rows = db(db.mytable.myfield == 'value').select(db.mytable.ALL)
# >>> for row in rows: print row.id, row.myfield
# -------------------------------------------------------------------------

# -------------------------------------------------------------------------
# after defining tables, uncomment below to enable auditing
# -------------------------------------------------------------------------
# auth.enable_record_versioning(db)

# personalizzazioni Andrea Fae'
# impostazioni autenticazione AD pnbcc
from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods.append(ldap_auth(mode='ad',
                                             manage_groups=False,
                                             manage_user=True,
                                             user_firstname_attrib='displayName:1',
                                             user_lastname_attrib='displayName:2',
                                             user_mail_attrib='mail',
                                             db=db,
                                             group_name_attrib='cn',
                                             group_member_attrib='member',
                                             group_filterstr='objectClass=Group',
                                             server='bccsi.net',
                                             logging_level='error',
                                             base_dn='OU=Office365, OU=BCC_202,OU=BCC_Users,DC=bccsi,DC=net'))

# disabilitazione funzioni utenti
auth.settings.actions_disabled.append('register')
auth.settings.actions_disabled.append('retrieve_username')
auth.settings.actions_disabled.append('request_reset_password')

# se l'utente è loggato ed ha registration_id valorizzato allora è un utente di dominio e pertanto non si dà possibilità di cambiare password
#print auth.is_logged_in()
if auth.is_logged_in() and auth.user.registration_id:
    auth.settings.actions_disabled.append('change_password')
# -*- coding: utf-8 -*-
crud = Crud(db)

db.define_table('sede',
                Field('nome', requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'sede.nome')]),
                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="Sede",plural="Sedi",
                format='%(nome)s')

db.define_table('uo',
                Field('nome', requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'uo.nome')]),
                Field('sede', 'reference sede'),
                Field('telefono'),
                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="Uo",plural="Uo",migrate='uo.table',
                format='%(nome)s')

db.define_table('fornitore',
                Field('nome', requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'fornitore.nome')]),
                Field('email',requires=[IS_NOT_EMPTY(),IS_EMAIL()]),
                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="fornitore",plural="fornitori",migrate='fornitore.table',
                format='%(nome)s')

# la combinazione tipo-seriale deve essere unica
db.define_table('asset',
                Field('tipo',requires=IS_IN_SET(['BA','CD','FW','MO','PC','SC','SE','ST','SW','SL'])),
                Field('seriale', requires=IS_NOT_EMPTY()),
                Field('nome',requires=IS_NOT_EMPTY()),
                Field('uo', 'reference uo'),
                Field('dataconsegna', type='date', requires=IS_DATE()),
                Field('datadismissione', type='date'),
                Field('modello', type='string'),
                Field('fornitore', 'reference fornitore'),
                Field('comodato', type='boolean', default='False'),
                Field('note','text'),
                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="Asset",plural="Asset",migrate='asset.table',
                format='%(tipo)s %(seriale)s')
db.asset.seriale.requires=IS_NOT_IN_DB(db(db.asset.tipo==request.vars.tipo),db.asset.seriale)
db.asset.dataconsegna.label=T("Data consegna")
db.asset.datadismissione.label=T("Data dismissione")

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')

"""db.define_table('sede_archive',
                Field('current_record', db.sede),
                db.sede,migrate='sede_archive.table')

db.define_table('asset_archive',
                Field('current_record', db.asset),
                db.asset,migrate='asset_archive.table')

db.define_table('uo_archive',
                Field('current_record', db.uo),
                db.uo,migrate='uo_archive.table')

db.define_table('ticket_archive',
                Field('current_record', db.ticket),
                db.ticket,migrate='ticket_archive.table')

db.define_table('fornitore_archive',
                Field('current_record', db.fornitore),
                db.fornitore,migrate='fornitore_archive.table')"""

# servita per settare tutto i campi comodato a false
"""rows = db(db.asset).select()
for row in rows:
    row.update_record(comodato='False')"""

# serivta per cancellare tutti i monitor dal DB
#db(db.asset.tipo=='MO').delete()
#db(db.asset.tipo==None).delete()

# servita per settare il fornitore assistenza per scanner
"""query = db.asset.tipo == 'SC'
rows = db(query).select()
for row in rows:
    row.update_record(fornitore=4)"""

Attachment: appconfig.ini
Description: Binary data

Reply via email to