[web2py] Auto authentification using PAM or LDAP
I'm developping an workflow application, to create documents (or needs or purchase requests..) that have to be validated by many users. This appli will work in an intranet. The user are authentified thru an AD. I have 2 questions, 2 needs : First one, due to the AD and internal policy, users always work with an authentification ; they start the PC and type login, and so on. Impossible to start a tool without authenticate. This appli is an internal appli, not reachable form outside. Question : is it possible to run the appli, create document, validate document by getting the ID of the user on the network ( on the AD), without displaying a "login" screen ? We already have to type login and password again for each tool we run, login again and again, while we are already authenticated. Second one : for each step of this process (on documents), the system has to send email to many users (the one who created the document, the next one that will have to validate). I already know the ID of all users of this workflow, I have to request the AD to know the email address. ... today it works thru a view in SQL-server ==> SELECT sAMAccountName AS Login, Name AS Nom_Complet, mail AS Adresse_Mail FROM OPENQUERY(ADSI, 'SELECT sAMAccountName, Name ,mail, userAccountControl FROM ''LDAP://xxx.dom/OU="Comptes XXX",DC=xxx,DC=dom'' WHERE objectClass = ''User'' ') AS tblADSI WHERE(userAccountControl = 512) I'd prefer do this directly from my app. Thanks in advance -- 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] The ondelete in a grid seems do nothing...
Hi, I manage a page with a sqlform ("Order") and a sqlform.grid ("Articles"). Test1 : On the grid, when I click on the button "Delete", this Article is removed from the grid ... on the screen. When I reload the order, I see the article again. Test2 : I add a line un my grid instruction, with an "ondelete"... But the callback is not executed. Extract of code : def delArticle(NomTable,IdArt): print "Suppression article " + NomTable + string(IdArt) def saisieda(): ... formModArt= SQLFORM.grid(dbW(dbW.TArt.NumDA==NumDA),formname= 'GridArticle', fields=[dbW.TArt.id,dbW.TArt.Article,dbW.TArt.Compte ,dbW.TArt.PUHT,dbW.TArt.Quantite,dbW.TArt.Description], create=True,deletable=True,searchable=False,csv= False,user_signature=False, ondelete=delArticle) -- 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] default filter in SQLFORM.grid
Hi, I'm writing an app to manager tasks / worflows / Purchase requests, ... So the first screen (index) is a SQLFORM.grid, that displays the active orders. But the most usefull should be that this grid shows the active order via a filter. The user can remove this filter to see all orders (and also the closed orders). Thank in advance for all ideas :) -- 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] Re: FPDF "ne commence pas par '%PDF-' "
SUPER ! With thiw, it works exactly as I wish. => A message appears "Do you want to open/save/saveAs ?", and after the choice "Open", I see my PDF in the "Acrobat" tool. Thank you very much for this advice :-) :-) Le lundi 26 juin 2017 07:12:49 UTC+2, Peter a écrit : > > Have been outputting pdfs for a while and this is what works for me ... > > note, I don't close the pdfpdf.close? but this allows the user to > either open or save the file anywhere on their machine (Linux and Windows) > > > > s_io = pdf.output(dest='S') > response.headers['Content-Type']='application/pdf' > response.headers['Content-Disposition'] = 'attachment; filename="%s"' > % invc_filename > raise HTTP(200, s_io, **response.headers) > >> >> >> -- 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] FPDF "ne commence pas par '%PDF-' "
Hi, A try to write my first PDF report (the user fill a form, manager it, at the end another user print this order). All the test I read in this forum or in the documentation alwyas end with "Le fichier ne commence pas par '%PDF-' Local\EWH-3508-0 " First test : from gluon.contrib.fpdf import FPDF def test(): pdf = FPDF() pdf.add_page() pdf.set_font('Arial', 'B', 16) pdf.cell(40,10,'Hello World') pdf.output('tuto1.pdf','F') return response.stream(open('tuto1.pdf')) ==> I get the message Second one : from gluon.contrib.fpdf import FPDF def test(): pdf = FPDF() pdf.add_page() pdf.set_font('Arial', 'B', 16) pdf.cell(40,10,'Hello World') response.headers['Content-Type'] = 'application/pdf' return XML(pdf.output('', 'S')) ==> I get the message I remark in the source code, that the "%PDF- + version" is written in the _enddoc function, called by the close. So I try to add "pdf.close()" ... ==> I also get the message. Other try : pdf = FPDF('P','mm','A4') # A4 Portrait en mm pdf.add_page() pdf.set_font('Arial', 'I', 14) pdf.cell(40, 10, "Hello, ExampleServer World") pdf.close() stuff = open("stuff.pdf", 'w') stuff.write(pdf.output('', 'S')) stuff.close() ==> I file is created, named stuff.pdf. When I try to open this file (with Windows Acrobat reader) => "Cette page contient une erreur" (This page contains an error). -- 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] Re: SQLFORM.grid filtering with local and external table
Oh Yes ! Instead of an algorythm with variables and loops and I saw this "belongs", but I hadn't imagined that it was the as the "IN" of a select... Thank you very much. I appologized, not to understand this myself :):):) -- 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] SQLFORM.grid filtering with local and external table
Hi, My app goes forward, I have plaisure to develop with web2py. But sometimes I don't find myself the solution for very specific search. My app works well now, I can fill a request, add/remove parts, add/remove attached, calculate price, send this request to collect signatures Now I try to display in the first "index" page (a SQLFORM.grid), only the requests that interest the user who is at the keybord (for the guitar it's someone else). The criteria are : * only the requests that are not closed (and another page or another filter to display old closed requests) * only the requests that were written by this user * OR the requests that this user HAS already signed OR those that this user HAS TO sign OR those that this user WILL HAVE to sign. A request (table = "Demande") has to be signed by many persons and managers (not always the same) => table = "Workflow" (shortcut TDW). In the first version of my app, each user see all the requests (not closed), and the SQLFORM.grid works well. form = SQLFORM.grid((dbW.Demande.Statut!='Close'), ...) In the second version, the user can see his own requests (that he has created) AND also those he HAS TO sign. form = SQLFORM.grid((dbW.Demande.Statut!='Close') & ((dbW.Demande.CreatedBy==session.CurrentUser) |(dbW.Demande.NextSign==session.CurrentUser)), But now I want to show also the requests that he HAS already signed, OR requests that he WILL HAVE to sign. FIRST TRY : form = SQLFORM.grid((dbW.Demande.Statut!='Close') & ((dbW.Demande.CreatedBy==session.CurrentUser) |(dbW.Demande.NumDA in (select NumDA from TDW where Responsable==session.CurrentUser)), I already knew that this syntax doesn't work. SECOND TRY : liste_DA_filtre = [] for DA in dbW(dbW.TDW.Responsable==session.CurrentUser).select(dbW.TDW. NumDA): liste_DA_filtre.append(DA.NumDA) form = SQLFORM.grid((dbW.Demande.Statut!='Close') & ((dbW.Demande.CreatedBy==session.CurrentUser) |(dbW.Demande.NumDA in liste_DA_filtre)), Is there any way to do a "in()" ? THIRD TRY : liste_DA_filtre = [] for DA in dbW(dbW.TDW.Responsable==session.CurrentUser).select(dbW.TDW. NumDA): liste_DA_filtre.append(DA.NumDA) selection_DA = dbW(dbW.WFDA_DemAchat).select().find( lambda row: row.Statut!='Close' and (row.CreatedBy==session. CurrentUser or row.NumDA in liste_DA_filtre)) form = SQLFORM.grid((selection_DA, ...) I know that this syntax is not correct : SQLFORM.gris needs a request, not a set of data. But I wrote this only to check the data that are filtered... and this is exactly the rows I'm looking for. -- 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] Re: Codec MS-SQL, unicode Latin1 UTF8
Hello, Many thanks at both of you :-) I've just made a lot of tests, a lot of combinations I confirm : mssql4 is NOT the good connector for this. mssql2 works much better ! ! For unicode fields (type nvarchar in SQL-Server), mssql2 without codec works very well, but doen't work for varchar fields (not unicode in SQL-Server). For traditionnal fields (type = varchar), mssql2 AND db_codec=latin1 make the fields working perfectly ! mssql3 also doesn't work. So I can now continue working on my workflow, it's very plaisant to see beautiful letters, like I used to :-) So my definitiv choice : mssql2 AND db_codec='latin1'. Thank you very much, and long life to web2py. -- 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] Codec MS-SQL, unicode Latin1 UTF8
Hello, For my app, with data in SQL-Server 2012, I cannot have all letter correctly written. First, in SQL-Server, there are 2 types for storing a string : * char and varchar are string types with "old" charset, ie not uniccode, and dependant on the site. * nchar, nvarchar are string types with unicode. We can store text from our country, but also stranger text. For me, in France, the database is declared "Collation = French_Cl_AS", this is équivalent to "Latin1". For my app, I use all types of data : a "code" is allways varchar(12), for example Supplier-code, Article-code, Supplier-address, accounting-acct, name of persons, ... but a comment field can countain many thing. I think I've tried all combinations to convert my app. Each combination works for a part, but doen't work in another part. For both case, I have : a => I already have data in my database, that are put from MS-Access, or directly from "SQL Server Management studio" (parameters list, to use with drop-down fields) In my database, I have data like "Frais Généraux", "Certificat de confirmité", The app has not to change this values I also have data that are a request that joins data from my app database, and my ERP-database (list of suppliers with address like "Saint Nom la Bretèche". b => I try to type a sentence in my SQLFORM, and this data is written in the database. The sentence is ==> l ' élève est dans la forêt, où ça ? I write it in 2 fields, one in varchar, the other in nvarchar. First, I set in the DAL "db_codec='Latin1' " 1a - All that data are well displayed in my app. 1b - For both fields, when I display the form, the systems shows ==> L'élève est dans la forêt, où ça ? And into the database, when I display it ==> L'élève est dans la forêt, où ça ? And if I request data from another tool (MS-Excel, that connects to the same database with an MS-Query), I also get L'élève est dans la forêt, où ça ? If I "valid" the form twice (the displayed data are unchanged), I get L'élève est dans la forêt, où ça ? Second, if I set the DAL with UTF-8 (so without any codec): 2a - The existing data (typed in Sqlserver Management Studio, or a request from different data including ERP) are not correct ==> Frais g�n�raux 2b - For my favorite sentence (l'élève est dans la forêt, où ça ?), this is correctly shown when I display it again in the SQLFORM. But when I extract data with a third-party tool, or look at the data with MS-Man-Studio, I get : ==> L'élève est dans la forêt, où ça ? The codec "Latin1" seems to be best : OK => I can display data from other tables (that comes from other tools, like ERP, or MS-Access apps) OK => When a field already contains a sentence, it's correctl displayed (codec can very well DE-code the Latin1) Not OK : when the use type a sentence in an SQLFORM, this sentence is bad EN-coded to Latin1. Curiosly, the result is exactly the same with varchar fields and nvarchar fields. I'm surprised of this. I've read a lot af things, and many post about codec and ODBC-link with MS-SQL.. I don't find the solution for my case. -- 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] Re: upload and download, in order to manage attached files
One step more :-) Without changing the above code, it's working now. The change I've written ==> in the DAL, I had "db_codec='latin1' ". I just removed it for another reason, and it works now. ... And I understand now the link /default/download/ : it's / controlleur="default" / function="download" / Params= It's OK for this, many thanks Dave for your help. And I'll open another post, about codec with MS SQL Server. -- 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] Re: upload and download, in order to manage attached files
Thank you Dave for your advices ! You're right, I didn't look at the "download" function, and I didn't change it. I've done this now : (1) I've removed the "auth" condition, and I change the db to dbW = the database for my app I also change the line in the view. New version of download : def download(): """ allows downloading of uploaded files http:///[app]/default/download/[filename] """ return response.download(request, dbW) And for the view : Old version Avec A : {{=A(ligne.Titre, _href=URL('upload',ligne.Document))}} New version : Avec A : {{=A(ligne.Titre, _href=URL('download',args=ligne.Document ))}} But it doesn't work. When i move the mouse on the field, I see at the bottom of the screen : http://127.0.0.1:8000/wfda/default/download/TPJ.Document.bfcea4c64f58c64e.466163743138303832302e706466.pdf I don't understand how the upload/download works : For upload, the default directory is /upload/..xxx.pdf For download, the directory is /default/download/..xxx.pdf Question : the "default/download" come from / ? For me, with my tests, the file is always in /upload. Many thanks for the time you spend with helping developpers :-) -- 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] upload and download, in order to manage attached files
Hi, I'm building an app to fill "PurchaseRequest", to valid it by the staff, and then type a "PurchaseOrder". Exactly like with a paper form that we fill, and get signatures to valid it. Now the main boby of the app works (fill the form, set/choose the route, send emails to the concerned persons (by request to the Active Directory), Now I need for this app, to input one or more (or none) attached file (quotation in PDF format, Excel file, technical data in PDF format)... I can upload this files, sort them, display the titles, ... Impossible to show the file. I see the file in the OS directories (/upload/, where is TPJ.Document.<.>.extension). I have a customised html page, but either I get "unknown page", or I get ... nothing. When I manually copy the link into explorer, I see the file The model (only the table for attached) : dbW.define_table('TPJ', Field('NumDA',type='integer'), Field('Document',type='upload',uploadfield=True,uploadfolder=os.path. join(request.folder,'uploads')), Field('Titre'), rname='WFDA_DA_PJ', migrate=False) The controlleur for filling in is only a test fonction : def saisie_pj(): form1 = SQLFORM(dbW.TPJ) if form1.process().accepted: response.flash = 'Votre PJ a été enregistrée' return dict(form1=form1) The display (and Iif possible showing the files): It is nested in the main form (and this form is now quite long) . form = SQLFORM(dbW.WFDA_DemAchat, DA, formstyle ='bootstrap3_inline', buttons=LBoutons) PiecesJointes = dbW(dbW.TPJ.NumDA==NumDA).select(dbW.TPJ.Titre, dbW.TPJ. Document) . And now the html view.. {{=form.custom.begin}} DEMANDE D'ACHAT: {{=form.custom.dspval.id}} .. {{=form.custom.submit}} {{=form.custom.end}} Pièces jointes : {{for ligne in PiecesJointes:}} Avec A : {{=A(ligne.Titre, _href=URL('upload',ligne.Document))}} Avec file: {{=ligne.Titre}} {{pass}} With the "=A(ligne.Titre...", I see the link "http://127.0.0.1/da/upload/TPJ.Document.blabla.pdf. When I click I get "404 unknown page" With the "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.