[web2py] Compute field values when adding to database

2010-05-18 Thread scausten
I have a file uploads table and want to have a unique, random code for each file as it is uploaded, so that my fields are id, file, code, where 'code' is generated by a given function (say, for sake of argument, randint(10,99)). Is this something I can do in the model, or do I need a form

[web2py] Re: Compute field values when adding to database

2010-05-18 Thread scausten
sion, onvalidation=my_form_processing) session.flash = 'record inserted' redirect(request.url) return dict(form=form) Does the 'my_form_processing' function go in the model or the controller? On May 18, 2:09 pm, scausten wrote: > I have a

[web2py] Using URL() in CSS

2010-05-23 Thread scausten
I've been trying to get images into my css (both stored in static), using URL() to pull the image, but because of the relative path from the css to the image folder, and the fact that URL() returns a url from the root(?), I'm having trouble with the syntax - is there a standard way of doing this?

[web2py] A quick question for everyone - generating a random code 'onvalidation'

2010-05-26 Thread scausten
I'm adding files content to my database with the following code being called onvalidation when the form is submitted. It really simply generates a 6-digit alphanumeric code as an identifier for the file: codes = db().select(db.products.code) # Grabs all the existing codes from the database while

[web2py] Re: A quick question for everyone - generating a random code 'onvalidation'

2010-05-27 Thread scausten
tbbooks.id == 1).count() > > > > On Wed, May 26, 2010 at 2:44 PM, scausten wrote: > > I'm adding files content to my database with the following code being > > called onvalidation when the form is submitted. It really simply > > generates a 6-digit alphanumeric c

[web2py] Storing API credentials

2010-05-28 Thread scausten
I'm implementing PayPal on my site and would like to know the best practice for securely storing my API credentials (user, pass, signature). Can this go in the database (say in a 'credentials' table), or should it be elsewhere?

[web2py] Download an external file to 'uploads'

2010-06-18 Thread scausten
I'm trying to download (using urllib.urlretrieve) a remote file into my application. It's a zip file containing an IP-to-country lookup table. I want to download the zip to the application's file system (probably 'uploads'), unzip it, process the csv and then import the sanitised data into my ip-to

[web2py] Re: Download an external file to 'uploads'

2010-06-18 Thread scausten
Should have tried harder myself - this works, but is there a better way of doing it? filename, headers = urllib.urlretrieve(link, path.join(os.getcwd(), "applications", request.application, "uploads", "foo.zip")) On Jun 18, 1:56 pm, scausten wrote: &

[web2py] CakePHP-like recursive queries?

