[web2py] IS_IN_SET, multiple=False, checkboxes
Hello, I have come uppon the following. If i declare the following field Field('test', notnull=True, requires=IS_IN_SET([1,2,3,4],multiple=False),widget=SQLFORM.widgets.checkboxes.widget), The expected behaviour should be to be able to select only one checkbox. What is happening is that i am allowed to select multiple boxes but gives me an error when i try to submit my form. Any ideas?
[web2py] how to present rows in multiple pages
I have a query that returns many (45) results and i want to l present 10 rows per page and have links at the bottom with the page numbers (1,2,3,4,5 and maybe a button next or previews). How can i implement this in web2py? Thnx
[web2py] automatic logout does not work
I set the auth.settings.expiration time but the user is not automatically logged out after the specified time I have tried setting auth.settings.expiration = 1 in db.py after before calling auth.define_tables()
Re: [web2py] referenced auth.user_id type string
Thanks for your answers guys. I have another question related to this topic. Say i want to reference an authorized user instead of a person table: db.define_table('cat', Field('name'), Field('owner', db.auth_user, default=auth.user_id,readable=False,writable=False),) So that the owner of the cat is the logged in user. Also i have a view that displays the cat owner. Lets say i want to have the option to either keep the cat or purge it or five it to another owner (in general take an action), after the user has been deleted. How can i do it? If i use ondelete=CASCADE the cat will be deleted ondelete=SET NULL the owner of the cat will be NULL ondelete=NO ACTION but there is no way to define take an action. Any ideas??
[web2py] MySQL constraints not updated but appended to old ones
I have a field Field('uUser2', db.auth_user, default=auth.user_id), at some moment i added ondelete=CASCADE later i changed it to ondelete=NO ACTION but when i checked my db i had KEY `rUser2__idx` (`ruser2`), CONSTRAINT `sounds_ibfk_1` FOREIGN KEY (`ruser`) REFERENCES `auth_user` (`id`) ON DELETE CASCADE, CONSTRAINT `sounds_ibfk_2` FOREIGN KEY (`ruser2`) REFERENCES `auth_user` (`id`) ON DELETE NO ACTION So the old constrain should be removed but it doesn't. Is this the expected behaviour??
Re: [web2py] referenced auth.user_id type string
What do you mean handle it in application logic? How/when do i detect from my app that a user has been deleted?
[web2py] remove references problem
I know that if i declare the following db.define_table('person', Field('name'),) db.define_table('cat', Field('name'), Field('owner',db.person)) db.cat.owner.requires = IS_IN_DB(db, db.person.id) Then if i delete a person, all the cats of this person will be deleted. But i declare the cat table like this db.define_table('cat', Field('name'), Field('owner',default=db.person.id)) db.cat.owner.requires = IS_IN_DB(db, db.person.id) the cats of that person are not deleted and i have a broken reference. Is there another way to fix this instead of doing it as described above?
[web2py] Re: remove references problem
Well i guess that doing db.define_table('cat', Field('name'), Field('owner',db.person,default=db.person.id)) db.cat.owner.requires = IS_IN_DB(db, db.person.id) does the job.
Re: [web2py] referenced auth.user_id type string
This is a solution but look at the following, if i declare db.define_table('person', Field('name'),) db.define_table('cat', Field('name'), Field('owner',integer,db.person,default=db.person.id)) db.cat.owner.requires = IS_IN_DB(db, db.person.id) the reference is broken. Is there another solution?
Re: [web2py] referenced auth.user_id type string
By reference is broken i mean that if i remove at some point the person, the cat that belongs to that person is not removed...
[web2py] migrate passwords from phpBB
I am trying to migrate users from phpBB whose passwords have been encrypted with php_pass. There is a python module that mimics the functionality of php_pass and i am wondering what is the best way to override the default encryption of web2py. Is it sufficient to override CRYPT() using something like: db.auth_user.password.requires = MyCrypt() Thanks
[web2py] Re: Massimo
My compliments as well to both Massimo and all contributors. Keep up the good work guys! Thodoris On Dec 7, 9:08 am, chandrakant kumar k.03chan...@gmail.com wrote: Programmers don't get the glory they deserve,http://goo.gl/yRJbR. On Wed, Dec 7, 2011 at 12:34 PM, Vineet vineet.deod...@gmail.com wrote: Oops. Inadvertently, I did not mention about the other contributors in my OP! Anthony's ( of course, the other members') replies have been very useful to me.
[web2py] hidding functionality and DRY
I have found myself doing multiple times in my views: {{if auth.user:}} # checking that a user in logged in and {{if auth.user.id == my_table.author_id:}} # if he is the author of a table entry SHOW SOMETHING ONLY TO THE AUTHOR OF THIS TABLE {{pass}} {{pass}} I am thinking that repeating myself is a bad code practice and i am going to make a function like is_author(auth.user, my_table.author_id) and in the view have {{if is_author(...):}} Could i hear some opinions on that? Also if there are parts of code that appear in multiple views, is it better to make a function that returns html code in order to make the code better???
[web2py] vars passed to LOAD become strings
I am trying to use the LOAD component and i have some questions. I would like to pass an argument to the LOAD function which is a table row but it is converted to a string and i can't access the row attributes. There is a way to pass them by value but i would prefer to pass the row instead (or a dictionary if possible). So in my index.html i have # where my_tables = db().select(db.my_tables.ALL) is returned from default/index {{for table in my_tables:}} {{=LOAD('info', 'tables_info.load', vars={'table':table}, ajax=True)}} {{pass}} i have defined the controller tables_info in info.py to return the the dictionary that it gets def tables_info(): table = request.vars.table return dict(table=table) And i have also defined the view info/tables_info.load where is the things that i would like to present div class=tables_info {{=type(table)}} {{=table.key}} /div Here i can't access the table.keys cause table is of type str. What can i do in this case?
[web2py] Re: vars passed to LOAD become strings
There is the solution to pass the table.id as an argument and then make an additional query to the database in tables_info to get the table but i don't like this solution because i already have the row from a previous query. An extra question, now in the div i present inside index div class=tables_info {{=type(table)}} {{=table.key}} /div i add an {{=A(Like, _href=URL('default', 'like', extension=False))}} which is a function in another controller ('default') that changes the value of 'like' (is a field of table like {{=table.key}} in the above example) How do i trigger the refresh of the div? The example in the book has a submit form that refreshes the page, but in my case there is not but still a value has changed. I guess that i should do something in my like function in default.py def like(): table_id = request.args(0) table = db.my_table[table_id] like = table.like + 1 table.update_record(like=like) # something here ?? Thanks for all the help On Dec 6, 11:22 am, thodoris pasxi...@gmail.com wrote: I am trying to use the LOAD component and i have some questions. I would like to pass an argument to the LOAD function which is a table row but it is converted to a string and i can't access the row attributes. There is a way to pass them by value but i would prefer to pass the row instead (or a dictionary if possible). So in my index.html i have # where my_tables = db().select(db.my_tables.ALL) is returned from default/index {{for table in my_tables:}} {{=LOAD('info', 'tables_info.load', vars={'table':table}, ajax=True)}} {{pass}} i have defined the controller tables_info in info.py to return the the dictionary that it gets def tables_info(): table = request.vars.table return dict(table=table) And i have also defined the view info/tables_info.load where is the things that i would like to present div class=tables_info {{=type(table)}} {{=table.key}} /div Here i can't access the table.keys cause table is of type str. What can i do in this case?
[web2py] Re: vars passed to LOAD become strings
I didn't know about the callback argument. Thanks a lot for the tip. In the above case then it is not necessary then. I was going to use something quite complicated for something simple. Is it possible for the callback to affect multiple fields, or else what happens if there are fields with the same id ?? So, when LOAD should be used then? On Dec 6, 2:54 pm, Anthony abasta...@gmail.com wrote: {{=A(Like, _href=URL('default', 'like', extension=False))}} which is a function in another controller ('default') that changes the value of 'like' (is a field of table like {{=table.key}} in the above example) How do i trigger the refresh of the div? The example in the book has a submit form that refreshes the page, but in my case there is not but still a value has changed. I guess that i should do something in my like function You might consider using the callback argument to A() -- seehttp://web2py.com/book/default/chapter/05#Built-in-Helpers. Anthony
[web2py] Re: vars passed to LOAD become strings
One question related to the A() callback. Defining a div id=some_id /div and adding a target=some_id to the A works very well. I tried to do session.flash/response.flash inside the callback function but it didn't work. Is there a way to do it? def callback_function(): it does some stuff... if s == 1: return something elif s == 2: return something else else: session.flash = Message return ??? Is this possible??? On Dec 6, 4:12 pm, Anthony abasta...@gmail.com wrote: On Dec 6, 9:49 am, thodoris pasxi...@gmail.com wrote: I didn't know about the callback argument. Thanks a lot for the tip. In the above case then it is not necessary then. I was going to use something quite complicated for something simple. Is it possible for the callback to affect multiple fields, or else what happens if there are fields with the same id ?? In HTML, dom elements should not share the same id. But if you need to update multiple divs, I suppose you could instead have the link click trigger a call to web2py's ajax() function, which can take ':eval' as the target -- you can then return some JS, which will get evaluated when returned (the JS can update multiple targets). Seehttp://web2py.com/book/default/chapter/10#Eval-target. Anthony
[web2py] problem selecting from field with IS_IN_SET
I have the following featured = (0,1,2,3,4,5) Field('rank','list:integer',requires=IS_IN_SET(featured, zero='rank'), readable=False, writable=False), So this field can only be set from appadmin and is set by default to [] when a record is made, IIUC. I want to select the tables that have been seti to something in admin, so i do the following tables = db(db.my_table.rank [0]).select(orderby=db.my_table.featured_rank) but tables also contains the entries that have the default value [] What am i doing wrong? Also can i set a default value to my field ???
[web2py] upload field value reset on form failure of another field
Is there any way to keep the value that was inserted on an upload field after failing to validate the form due to another field, so that the user doesn't have to search for the file again?
[web2py] unable to set reference Field back to None once set
I have this field db.define_table('B', Field('my_table', db.A, notnull=False, ondelete=SET NULL), db.B.my_table.requires = IS_EMPTY_OR ( IS_IN_DB(db(db.A.author_id==auth.user_id), db.A.id, '%(title)s')) That means that my_table can have references from A but only the ones that the same user has made OR is empty (None). And also when the referenced object is deleted the value becomes None. What i want to do is to remove a reference at some point. I have the id of the entry i want to change and i do db.B[id].my_table = None but it doesn't work. Actually it doesn't allow me to change it from a function. Do i do something wrong?
[web2py] change form submit button to clickable text
Is there a way to change the submit button into clickable text (like an _href) next to a field? Lets say i have this form: form = SQLFORM.factory(Field('my_table'))
[web2py] Re: unable to set reference Field back to None once set
I found the solution myself In order to save the change i have to use: update_record On Nov 30, 12:07 pm, thodoris pasxi...@gmail.com wrote: I have this field db.define_table('B', Field('my_table', db.A, notnull=False, ondelete=SET NULL), db.B.my_table.requires = IS_EMPTY_OR ( IS_IN_DB(db(db.A.author_id==auth.user_id), db.A.id, '%(title)s')) That means that my_table can have references from A but only the ones that the same user has made OR is empty (None). And also when the referenced object is deleted the value becomes None. What i want to do is to remove a reference at some point. I have the id of the entry i want to change and i do db.B[id].my_table = None but it doesn't work. Actually it doesn't allow me to change it from a function. Do i do something wrong?
[web2py] call submit from an A tag
Is there a way to change the submit button into clickable text? Lets say i have this form: form = SQLFORM.factory(Field('my_table')) and i can do table = form.element() to get the element table.append(INPUT(_type='submit', _value='submit')): this appends the submit button next to the element but is there a way to call submit for an A, like this ??? table.append(A('Submit',_type='submit', _value='submit')))
[web2py] referenced auth.user_id type string
Hello, Simple question: auth.user.id returns an integer but if i define a field in a table: Field('author_id', default=auth.user_id) author_id is a string and if i want in a later step to compare these values it doesn't seem good tactic to do str(auth.user.id)
[web2py] clean upload notnull field after being set
Hello, I have this Field Field('cover','upload',notnull=False,autodelete=True), When the form is displayed you click on browse you can select the file. But once a file is selected you cannot undo your choice. There is always the choice to reload the page that holds the form and clean the field but is there another way to do it??
[web2py] Re: clean upload notnull field after being set
Thanx for the reply, Well, whenever i put the cursor on the text area a popup window opens to choose the file, so i can't edit the text. About the solution with Javascript, how can i reference the field that i want to clear? I could do something like: form.append(INPUT(_type=button, _value=Clear, _onclick=form.field[3]='';)) On Nov 29, 4:25 pm, Anthony abasta...@gmail.com wrote: Unless you're using a special widget, once you select a file for upload, the browser should simply put the filename in the string field next to the browse button. You should be able to put the cursor in that string field and delete the filename. As an alternative, I suppose you could add a button/link with some Javascript that automatically clears the field when clicked. Anthony On Tuesday, November 29, 2011 10:18:32 AM UTC-5, thodoris wrote: Hello, I have this Field Field('cover','upload',notnull=False,autodelete=True), When the form is displayed you click on browse you can select the file. But once a file is selected you cannot undo your choice. There is always the choice to reload the page that holds the form and clean the field but is there another way to do it??
[web2py] where to update response.headers on success
where can i update the response.headers before form.accepts returns True? Because i guess that if i update it after form.accepts returns then the response has already been sent. Thodoris
[web2py] how to keep response.headers after redirect
I want to do the following: I want to add a key to response.headers response.headers['success']='True' after a successful file upload and also redirect. The problem is that i also want to redirect after successful upload but redirect makes a new reasponse.headers and i lose the key i want to add. Is there a way to solve this? When upload fails and i don't get redirected i can see my key in the headers. My code is: @auth.requires_login() def upload(): db.reactable.id.default = request.args(0) form=SQLFORM(db.table) response.headers['success']='False' if form.accepts(request.vars,session): response.headers['success']='True' session.flash=Record added redirect(URL('index')) return dict(form=form)
[web2py] Re: how to keep response.headers after redirect
No it does not. Your solution is quite clean and of course works. Thanx a lot! On Nov 28, 2:37 pm, Anthony abasta...@gmail.com wrote: Does it have to be a response header? How about adding a flag as a URL arg or var: redirect(URL('index', vars=dict(success='True'))) If you need to check it on the client side, you can access the query string in JS via window.location.search. Alternatively, you could have the 'index' function itself set the header based on the query string: def index(): if request.vars.success: response.headers['success'] = 'True' Anthony On Monday, November 28, 2011 8:15:02 AM UTC-5, thodoris wrote: I want to do the following: I want to add a key to response.headers response.headers['success']='True' after a successful file upload and also redirect. The problem is that i also want to redirect after successful upload but redirect makes a new reasponse.headers and i lose the key i want to add. Is there a way to solve this? When upload fails and i don't get redirected i can see my key in the headers. My code is: @auth.requires_login() def upload(): db.reactable.id.default = request.args(0) form=SQLFORM(db.table) response.headers['success']='False' if form.accepts(request.vars,session): response.headers['success']='True' session.flash=Record added redirect(URL('index')) return dict(form=form)
[web2py] cancel upload leftovers
I have a form that has an upload field. If i add a cancel button to the form that for example redirects to 'index' the cancel is stopped but what if i wanted to cancel the upload from an app?? I am asking this cause i am uploading a file from an iphone app to the database but when i cancel that post request, there is an entry in the databade which corresponds to the part of the file that was uploaded until that moment. Any thoughts?
[web2py] cancel upload, return value
I have a form that has an upload field. The file can be big and i would like to add a cancel button to cancel the upload. If i add a cancel button to the form that for example redirects to 'index' the cancel is stopped but what is the logic behind it. Is some value returned and the form fails?? I am asking this cause i am uploading a file from an iphone app to the database but when i cancel that request, there is an entry in the databade which is a part of the file. Any thoughts?
[web2py] add key to response.headers for remote app?
What do i have to do in order for a remote app to know that a post of a form was successful? I tried to add a key to response.headers but when i read the response from my app i don't see my key there. Is it correct what i am doing? if form.accepts(request.vars,session): response['headers']['success']=True Thodoris
[web2py] field related to auth.user.id problem when user not logged in
Two questions: I have the following scheme: db.define_table('table', Field('title'), Field('author_id', default=auth.user_id,readable=False, writable=False), ... ) db.define_table('videos', Field('author_id',default=auth.user_id,readable=False, writable=False), Field('table',db.table) ) and i want the videos.table field to take values only from the entries that the same user has entered or Null db.videos.table.requires = IS_IN_DB(db(db.table.author_id==auth.user.id), db.table.id, '% (title)s') I get an error NoneType' object has no attribute 'id' , because the user initially is not logged in so there is no auth.user.id How can i solve this? Second question, if the user had entered a lot of entries which is the best way to display the dropdown list of tables??? Thodoris
[web2py] Re: field related to auth.user.id problem when user not logged in
Thanx for the help guys, what i did finally is db.videos.table.requires = IS_EMPTY_OR (IS_IN_DB(db(db.table.author_id==auth.user_id), db.table.id, '% (title)s')) What about displaying a BIG dropdown list of tables entries? Any help here ??? On Nov 21, 4:09 pm, Anthony abasta...@gmail.com wrote: But, according to your define_table()'s, these tables can only be managed (insert or update) with a logged user, or default contents will raise an excpetion because there's no logged user. The defaults won't raise an exception (as long as auth is defined prior to the table definitions), because auth.user_id simply returns None when the user is not logged in (i.e., it is not undefined). The same is true for auth.user -- it returns None when there is no logged in user (though auth.user.id will raise an exception because if auth.user is None, obviously it has no 'id' attribute). See very end of this section:http://web2py.com/book/default/chapter/08#Authentication Anthony
[web2py] text field remove default when user inputs data
Hello, I have a text field in my db with a default instructive text like Enter your comment here, but i would like when the user tries to input text, the default text to disappear without having to delete it manually
[web2py] Re: text field remove default when user inputs data
Thnx a lot! On Nov 16, 10:42 am, Anthony abasta...@gmail.com wrote: You can use a comment instead of a default: Fields(..., comment='Enter your comment here') though that will display next to or below the input field (depending on your formstyle) rather than in the text box itself. As an alternative, you can set the HTML5 'placeholder' attribute for the input field by customizing the field's widget: Field(..., widget=lambda f,v: SQLFORM.widgets.text.widget(f, v, _placeholder='Enter your comment here')) Anthony On Wednesday, November 16, 2011 4:24:54 AM UTC-5, thodoris wrote: Hello, I have a text field in my db with a default instructive text like Enter your comment here, but i would like when the user tries to input text, the default text to disappear without having to delete it manually
[web2py] menu problem when importing layout
Hello, When i install any layout in my app, i always have the following problem with the menu. Instead of the menu just expanding and covering the text bellow, it pushes all the text under it. I know that it should be a css problem but since i am new to css i would appreciate the help. The layout i use is called Replenish (http://web2py.com/ layouts/static/plugin_layouts/layouts/Replenish/index.html). Thodoris
[web2py] list:integer restrict
Hello, i would like to do the following but i am not sure how to do it. I want to define a field like rank = (0,1,2,3,4,5) Field('rank','list:integer',requires=IS_IN_SET(rank)), but i would like to implement the restriction that if for example 1 is already set, it won't appear in the list. Any ideas???
[web2py] hide functionality from non authenticated users
I want to do the following def some_function(): a = ... b = ... if auth.is_logged_in(): c = ... else: c = None return (a=a,b=b,c=c) And in the view some_function.html {{if c is not None:}} do something here {{pass}} which is the best practice to do it?
[web2py] Re: hide functionality from non authenticated users
There is nothing wrong, i just want to know if this is a clean way to do what i do above or there is a better way. Thodoris On Nov 15, 1:26 pm, Kenneth Lundström kenneth.t.lundst...@gmail.com wrote: Whats wrong in what you just described? {{if c != None:}} Kenneth I want to do the following def some_function(): a = ... b = ... if auth.is_logged_in(): c = ... else: c = None return (a=a,b=b,c=c) And in the view some_function.html {{if c is not None:}} do something here {{pass}} which is the best practice to do it?
[web2py] Re: hide functionality from non authenticated users
If c is for example a form is it safe to return it but not display it in the view?? On Nov 15, 2:01 pm, Anthony abasta...@gmail.com wrote: You can test for a logged in user via: if auth.user: auth.user is the record of the currently logged in user, or None if the user is not logged in. Also, do you need to do something with the value of c in the logged in case? If not, then just test for a logged in user directly in the view. {{if auth.user:}} Anthony On Tuesday, November 15, 2011 7:37:10 AM UTC-5, thodoris wrote: There is nothing wrong, i just want to know if this is a clean way to do what i do above or there is a better way. Thodoris On Nov 15, 1:26 pm, Kenneth Lundström kenneth.t...@gmail.com wrote: Whats wrong in what you just described? {{if c != None:}} Kenneth I want to do the following def some_function(): a = ... b = ... if auth.is_logged_in(): c = ... else: c = None return (a=a,b=b,c=c) And in the view some_function.html {{if c is not None:}} do something here {{pass}} which is the best practice to do it?
[web2py] Janrain Social Widget Setup
Hello, I am trying to integrate the Janrain Social Widget to my project. For the moment i have user authentication with Janrain but i am having problems adding the Social Widget. The instructions from Janrain say: 1) Download the rpx_xdcomm.html file and place it in the root directory of your website. 2) Copy and paste this block of code into the page you want to invoke the widget from: ... RPXNOW.init({appId: 'aeebhlpldndcpmloacee', xdReceiver: '/rpx_xdcomm.html'}); 3) Invoke the widget I followed the above steps but i get the following: Error: unable to load http://127.0.0.1:8000/rpx_xdcomm.html Where should i put rpx_xdcomm.html ??? and what does root directory of your website means? I am running all using the incorporated web server in web2py. Any help???
[web2py] 500 Internal Server Error
I have the following configuration auth.settings.allow_basic_login=True db.define_table( 'files', Field('file','upload')) @auth.requires_login() def upload(): form = crud.create(db.files) return dict(form=form) and i applied the PATCH mentioned here https://groups.google.com/forum/#!topic/web2py/CDHOUqtICn8 I executed the setup-web2py-ubuntu.sh script and the everything works ok from the webpage. What i want to do is upload a file using curl. If i don't use authentication, using the following command the file is uploaded: curl -F file=@/home/thodoris/Documents/test.jpg.rtp -F _formname=files/ None http://192.168.1.75/test/default/upload If i use authentication and use the command curl --verbose -u t...@nowhere.com: -F file=@/home/thodoris/ Documents/test.jpg.rtp -F _formname=files/None http://192.168.1.75/test/default/upload i get the following error: * About to connect() to 192.168.1.75 port 80 (#0) * Trying 192.168.1.75... connected * Connected to 192.168.1.75 (192.168.1.75) port 80 (#0) * Server auth using Basic with user 't...@nowhere.com' POST /test/default/upload HTTP/1.1 Authorization: Basic dGVzdEBub3doZXJlLmNvbToxMTEx User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18 Host: 192.168.1.75 Accept: */* Content-Length: 60669 Expect: 100-continue Content-Type: multipart/form-data; boundary=dd827f333b42 HTTP/1.1 100 Continue HTTP/1.1 500 Internal Server Error Date: Thu, 03 Nov 2011 11:24:32 GMT Server: Apache/2.2.17 (Ubuntu) Vary: Accept-Encoding Content-Length: 592 Connection: close Content-Type: text/html; charset=iso-8859-1 !DOCTYPE HTML PUBLIC -//IETF//DTD HTML 2.0//EN htmlhead title303 SEE OTHER/title /headbody h1SEE OTHER/h1 pThe server encountered an internal error or misconfiguration and was unable to complete your request./p pPlease contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error./p pMore information about this error may be available in the server error log./p hr addressApache/2.2.17 (Ubuntu) Server at 192.168.1.75 Port 80/ address /body/html * Closing connection #0 And the error in apache log is: [Thu Nov 03 12:24:32 2011] [error] [client 192.168.1.75] malformed header from script. Bad header=x98%255Cxa0%255CxdaKk4Ht%255Cx: wsgihandler.py When i use the internal server from web2py and not Apache i use the exact same configuration and it WORKS. Could someone give me some advice of how to solve this???
Re: [web2py] Re: Found a bug: XMLRPC with basic authorization fails
Hi, I have tested the patch against 1.99.2 stable version of web2py and it works. auth.settings.allow_basic_login=True has to be set in order to be able to upload files using curl. Thodoris
[web2py] Re: curl post with authentication
Yes it is related and there is a patch for this. More details on the above link. On Oct 28, 2:27 pm, szimszon szims...@gmail.com wrote: Could be related:https://groups.google.com/forum/#!topic/web2py/lLCCUrwB5x0
[web2py] curl post with authentication
Hi, I have this simple configuration: db.define_table( 'files', Field('file','upload')) @auth.requires_login() def upload(): db.files.id.default = request.args(0) form = crud.create(db.files) return dict(form=form) If i remove authentication from upload() i can upload a file using curl. But i would like apply the authentication restriction. So i register a user with username: t...@nowhere.com and password: and i try the following command curl --verbose -u t...@nowhere.com: -F file=@/home/thodoris/ Downloads/test.rtp -F _formname=files/None http://127.0.0.1:8000/test/default/upload and i get the following error message: * About to connect() to 127.0.0.1 port 8000 (#0) * Trying 127.0.0.1... connected * Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0) * Server auth using Basic with user 't...@nowhere.com' POST /test/default/upload HTTP/1.1 Authorization: Basic dGVzdEBub3doZXJlLmNvbToxMTEx User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18 Host: 127.0.0.1:8000 Accept: */* Content-Length: 3187083 Expect: 100-continue Content-Type: multipart/form-data; boundary=69a14296aa8c HTTP/1.1 100 Continue HTTP/1.1 303 SEE OTHER Set-Cookie: session_id_test=127.0.0.1-0054c564-830d-4fe4- ae3d-924a1ba931b8; Path=/ Content-Type: text/html; charset=UTF-8 * Avoided giant realloc for header (max is 102400)! * Closing connection #0 curl: (27) Avoided giant realloc for header (max is 102400)! Could anyone help me understand what the problem is and how to solve it? I have also tried setting auth.settings.allow_basic_login=True in the models but still the same.
[web2py] Re: Found a bug: XMLRPC with basic authorization fails
Hi, i have come across the same problem. Do you have any idea when will the patch be included in a realease?
Re: [web2py] Re: Found a bug: XMLRPC with basic authorization fails
Hi Hong-Khoan, Sure, send it to me and i will try it. Regards, Thodoris
[web2py] upload file to database using curl
Hello, I have been trying to find a way of how to upload a file in a database using curl but i can't find any references. I have found a reference that describes how to submit text so i guess that uploading a file should possible as well. What i want to do is to upload a file from my application that is written in C++ to the web server. I am new to web2py so i would appreciate any advice. Thodoris
[web2py] count file downloads
Hi, I am wondering what is the best way to count how many times a file has been downloaded. I have the following: db.define_table('image', Field('file', 'upload'), Field('downloads','integer', default=0,readable=False, writable=False)) I have a view that has the following: {{=A(Download, _href=URL('download', args=image.file))}} So when Download is clicked the file file will be downloaded. The function that is called is: def download(): return response.download(request,db) How can i increase the can increase the image.downloads each time a file is downloaded. I don't know how or if it is possible to pass the image.id in download and increase the counter doing something like: item = db.image[request.vars.id] new_downloads = item.downloads + 1 item.update_record(downloads=new_downloads) I tried passing more arguments to download like args=[image.file, mage.id] but it fails. Any ideas
[web2py] Re: count file downloads
Thanx Antony! I can't believe it was as simple as that... On Oct 27, 5:50 pm, Anthony abasta...@gmail.com wrote: response.download expects the last arg in the url to be the filename, so you might be able to pass the image.id as the first arg: args=[image.id, image.file] Anthony On Thursday, October 27, 2011 11:39:22 AM UTC-4, thodoris wrote: Hi, I am wondering what is the best way to count how many times a file has been downloaded. I have the following: db.define_table('image', Field('file', 'upload'), Field('downloads','integer', default=0,readable=False, writable=False)) I have a view that has the following: {{=A(Download, _href=URL('download', args=image.file))}} So when Download is clicked the file file will be downloaded. The function that is called is: def download(): return response.download(request,db) How can i increase the can increase the image.downloads each time a file is downloaded. I don't know how or if it is possible to pass the image.id in download and increase the counter doing something like: item = db.image[request.vars.id] new_downloads = item.downloads + 1 item.update_record(downloads=new_downloads) I tried passing more arguments to download like args=[image.file, mage.id] but it fails. Any ideas