[web2py] Re: GAE and MySQL
any suggestion for a free hosting to fully use web2py??? Have you looked at Amazon EC2 any? You get a year free of a Micro computing instance. That would be a good 'free' hosting alternative. You'll have to set up your server on your own. Plenty of good advice in the web2py book though. On May 28, 10:29 pm, Ialejandro ialejandr...@gmail.com wrote: Hi every one!!! I was wondering if is possible to deploy an app using GAE but taking data from a MySQL server, for example I have a free account at 000webhost with MySQL DB and I'd like to use GAE just as a hosting service and connect to my 000webhost DB. Is it possible??? if not, any suggestion for a free hosting to fully use web2py??? Thank's!!!
cacheing query (was: Re: [web2py] Re: csv file name and other...)
On 27/05/2011 23:20, Manuele Pesenti wrote: On 27/05/2011 15:53, Anthony wrote: You could cache the query: http://web2py.com/book/default/chapter/06#Caching-Selects the controller I got define a join of some tables and let the user to customize some query parameter such as the filter and the columns to display... if I cache the select and than filter it with it's 'find' method will an identical query be catched from the ram and not performed again? can I test it in someway? thans again Manuele good to know :) many thanks Manuele
[web2py] how to set a default image for an SQLFORM 'upload' field?
Haven't been able to find any examples showing how to define a default image for an upload field of a db table (headshot for a person's profile). Is it possible? Does anyone know how? thanks! Luis.
[web2py] Re: Required password
Thanks!
[web2py] Postgresql database schema
Hi all, I've a legacy enterprise application that use postgresql as database. Existing tables are divided on different database schemas (not only public). Now I want to rewrite a single application that use existing tables on schema xyz. Does web2py support that? Thank you -- Massimiliano
[web2py] Multiple Submits.
I have noticed that users using mobile web browsers have been submitting forms multiple times; I think this is due to slower mobile networks. What is the best way to prevent multiple form submissions? Thanks.
[web2py] recursive tree views
Hi everyone, I have a question about the views and their posibility to create tree views recursively. I want something like this in a view: {{for item in items:}} div here goes the main item data./div div class=childrens {{if item.childs:}} HERE GOES THE SAME STRUCTURE. {{pass}} /div {{pass}} the problem is that the childs can have their own childs, and so on. Somebody knows if there is some way to do this with the views system? The final html is more complex with lots of CSS classes, and we want to separate the views and the code as possible to make it easier to maintain (and let to one graphic designer modify everything without have to touch python files). Thanks in advance, Best regards, Daniel
Re: [web2py] Postgresql database schema
On 30 May 2011 12:14, Massimiliano mbelle...@gmail.com wrote: Existing tables are divided on different database schemas (not only public). Now I want to rewrite a single application that use existing tables on schema xyz. Does web2py support that? I could not get DAL to work with that(different schemas) type of setup and would also like to know whether that can be done. I had so much trouble using a legacy mysql database that I in the end decided to rebuild the total database in the end. I will not easily try the legacy usage of Web2py in future. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
Re: [web2py] Username field is editable on profile
Thanks! On Sat, May 28, 2011 at 11:41 PM, Bruno Rocha rochacbr...@gmail.com wrote: def user(): if request.args(0)=='profile': db.auth_user.username.readable = db.auth_user.username.writable = False return dict(form=auth()) -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] On Sat, May 28, 2011 at 11:28 PM, Bruno Rocha rochacbr...@gmail.comwrote: You have to do that in the controller, not in view. {{=form}} is already builded in the controller, so if you define 'readable' in view it will not effect the already created object. Go to controllers/deafult.py and in 'def user()' include the piece of code. -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] On Sat, May 28, 2011 at 11:12 PM, Tito Garrido titogarr...@gmail.comwrote: I've tried: {{extend 'layout.html'}} div align='center' width='100%' h2{{=T( request.args(0).replace('_',' ').capitalize() )}}/h2 div id=web2py_user_form {{if request.args(0)=='profile':}} {{db.auth_user.username.readable = False}} {{db.auth_user.username.writable = False}} {{pass}} {{=form}} Didn't work... what am I doing wrong here? On Sat, May 28, 2011 at 11:09 PM, Tito Garrido titogarr...@gmail.comwrote: Good point! Thanks! On Sat, May 28, 2011 at 9:46 PM, pbreit pbreitenb...@gmail.com wrote: You can set it in the controller. Something like if request.args(0)=='profile': in the user() function -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___
[web2py] Re: clarification of usage of auth
OK to answer my own second question: if not auth.has_permission(delete, mytable): crud.settings.update_deletable = False On May 29, 9:06 pm, apple simo...@gmail.com wrote: I have added auth to my application using crud. However there are a couple of areas where it does not act as I was expecting. 1) If I have change a permission from create to update then I now have both permissions until I log off. I guess it has cached the old permission somewhere. Is it possible to force any changes to happen immediately? 2) If I have update permission it allows me to delete as well. Is it possible to allow update but not delete? As I am using crud in the application it is the same function for update and delete so it is not possible to use a decorator nor to put a test within the code for permissions.
[web2py] Input format Year/Month
Hi! First i'd like to thank Massimo and all other developers/contributors for the great framework, keep up the good work! Now to my question: How can I create a field that allows input only in the format /MM. And how should i store the value as date (i thought maybe in the format /MM/01, or is there a better way)?. How can i achive that? Thanks in advance Gerd
Re: [web2py] recursive tree views
I am investigating this area for quite time https://docs.google.com/document/d/1ZOwRUJz4gRPI875rftTfwOBIera1JgZDPulooGjNyu0/edit?hl=en_US you can choose from a few models, but my idea is to preload all rows in controller then to pass them to view in controller: #OrderedTree rows = db(db.tree_table).select(orderby=db.tree_table.line) #Nested Sets rows = db(db.tree_table).select(orderby=db.tree_table.left) #AdjacencyList rows = get_recursive_all_items(#here goes your recursive function to get all items) also I assume that item level is precomputed and is 0 based in view: style .category{ padding-left: 20px; border:1px solid #aa; } /style {{last_level=0}} {{for row in rows:}} {{if row.levellast_level:}} {{=XML('/div'*(last_level-row.level))}} {{pass}} {{if row.levellast_level:}} div class=category {{pass}} div{{=row.item_data}}/div {{last_level = row.level}} {{pass}} {{=XML('/div'*(last_level))}}
[web2py] Re: recursive tree views
Since the views allow you to define functions, you I would expect you can use a recursive call to display the child items (warning the following code has never seen a python interpreter): define a function: {{def showtree(tree):}} ul {{for i in tree.items:}} li Displaying child {{=i}} {{showtree(i)}} /div {{pass}} /ul {{return}} usage: {{showtree(mytree)}}
[web2py] Re: recursive tree views
sorry i sent by accident! i hadn't finished editing the code :( Since the views allow you to define functions, you I would expect you can use a recursive call to display the child items (warning the following code has never seen a python interpreter): define a function: {{def showtree(tree):}} ul {{for i in tree.items:}} li Displaying child {{=i}} {{showtree(i)}} /li {{pass}} /ul {{return}} usage: {{showtree(mytree)}}
[web2py] Re: Multiple Submits.
form.accepts(request,session) prevents double form submission UNLESS they are actually reloading the page a second time and submitting the newly realoaded page a second time. If this is what they are doing, perhaps the flash notification is not showing for them. Try embed the flash notifcation in the body of the page. On May 30, 6:37 am, David J. da...@styleflare.com wrote: I have noticed that users using mobile web browsers have been submitting forms multiple times; I think this is due to slower mobile networks. What is the best way to prevent multiple form submissions? Thanks.
[web2py] template in crud
Hi all, I have been searching for a customizable way to select and deselect fields. i have found this way tempate_01 = {'myfiled':False, 'myscofield':True} read this values in the db defitionion. Field('myfield', type='text',readable=template_01'myfiled']), is this a good way to do this? Because i generally don't like writing lots of global variables, thanks
[web2py] Re: Input format Year/Month
Try this: Field('myfield','date',requires=IS_DATE(format='%Y/ %m'),widget=SQLHTML.wisgets.string.widget) On May 30, 7:24 am, Gerd gerd.niem...@gmail.com wrote: Hi! First i'd like to thank Massimo and all other developers/contributors for the great framework, keep up the good work! Now to my question: How can I create a field that allows input only in the format /MM. And how should i store the value as date (i thought maybe in the format /MM/01, or is there a better way)?. How can i achive that? Thanks in advance Gerd
[web2py] Re: how to set a default image for an SQLFORM 'upload' field?
Forgot to mention, I need this on google appengine. My hack so far: - create a new DB table, 'default images' db.define_table('default_images', Field('name', requires=IS_NOT_EMPTY()), Field('uploaded','upload', requires=IS_NOT_EMPTY())) - create a admin-only function which allows upload of default images - now when a new user is to be created, I can pre-populate their 'person' record with the default image: default_headshot = db(db.default_images.name == 'default_headshot').select().first() new_me = db.person.insert(email = session.auth.user.email, first_name = session.auth.user.first_name, last_name = session.auth.user.last_name, head_shot = default_headshot.uploaded, head_shot_blob = default_headshot.uploaded_blob) # below doesn't work # head_shot = URL(c='static', f='images', 'default_headshot.jpg')) form = SQLFORM(db.person, new_me) This works, except that the first time the controller runs and creates the new record, the SQLFORM does not display the image. On subsequent calls, (if the person wants to change their profile info), it does show properly. Is there a smarter/easier way??? thanks, Luis.
Re: [web2py] Re: experimental... .pdf
@mart: yes, the visual designer requires only wxpython (and pyfpdf). I'm working on html conversion enhancements and there are some advance on utf-8 support, they will be fixed soon. Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Mon, May 30, 2011 at 2:19 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: In trunk, web2py tries to use markmin2pdflatex is installed. If not it uses pyfpdf. pyfpdf fails on some html, for example if table do not follow the pyfpdf specs. I believe Marino is working on making pyfpdf more forgiving. Massimo On May 29, 10:39 pm, Christopher Steel chris.st...@gmail.com wrote: I am going try things out again when I get a chance. This stuff is just great. I love the fact that we build on a solid API so in the end we get the GUI and command line and API access for developers and the blind. It totally rocks!!! Markmin to PDF would be very interesting as well.. Chris On May 27, 12:08 pm, Mariano Reingart reing...@gmail.com wrote: Regarding PyFPDF: Headers should be rendered. Tables need at least a first TH, prior any TD, who indicates column width (and it is wise to use THEAD and TBODY when you have multiple pages), see:http://code.google.com/p/pyfpdf/wiki/WriteHTML table border=0 align=center width=50% theadtrth width=30%Header 1/thth width=70%header 2/th/tr/thead tbody trtdcell 1/tdtdcell 2/td/tr trtdcell 2/tdtdcell 3/td/tr /tbody /table I'm planning to fix this issues, to cover more basic html conversions. You can see what can do pyfpdf in this file:http://pyfpdf.googlecode.com/files/html.pdf BTW, did you see the new visual designer of pdf templates? http://code.google.com/p/pyfpdf/wiki/Templates?ts=1306512231updated=... It is a wx application, and I'm planning to connect it using DAL to ease template/report generation (I think this is much easier and manageable way than converting html). Best regards, Mariano Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.com On Fri, May 27, 2011 at 1:35 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: There are still problems...it does not render headers and tables... On May 26, 11:06 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I just made a change to trunk about. the new generic.pdf uses pyfpdf and it is smart in locating files for including images. massimo On May 26, 10:44 pm, Christopher Steel chris.st...@gmail.com wrote: I think report.pdf required reportlab? Massimo had an application for creating forms that used markmin and latex. This web2py app includes a plugin that implements an assortment of pdf stuff (mostly your implementation of pyfpdf and the report.pdf, was that a Google thing?. Anyway the plugin is handy for testing and experimenting and includes some other PDF examples, one with a different font. http://code.google.com/p/uc-pyfpdf/ If you need some testing let me know, I love PDF's Cheers, Chris On May 26, 3:48 pm, Mariano Reingart reing...@gmail.com wrote: Putting the following code in generic.pdf and getting report.pdf does not work? (also, per default there is a generic.pdf made by massimo that uses markmin and latex if I remember it correctly) from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.sanitizer import sanitize class MyFPDF(FPDF, HTMLMixin): pass pdf=MyFPDF() pdf.add_page() html=response.render('%s/%s.html' % (request.controller,request.function)) html = sanitize(html, escape=False) pdf.write_html(html) response.headers['Content-Type']='application/pdf' response.write(pdf.output(dest='S'), escape=False) Mariano Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.comOnThu, May 26, 2011 at 4:30 PM, luifran lbernalhernan...@yahoo.es wrote: if I have a view , for example report.html, how I render this view in pdf with the generic pdf? On 4 oct 2010, 17:08, Mariano Reingart reing...@gmail.com wrote: On Sun, Oct 3, 2010 at 1:10 AM, mdipierro mdipie...@cs.depaul.edu wrote: I am sure this can also be done and better with pyfpdf but I have not tried. Perhaps Mariano can help us Having latest web2py versions (including pyfpdf), write in a views/generic.pdf: begin file {{ from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.sanitizer import sanitize class MyFPDF(FPDF, HTMLMixin): pass pdf=MyFPDF()pdf.add_page() html=response.render('%s/%s.html' % (request.controller,request.function)) html = sanitize(html, escape=False)pdf.write_html(html) response.headers['Content-Type']='application/pdf'
Re: [web2py] Re: recursive tree views
Thanks Stefaan and Vasile for your answers!! I will try with the function :) El lun, 30-05-2011 a las 06:29 -0700, stefaan escribió: sorry i sent by accident! i hadn't finished editing the code :( Since the views allow you to define functions, you I would expect you can use a recursive call to display the child items (warning the following code has never seen a python interpreter): define a function: {{def showtree(tree):}} ul {{for i in tree.items:}} li Displaying child {{=i}} {{showtree(i)}} /li {{pass}} /ul {{return}} usage: {{showtree(mytree)}}
[web2py] Re: Default user.html
Thank you very much. Dwayne On 30 mai, 02:18, Massimo Di Pierro massimo.dipie...@gmail.com wrote: You can disable actions if you use third party authentication. On May 29, 6:19 pm, Dwayne Blind dwaynebl...@gmail.com wrote: Hi, The following lines are usual : div id=web2py_user_form {{=form}} {{if request.args(0)=='login':}} {{if not 'register' in auth.settings.actions_disabled:}} # CONDITION N°1 br/a href={{=URL(r=request,args='register')}}register/a {{pass}} {{if not 'request_reset_password' in auth.settings.actions_disabled:}} # CONDITION N°2 br/a href={{=URL(r=request,args='request_reset_password')}}lost password/a {{pass}} {{pass}} /div The links register and lost password appear conditionally on the conditions 1 and 2. Can somebody explain these conditions to me ? I have the impression that these links always appear :) Thanks a lot, Dwayne- Masquer le texte des messages précédents - - Afficher le texte des messages précédents -
[web2py] Re: how to set a default image for an SQLFORM 'upload' field?
In my views, I check for an image and if there isn't one, display a dummy. No sense in storing that for each record.
[web2py] Re: how to set a default image for an SQLFORM 'upload' field?
I agree. {{=IMG(_src=row.image and URL('download,args=row.image) or URL('static','dummy.png'))}} On May 30, 10:11 am, pbreit pbreitenb...@gmail.com wrote: In my views, I check for an image and if there isn't one, display a dummy. No sense in storing that for each record.
[web2py] Email invitation
Dear all, I am trying to implement an email invitation system. # coding: utf8 def invitation(): form = FORM(INPUT(_name='email', requires=IS_NOT_EMPTY()), INPUT(_type='submit')) if form.accepts(request.vars): uuid=str(uuid.uuid4()) db.invitation.insert(token = uuid) mail.send(to=form.vars.email,message='click %s to register' % URL('register',args=uuid)) redirect(URL('index')) return dict(form=form) I inspired myself from a code that I found on Stackoverflow but I am new with Web2py. The code does not work. Can somebody help me ? Thanks a lot, Dwayne P.S. : the indentation on Google Groups is a bit painful !
[web2py] Re: Multiple tables: update/insert/delete: in one form
Can anybody toss his/her ideas on my code given in the previous post? ---Vineet
[web2py] Re: Email invitation
What's not working? One thing I noticed is that the URL in the email is not going to work because URL() creates a relative URL (/register/uuid). You'll need to do something like: message='click http://mysite.com/register/%s to register' % uuid or message='click a href=http://mysite.com/register/%sregister/a to register' % uuid
[web2py] Re: how to set a default image for an SQLFORM 'upload' field?
Perfect! Thanks!! These tidbit examples are invaluable! As I learn web2py, I am taking notes of where I get stuck, in order to eventually provide suggestions for improving the doc/manual from the novice's eyes (once you already know everything, it isn't as obvious what's missing). The documentation and manual are already quite excellent, part of the reason why I chose web2py (besides, the very clean, structured design, and power!). This is a great example because it shows - how to combine logical expressions to select between user data and a default - how to use URL and IMG with uploaded and static data (didn't find that in the manual or online examples) I'm also re-reading the HTML Helpers in The VIews chapter :) ..and now on to the really hard stuff ... making everything look good ... Thank you!!! Luis.
[web2py] importing a db/model from other app
1) How can I import the db/model of one application for another? I've been reading threads like this, on sharing models and I've seen some suggestions on creating a module to export a DB from the source app and the use of the local_import() method. I've tried that, but couldn't make it work. Would you give me an example of what code would that module? 2) Let's say I don't want to touch in the db/model source app. Would there by any way to make this work without having to add any module? Thank you, Best regards
[web2py] Upload to Insert csv.
I simply want to upload a csv file and then insert that data into the db; I am sure buried somewhere there is a template for a simple web upload to csv insert into DB. If not; Is it possible to load it directly from the web without saving the file on disk first? Thanks in advance for any guidance? Thanks.
Re: [web2py] Re: experimental... .pdf
Me thinks of an HTML version in Javascript built into web2py. Me faints. --- Jason On 05/30/2011 05:39 PM, Mariano Reingart wrote: @mart: yes, the visual designer requires only wxpython (and pyfpdf). I'm working on html conversion enhancements and there are some advance on utf-8 support, they will be fixed soon. Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Mon, May 30, 2011 at 2:19 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: In trunk, web2py tries to use markmin2pdflatex is installed. If not it uses pyfpdf. pyfpdf fails on some html, for example if table do not follow the pyfpdf specs. I believe Marino is working on making pyfpdf more forgiving. Massimo On May 29, 10:39 pm, Christopher Steelchris.st...@gmail.com wrote: I am going try things out again when I get a chance. This stuff is just great. I love the fact that we build on a solid API so in the end we get the GUI and command line and API access for developers and the blind. It totally rocks!!! Markmin to PDF would be very interesting as well.. Chris On May 27, 12:08 pm, Mariano Reingartreing...@gmail.com wrote: Regarding PyFPDF: Headers should be rendered. Tables need at least a first TH, prior any TD, who indicates column width (and it is wise to use THEAD and TBODY when you have multiple pages), see:http://code.google.com/p/pyfpdf/wiki/WriteHTML table border=0 align=center width=50% theadtrth width=30%Header 1/thth width=70%header 2/th/tr/thead tbody trtdcell 1/tdtdcell 2/td/tr trtdcell 2/tdtdcell 3/td/tr /tbody /table I'm planning to fix this issues, to cover more basic html conversions. You can see what can do pyfpdf in this file:http://pyfpdf.googlecode.com/files/html.pdf BTW, did you see the new visual designer of pdf templates? http://code.google.com/p/pyfpdf/wiki/Templates?ts=1306512231updated=... It is a wx application, and I'm planning to connect it using DAL to ease template/report generation (I think this is much easier and manageable way than converting html). Best regards, Mariano Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.com On Fri, May 27, 2011 at 1:35 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: There are still problems...it does not render headers and tables... On May 26, 11:06 pm, Massimo Di Pierromassimo.dipie...@gmail.com wrote: I just made a change to trunk about. the new generic.pdf uses pyfpdf and it is smart in locating files for including images. massimo On May 26, 10:44 pm, Christopher Steelchris.st...@gmail.com wrote: I think report.pdf required reportlab? Massimo had an application for creating forms that used markmin and latex. This web2py app includes a plugin that implements an assortment of pdf stuff (mostly your implementation of pyfpdf and the report.pdf, was that a Google thing?. Anyway the plugin is handy for testing and experimenting and includes some other PDF examples, one with a different font. http://code.google.com/p/uc-pyfpdf/ If you need some testing let me know, I love PDF's Cheers, Chris On May 26, 3:48 pm, Mariano Reingartreing...@gmail.com wrote: Putting the following code in generic.pdf and getting report.pdf does not work? (also, per default there is a generic.pdf made by massimo that uses markmin and latex if I remember it correctly) from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.sanitizer import sanitize class MyFPDF(FPDF, HTMLMixin): pass pdf=MyFPDF() pdf.add_page() html=response.render('%s/%s.html' % (request.controller,request.function)) html = sanitize(html, escape=False) pdf.write_html(html) response.headers['Content-Type']='application/pdf' response.write(pdf.output(dest='S'), escape=False) Mariano Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.comOnThu, May 26, 2011 at 4:30 PM, luifranlbernalhernan...@yahoo.es wrote: if I have a view , for example report.html, how I render this view in pdf with the generic pdf? On 4 oct 2010, 17:08, Mariano Reingartreing...@gmail.com wrote: On Sun, Oct 3, 2010 at 1:10 AM, mdipierromdipie...@cs.depaul.edu wrote: I am sure this can also be done and better with pyfpdf but I have not tried. Perhaps Mariano can help us Having latest web2py versions (including pyfpdf), write in a views/generic.pdf: begin file {{ from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.sanitizer import sanitize class MyFPDF(FPDF, HTMLMixin): pass pdf=MyFPDF()pdf.add_page() html=response.render('%s/%s.html' % (request.controller,request.function)) html = sanitize(html, escape=False)pdf.write_html(html) response.headers['Content-Type']='application/pdf' response.write(pdf.output(dest='S'), escape=False) }} end file--- At MyFPDF class you can add headers and footers. The sanitize part is to strip some HTML tags that cannot be rendered (ie. javascript). As some DIVs contents and similar may still pass
[web2py] Re: Upload to Insert csv.
Something like this: http://web2py.com/book/default/chapter/06?search=csv#Exporting-and-Importing-Data
[web2py] Re: importing a db/model from other app
I don't understand the question. Do you want to share the same DB from two different apps? I suppose you could copy the models and then set your DB connection strings to point to the same DB. In one app set migrate=False. You might even be able to symbolically link the models from one app to the other. The DAL can work standalone so you could put it in a module, Web2py's site_packages or anywhere in your Python path. If you use it outside it's normal location, include from gluon.dal import * at the top of your files and then you should be able to do all the same things (db = DAL(..., db.define_table(...). You mentioned exporting which is quite different. http://web2py.com/book/default/chapter/06?search=Exporting-and-Importing-Data Might need to understand more completely what you are trying to do.
[web2py] Re: Email invitation
Thanks for your help. This is the error message I get : Internal error Ticket issued: myproject/127.0.0.1.2011-05-30.20-27-41.46efa4bd- a623-4bb9-8a5d-3579d3693c8e Here is the traceback : Traceback (most recent call last): File gluon/restricted.py, line 181, in restricted File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py, line 16, in module File gluon/globals.py, line 133, in lambda File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py, line 9, in invitation UnboundLocalError: local variable 'uuid' referenced before assignment I don't know exactly what the uuid variable is. I understand it is some kind of a number. I thank you very much. Dwayne On 30 mai, 18:32, pbreit pbreitenb...@gmail.com wrote: What's not working? One thing I noticed is that the URL in the email is not going to work because URL() creates a relative URL (/register/uuid). You'll need to do something like: message='clickhttp://mysite.com/register/%sto register' % uuid or message='click a href=http://mysite.com/register/%sregister/a to register' % uuid
[web2py] Re: Email invitation
What does your code look like now? And line 16? Does it still include uuid=str(uuid.uuid4()) ?
[web2py] Re: Email invitation
Or line 9, rather.
Re: [web2py] Re: Email invitation
On May 30, 2011, at 9:32 AM, pbreit wrote: What's not working? One thing I noticed is that the URL in the email is not going to work because URL() creates a relative URL (/register/uuid). You'll need to do something like: URL() takes a host argument; that should do the trick. message='click http://mysite.com/register/%s to register' % uuid or message='click a href=http://mysite.com/register/%sregister/a to register' % uuid
[web2py] Purpose of is_active in auth.signature?
If I use auth.signature in my own tables, I get is_active. Can I use it or is it reserved for something else? I understand it is useful in place of deleting a record?
[web2py] Re: Email invitation
There are 15 lines in invitation.py. And line 9 is : uuid=str(uuid.uuid4()). Thanks On 30 mai, 20:48, pbreit pbreitenb...@gmail.com wrote: Or line 9, rather.
[web2py] Make user its own controller?
Can I pull user out of default.py into its own controller? I'm guessing no since things would switch from args to functions. Has anyone tried this?
[web2py] Re: Email invitation
Did you get that error before? Do you have import uuid in the file?
Re: [web2py] Re: Upload to Insert csv.
Yes; But I was wondering if could be done in one step without saving the file first; just auto importing the uploaded file? On 5/30/11 2:20 PM, pbreit wrote: Something like this: http://web2py.com/book/default/chapter/06?search=csv#Exporting-and-Importing-Data
Re: [web2py] Re: Upload to Insert csv.
Yes I see it now. Thanks. def import_and_sync(): form = FORM(INPUT(_type='file', _name='data'), INPUT(_type='submit')) if form.accepts(request.vars): db.import_from_csv_file(form.vars.data.file,unique=False) # for every table for table in db.tables: # for every uuid, delete all but the latest items = db(db[table].id0).select(db[table].id, db[table].uuid, orderby=db[table].modified_on, groupby=db[table].uuid) for item in items: db((db[table].uuid==item.uuid)\ (db[table].id!=item.id)).delete() return dict(form=form) On 5/30/11 2:20 PM, pbreit wrote: Something like this: http://web2py.com/book/default/chapter/06?search=csv#Exporting-and-Importing-Data
[web2py] Re: Email invitation
Nope I don't have import uuid :( Should I ? Where can I read more about uuid ? Thank you On 30 mai, 21:15, pbreit pbreitenb...@gmail.com wrote: Did you get that error before? Do you have import uuid in the file?
[web2py] Deploying with default web2py server?
I apologize if this has already been answered somewhere. Are there any disadvantages to deploying using the default server that comes with web2py?
[web2py] GAE for Dummies - again
Hi, a similar problem After deployment to GAE I got: WARNING appengine_rpc.py:435 ssl module not found. Without the ssl module, the identity of the remote host cannot be verified, and connections may NOT be secure. To fix this, please install the ssl module from http://pypi.python.org/pypi/ssl . Therefore I cannot see any ticket. Is there any description how to install ssl? I think everybody needs it to look at the tickets. I am using WinXP for developing. Regards, Martin
[web2py] Aw: Re: Input format Year/Month
Hi! Thank you, i'll give it a try ;) regards Gerd
[web2py] Re: drop down box content depends of another drop box
I have exactly the same problem, did you find any solution? On May 11, 3:26 am, pepe_eloy pepe.e...@gmail.com wrote: Thanks for the answer. Yeah, I tried that solution, but when can I save in the table empresa the fields category and subcategoria only the categoria field has values. Why? Thanks
[web2py] Re: experimental... .pdf
I think we just need ANY html editor... the only issue are TABLEs. On May 30, 1:06 pm, Jason Brower encomp...@gmail.com wrote: Me thinks of an HTML version in Javascript built into web2py. Me faints. --- Jason On 05/30/2011 05:39 PM, Mariano Reingart wrote: @mart: yes, the visual designer requires only wxpython (and pyfpdf). I'm working on html conversion enhancements and there are some advance on utf-8 support, they will be fixed soon. Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Mon, May 30, 2011 at 2:19 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: In trunk, web2py tries to use markmin2pdflatex is installed. If not it uses pyfpdf. pyfpdf fails on some html, for example if table do not follow the pyfpdf specs. I believe Marino is working on making pyfpdf more forgiving. Massimo On May 29, 10:39 pm, Christopher Steelchris.st...@gmail.com wrote: I am going try things out again when I get a chance. This stuff is just great. I love the fact that we build on a solid API so in the end we get the GUI and command line and API access for developers and the blind. It totally rocks!!! Markmin to PDF would be very interesting as well.. Chris On May 27, 12:08 pm, Mariano Reingartreing...@gmail.com wrote: Regarding PyFPDF: Headers should be rendered. Tables need at least a first TH, prior any TD, who indicates column width (and it is wise to use THEAD and TBODY when you have multiple pages), see:http://code.google.com/p/pyfpdf/wiki/WriteHTML table border=0 align=center width=50% theadtrth width=30%Header 1/thth width=70%header 2/th/tr/thead tbody trtdcell 1/tdtdcell 2/td/tr trtdcell 2/tdtdcell 3/td/tr /tbody /table I'm planning to fix this issues, to cover more basic html conversions. You can see what can do pyfpdf in this file:http://pyfpdf.googlecode.com/files/html.pdf BTW, did you see the new visual designer of pdf templates? http://code.google.com/p/pyfpdf/wiki/Templates?ts=1306512231updated=... It is a wx application, and I'm planning to connect it using DAL to ease template/report generation (I think this is much easier and manageable way than converting html). Best regards, Mariano Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.com On Fri, May 27, 2011 at 1:35 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: There are still problems...it does not render headers and tables... On May 26, 11:06 pm, Massimo Di Pierromassimo.dipie...@gmail.com wrote: I just made a change to trunk about. the new generic.pdf uses pyfpdf and it is smart in locating files for including images. massimo On May 26, 10:44 pm, Christopher Steelchris.st...@gmail.com wrote: I think report.pdf required reportlab? Massimo had an application for creating forms that used markmin and latex. This web2py app includes a plugin that implements an assortment of pdf stuff (mostly your implementation of pyfpdf and the report.pdf, was that a Google thing?. Anyway the plugin is handy for testing and experimenting and includes some other PDF examples, one with a different font. http://code.google.com/p/uc-pyfpdf/ If you need some testing let me know, I love PDF's Cheers, Chris On May 26, 3:48 pm, Mariano Reingartreing...@gmail.com wrote: Putting the following code in generic.pdf and getting report.pdf does not work? (also, per default there is a generic.pdf made by massimo that uses markmin and latex if I remember it correctly) from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.sanitizer import sanitize class MyFPDF(FPDF, HTMLMixin): pass pdf=MyFPDF() pdf.add_page() html=response.render('%s/%s.html' % (request.controller,request.function)) html = sanitize(html, escape=False) pdf.write_html(html) response.headers['Content-Type']='application/pdf' response.write(pdf.output(dest='S'), escape=False) Mariano Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.comOnThu, May 26, 2011 at 4:30 PM, luifranlbernalhernan...@yahoo.es wrote: if I have a view , for example report.html, how I render this view in pdf with the generic pdf? On 4 oct 2010, 17:08, Mariano Reingartreing...@gmail.com wrote: On Sun, Oct 3, 2010 at 1:10 AM, mdipierromdipie...@cs.depaul.edu wrote: I am sure this can also be done and better with pyfpdf but I have not tried. Perhaps Mariano can help us Having latest web2py versions (including pyfpdf), write in a views/generic.pdf: begin file {{ from gluon.contrib.pyfpdf import FPDF, HTMLMixin from gluon.sanitizer import sanitize class MyFPDF(FPDF, HTMLMixin): pass pdf=MyFPDF()pdf.add_page() html=response.render('%s/%s.html' % (request.controller,request.function)) html = sanitize(html,
[web2py] Re: Deploying with default web2py server?
depends on the requirements of your system, but in principle the web2py development server is sufficient On 30 mayo, 21:58, ra3don ra3do...@gmail.com wrote: I apologize if this has already been answered somewhere. Are there any disadvantages to deploying using the default server that comes with web2py?
Re: [web2py] Deploying with default web2py server?
from the book (http://web2py.com/book/default/chapter/11) web2py comes with an SSL21http://en.wikipedia.org/wiki/Secure_Sockets_Layer enabled web server, the Rocket wsgiserver22 https://launchpad.net/rocket . While this is a fast web server, it has limited configuration capabilities. For this reason it is best to deploy web2py behind Apache78http://www.apache.org/ , Lighttpd85 http://www.lighttpd.net/ or Cherokee86http://www.cherokee-project.com/download/ On Mon, May 30, 2011 at 8:58 PM, ra3don ra3do...@gmail.com wrote: I apologize if this has already been answered somewhere. Are there any disadvantages to deploying using the default server that comes with web2py? -- Sebastian E. Ovide
[web2py] Re: Make user its own controller?
you can. def register(): return dict(form=auth.register()) On May 30, 2:12 pm, pbreit pbreitenb...@gmail.com wrote: Can I pull user out of default.py into its own controller? I'm guessing no since things would switch from args to functions. Has anyone tried this?
[web2py] Re: importing a db/model from other app
Have you tried Massimo's new script? I've been unexpectedly busy in the last few days, but I hope to have time to complete wrapping that script in argparse this evening (or tomorrow) which will have just a few more options that I have found useful (ie. truncate, delete db, copy model, etc.). With or without argparse, its pretty sweet! from his posting (May 23) title: script to clone a database http://code.google.com/p/web2py/source/browse/scripts/cpdb.py Usage: python web2py.py -S app -M -N -R scripts/cpdb.py -A 'sqlite:// other_db.sqlite' It will copy all data from current db to other_db (sqlite or not) The -A argument can be any URI string for example 'mysql://username:password@localhost/ dbname' hope it helps! Mart :) On May 30, 2:33 pm, pbreit pbreitenb...@gmail.com wrote: I don't understand the question. Do you want to share the same DB from two different apps? I suppose you could copy the models and then set your DB connection strings to point to the same DB. In one app set migrate=False. You might even be able to symbolically link the models from one app to the other. The DAL can work standalone so you could put it in a module, Web2py's site_packages or anywhere in your Python path. If you use it outside it's normal location, include from gluon.dal import * at the top of your files and then you should be able to do all the same things (db = DAL(..., db.define_table(...). You mentioned exporting which is quite different.http://web2py.com/book/default/chapter/06?search=Exporting-and-Import... Might need to understand more completely what you are trying to do.
[web2py] Re: GAE for Dummies - again
Martin, i'm a little confused here, i think you are mixing the SDK with the production GAE. Yes, that error shows when deploying, but it's in reference to the fact that for the code upload to GAE you don't have SSL, nothing to do with ssl on GAE. For what it's worth, https is available on appspot.com domains. lots have changed since i started using web2py with GAE, and i'm slow to adjust - i don't know if it yet is possible to view tickets in the web2py way on GAE yet or not, but i find that the GAE logs are just as good as the ticket system. when running the development server i read the console output, when in production i login to the GAE console and click on logs. stack traces are saved there just like in tickets - though the GAE logs leave it as an exercise for the coder to open their source files and read the lines referred to in the traceback. if you want SSL for the deployment process, follow the link the google conveniently provides in the error message. i have not done the install on windows so i can't speak to how easy/hard that is. cfh
[web2py] Thanks to all members for all you time and effort !!
I`d like to thank the web2py forum members THANKS for all you assistance... finally im finished my course usuing web2py and this forum added me in so many ways. what I found very funny was that at the beginning of my web course when my lecturer told us(my class and I) that we would be using a framework called Web2py I was not the very enthused.. and believe me when I tell you that half of the semester was crazy.. no one wanted to learn the framework because it was so hard and according to the majority they didn't understand it(in my opinion prob because most of us never worked with a framework and also because we were so reluctant to change our work methods). It got to the point where people were blaming their failure on Web2py. Up till now ,with my last 2 assignments , Web2py was the reason why they could not complete it.. I must admit though, I hated the framework when i started. It was the first course that I literally had no clue as to what I was doing(meaning I also blamed Web2py). Now my my.. to my surprise, I am doing what i could not fathom at the beginning of the semester.. I definitely have learnt to appreciate Web2py.. it has taught me far more than I expected... and my classmates (the ones that have woken up to change) have realized and has openly expressed that as well.. So again thank you all for all your efforts to assist!! Special thanks to Massimo Di Pierro..(smiles) Thanks a million to all Live Laugh Love || Strength, Courage and Wisdom “Nothing in this world can take the place of persistence. Talent will not; nothing is more common than unsuccessful people with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. The slogan press on has solved and always will solve the problems of the human race”
[web2py] Thanks to all members for all you time and effort !!
I`d like to thank the web2py forum members THANKS for all you assistance... finally im finished my course usuing web2py and this forum added me in so many ways. what I found very funny was that at the beginning of my web course when my lecturer told us(my class and I) that we would be using a framework called Web2py I was not the very enthused.. and believe me when I tell you that half of the semester was crazy.. no one wanted to learn the framework because it was so hard and according to the majority they didn't understand it(in my opinion prob because most of us never worked with a framework and also because we were so reluctant to change our work methods). It got to the point where people were blaming their failure on Web2py. Up till now ,with my last 2 assignments , Web2py was the reason why they could not complete it.. I must admit though, I hated the framework when i started. It was the first course that I literally had no clue as to what I was doing(meaning I also blamed Web2py). Now my my.. to my surprise, I am doing what i could not fathom at the beginning of the semester.. I definitely have learnt to appreciate Web2py.. it has taught me far more than I expected... and my classmates (the ones that have woken up to change) have realized and has openly expressed that as well.. So again thank you all for all your efforts to assist!! Special thanks to Massimo Di Pierro..(smiles) Thanks a million to all Live Laugh Love || Strength, Courage and Wisdom “Nothing in this world can take the place of persistence. Talent will not; nothing is more common than unsuccessful people with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. The slogan press on has solved and always will solve the problems of the human race”
[web2py] Cannot register or login a user
I've goofed up my application in some way that prevents me from registering or logging in. How do I fix this please?
[web2py] Re: Thanks to all members for all you time and effort !!
Can you tell us which school? On May 30, 5:56 pm, Resa taratbr...@gmail.com wrote: I`d like to thank the web2py forum members THANKS for all you assistance... finally im finished my course usuing web2py and this forum added me in so many ways. what I found very funny was that at the beginning of my web course when my lecturer told us(my class and I) that we would be using a framework called Web2py I was not the very enthused.. and believe me when I tell you that half of the semester was crazy.. no one wanted to learn the framework because it was so hard and according to the majority they didn't understand it(in my opinion prob because most of us never worked with a framework and also because we were so reluctant to change our work methods). It got to the point where people were blaming their failure on Web2py. Up till now ,with my last 2 assignments , Web2py was the reason why they could not complete it.. I must admit though, I hated the framework when i started. It was the first course that I literally had no clue as to what I was doing(meaning I also blamed Web2py). Now my my.. to my surprise, I am doing what i could not fathom at the beginning of the semester.. I definitely have learnt to appreciate Web2py.. it has taught me far more than I expected... and my classmates (the ones that have woken up to change) have realized and has openly expressed that as well.. So again thank you all for all your efforts to assist!! Special thanks to Massimo Di Pierro..(smiles) Thanks a million to all Live Laugh Love || Strength, Courage and Wisdom “Nothing in this world can take the place of persistence. Talent will not; nothing is more common than unsuccessful people with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. The slogan press on has solved and always will solve the problems of the human race”
[web2py] Re: Cannot register or login a user
LOL. Make sure that you have def user(): return dict(form=auth()) If still does not work, show us your db.py On May 30, 5:41 pm, rjmolesa rjmol...@gmail.com wrote: I've goofed up my application in some way that prevents me from registering or logging in. How do I fix this please?
[web2py] Re: Deploying with default web2py server?
Ok, that answers my question. Thanks alot! On May 30, 3:50 pm, Sebastian E. Ovide sebastian.ov...@gmail.com wrote: from the book (http://web2py.com/book/default/chapter/11) web2py comes with an SSL21http://en.wikipedia.org/wiki/Secure_Sockets_Layer enabled web server, the Rocket wsgiserver22 https://launchpad.net/rocket . While this is a fast web server, it has limited configuration capabilities. For this reason it is best to deploy web2py behind Apache78http://www.apache.org/ , Lighttpd85 http://www.lighttpd.net/ or Cherokee86http://www.cherokee-project.com/download/ On Mon, May 30, 2011 at 8:58 PM, ra3don ra3do...@gmail.com wrote: I apologize if this has already been answered somewhere. Are there any disadvantages to deploying using the default server that comes with web2py? -- Sebastian E. Ovide
[web2py] Re: Thanks to all members for all you time and effort !!
University of the West Indies On May 30, 4:05 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you tell us which school? On May 30, 5:56 pm, Resa taratbr...@gmail.com wrote: I`d like to thank the web2py forum members THANKS for all you assistance... finally im finished my course usuing web2py and this forum added me in so many ways. what I found very funny was that at the beginning of my web course when my lecturer told us(my class and I) that we would be using a framework called Web2py I was not the very enthused.. and believe me when I tell you that half of the semester was crazy.. no one wanted to learn the framework because it was so hard and according to the majority they didn't understand it(in my opinion prob because most of us never worked with a framework and also because we were so reluctant to change our work methods). It got to the point where people were blaming their failure on Web2py. Up till now ,with my last 2 assignments , Web2py was the reason why they could not complete it.. I must admit though, I hated the framework when i started. It was the first course that I literally had no clue as to what I was doing(meaning I also blamed Web2py). Now my my.. to my surprise, I am doing what i could not fathom at the beginning of the semester.. I definitely have learnt to appreciate Web2py.. it has taught me far more than I expected... and my classmates (the ones that have woken up to change) have realized and has openly expressed that as well.. So again thank you all for all your efforts to assist!! Special thanks to Massimo Di Pierro..(smiles) Thanks a million to all Live Laugh Love || Strength, Courage and Wisdom “Nothing in this world can take the place of persistence. Talent will not; nothing is more common than unsuccessful people with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. The slogan press on has solved and always will solve the problems of the human race”
[web2py] error: type 'exceptions.AttributeError'('dict' object has no attribute 'startswith'), dal.py in migrate_table at line 703
Hi, Running latest trunk, I get the following error (on any request): type 'exceptions.AttributeError'('dict' object has no attribute 'startswith') File C:\web2py\gluon\dal.py in migrate_table at line 703 ... sql_fields[key].startswith('INT,') ... Maybe ['sql'] should be added to sql_fields[key] in line # 703 and to sql_fields_old[key] in line # 704?. Thanks, Carlos
[web2py] Re: Email invitation
I haved added import uuid at the top of myproject/controllers/ invitation.py, but it does not change anything. myproject/models/invitation.py looks like this : db.define_table('invitation',Field('token')) myproject/views/invitation.html looks like this : {{extend 'layout.html'}} {{=form}} Any clue ? Sorry I am just a beginner... I have read the UUID Wikipedia page. On 30 mai, 21:42, Dwayne Blind dwaynebl...@gmail.com wrote: Nope I don't have import uuid :( Should I ? Where can I read more about uuid ? Thank you On 30 mai, 21:15, pbreit pbreitenb...@gmail.com wrote: Did you get that error before? Do you have import uuid in the file?- Masquer le texte des messages précédents - - Afficher le texte des messages précédents -
[web2py] Re: Thanks to all members for all you time and effort !!
Thank you Resa. We hope to have more of your questions and suggestions on the list. On May 30, 6:24 pm, Resa taratbr...@gmail.com wrote: University of the West Indies On May 30, 4:05 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you tell us which school? On May 30, 5:56 pm, Resa taratbr...@gmail.com wrote: I`d like to thank the web2py forum members THANKS for all you assistance... finally im finished my course usuing web2py and this forum added me in so many ways. what I found very funny was that at the beginning of my web course when my lecturer told us(my class and I) that we would be using a framework called Web2py I was not the very enthused.. and believe me when I tell you that half of the semester was crazy.. no one wanted to learn the framework because it was so hard and according to the majority they didn't understand it(in my opinion prob because most of us never worked with a framework and also because we were so reluctant to change our work methods). It got to the point where people were blaming their failure on Web2py. Up till now ,with my last 2 assignments , Web2py was the reason why they could not complete it.. I must admit though, I hated the framework when i started. It was the first course that I literally had no clue as to what I was doing(meaning I also blamed Web2py). Now my my.. to my surprise, I am doing what i could not fathom at the beginning of the semester.. I definitely have learnt to appreciate Web2py.. it has taught me far more than I expected... and my classmates (the ones that have woken up to change) have realized and has openly expressed that as well.. So again thank you all for all your efforts to assist!! Special thanks to Massimo Di Pierro..(smiles) Thanks a million to all Live Laugh Love || Strength, Courage and Wisdom “Nothing in this world can take the place of persistence. Talent will not; nothing is more common than unsuccessful people with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. The slogan press on has solved and always will solve the problems of the human race”
Re: [web2py] Thanks to all members for all you time and effort !!
congratulations for complete your course, happy web2py forever... \(^o^)/
[web2py] Re: GROUP BY Date, Ignore Time
Awesome. Exactly what I needed, thank you. On May 29, 4:14 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: set = db(db.posts.id).select(db.posts.posted_date, count, groupby=db.posts.posted_date.year()|db.posts.posted_date.month()| db.posts.posted_date.day()) On May 29, 2:42 pm, Neodudeman tams...@gmail.com wrote: Hi web2py; I've got some problems. I'm attempting to get a count of some rows based on thedate; but when I attempt the grouping, it includes thetimeas well, giving me a false count. (Since no two rows were created at the exact same second, the count never goes above 1 per 'date') Here's my current code: count = db.posts.id.count() set = db(db.posts.id).select(db.posts.posted_date, count, groupby=db.posts.posted_date) How can I change the groupby toignorethetimeportion of the posted_date?
[web2py] Re: Email invitation
We need to see the code and the error message.
[web2py] Re: Email invitation
1. # coding: utf8 2. import uuid 3. 4. def invitation(): 5. 6. form = FORM(INPUT(_name='email', requires=IS_NOT_EMPTY()), 7. INPUT(_type='submit')) 8. 9. if form.accepts(request.vars): 10. uuid=str(uuid.uuid4()) 11. db.invitation.insert(token = uuid) 12. mail.send(to=form.vars.email,message='click %s to register' % URL('register',args=uuid)) 13. redirect(URL('index')) 14. 15. return dict(form=form) 16. Traceback (most recent call last): File gluon/restricted.py, line 181, in restricted File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py, line 17, in module File gluon/globals.py, line 133, in lambda File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py, line 10, in invitation UnboundLocalError: local variable 'uuid' referenced before assignment (The traceback is the same.) On 31 mai, 02:03, pbreit pbreitenb...@gmail.com wrote: We need to see the code and the error message.
[web2py] Re: error: type 'exceptions.AttributeError'('dict' object has no attribute 'startswith'), dal.py in migrate_table at line 703
I do not think you are running trunk. Do you have this code in dal.py? def fix(item): k,v=item if not isinstance(v,dict): v=dict(type='unkown',sql=v) return k.lower(),v ### make sure all field names are lower case to avoid conflicts sql_fields = dict(fix(v) for v in sql_fields.items()) sql_fields_old = dict(fix(v) for v in sql_fields_old.items()) sql_fields_aux = dict(fix(v) for v in sql_fields_aux.items()) What do your lines 703 and 704. say? On May 30, 6:26 pm, Carlos carlosgali...@gmail.com wrote: Hi, Running latest trunk, I get the following error (on any request): type 'exceptions.AttributeError'('dict' object has no attribute 'startswith') File C:\web2py\gluon\dal.py in migrate_table at line 703 ... sql_fields[key].startswith('INT,') ... Maybe ['sql'] should be added to sql_fields[key] in line # 703 and to sql_fields_old[key] in line # 704?. Thanks, Carlos
[web2py] Re: Email invitation
The problem is: import uuid def invitation(): uuid ... uuid = ... the interpreter thinks the uuid in the function is a local one and not the same uuid defined outside by the import. On May 30, 7:43 pm, Dwayne Blind dwaynebl...@gmail.com wrote: 1. # coding: utf8 2. import uuid 3. 4. def invitation(): 5. 6. form = FORM(INPUT(_name='email', requires=IS_NOT_EMPTY()), 7. INPUT(_type='submit')) 8. 9. if form.accepts(request.vars): 10. uuid=str(uuid.uuid4()) 11. db.invitation.insert(token = uuid) 12. mail.send(to=form.vars.email,message='click %s to register' % URL('register',args=uuid)) 13. redirect(URL('index')) 14. 15. return dict(form=form) 16. Traceback (most recent call last): File gluon/restricted.py, line 181, in restricted File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py, line 17, in module File gluon/globals.py, line 133, in lambda File C:/Users/Coco/Downloads/web2py_win/web2py/applications/ myproject/controllers/invitation.py, line 10, in invitation UnboundLocalError: local variable 'uuid' referenced before assignment (The traceback is the same.) On 31 mai, 02:03, pbreit pbreitenb...@gmail.com wrote: We need to see the code and the error message.
[web2py] Re: GROUP BY Date, Ignore Time
notice you can also do: post_date=db.posts.posted_date.year()|db.posts.posted_date.month()| db.posts.posted_date.day() set = db(db.posts.id).select(db.posts.posted_date, count,groupby=pos_date) in case you need it in more than once place. On May 30, 6:38 pm, Neodudeman tams...@gmail.com wrote: Awesome. Exactly what I needed, thank you. On May 29, 4:14 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: set = db(db.posts.id).select(db.posts.posted_date, count, groupby=db.posts.posted_date.year()|db.posts.posted_date.month()| db.posts.posted_date.day()) On May 29, 2:42 pm, Neodudeman tams...@gmail.com wrote: Hi web2py; I've got some problems. I'm attempting to get a count of some rows based on thedate; but when I attempt the grouping, it includes thetimeas well, giving me a false count. (Since no two rows were created at the exact same second, the count never goes above 1 per 'date') Here's my current code: count = db.posts.id.count() set = db(db.posts.id).select(db.posts.posted_date, count, groupby=db.posts.posted_date) How can I change the groupby toignorethetimeportion of the posted_date?
[web2py] Re: error: type 'exceptions.AttributeError'('dict' object has no attribute 'startswith'), dal.py in migrate_table at line 703
Sorry, line # 698 (and maybe 699) ... File C:\web2py\gluon\dal.py, line 4212, in define_table polymodel=polymodel) File C:\web2py\gluon\dal.py, line 641, in create_table fake_migrate=fake_migrate) File C:\web2py\gluon\dal.py, line 698, in migrate_table sql_fields[key].startswith('INT,') and \ AttributeError: 'dict' object has no attribute 'startswith' elif sql_fields[key]['sql'] != sql_fields_old[key]['sql'] \ and not isinstance(table[key].type, SQLCustomType) \ and not (table[key].type.startswith('reference') and \ sql_fields[key].startswith('INT,') and \ sql_fields_old[key].startswith('INT NOT NULL,')): I do have that code you mention in dal.py. Thanks, Carlos
Re: [web2py] Re: Cannot register or login a user
No dice. Let me add that I get the registration and login forms, but that when I hit submit nothing happens. The form clears and reloads. I have 1 entry in auth_user table from when registration worked. Switching to janrain.com authentication also fails. My db.py can be found here http://pastie.textmate.org/1995863. I have used the wizard several times now to not only create but edit my application. So if it helps my db_wizard.py is here http://pastie.textmate.org/1995892. Thanks for the help. On Mon, May 30, 2011 at 7:08 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: LOL. Make sure that you have def user(): return dict(form=auth()) If still does not work, show us your db.py On May 30, 5:41 pm, rjmolesa rjmol...@gmail.com wrote: I've goofed up my application in some way that prevents me from registering or logging in. How do I fix this please? -- Jon Molesa rjmol...@gmail.com
[web2py] Re: Postgresql database schema
You could always change the schema before executing the db commands: db.executesql(set search_path to 'schemaname,public';) If you could determine the name of the schema first that would be feasible. On May 30, 5:14 am, Massimiliano mbelle...@gmail.com wrote: Hi all, I've a legacy enterprise application that use postgresql as database. Existing tables are divided on different database schemas (not only public). Now I want to rewrite a single application that use existing tables on schema xyz. Does web2py support that? Thank you -- Massimiliano
Re: [web2py] Re: Cannot register or login a user
That line exists in default.py. On Mon, May 30, 2011 at 7:08 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: LOL. Make sure that you have def user(): return dict(form=auth()) If still does not work, show us your db.py On May 30, 5:41 pm, rjmolesa rjmol...@gmail.com wrote: I've goofed up my application in some way that prevents me from registering or logging in. How do I fix this please? -- Jon Molesa rjmol...@gmail.com
[web2py] Re: error: type 'exceptions.AttributeError'('dict' object has no attribute 'startswith'), dal.py in migrate_table at line 703
you are right. good catch! On May 30, 8:34 pm, Carlos carlosgali...@gmail.com wrote: Sorry, line # 698 (and maybe 699) ... File C:\web2py\gluon\dal.py, line 4212, in define_table polymodel=polymodel) File C:\web2py\gluon\dal.py, line 641, in create_table fake_migrate=fake_migrate) File C:\web2py\gluon\dal.py, line 698, in migrate_table sql_fields[key].startswith('INT,') and \ AttributeError: 'dict' object has no attribute 'startswith' elif sql_fields[key]['sql'] != sql_fields_old[key]['sql'] \ and not isinstance(table[key].type, SQLCustomType) \ and not (table[key].type.startswith('reference') and \ sql_fields[key].startswith('INT,') and \ sql_fields_old[key].startswith('INT NOT NULL,')): I do have that code you mention in dal.py. Thanks, Carlos
[web2py] Re: importing a db/model from other app
What I want is not to clone a db or model but to be able to manage one DB from other app. I am trying to do a modified version of the admin app where you just have to chose an option to a target app and it will plug into it working as a backoffice for managers/administrators of that app. if I use the same DAL string I will get the same DB, but will I get the model too? I've been trying it but I get no databases/tables listing in my app :/ Thank you On May 30, 10:07 pm, mart msenecal...@gmail.com wrote: Have you tried Massimo's new script? I've been unexpectedly busy in the last few days, but I hope to have time to complete wrapping that script in argparse this evening (or tomorrow) which will have just a few more options that I have found useful (ie. truncate, delete db, copy model, etc.). With or without argparse, its pretty sweet! from his posting (May 23) title: script to clone a database http://code.google.com/p/web2py/source/browse/scripts/cpdb.py Usage: python web2py.py -S app -M -N -R scripts/cpdb.py -A 'sqlite:// other_db.sqlite' It will copy all data from current db to other_db (sqlite or not) The -A argument can be any URI string for example 'mysql://username:password@localhost/ dbname' hope it helps! Mart :) On May 30, 2:33 pm, pbreit pbreitenb...@gmail.com wrote: I don't understand the question. Do you want to share the same DB from two different apps? I suppose you could copy the models and then set your DB connection strings to point to the same DB. In one app set migrate=False. You might even be able to symbolically link the models from one app to the other. The DAL can work standalone so you could put it in a module, Web2py's site_packages or anywhere in your Python path. If you use it outside it's normal location, include from gluon.dal import * at the top of your files and then you should be able to do all the same things (db = DAL(..., db.define_table(...). You mentioned exporting which is quite different.http://web2py.com/book/default/chapter/06?search=Exporting-and-Import... Might need to understand more completely what you are trying to do.
[web2py] Re: importing a db/model from other app
I believe you are thinking of appadmin which is a controller in each app.
[web2py] ProgrammingError: there is no unique constraint matching given keys for referenced table xuser
Hi, I'm using latest trunk, with 'xuser' instead of auth_user (which is not the issue because I was getting no errors up until very recently). Note that everything was working ok (no errors) up until 4 changesets ago, i.e. up until changeset # e33d3578be33 (fixed problem with load and string args). If I update to that changeset (e33d3578be33), everything works ok again. web2py™ Version 1.96.0 (2011-05-30 21:04:39) Python Python 2.6.4: C:\Python26\python.exe File C:\web2py\gluon\dal.py, line 4212, in define_table polymodel=polymodel) File C:\web2py\gluon\dal.py, line 641, in create_table fake_migrate=fake_migrate) File C:\web2py\gluon\dal.py, line 729, in migrate_table self.execute(sub_query) File C:\web2py\gluon\dal.py, line 1222, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1217, in log_execute ret = self.cursor.execute(*a,**b) ProgrammingError: there is no unique constraint matching given keys for referenced table xuser def log_execute(self,*a,**b): self.db._lastsql = a[0] t0 = time.time() ret = self.cursor.execute(*a,**b) self.db._timings.append((a[0],time.time()-t0)) return ret Variables a ('ALTER TABLE xuser ADD xupdated_by__tmp INTEGER REFERENCES xuser(first_name) ON DELETE SET NULL;',) b {} self gluon.dal.PostgreSQLAdapter object at 0x03872450 ret undefined self.cursor cursor object at 0x0390A990; closed: 0 self.cursor.execute built-in method execute of psycopg2._psycopg.cursor object at 0x0390A990 Thanks, Carlos
[web2py] Re: ProgrammingError: there is no unique constraint matching given keys for referenced table xuser
Can I see your model definition for table xauth? On May 30, 10:34 pm, Carlos carlosgali...@gmail.com wrote: Hi, I'm using latest trunk, with 'xuser' instead of auth_user (which is not the issue because I was getting no errors up until very recently). Note that everything was working ok (no errors) up until 4 changesets ago, i.e. up until changeset # e33d3578be33 (fixed problem with load and string args). If I update to that changeset (e33d3578be33), everything works ok again. web2py™ Version 1.96.0 (2011-05-30 21:04:39) Python Python 2.6.4: C:\Python26\python.exe File C:\web2py\gluon\dal.py, line 4212, in define_table polymodel=polymodel) File C:\web2py\gluon\dal.py, line 641, in create_table fake_migrate=fake_migrate) File C:\web2py\gluon\dal.py, line 729, in migrate_table self.execute(sub_query) File C:\web2py\gluon\dal.py, line 1222, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1217, in log_execute ret = self.cursor.execute(*a,**b) ProgrammingError: there is no unique constraint matching given keys for referenced table xuser def log_execute(self,*a,**b): self.db._lastsql = a[0] t0 = time.time() ret = self.cursor.execute(*a,**b) self.db._timings.append((a[0],time.time()-t0)) return ret Variables a ('ALTER TABLE xuser ADD xupdated_by__tmp INTEGER REFERENCES xuser(first_name) ON DELETE SET NULL;',) b {} self gluon.dal.PostgreSQLAdapter object at 0x03872450 ret undefined self.cursor cursor object at 0x0390A990; closed: 0 self.cursor.execute built-in method execute of psycopg2._psycopg.cursor object at 0x0390A990 Thanks, Carlos
[web2py] Re: ProgrammingError: there is no unique constraint matching given keys for referenced table xuser
Can I also see your databases/_xauth.table (unpickled)? On May 30, 10:34 pm, Carlos carlosgali...@gmail.com wrote: Hi, I'm using latest trunk, with 'xuser' instead of auth_user (which is not the issue because I was getting no errors up until very recently). Note that everything was working ok (no errors) up until 4 changesets ago, i.e. up until changeset # e33d3578be33 (fixed problem with load and string args). If I update to that changeset (e33d3578be33), everything works ok again. web2py™ Version 1.96.0 (2011-05-30 21:04:39) Python Python 2.6.4: C:\Python26\python.exe File C:\web2py\gluon\dal.py, line 4212, in define_table polymodel=polymodel) File C:\web2py\gluon\dal.py, line 641, in create_table fake_migrate=fake_migrate) File C:\web2py\gluon\dal.py, line 729, in migrate_table self.execute(sub_query) File C:\web2py\gluon\dal.py, line 1222, in execute return self.log_execute(*a, **b) File C:\web2py\gluon\dal.py, line 1217, in log_execute ret = self.cursor.execute(*a,**b) ProgrammingError: there is no unique constraint matching given keys for referenced table xuser def log_execute(self,*a,**b): self.db._lastsql = a[0] t0 = time.time() ret = self.cursor.execute(*a,**b) self.db._timings.append((a[0],time.time()-t0)) return ret Variables a ('ALTER TABLE xuser ADD xupdated_by__tmp INTEGER REFERENCES xuser(first_name) ON DELETE SET NULL;',) b {} self gluon.dal.PostgreSQLAdapter object at 0x03872450 ret undefined self.cursor cursor object at 0x0390A990; closed: 0 self.cursor.execute built-in method execute of psycopg2._psycopg.cursor object at 0x0390A990 Thanks, Carlos
[web2py] Re: Thanks to all members for all you time and effort !!
Good for you on the course completion. There is a lot to learn especially if you have never done web development before of this type. For web development many people do HTML/CSS and to a lesser degree Javascript only so the server only pushes pages that are pre-canned. I worked with Java for many years doing server development and by comparison web2py is a dream. Part of the comparative ease of use is Python but much of it is the organization and integration of web2py. At first it looks like magic, then you learn a little because magic is an uneasy feeling but as you gain experience you learn some more and start to realize how well put together it all is. Java in it's own way is okay, just so much boiler plate code and some of the frameworks have you writing pages of XML that has no equivalent in web2py mainly because it follows a philosophy similar to Ruby on Rails (convention not configuration). Maybe see you back if you do more with web2py.
[web2py] Re: importing a db/model from other app
well then, not sure then is this helps, but I have 1 web app looking a db and a script (no web, just dal) that points to the same DB, both can select, update, insert from the same DB etc... as long as both know about the tables (and one has migrate=True). Changes on one side side can be seen by the other. when developing or making changes, or adding or removing tables (typically I do this from script), I always finish off by running a script that will look for all instances of db.define_table('',(bla)), and will re-write those lines in db.py I assume this can also be done as easily with 2 web apps... Is that what you mean? Mart :) On May 30, 11:25 pm, pbreit pbreitenb...@gmail.com wrote: I believe you are thinking of appadmin which is a controller in each app.
Re: [web2py] Re: Cannot register or login a user
Nevermind. Thanks anyway. On Mon, May 30, 2011 at 10:23 PM, Jon Molesa rjmol...@gmail.com wrote: That line exists in default.py. On Mon, May 30, 2011 at 7:08 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: LOL. Make sure that you have def user(): return dict(form=auth()) If still does not work, show us your db.py On May 30, 5:41 pm, rjmolesa rjmol...@gmail.com wrote: I've goofed up my application in some way that prevents me from registering or logging in. How do I fix this please? -- Jon Molesa rjmol...@gmail.com -- Jon Molesa rjmol...@gmail.com