2010-07-22 Thread scausten
There's a really cool feature in the CakePHP web framework whereby you can query a database recursively and have a query return not only the records of a given query, but also any other records they refer to, and I was wondering if there's anything similar in web2py. (There is a 'recursive' flag in

[web2py] Re: CakePHP-like recursive queries?

2010-07-22 Thread scausten
I'm an idiot. I actually hadn't tried the transaction.product.name syntax, and lo-and-behold, it works. web2py is awesome. On Jul 22, 8:31 pm, scausten wrote: > There's a really cool feature in the CakePHP web framework whereby you > can query a database recursively and ha

[web2py] Custom auth view throws 404

2010-04-22 Thread scausten
Hi, Bit of a noob question (sorry) but I'd like to add a page "/user/ combinedLogin" to my app, which combines the login and register forms, but can't work it out. This: if request.args(0)=="login": =auth.login() =auth.register() works fine, but I'd like to expose a new url (/user/combin

[web2py] Re: Custom auth view throws 404

2010-04-23 Thread scausten
3 pm, mdipierro wrote: > How about > > {{extend 'layout.html'}} > Login > {{=auth.login()}} > Register > {{=auth.register()}} > > On Apr 22, 3:49 pm, scausten wrote: > > > > > Hi, > > > Bit of a noob question (sorry) but I'd like to add a

[web2py] .load fallback to .html?

2010-09-14 Thread scausten
I've noticed that Zencoding doesn't highlight code when editing .load views for components, so I find myself doing all my editing in a .html view, then copying the whole thing over into my .load view and removing my {{extend}}. Firstly it would be cool if zencoding could be made to treat .load vie

[web2py] Passing _class when LOADing components

2010-09-15 Thread scausten
Would it be possible to add the ability to pass _class (in the same way as with HTML Helpers) to the LOAD function, i.e.: {{=LOAD('default', 'foo.load', ajax=True, _class="bar")}} to generate loading... Or is there a better way?

[web2py] Creating an upload 'queue'/uploading in the background

2010-09-21 Thread scausten
Does anyone have ideas on how to implement an upload 'queue'? Specifically, my site allows users to upload mp3s, but I'd like to defer the uploading of submitted files when a form is submitted so that the user can continue browsing the site while their file uploads in the background. Ideally I'd l

[web2py] Re: VPS.net With Web2py.... Unable to install Application

2010-09-23 Thread scausten
Hi Massimo, I've tried to install web2py on vps.net today and I'm getting the following error message: ./setup-web2py-ubuntu.sh: line 4: syntax error near unexpected token `newline' Could you have a look at it please? On Sep 23, 4:36 am, mdipierro wrote: > yes this should do it > > sudo /etc/

[web2py] Re: VPS.net With Web2py.... Unable to install Application

2010-09-23 Thread scausten
Don't worry, I was doing something extraordinarily stupid - the script is fine. On Sep 23, 2:05 pm, mdipierro wrote: > I do not see anything wrong with line 4 > > On Sep 23, 5:25 am, scausten wrote: > > > > > Hi Massimo, > > > I've tried to install

[web2py] Re: LOAD/web2py_component 'ajax' upload ... again

2010-10-25 Thread scausten
Another bump - has anyone had any further thoughts on how to get web2py-component-command or web2py-component-flash working with this code? On Oct 13, 1:38 pm, selecta wrote: > *bump* > sinceuploadforms do not work in web2py components anyway this code > could be integrated into web2py without th

[web2py] Re: LOAD/web2py_component 'ajax' upload ... again

2010-10-25 Thread scausten
}}); }); {{pass}} It's ugly, but it seems to work ok for simple stuff... On Oct 25, 9:37 am, scausten wrote: > Another bump - has anyone had any further thoughts on how to get > web2py-component-command or web2py-component-flash working with this > code? >

[web2py] Re: LOAD/web2py_component 'ajax' upload ... again

2010-10-25 Thread scausten
for eval since the script will be interpreted anyway > > On Oct 25, 11:23 am, scausten wrote: > > > > > > > > > I've had some success with a very simple workaround for web2py- > > component-command. In the form.accepts in my SQLFORM, I set a variable &

[web2py] Should I store miscellaneous user data in auth_user?

2011-01-20 Thread scausten
I've got a few items of supplementary data about my users relating to my e-commerce app, including current balance, total earnings, and other bits and pieces. Because these are not directly related to access control, I have a gut feeling that I should store them in a different table and have a sing

[web2py] Re: Should I store miscellaneous user data in auth_user?

2011-01-20 Thread scausten
Thanks Bruno - just out of interest, why do you prefer to use db[auth.settings.table_user_name] over db.auth_user? On Jan 20, 8:01 pm, Bruno Rocha wrote: > But, if you want a customized auth_user table, here is a good example > > https://bitbucket.org/hc/scanme/src/743ed270faae/models/db_scanme.p

[web2py] Auth callbacks when using Janrain

2011-01-27 Thread scausten
I'm using Janrain and I need to perform some actions post- registration, but the usual auth callbacks don't seem to be working. I'm running a very simple test function in my model: db.define_table('user_data',Field('testfield')) auth.settings.register_onvalidation.append(lambda form:db.user_data.i

[web2py] Re: Appadmin not showing default widgets for plugin tables

2012-09-12 Thread scausten
I'm having the same trouble with the following table definition (version 2.0.8) db.define_table('clients', Field('name')) db.define_table('promotions', Field('client', 'reference clients'), Field('name'), Field('star

[web2py] Re: Appadmin not showing default widgets for plugin tables

2012-09-13 Thread scausten
gt; > Il giorno mercoledì 12 settembre 2012 17:28:50 UTC+2, scausten ha scritto: >> >> I'm having the same trouble with the following table definition (version >> 2.0.8) >> >> db.define_table('clients', >> Field('name')) >&g

[web2py] Has anyone done a detailed security analysis or attempted a methodical attack on web2py?

2012-07-09 Thread scausten
One of the awesome things about web2py is of course the built-in and well-documented resilience against a range of attack methods, but I was wondering if anyone has attempted a methodical (white-hat) attack to probe any potential weaknesses? Just out of interest :)

[web2py] Is it possible to LOAD a component after a page has rendered?

2012-01-28 Thread scausten
I'd like to asynchronously load one of a choice of components into a view, based on a user selection after the page has loaded. It's relatively trivial to do this by changing the src on an iFrame which embeds the component view, but this doesn't feel like a web2py-ish way of doing things. It would

[web2py] Re: Is it possible to LOAD a component after a page has rendered?

2012-01-29 Thread scausten
Thanks! web2py easy, as always. On Jan 28, 11:24 am, Alan Etkin wrote: > You can use javascript onclick and the web2py.js function > web2py_component(action,target) to load the source on demand. > You need to set a target div or other element in the view previously > and get the triggered event's

[web2py] Update record in session

2012-02-09 Thread scausten
Is is possible to hold a record in session, something like: id = db.transactions.insert() session.transaction = db.transactions[id] and directly update_record the session.transaction, session.transaction.update_record(x=y)# This throws KeyError: 'update_record' or is it necessary to res