[web2py] REST API no matching pattern

2012-12-30 Thread Jeff Kusi
I followed the example for the  REST API (multiple times actually). However 
I keep getting *"**no matching pattern"* every time.
In fact it looks like the auto pattern is not generating because when I 
navigate to 
api/patterns.json, I see 

{"content": "auto"}

instead of the beautiful rendering of all my table patterns.

Here are the sample tables I tested with
db.define_table('person',Field('name'),Field('info'))
db.define_table('pet',Field('owner',db.person),Field('name'),Field('info'))

Here's my api code

@request.restful()
def api():
response.view = 'generic.'+request.extension
def GET(*args,**vars):
patterns = 'auto'
parser = db.parse_as_rest(patterns,args,vars)
if parser.status == 200:
return dict(content=parser.response)
else:
raise HTTP(parser.status,parser.error)
def POST(table_name,**vars):
return db[table_name].validate_and_insert(**vars)
def PUT(table_name,record_id,**vars):
return db(db[table_name]._id==record_id).update(**vars)
def DELETE(table_name,record_id):
return db(db[table_name]._id==record_id).delete()
return locals()


web2py version 2.3.2 (2012-12-17 15:03:30) stable
python version 2.7

Any help please?

-- 





Re: [web2py] Added Conditional Validation in the Model...

2012-12-30 Thread Bruno Rocha
Ok, SQLITE does not allow it, so you can try a different approach.

Remove the unique and the notnull

*Field('unikey'', compute=lambda row: "%(user)d_%(location)s" % row)

add a validator.

db.site.unikey.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, ' site.unikey')]
*

-- 





[web2py] Re: YUI3 IO POST

2012-12-30 Thread b00m_chef
The solution was that I needed to get rid of the following in my YUI 3 code:

headers: {
   'Content-Type': 'application/json'
   }

Woohoo!!  I can now send and receive JSON data :-D



On Sunday, December 30, 2012 8:55:34 PM UTC-8, b00m_chef wrote:
>
> This might be a web2py bug...not sure...
>
> I have been trying to get web2py to read a post request sent from 
> javascript, but without any success. I hope you guys can help figure out 
> what is going on. Note that request.env.content_length is the correct 
> length of the data being passed. However, it fails to show up in the 
> request.post_vars...what's going on? I should also point out that if I 
> change the method to "GET", then I can see the data in the request.vars and 
> request.get_vars without any problems.  Is there a way to access the header 
> date directly (skipping request.vars)?
>
> Also note that jQuery.ajax() with the same data below works fine. Here is 
> jQuery version:
> jQuery.ajax(
> {
> type: "POST",
> url: 'data', //python function
> data: {array: 1234},//data sent to server
> dataType: 'json',
> error: function(msg){alert(msg);},
> success: function(data){
> alert(data);
> },
> timeout: 2000
> }
> );
>
>
>
>
> Here is the YUI 3 code:
>
> View:
> 
>
> YUI().use("json-stringify", "io", "dump", "json-parse", function(Y) {
> Y.io('data', {
> method: 'POST',
> data: {array: 1234},
> on: {
> success: function(id, o) {
> var jsonResponse = Y.JSON.parse(o.response)
> Y.log("RAW JSON DATA: " + o);
> Y.log("json data: " + o.responseText);
> Y.log("header:" + jsonResponse.header);
> Y.log("status:" + o.statusText);
> Y.log("keys:" + Object.keys(o));
> Y.log("id:" + id);
> Y.one("#output").set("text", o.response); 
> },
> failure: function(x, o) {
> alert("Async call failed!");
> }
> },
> headers: {
> 'Content-Type': 'application/json'
> }
> })
>
> });
> -->
> 
>
> Type something and press the button.
>The last 10 entries will appear sorted in a table below.
>
> 
> OK
>
> 
> 
> 
>
> Controller:
> @service.json
> def data():
> if request.vars:
> for var in request.vars:
> data[var] = []
> data[var].append(request.vars[var])
>  return data
>
>
>
>

-- 





Re: [web2py] Added Conditional Validation in the Model...

2012-12-30 Thread Jason Brower
However.  I just tried it and was told it can't be done.
OperationalError: Cannot add a UNIQUE column

Error snapshot help

(Cannot add a UNIQUE column)
Bummer.
BR,
Jason Brower


On Sun, Dec 30, 2012 at 8:16 AM, Bruno Rocha  wrote:
 can see two options.

1. Use form validation:


def check_user(form):
    query = db.site.user == form.vars.user
    query &= db.site.location == form.vars.location
    if db(query).count():
    form.errors.user = "already exists" 

def action():
    form = SQLFORM(db.site)
    if form.process(onvalidation=check_user).accepted:
    # do whathever

2. Create a computed Uni-Key


db.define_table('site',
    Field('location', 'string'),
    Field('user', db.auth_user, readable=False, writable=False),
    Field('typos', 'blob', readable=False, writable=False, default=None),
    Field('status', 'string', readable=False, writable=False, 
default='pending'),
    Field('last_scan', 'datetime', readable=False, writable=False, 
default=None),
    Field('unikey' , unique=True, notnull=True, compute=lambda row: 
"%(user)d_%(location)s" % row
)



On Sun, Dec 30, 2012 at 4:06 AM, encompass  wrote:
I have this in my model.
db.define_table('site',
    Field('location', 'string'),
    Field('user', db.auth_user, readable=False, writable=False),
    Field('typos', 'blob', readable=False, writable=False, default=None),
    Field('status', 'string', readable=False, writable=False, 
default='pending'),
    Field('last_scan', 'datetime', readable=False, writable=False, default=None)
)

db.site.status.requires = IS_IN_SET(['pending', 'working', 'done'])
db.site.location.requires = IS_URL()
I want it so that it validates that the combination of db.site.user and 
db.site.location are a unique value.  How do I do that in web2py?
I assume there is a way to do this in the model file and now in a controller 
with checks before insert.
BR,
Jason
-- 
 
 
 

-- 
 
 
 

-- 





Re: [web2py] Added Conditional Validation in the Model...

2012-12-30 Thread Jason Brower
I'll take number 2. :) Looks much cleaner to me!  I new about number 1 but was 
hoping to see something that sat in the model.  Thanks.
BR,
Jason Brower


On Sun, Dec 30, 2012 at 8:16 AM, Bruno Rocha  wrote:
 can see two options.

1. Use form validation:


def check_user(form):
    query = db.site.user == form.vars.user
    query &= db.site.location == form.vars.location
    if db(query).count():
    form.errors.user = "already exists" 

def action():
    form = SQLFORM(db.site)
    if form.process(onvalidation=check_user).accepted:
    # do whathever

2. Create a computed Uni-Key


db.define_table('site',
    Field('location', 'string'),
    Field('user', db.auth_user, readable=False, writable=False),
    Field('typos', 'blob', readable=False, writable=False, default=None),
    Field('status', 'string', readable=False, writable=False, 
default='pending'),
    Field('last_scan', 'datetime', readable=False, writable=False, 
default=None),
    Field('unikey' , unique=True, notnull=True, compute=lambda row: 
"%(user)d_%(location)s" % row
)



On Sun, Dec 30, 2012 at 4:06 AM, encompass  wrote:
I have this in my model.
db.define_table('site',
    Field('location', 'string'),
    Field('user', db.auth_user, readable=False, writable=False),
    Field('typos', 'blob', readable=False, writable=False, default=None),
    Field('status', 'string', readable=False, writable=False, 
default='pending'),
    Field('last_scan', 'datetime', readable=False, writable=False, default=None)
)

db.site.status.requires = IS_IN_SET(['pending', 'working', 'done'])
db.site.location.requires = IS_URL()
I want it so that it validates that the combination of db.site.user and 
db.site.location are a unique value.  How do I do that in web2py?
I assume there is a way to do this in the model file and now in a controller 
with checks before insert.
BR,
Jason
-- 
 
 
 

-- 
 
 
 

-- 





[web2py] Re: web2py and redis queue

2012-12-30 Thread Bruno Rocha
The monitor tool runs on Flask I am sure it will be easy to write a web2py
version of this. Maybe as a plugin.
Em 31/12/2012 00:09, "Bruno Rocha"  escreveu:

>
> Running delayed jobs with web2py and Redis Queue:
>
> http://rochacbruno.com.br/web2py-and-redis-queue/
>
> Bruno.
>

-- 





Re: [web2py] Where to host web2py

2012-12-30 Thread Andrew
Hm ok, I think that threading error is just a red-herring. If you feel 
comfortable enough, I could try and import your setup into a spare gear on 
my account and triage it that way. You can take an exact export with the 
rhc snapshot command and I can import it and see if I can pin down what's 
up with the auth. 

If you're not comfortable with that, a few other things you can check are:

1. Make sure there's not a symlink overriding your parameters_443.py 
pointing to a non-existant file. Basically I just stick the password in 
parameters_8080.py and symlink that to parameters_80.py and 
parameters_443.py 

2. Make sure the parameters file you're using doesn't have some weird 
permissions set (also ssh in and make sure they look good there in 
$OPENSHIFT_REPO_DIR since it's possible something could get munged on the 
push up).

3. Try and copy that same parameters file you're using in a vanilla web2py 
setup and make sure that instance can read it and you can log in. 

4. Lastly, if you're familiar with linux, you could manually run web2py in 
the Openshift gear preceded by strace to see where it's looking for your 
parameters file (maybe python profiling would do something similar? I 
haven't used it, just a guess). Maybe syspath got messed up in the setup or 
something like that.

Let me know how it goes. 
On Saturday, December 29, 2012 11:30:58 PM UTC-6, Gustavo Souza wrote:
>
> Hello, Andrew!
>
> I'm using https, and my error logs I am giving this message:
>
> [Sun Dec 30 00:13:12 2012] [notice] SELinux policy enabled; httpd running 
> as context unconfined_u:system_r:openshift_t:s0:c5,c110
> [Sun Dec 30 00:13:12 2012] [notice] mod_bw : Memory Allocated 32 bytes 
> (each conf takes 32 bytes)
> [Sun Dec 30 00:13:12 2012] [notice] mod_bw : Version 0.8 - Initialized [1 
> Confs]
> [Sun Dec 30 00:13:12 2012] [notice] Digest: generating secret for digest 
> authentication ...
> [Sun Dec 30 00:13:12 2012] [notice] Digest: done
> [Sun Dec 30 00:13:12 2012] [notice] Apache/2.2.15 (Unix) mod_wsgi/3.2 
> Python/2.6.6 configured -- resuming normal operations
> [Sun Dec 30 00:13:30 2012] [error] Exception KeyError: 
> KeyError(140598980249568,) in  '/usr/lib64/python2.6/threading.pyc'> ignored
> [Sun Dec 30 00:25:31 2012] [notice] mod_bw : Memory Allocated 32 bytes 
> (each conf takes 32 bytes)
> [Sun Dec 30 00:25:31 2012] [notice] mod_bw : Version 0.8 - Initialized [1 
> Confs]
> [Sun Dec 30 00:25:31 2012] [notice] Digest: generating secret for digest 
> authentication ...
> [Sun Dec 30 00:25:31 2012] [notice] Digest: done
> [Sun Dec 30 00:25:31 2012] [notice] Apache/2.2.15 (Unix) mod_wsgi/3.2 
> Python/2.6.6 configured -- resuming normal operations
>
>
>
> 2012/12/28 Andrew >
>
>> Gustavo,
>>
>> Make sure that you're accessing it via https, I've noticed that if I 
>> click on the admin button from the main page accessed via http, it uses 
>> whatever transport protocol that was specified to get there. 
>>
>> If you're already doing this I'd take a look at the web2py logs in 
>> $OPENSHIFT_PYTHON_LOG_DIR. A while back I had submitted a bug for how their 
>> proxy didn't set wsgi params when it passed the request to the gear. That's 
>> been the only time I've run into an issue like that. 
>>
>> Also make sure your options_std.py is linked to options.py 
>>
>> If you come across any more info, I'd be happy to take a look.
>>
>> Andrew
>>
>>
>> On Wednesday, December 26, 2012 8:38:21 AM UTC-6, Gustavo Souza wrote:
>>>
>>> Hi Adrew, I followed these steps and was able to deploy the web2py, and 
>>> it works! ... I did with version 2.3.2
>>> My only problem is that the web2py admin panel is disabled.
>>> I created the file "parameters_443.py" and put the password hash, but 
>>> still the message appears "admin disabled because unable to access password
>>> file "
>>>
>>> I have to change something?
>>>
>>> Em domingo, 19 de agosto de 2012 20h39min52s UTC-3, Andrew escreveu:

 A little different in order. 

 Do all the openshift stuff first, then download web2py and copy it into 
 the wsgi folder. 

 I would suggest using the application file I provide on the github repo 
 and modify:

 This:
 sys.path.append(os.path.join(**os.environ['OPENSHIFT_REPO_**DIR'], 
 'libs', 'gluon'))
 to This:
 sys.path.append(os.path.join(**os.environ['OPENSHIFT_REPO_**DIR'], 
 'wsgi', 'web2by', 'gluon')) #honestly I don't know if sys.path.append 
 handles stuff recursively so maybe this isn't necessary and you just 
 comment out the gluon line. 

 There are other nuances like addressing db host / port / user / pass 
 variables that should all be setup in wsgi/application file. For example 
 if 
 you're using SQL lite, I have an example variable setup in the 
 wsgi/application handler and then in your model you'd just use something 
 like: 

 db = DAL('sqlite://storage.sqlite',**folder=SQLITE_DIR)

 If you want to use the admi

Re: [web2py] Re: Python Redis Queue

2012-12-30 Thread Alec Taylor
On Mon, Dec 31, 2012 at 11:37 AM, Bruno Rocha  wrote:
> DONE!!!
>
> 1. create a file called web2py-rq.py
>
> #!/usr/bin/env python
> import sys
> from rq import Queue, Connection, Worker
>
> # Preload libraries
> #import library_that_you_want_preloaded
>
> # Provide queue names to listen to as arguments to this script,
> # similar to rqworker
> with Connection():
> qs = map(Queue, sys.argv[1:]) or [Queue()]
> w = Worker(qs)
> w.work()
>
> 2. start the worker in web2py context
> python web2py.py -S yourapp -M -R /path/to/web2py-rq.py
>
>
> Now it is easiest to send delayed messages!
>
> I will create a slice and will send the script to be included in contrib.

Awesome; can hardly wait :D

-- 





[web2py] Serve different files based on JavaScript capability?

2012-12-30 Thread Alec Taylor
I have static versions of my pages generated by automatically
headlessly snapshotting my AngularJS rendered pages.

When JavaScript is disabled or a scraper views the site; I want the
static versions to be served. Otherwise I want to server the
JavaScript-heavy files.

How do I do this in web2py; and what are the downsides of this approach?

Thanks for all suggestions,

Alec Taylor

-- 





[web2py] YUI3 IO POST

2012-12-30 Thread b00m_chef
I have been trying to get web2py to read a post request sent from 
javascript, but without any success. I hope you guys can help figure out 
what is going on. Here is the code:

View:


YUI().use("json-stringify", "io", "dump", "json-parse", function(Y) {
Y.io('data', {
method: 'POST',
data: 'test',
on: {
success: function(id, o) {
var jsonResponse = Y.JSON.parse(o.response)
Y.log("RAW JSON DATA: " + o);
Y.log("json data: " + o.responseText);
Y.log("header:" + jsonResponse.header);
Y.log("status:" + o.statusText);
Y.log("keys:" + Object.keys(o));
Y.log("id:" + id);
Y.one("#output").set("text", o.response); 
},
failure: function(x, o) {
alert("Async call failed!");
}
},
headers: {
'Content-Type': 'application/json'
}
})

});
-->


Type something and press the button.
   The last 10 entries will appear sorted in a table below.


OK





Controller:
@service.json
def data():
if request.vars:
for var in request.vars:
data[var] = []
data[var].append(request.vars[var])
 return data



-- 





Re: [web2py] Re: Python Redis Queue

2012-12-30 Thread Bruno Rocha
DONE!!!

1. create a file called web2py-rq.py

#!/usr/bin/env python
import sys
from rq import Queue, Connection, Worker

# Preload libraries
#import library_that_you_want_preloaded

# Provide queue names to listen to as arguments to this script,
# similar to rqworker
with Connection():
qs = map(Queue, sys.argv[1:]) or [Queue()]
w = Worker(qs)
w.work()

2. start the worker in web2py context
python web2py.py -S yourapp -M -R /path/to/web2py-rq.py


Now it is easiest to send delayed messages!

I will create a slice and will send the script to be included in contrib.

-- 





Re: [web2py] `@service.json` works locally but not on Heroku?

2012-12-30 Thread Anthony
Keep in mind that you should be careful about when and where you enable 
generic views. The reason they are not always enabled by default is that 
they can allow private data to be leaked -- you may pass extra data to an 
HTML view that does not get rendered by the view (e.g., data used only to 
evaluate conditions in the view, or extra columns in a database select that 
are not actually displayed), but an attacker can simply add a .json or .xml 
extension to the URL and then get the generic.json or generic.xml view to 
render even the private data. So, you should only enable the generic views 
in controlled conditions when you know exactly what data are going to those 
views.

Anthony

On Friday, December 28, 2012 11:47:55 PM UTC-5, Alec Taylor wrote:
>
> Thanks, that did the trick. 
>
> Strange that it had different results locally though… 
>
> On Sat, Dec 29, 2012 at 3:42 PM, Bruno Rocha 
> > 
> wrote: 
> > add 
> > 
> > response.generic_patterns = ["*.json"] to your models or even to your 
> > controller 
> > 
> > 
> > [appname/controllers/api.py] 
> > 
> > response.generic_patterns = ['*.json'] 
> > 
> > @service.json 
> > def v1(): 
> > return dict(version=0.5) 
> > 
> > 
> > On Sat, Dec 29, 2012 at 2:34 AM, Alec Taylor 
> > > 
> wrote: 
> >> 
> >> [appname/controllers/api.py] 
> >> @service.json 
> >> def v1(): 
> >> return dict(version=0.5) 
> >> 
> >> curl -X GET http://localhost/api/v1.json 
> >> {"version": 0.5} 
> >> 
> >> curl -X GET http://appname.herokuapp.com/api/v1.json 
> >> invalid view (api/v1.json) 
> >> 
> >> -- 
> >> 
> >> The application itself is identical; to be specific I created a hard 
> >> link from my heroku app to my local web2py folder. 
> >> 
> >> How do I get JSON services working remotely? 
> >> 
> >> Thanks for all suggestions, 
> >> 
> >> Alec Taylor 
> >> 
> >> -- 
> >> 
> >> 
> >> 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





Re: [web2py] Re: Python Redis Queue

2012-12-30 Thread Bruno Rocha
Just like this: https://github.com/ui/django-rq

We shoukd have a web2py-rq

-- 





Re: [web2py] Re: Python Redis Queue

2012-12-30 Thread Bruno Rocha
Would be better to find a way to start the rqworker inside the web2py
environment

python web2py.py -S myapp -M -R rqworker

how to do it?

-- 





Re: [web2py] Re: Python Redis Queue

2012-12-30 Thread Bruno Rocha
1. Instal Redis
apt-get install redis-server

2. Install rq
   sudo pip install rq

3. Create a file in modules called queued_functions.py

#!/usr/bin/env python
#-*- coding:utf-8 -*-

# need to put this for mail to work
import sys
sys.path.append("/path/to/web2py")
from gluon.tools import Mail

def send_email(*args, **kwargs):
mail = Mail()
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = 'youru...@gmail.com'
mail.settings.login = 'login:pass'
return mail.send(*args, **kwargs)

4. In models create your queue

from redis import Redis
from rq import Queue
q = Queue(connection=Redis())

5. In controllers/default.py

def contact():
form = SQLFORM.factory(Field("name", label="your name"),
Field("message", "text"))
if form.accepts(request):
q.enqueue(send_email, to="myn...@gmail.com", subject"%s contacted
you" % form.vars.name, message=form.vars.message)
return dict(form=form)

6. Click the form and send some emails to enqueue them on redis

7. Start the worker, open another terminal and tyoe

$ rqworker


8. Done! the enqueued emails will be sent.

OPTIONAL:

You can monitor with RQ Dashboard: http://python-rq.org/docs/monitoring/
Or using the command line:

$ rqinfohigh   |██ 20low
|██ 12default|█ 83 queues, 45 jobs total
Bricktop.19233 idle: lowBricktop.19232 idle: high, default,
lowBricktop.18349 idle: default3 workers, 3 queues

-- 





[web2py] Re: Webfaction & web2py - upgraded to 2.3.2 and now nothing works remotely

2012-12-30 Thread wdtnh
If this helps. 

I noticed two things happen after I install the web2py script.
- standard installation script - the welcome application works fine 
- edit the db.py file to switch from SQLITE to MYSQL 
 db = 
DAL('mysql://myusername:mypwd@localhost/databasename',pool_size=1,check_reserved=['all'],migrate=False)

then re-enter the URL and now I get  auth_user table already exists 
error.   The mysql database has already been created with the tables and 
then
hit F5 again in the browser then I get the 504 error. 




On Sunday, December 30, 2012 6:09:17 PM UTC-5, wdtnh wrote:
>
> Upgraded my web2py application on webfaction to latest version 2.3.2. - 
> actually did a clean installation of web2py both locally and remotely.  
> Created a new version of the mysql database instance as well - both local 
> and remotely.  
>
> Clean installation locally as well including database.  Everything running 
> fine locally.  
>
> I'm getting an ERROR 504.gateway timeout on my live site and no clue.  
> Been troubleshooting for over 20 hours and would appreciate any suggestion 
> as to what might be going on.  
>
> Thanks in advance.
>
>
>

-- 





[web2py] Webfaction & web2py - upgraded to 2.3.2 and now nothing works remotely

2012-12-30 Thread wdtnh
Upgraded my web2py application on webfaction to latest version 2.3.2. - 
actually did a clean installation of web2py both locally and remotely.  
Created a new version of the mysql database instance as well - both local 
and remotely.  

Clean installation locally as well including database.  Everything running 
fine locally.  

I'm getting an ERROR 504.gateway timeout on my live site and no clue.  Been 
troubleshooting for over 20 hours and would appreciate any suggestion as to 
what might be going on.  

Thanks in advance.


-- 





[web2py] Has anyone made a simple chat system with websocket_messaging.py? General questions about chat.

2012-12-30 Thread HittingSmoke
I was randomly tinkering around and discovered websocket_messaging.py

I've got that running and it appears to be receiving messages from the 
sample functions but I can't seem to get them to actually display in the 
browser. I was wondering if there was some sort of nice, canned websocket 
javascript client that can just be added to a web2py app and pointed at 
websocket_messaging.py.

Has anyone used websocket_messaging.py it to build a more robust chat 
server that ties in with auth? The key/token thing confused me a bit.

How do you store messages using websocket_messaging.py? The script size in 
memory could get quite huge. Writing the history to a database table is the 
first option that comes to mind but at first glance I don't see any way to 
purge all or part of the stored input of the script. Is this something that 
would need to be done within tornado (which I have absolutely no experience 
with)?

I'm still very new to all of this and plan on eventually building a simple 
message board app. Since IRC is becoming less and less common I'd like to 
create a chat system to pair it with. Does anyone have any experience with 
websocket_messaging.py they'd like to share, or other recommendations?

-- 





[web2py] Re: Upload field with clear text filename

2012-12-30 Thread Alan Etkin
My bad:

Assigning to a form.vars item before calling to .process() works

The issue is that the first code posted by Joe tests for the boolean value 
of form.vars.upload (an instance of the file storage object) and that 
object always evaluates to False, so:

if request.vars.update:


is omitted.

-- 





[web2py] Re: Python Redis Queue

2012-12-30 Thread Massimo Di Pierro
Could you show an example?

On Sunday, 30 December 2012 15:11:12 UTC-6, rochacbruno wrote:
>
> Hi, I recently discovered a nice tool called Python RQ
>
> It is the same as Celery or web2py scheduller, but I find it easy to 
> install and manage.
>
> http://python-rq.org/
>
> I just configured this as my mail sender on web2py app, works very well.
>
>
>

-- 





[web2py] Re: SQLFORM widget support for wider range of input types

2012-12-30 Thread Massimo Di Pierro
Seems like a good idea. What do other think? If the difference is only in 
the type, could we simply override the value of type using a class variable 
and use the widget method of the base class?

Massimo

On Sunday, 30 December 2012 12:01:06 UTC-6, Calvin wrote:
>
> Hi Massimo
>
> Here is a patch which updates the date, time and datetime widget. If this 
> approach is acceptable, I am happy to provide a patch for the other types 
> as well.
>
> Calvin
>
> On Sunday, 30 December 2012 00:50:59 UTC+8, Massimo Di Pierro wrote:
>>
>> I think this would be a good idea but somebody should be in charge of 
>> this. Perhaps we can take this approach for web3py where widgets will have 
>> a simpler internal design. It will be possible to use web3py widgets in 
>> web2py.
>>
>> Anybody wants to be in charge of this? I can explain more so we can 
>> discuss options.
>>
>> Massimo
>>
>>
>>

-- 





[web2py] Re: Upload field with clear text filename

2012-12-30 Thread Massimo Di Pierro
This

form=SQLFORM(db.fileobject)
if request.vars.upload:
form.vars.filename = request.vars.upload.filename
if form.process().accepted: ...

should work. Please open a ticket.


On Friday, 28 December 2012 03:15:52 UTC-6, Joe Barnhart wrote:
>
> I'm not sure why this is difficult, but I see many posts about this when I 
> search, yet none exactly work for me.  This seems like it should be easy 
> but is surprisingly difficult in web2py.
>
> I want to keep a table of uploaded files with the uploads in a "blob" 
> field and the names in clear text in a "filename" field.  Like this model:
>
> db.define_table("fileobject",
> Field("filename","string",length=50,readable=False,writable=False),
> Field("upload","upload",uploadfield="object_data"),
> Field("object_type","string",length=20,readable=False,writable=False),
> Field("object_data","blob"),
> Field("owner","reference auth_user",default=auth.user_id,readable=
> False,writable=False),
> Field("saved","datetime",default=datetime.now(),readable=False,
> writable=False),
> Field("state","string",length=16,readable=False,writable=False),
> migrate=settings.migrate)
>
> Reading the relevant posts and the online book lead me to believe the way 
> is with a controller like this one:
>
> def index():
> form=SQLFORM(db.fileobject)
> if request.vars.upload:
> form.vars.filename = request.vars.upload.filename
> if form.process().accepted:
> response.flash = 'form accepted'
> elif form.errors:
> response.flash = 'form has errors'
> return dict(form=form)
>
> And yet this controller does not work.  The blob is filled in but the 
> filename is ignored and shows in the table as "None".  In fact, form.vars 
> is an empty collection and placing form.vars.filename in it does not 
> produce an error, but it is ignored by the form processing.  In addition to 
> the filename, I'd like to add the information about the object type etc. at 
> the same point in the process, i.e. after the file has been chosen but 
> before it has been loaded into the database.
>
> I've been trying to scan through the code (I'm using 2.3.2 source) to 
> answer my own questions about the upload field but it's just taking too 
> much time.  The upload field is one of those parts of web2py that you 
> either love or... uh... don't.  To me it seems designed for a very specific 
> use model.  If my use model deviates too much then using "upload" is like 
> pounding square pegs into round holes.  I'm tired of pounding.  Someone 
> show me how to whittle off the corners of my square peg!
>
> (You would think this would be an easy task, yet from the number of posts 
> on this exact topic I know I'm in the company of a large number of others.)
>
>
>

-- 





[web2py] Python Redis Queue

2012-12-30 Thread Bruno Rocha
Hi, I recently discovered a nice tool called Python RQ

It is the same as Celery or web2py scheduller, but I find it easy to
install and manage.

http://python-rq.org/

I just configured this as my mail sender on web2py app, works very well.

-- 





[web2py] Re: upload from Edit page

2012-12-30 Thread Alan Etkin
I suspect you're trying to give a multi-file upload in-the-same-page 
solution as Google and other brands do: AFAIK the standard upload widget 
cannot handle multiple submissions in one form, but you could implement 
your own widget with the help of this thread:

https://groups.google.com/d/topic/web2py/XpnUb2_MaRc/discussion

-- 





[web2py] Re: Streaming for large video files

2012-12-30 Thread Massimo Di Pierro
There are different issues with streaming.

web2py supportes https streaming, if modified since, and range requests. 
This means that if the client is smart enough it will cache previously 
downloaded data and will request data in chunks (range requests) which will 
then be streamed by the server.

Server side this is robust but there are things that can go wrong. If the 
client makes a request, does not stream in data, but does not close the 
connection, the web2py thread is wasted/idle until killed by the web 
server. You have some parameters you can play with (min/max number of 
threads, time before they get killed, response.stream(chunk_size=...)).

With an async server (like node.js) you do not have to worry about loss of 
resources when a connection is open and the client is idle. 

Massimo



On Sunday, 30 December 2012 14:32:44 UTC-6, Magnitus wrote:
>
> I am currently in the process of writing a netflix/youtube-like app that 
> allows you stream movies on your local LAN (eventually, perhaps over the 
> internet even, but that is not an immediate priority, especially given my 
> limited data transfer allowance by my ISP) using a web interface.
>
> I am writing this mostly for personal use as a spare time project, but 
> intent to release the code over some Creative Commons when done.
>
> However, I encountered a massive roadblock with Web2py. Streaming large 
> video files (over 1GB) is painfully slow (sometimes, the movie doesn't load 
> at all and either way, the framework doesn't recover from attempting to 
> stream such a file in a graceful manner when the user aborts by clicking 
> back in the browser window).
>
> At this point, I'm not sure if it's because of the Framework itself or the 
> underlying server.
>
> I tried with both Rocket and Tornado to no avail. I was tempted to try 
> with Apache, but then thought that if I wanted to make the app available 
> for regular Joes to use, that might not be the most user-friendly way to 
> distribute it.
>
> I tried with various client-side technologies (in-browser video with 
> html5, VLC plugin, embeded DivX player, embedded WMP) to no avail.
>
> Then, just for kicks, I picked up a Node.js introductory book (Learning 
> Node by O'Reilly) which I'm in the process of reading and tried their 
> streaming example with a large video file and it worked a lot better.
>
> At this point, I'm tempted to use web2py for most of the app, but delegate 
> video streaming to node (they can communicate via the database and/or 
> sockets).
>
> Am I crazy or does my idea make sense?
>

-- 





[web2py] Re: Streaming for large video files

2012-12-30 Thread Alan Etkin
> El domingo, 30 de diciembre de 2012 17:32:44 UTC-3, Magnitus escribió:I 
am currently in the process of writing a 
> netflix/youtube-like app that allows you stream movies on your local LAN 
(eventually, perhaps over the internet even, but that is 
> not an immediate priority, especially given my limited data transfer 
allowance by my 

FYI

Look at this project

http://code.google.com/p/video2py

It's intended as a video db with support for subtitles and slides. It 
consumes video streams by third party services or local files. It was 
developed for hosting PyConAr 2012 videos, but we want to adapt it (maybe 
as plugin) for integrating it in the next web2py conference's app.

Implemented features:

- video submission (local file, YouTube, Vimeo)
- video (per user) subtitulation (web interface)
- video slides submission and sync (web interface)
- subtitle import/export from/to .srt

It would be great if you could mix the projects.

-- 





Re: [web2py] Redmine beside web2py with Nginx deployment script

2012-12-30 Thread Arnon Marcus
10x for the info.
Is there any benefit for using the server vs. the desktop flavor?

About pgAdmin, I don't really understand what you mean.
We have been using posgreSQL with web2py in production for almost 3 years
now. Using phpPgAdmin on our production was never an option - always a
necessity. Maybe it's becuse we are using an outdated version of web2py,
but from our experience, the DAL isn't perfect - there are many advanced
features of PostgreSQL that are not supported (I can give you a list of
those), so we HAVE to use some kind of interface to further customize our
schema outside of web2py. I don't really see how we can do this in a dev
machine and not need to do the same for the prod. machine. If they share a
database, then the database is on the prod. machine - and we need phpPgAdmin.
If each of them have a separate machine, then we need 2 phpPgAdmins one on
each machine. As far as I know, you can't have your database installed
inone machine, and have your
phpPgAdmin hosted on another - in its configuration file, you have to
specify the local path of the pg_dump.exe and stuff like that it needs for
it's operation. And again, we need it's operation for unsupported feattures of
postgreSQL in web2py.
As for PgAdmin-III, well, we basically only use if when transferring our
database + schema as an SQL string, from one machine to another. Somehow
the same thing using phpPgAdmin doesn't take us the whole way the same way
PgAdmin-III does when doing that.
If we were starting a new project, I could have agreed with you - we
wouldn't need phpPgAdmin AND PgAdmin-III. But since we already have a
database somewhere else (meaning, outside the virtual machine I just
installed thanks to you), we need PgAdmin-III for the database transferring.
 And since the installation of it in ubuntu is extremely simple, and having
our solution installing a default ubuntu installation of postgreSQL, I
would have expected the installation of PgAdmin-II to have automatically
identified the postgreSQL service/process that is running - but when I
launch it, and try to "connect", it apparently doesn't find it properly. I
can't seem to be able to connect to the postgreSQL service with it. I don't
see any redmine database I can connect to. I think we are confusing the
database node, with the connection-string/setting for PgAdmin to find the
server/service/process/whatever...

Any thought?

And any pointers you could give me for trying to install phpPgAdmin?
I was able to locate where web2py is and where redmine is. But where is
nginx? How do I further configure it for php ? Any configuration file I
should know aboout?

And what about web2py?
Is it connected to postgreSQL?
I guess not, because it's just the welcome application, that uses sqlite by
default, right?
I guess if I can connect to postgreSQL with PgAdmin, I will have found the
specification I need to use in the connection string in web2py for our
application (we currently use the default settings for postgreSQL connection
and it works)

I was able to install everything smoothly on ubuntu 12.04 desktop x64 with
virtual box on windows 7 x64. Web2py and redmine are loading successfully
locally with firefox. But how do I access them elsewhere on our intranet?
I tries "ifcondif" in the reminal, and got a 10.0.2.15 ip adress... That's
not usefull, I guess... I'll admit I am a nube at linux and virtual
machinesstuff... Would appreciate any pointers you could give me...


On Sun, Dec 30, 2012 at 10:36 AM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:

> Arnon,
>
> I test it with 12.04 server 64 bit under VirtualBox with windows 7 64 bit
> as guest and it works fine. It surely work under ubuntu desktop, but not
> tested. The purpose of the script is to deploy rapidly a new prod/stage
> server with basic configuration that you can tweaks for your needs later.
> Since you don't really require Nginx for develppment it make no sens to
> install pgAdmin on the staging/prod server, you generally install it on
> your dev system. You can install phpPGAdmin if you want, but when I try it
> (very longtime ago, may have change) it was not the same quality of
> phpmyadmin, just for you to know that. I let you find your way to install
> it (google...).
>
> Default postgres database name is redmine and user name for redemine is
> redmine and the password is the one you enter when the script ask for it.
>
> You can, try it with 12.10, but I prefer 12.04 since it LTS and I don't
> want to setup new environnement in less than a year.
>
> Richard
>
>
> On Sun, Dec 30, 2012 at 1:26 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> I will be glad, if you want to...
>>
>> :)
>>
>> Richard
>>
>>
>> On Fri, Dec 28, 2012 at 11:12 PM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Would you suggest we include it in web2py/scripts/?
>>>
>>>
>>> On Friday, 28 December 2012 14:17:12 UTC-6, Richard wrote:

 Hello,

 This is a new year gift for the one who woul

[web2py] Re: Upload field with clear text filename

2012-12-30 Thread Alan Etkin
El viernes, 28 de diciembre de 2012 06:15:52 UTC-3, Joe Barnhart escribió:
>
> I'm not sure why this is difficult, but I see many posts about this when I 
> search, yet none exactly work for me.  This seems like it should be easy 
> but is surprisingly difficult in web2py.


A possible workaround (worked with SQLite and web2py trunk)

def index():
form=SQLFORM(db.fileobject)
if form.process().accepted:
form.vars.filename = request.vars.theupload.filename
db.fileobject[form.vars.id].update_record(filename=form.vars.
filename)
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)

The caveat is that you need an extra db command per request

Still, the fact that form.vars.filename doesn't write the new value on db 
insert seems to be a bug.

-- 





Re: [web2py] how to create profiles

2012-12-30 Thread sasogeek
Worked! :) thanks

On Sunday, 30 December 2012 19:59:28 UTC, Massimo Di Pierro wrote:
>
> How about
>
> #model
> auth.settings.extra_fields['auth_user'] = [Field('personal_info','text')]
>
> #controller
> def profile(): return dict(user=db.auth_user(request.args(0,cast=int)))
>
> #view profile.html
> {{extend 
> 'layout.html'}}{{=user.first_name}}{{=user.personal_info}}
>
> Mind that profile() should only be exposed in HTML (not JSON, XML, etc) 
> unless you filer the fields, else it may expose personal info.
>
> On Sunday, 30 December 2012 11:46:57 UTC-6, sasogeek wrote:
>>
>> can i create a new view so that i can have something like 
>> http://...[app]/[controller]/[view]/profile/[user_id] and based on the user 
>> id, the view displays a particular profile? like the show controller/view 
>> in the example images app in the documentation...? and even if so, can i 
>> have some code guidance cos i'm not too good with the auth system and 
>> web2py in general...
>>
>> On Sunday, 30 December 2012 17:30:45 UTC, sasogeek wrote:
>>>
>>> well in my application, i allow users to register and login using the 
>>> auth, but auth only exposes http://...[app]/[controller]/[view]/profile
>>> which is the profile of the currently logged in user. i want to create a 
>>> link so that other users can click on it to see other people's profiles.
>>>
>>> On Sunday, 30 December 2012 00:40:44 UTC, viniciusban wrote:

 What do you mean with "user profiles"? 


 On Sat, Dec 29, 2012 at 8:51 AM, sasogeek  wrote: 
 > How do allow users to see their profiles and that of other users...? 
 > 
 > -- 
 > 
 > 
 > 

>>>

-- 





[web2py] Streaming for large video files

2012-12-30 Thread Magnitus
I am currently in the process of writing a netflix/youtube-like app that 
allows you stream movies on your local LAN (eventually, perhaps over the 
internet even, but that is not an immediate priority, especially given my 
limited data transfer allowance by my ISP) using a web interface.

I am writing this mostly for personal use as a spare time project, but 
intent to release the code over some Creative Commons when done.

However, I encountered a massive roadblock with Web2py. Streaming large 
video files (over 1GB) is painfully slow (sometimes, the movie doesn't load 
at all and either way, the framework doesn't recover from attempting to 
stream such a file in a graceful manner when the user aborts by clicking 
back in the browser window).

At this point, I'm not sure if it's because of the Framework itself or the 
underlying server.

I tried with both Rocket and Tornado to no avail. I was tempted to try with 
Apache, but then thought that if I wanted to make the app available for 
regular Joes to use, that might not be the most user-friendly way to 
distribute it.

I tried with various client-side technologies (in-browser video with html5, 
VLC plugin, embeded DivX player, embedded WMP) to no avail.

Then, just for kicks, I picked up a Node.js introductory book (Learning 
Node by O'Reilly) which I'm in the process of reading and tried their 
streaming example with a large video file and it worked a lot better.

At this point, I'm tempted to use web2py for most of the app, but delegate 
video streaming to node (they can communicate via the database and/or 
sockets).

Am I crazy or does my idea make sense?

-- 





Re: [web2py] Update and Delete row issue

2012-12-30 Thread Wonton
I will try to do it, but, since I have confidential data I don't know if I 
will be able do it. Meanwhile I will try to make a fresh app and go step by 
step.

El domingo, 30 de diciembre de 2012 18:19:42 UTC+1, Niphlod escribió:
>
>
>
> On Sunday, December 30, 2012 2:33:42 PM UTC+1, Wonton wrote:
>>
>> But it's strange. I have all this code inside my default.py controller, 
>> inside web2py. 
>> Indeen, these 2 lines:
>> query = db(db.table.field1=='What I am looking for')
>> query.update(field2='hello')   
>> work perfectly even without the db.commit().
>>
>>  
> Ok
>  
>
>> But, this code:
>> query = db(db.table.field1=='What I am looking for')
>> deletedRow = query.delete()
>> is not working if I don't use the db.commit() instruction. I mean, it 
>> seems that the deletion is ok, it doesn't crash and doesn't return any 
>> error, but the database is not modified.
>>
>>
> Please post your model and the controller as attachments (or the app if 
> you can), because that has to work (and indeed works fine in a fresh app).  
>

-- 





Re: [web2py] how to create profiles

2012-12-30 Thread Massimo Di Pierro
How about

#model
auth.settings.extra_fields['auth_user'] = [Field('personal_info','text')]

#controller
def profile(): return dict(user=db.auth_user(request.args(0,cast=int)))

#view profile.html
{{extend 
'layout.html'}}{{=user.first_name}}{{=user.personal_info}}

Mind that profile() should only be exposed in HTML (not JSON, XML, etc) 
unless you filer the fields, else it may expose personal info.

On Sunday, 30 December 2012 11:46:57 UTC-6, sasogeek wrote:
>
> can i create a new view so that i can have something like 
> http://...[app]/[controller]/[view]/profile/[user_id] and based on the user 
> id, the view displays a particular profile? like the show controller/view 
> in the example images app in the documentation...? and even if so, can i 
> have some code guidance cos i'm not too good with the auth system and 
> web2py in general...
>
> On Sunday, 30 December 2012 17:30:45 UTC, sasogeek wrote:
>>
>> well in my application, i allow users to register and login using the 
>> auth, but auth only exposes http://...[app]/[controller]/[view]/profile
>> which is the profile of the currently logged in user. i want to create a 
>> link so that other users can click on it to see other people's profiles.
>>
>> On Sunday, 30 December 2012 00:40:44 UTC, viniciusban wrote:
>>>
>>> What do you mean with "user profiles"? 
>>>
>>>
>>> On Sat, Dec 29, 2012 at 8:51 AM, sasogeek  wrote: 
>>> > How do allow users to see their profiles and that of other users...? 
>>> > 
>>> > -- 
>>> > 
>>> > 
>>> > 
>>>
>>

-- 





Re: [web2py] Redmine beside web2py with Nginx deployment script

2012-12-30 Thread Richard Vézina
Arnon,

I test it with 12.04 server 64 bit under VirtualBox with windows 7 64 bit
as guest and it works fine. It surely work under ubuntu desktop, but not
tested. The purpose of the script is to deploy rapidly a new prod/stage
server with basic configuration that you can tweaks for your needs later.
Since you don't really require Nginx for develppment it make no sens to
install pgAdmin on the staging/prod server, you generally install it on
your dev system. You can install phpPGAdmin if you want, but when I try it
(very longtime ago, may have change) it was not the same quality of
phpmyadmin, just for you to know that. I let you find your way to install
it (google...).

Default postgres database name is redmine and user name for redemine is
redmine and the password is the one you enter when the script ask for it.

You can, try it with 12.10, but I prefer 12.04 since it LTS and I don't
want to setup new environnement in less than a year.

Richard


On Sun, Dec 30, 2012 at 1:26 PM, Richard Vézina  wrote:

> I will be glad, if you want to...
>
> :)
>
> Richard
>
>
> On Fri, Dec 28, 2012 at 11:12 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Would you suggest we include it in web2py/scripts/?
>>
>>
>> On Friday, 28 December 2012 14:17:12 UTC-6, Richard wrote:
>>>
>>> Hello,
>>>
>>> This is a new year gift for the one who would use Redmine beside
>>> web2py...
>>>
>>> :)
>>>
>>> The script is largely base on new Niphold web2py nginx deployment script
>>> (https://groups.google.com/**forum/?fromgroups=#!searchin/**
>>> web2py/nginx$20niphold/web2py/**15J3T35_K_w/v_t1099dIf4J
>>> ).
>>>
>>> I spend many hours write it, test it and debug Redmine, so I copyright
>>> it and distribute it under CC without commercial use.
>>>
>>> Executing it in a fresh Ubuntu 12.04 server you will get :
>>> - Latest Redmine stable (2.2.0 from http://rubyforge.org),
>>> - Rails (3.2.9 from GEM)
>>> - Ruby (ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]) (Ubuntu
>>> ruby-dev package that should correspond to the latest stable Ruby)
>>> - working with Unicorn (latest stable from GEM),
>>> - web2py (latest stable)
>>> - uWSGI (I think latest stable), start in Emperor mode
>>> - Nginx (Ubuntu default)
>>> - PostgreSQL (Ubuntu default)
>>> - Redmine database will be installed in PostgreSQL
>>> - Self Signed SSL Certificat
>>>
>>> I try to make the script asking all the question at the beginning of the
>>> installation process just after launch it, but there is a confirmation
>>> asked during execution where you have to choose which language to use for
>>> the Redmine default values. Just hit enter you will get English Redmine
>>> default values.
>>>
>>> At the end of the execution, you should access your sever like this :
>>>
>>> http://IPADSRESS/
>>> # web2py Welcome should appear
>>> http://IPADSRESS/redmine
>>> # Redmine!
>>>
>>> Please report issue, submit improvement or post any comment here, and I
>>> will be glad to improve the script.
>>>
>>> Happy new year to all!
>>>
>>> Richard
>>>
>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Redmine beside web2py with Nginx deployment script

2012-12-30 Thread Richard Vézina
I will be glad, if you want to...

:)

Richard


On Fri, Dec 28, 2012 at 11:12 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Would you suggest we include it in web2py/scripts/?
>
>
> On Friday, 28 December 2012 14:17:12 UTC-6, Richard wrote:
>>
>> Hello,
>>
>> This is a new year gift for the one who would use Redmine beside
>> web2py...
>>
>> :)
>>
>> The script is largely base on new Niphold web2py nginx deployment script (
>> https://groups.google.com/**forum/?fromgroups=#!searchin/**
>> web2py/nginx$20niphold/web2py/**15J3T35_K_w/v_t1099dIf4J
>> ).
>>
>> I spend many hours write it, test it and debug Redmine, so I copyright it
>> and distribute it under CC without commercial use.
>>
>> Executing it in a fresh Ubuntu 12.04 server you will get :
>> - Latest Redmine stable (2.2.0 from http://rubyforge.org),
>> - Rails (3.2.9 from GEM)
>> - Ruby (ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]) (Ubuntu
>> ruby-dev package that should correspond to the latest stable Ruby)
>> - working with Unicorn (latest stable from GEM),
>> - web2py (latest stable)
>> - uWSGI (I think latest stable), start in Emperor mode
>> - Nginx (Ubuntu default)
>> - PostgreSQL (Ubuntu default)
>> - Redmine database will be installed in PostgreSQL
>> - Self Signed SSL Certificat
>>
>> I try to make the script asking all the question at the beginning of the
>> installation process just after launch it, but there is a confirmation
>> asked during execution where you have to choose which language to use for
>> the Redmine default values. Just hit enter you will get English Redmine
>> default values.
>>
>> At the end of the execution, you should access your sever like this :
>>
>> http://IPADSRESS/
>> # web2py Welcome should appear
>> http://IPADSRESS/redmine
>> # Redmine!
>>
>> Please report issue, submit improvement or post any comment here, and I
>> will be glad to improve the script.
>>
>> Happy new year to all!
>>
>> Richard
>>
>  --
>
>
>
>

-- 





[web2py] Re: SQLFORM widget support for wider range of input types

2012-12-30 Thread Calvin
Hi Massimo

Here is a patch which updates the date, time and datetime widget. If this 
approach is acceptable, I am happy to provide a patch for the other types 
as well.

Calvin

On Sunday, 30 December 2012 00:50:59 UTC+8, Massimo Di Pierro wrote:
>
> I think this would be a good idea but somebody should be in charge of 
> this. Perhaps we can take this approach for web3py where widgets will have 
> a simpler internal design. It will be possible to use web3py widgets in 
> web2py.
>
> Anybody wants to be in charge of this? I can explain more so we can 
> discuss options.
>
> Massimo
>
>
>

-- 



>From 4a4806d78aa18ea109b8c14e425d12cc3ed49071 Mon Sep 17 00:00:00 2001
From: Calvin Sim 
Date: Mon, 31 Dec 2012 01:56:23 +0800
Subject: [PATCH] updated date, time, datetime widget's type attribute to
 enable more specific inputs with compatible browsers.

---
 gluon/sqlhtml.py |   42 +-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py
index a5827e9..7f4423b 100644
--- a/gluon/sqlhtml.py
+++ b/gluon/sqlhtml.py
@@ -160,16 +160,56 @@ class DecimalWidget(StringWidget):
 class TimeWidget(StringWidget):
 _class = 'time'
 
+@classmethod
+def widget(cls, field, value, **attributes):
+"""
+generates an INPUT time tag.
+
+see also: :meth:`FormWidget.widget`
+"""
+
+default = dict(_type='time', value=value)
+attr = cls._attributes(field, default,
+   **attributes)
+return INPUT(**attr)
+
 
 class DateWidget(StringWidget):
 _class = 'date'
 
+@classmethod
+def widget(cls, field, value, **attributes):
+"""
+generates an INPUT date tag.
+
+see also: :meth:`FormWidget.widget`
+"""
+
+default = dict(_type='date', value=value)
+attr = cls._attributes(field, default,
+   **attributes)
+return INPUT(**attr)
+
 
 class DatetimeWidget(StringWidget):
 _class = 'datetime'
 
 
-class TextWidget(FormWidget):
+clamethod
+def widget(cls, field, value, **attributes):
+"""
+generates an INPUT datetime tag.
+
+see also: :meth:`FormWidget.widget`
+"""
+
+default = dict(_type='datetime', value=value)
+attr = cls._attributes(field, default,
+   **attributes)
+return INPUT(**attr)
+
+
+ TextWidget(FormWidget):
 _class = 'text'
 
 @classmethod
-- 
1.7.10.2 (Apple Git-33)



Re: [web2py] how to create profiles

2012-12-30 Thread sasogeek


On Sunday, 30 December 2012 17:46:57 UTC, sasogeek wrote:
>
> can i create a new view so that i can have something like 
> http://...[app]/[controller]/[view]/profile/[user_id] and based on the user 
> id, the view displays a particular profile? like the show controller/view 
> in the example images app in the documentation...? and even if so, can i 
> have some code guidance cos i'm not too good with the auth system and 
> web2py in general...
>
> On Sunday, 30 December 2012 17:30:45 UTC, sasogeek wrote:
>>
>> well in my application, i allow users to register and login using the 
>> auth, but auth only exposes http://...[app]/[controller]/[view]/profile
>> which is the profile of the currently logged in user. i want to create a 
>> link so that other users can click on it to see other people's profiles.
>>
>> On Sunday, 30 December 2012 00:40:44 UTC, viniciusban wrote:
>>>
>>> What do you mean with "user profiles"? 
>>>
>>>
>>> On Sat, Dec 29, 2012 at 8:51 AM, sasogeek  wrote: 
>>> > How do allow users to see their profiles and that of other users...? 
>>> > 
>>> > -- 
>>> > 
>>> > 
>>> > 
>>>
>>

-- 





Re: [web2py] how to create profiles

2012-12-30 Thread sasogeek
can i create a new view so that i can have something like 
http://...[app]/[controller]/[view]/[user_id] and based on the user id, the 
view displays a particular profile? like the show controller/view in the 
example images app in the documentation...? and even if so, can i have some 
code guidance cos i'm not too good with the auth system and web2py in 
general...

On Sunday, 30 December 2012 17:30:45 UTC, sasogeek wrote:
>
> well in my application, i allow users to register and login using the 
> auth, but auth only exposes http://...[app]/[controller]/[view]/profile
> which is the profile of the currently logged in user. i want to create a 
> link so that other users can click on it to see other people's profiles.
>
> On Sunday, 30 December 2012 00:40:44 UTC, viniciusban wrote:
>>
>> What do you mean with "user profiles"? 
>>
>>
>> On Sat, Dec 29, 2012 at 8:51 AM, sasogeek  wrote: 
>> > How do allow users to see their profiles and that of other users...? 
>> > 
>> > -- 
>> > 
>> > 
>> > 
>>
>

-- 





Re: [web2py] how to create profiles

2012-12-30 Thread sasogeek
well in my application, i allow users to register and login using the auth, 
but auth only exposes http://...[app]/[controller]/[view]/profile
which is the profile of the currently logged in user. i want to create a 
link so that other users can click on it to see other people's profiles.

On Sunday, 30 December 2012 00:40:44 UTC, viniciusban wrote:
>
> What do you mean with "user profiles"? 
>
>
> On Sat, Dec 29, 2012 at 8:51 AM, sasogeek > 
> wrote: 
> > How do allow users to see their profiles and that of other users...? 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





Re: [web2py] Redmine beside web2py with Nginx deployment script

2012-12-30 Thread Arnon Marcus
How do I manage the database with PGAdminII ?
Which database should I choose?
What would be the user-name?
How can one install phpPGadmin on this configuration?


On Sun, Dec 30, 2012 at 2:47 PM, Arnon Marcus  wrote:

> Is this for the server or desktop flavor ?
>
>
> On Sun, Dec 30, 2012 at 2:16 PM, Arnon Marcus wrote:
>
>> Will this work with ubuntu 12.10 ?
>>
>>
>> On Sat, Dec 29, 2012 at 6:12 AM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Would you suggest we include it in web2py/scripts/?
>>>
>>>
>>> On Friday, 28 December 2012 14:17:12 UTC-6, Richard wrote:

 Hello,

 This is a new year gift for the one who would use Redmine beside
 web2py...

 :)

 The script is largely base on new Niphold web2py nginx deployment
 script (https://groups.google.com/**forum/?fromgroups=#!searchin/**
 web2py/nginx$20niphold/web2py/**15J3T35_K_w/v_t1099dIf4J
 ).

 I spend many hours write it, test it and debug Redmine, so I copyright
 it and distribute it under CC without commercial use.

 Executing it in a fresh Ubuntu 12.04 server you will get :
 - Latest Redmine stable (2.2.0 from http://rubyforge.org),
 - Rails (3.2.9 from GEM)
 - Ruby (ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux])
 (Ubuntu ruby-dev package that should correspond to the latest stable Ruby)
 - working with Unicorn (latest stable from GEM),
 - web2py (latest stable)
 - uWSGI (I think latest stable), start in Emperor mode
 - Nginx (Ubuntu default)
 - PostgreSQL (Ubuntu default)
 - Redmine database will be installed in PostgreSQL
 - Self Signed SSL Certificat

 I try to make the script asking all the question at the beginning of
 the installation process just after launch it, but there is a confirmation
 asked during execution where you have to choose which language to use for
 the Redmine default values. Just hit enter you will get English Redmine
 default values.

 At the end of the execution, you should access your sever like this :

 http://IPADSRESS/
 # web2py Welcome should appear
 http://IPADSRESS/redmine
 # Redmine!

 Please report issue, submit improvement or post any comment here, and I
 will be glad to improve the script.

 Happy new year to all!

 Richard

>>>  --
>>>
>>>
>>>
>>>
>>
>>
>

-- 





Re: [web2py] Update and Delete row issue

2012-12-30 Thread Niphlod


On Sunday, December 30, 2012 2:33:42 PM UTC+1, Wonton wrote:
>
> But it's strange. I have all this code inside my default.py controller, 
> inside web2py. 
> Indeen, these 2 lines:
> query = db(db.table.field1=='What I am looking for')
> query.update(field2='hello')   
> work perfectly even without the db.commit().
>
>  
Ok
 

> But, this code:
> query = db(db.table.field1=='What I am looking for')
> deletedRow = query.delete()
> is not working if I don't use the db.commit() instruction. I mean, it 
> seems that the deletion is ok, it doesn't crash and doesn't return any 
> error, but the database is not modified.
>
>
Please post your model and the controller as attachments (or the app if you 
can), because that has to work (and indeed works fine in a fresh app).  

-- 





[web2py] Re: Update and Delete row issue

2012-12-30 Thread Anthony

>
> 1) Regarding to the update:

As far as I know, to update a row I should do something like this:
>query = db(db.table.field1=='What I am looking for')
>query.update(field2='hello')   
>rows = query.select()
>
>row = rows[0]
>row.update_record()
>
>
Note, you could also have done something like this:

row = db(db.table.field1=='What I am looking for').select().first()
row.update(field2='hello')
row.update_record()


row.update(...) only updates the row object itself, not the associated 
record in the database. However, if you make one or more updates to the row 
object, you can subsequently call row.update_record() with no arguments, 
and it will propagate the row updates to the database (as a single update). 
That is probably the example in the book to which you are referring, shown 
at the end of this 
section
.

Anthony


-- 





Re: [web2py] Update and Delete row issue

2012-12-30 Thread Wonton
But it's strange. I have all this code inside my default.py controller, 
inside web2py. 
Indeen, these 2 lines:
query = db(db.table.field1=='What I am looking for')
query.update(field2='hello')   
work perfectly even without the db.commit().

But, this code:
query = db(db.table.field1=='What I am looking for')
deletedRow = query.delete()
is not working if I don't use the db.commit() instruction. I mean, it seems 
that the deletion is ok, it doesn't crash and doesn't return any error, but 
the database is not modified.


El domingo, 30 de diciembre de 2012 14:17:29 UTC+1, Niphlod escribió:
>
> for future references: 
>
> issuing db.commit() is necessary only if you're using DAL outside web2py. 
> As soon as the function in the controller is executed, a db.commit() is 
> issued automatically as long as no exceptions are thrown.
>
> query = db(db.table.field1=='What I am looking for')
> query.update(field2='hello')   
> rows = query.select()
> row = rows[0]
> row.update_record()
>
> works ok, although there is no need for the last 3 lines to be executed.
>
> query = db(db.table.field1=='What I am looking for')
> deletedRow = query.delete()
>
> works fine also.
>
>
> On Sunday, December 30, 2012 11:49:05 AM UTC+1, Wonton wrote:
>>
>> Hello viniciusban!
>>
>> The line "db.commit()" solved these 2 problems, thank you very much!
>>
>> Regarding to why I used "update_record()" without parameters, I took it 
>> from an example I saw on Internet, maybe the example was wrong or maybe 
>> (probably) I missunderstood the example.
>>
>> Thank you very much again!
>>
>> El domingo, 30 de diciembre de 2012 01:57:15 UTC+1, viniciusban escribió:
>>>
>>> On Sat, Dec 29, 2012 at 10:19 PM, Wonton  wrote: 
>>> > Hello everyone and happy new year! 
>>>
>>> Hi. 
>>>
>>> > 
>>> > I'm having an issue regarding the updating and deletion of a row in my 
>>> > tables and I can't find any solution, so I hope you can help me. 
>>> > 
>>> > 1) Regarding to the update: 
>>> > As far as I know, to update a row I should do something like this: 
>>> >query = db(db.table.field1=='What I am looking for') 
>>> >query.update(field2='hello') 
>>> >rows = query.select() 
>>>
>>> Issue a db.commit() here 
>>>
>>> > 
>>> >row = rows[0] 
>>> >row.update_record() 
>>> > 
>>> > But this is not working, it doesn't update the row. 
>>>
>>> Probably you have a transaction issue. 
>>>
>>> BTW, your update_record() doesn't change any field content. What are 
>>> you trying to do with it? 
>>>
>>>
>>> > 
>>> > So, I'm confused about the use of update and update_record, is ok if I 
>>> only 
>>> > use update(...)? 
>>>
>>> Actually, update() would be preferred over update_record() because it 
>>> generates a SQL UPDATE statement. On the other hand, update_record() 
>>> generates a SQL UPDATE after the record has been read, via SQL SELECT. 
>>>
>>> Thinking "transactionally", you should use update() all the time. 
>>> update_record() would be for a few situations. 
>>>
>>> > 
>>> > 2) Regarding to the delete: 
>>> > I'm deleting a row with this code: 
>>> > query = db(db.table.field1=='What I am looking for') 
>>> > deletedRow = query.delete() 
>>>
>>> Again, try to db.commit() here, after query.delete() 
>>>
>>> > The problem is that if I open this table with Database AppAdmin and 
>>> refresh 
>>> > it, the (supposed deleted) row is still there. 
>>> > Is the row really deleted, I guess not, so what could I be doing 
>>> wrong? 
>>>
>>> Remind Web2py issues an automatic db.commit() at the end of every 
>>> succesful request, but if you're in Web2py shell, there's no "end of 
>>> request". So, you should db.commit() by yourself. 
>>>
>>

-- 





Re: [web2py] Update and Delete row issue

2012-12-30 Thread Niphlod
for future references: 

issuing db.commit() is necessary only if you're using DAL outside web2py. 
As soon as the function in the controller is executed, a db.commit() is 
issued automatically as long as no exceptions are thrown.

query = db(db.table.field1=='What I am looking for')
query.update(field2='hello')   
rows = query.select()
row = rows[0]
row.update_record()

works ok, although there is no need for the last 3 lines to be executed.

query = db(db.table.field1=='What I am looking for')
deletedRow = query.delete()

works fine also.


On Sunday, December 30, 2012 11:49:05 AM UTC+1, Wonton wrote:
>
> Hello viniciusban!
>
> The line "db.commit()" solved these 2 problems, thank you very much!
>
> Regarding to why I used "update_record()" without parameters, I took it 
> from an example I saw on Internet, maybe the example was wrong or maybe 
> (probably) I missunderstood the example.
>
> Thank you very much again!
>
> El domingo, 30 de diciembre de 2012 01:57:15 UTC+1, viniciusban escribió:
>>
>> On Sat, Dec 29, 2012 at 10:19 PM, Wonton  wrote: 
>> > Hello everyone and happy new year! 
>>
>> Hi. 
>>
>> > 
>> > I'm having an issue regarding the updating and deletion of a row in my 
>> > tables and I can't find any solution, so I hope you can help me. 
>> > 
>> > 1) Regarding to the update: 
>> > As far as I know, to update a row I should do something like this: 
>> >query = db(db.table.field1=='What I am looking for') 
>> >query.update(field2='hello') 
>> >rows = query.select() 
>>
>> Issue a db.commit() here 
>>
>> > 
>> >row = rows[0] 
>> >row.update_record() 
>> > 
>> > But this is not working, it doesn't update the row. 
>>
>> Probably you have a transaction issue. 
>>
>> BTW, your update_record() doesn't change any field content. What are 
>> you trying to do with it? 
>>
>>
>> > 
>> > So, I'm confused about the use of update and update_record, is ok if I 
>> only 
>> > use update(...)? 
>>
>> Actually, update() would be preferred over update_record() because it 
>> generates a SQL UPDATE statement. On the other hand, update_record() 
>> generates a SQL UPDATE after the record has been read, via SQL SELECT. 
>>
>> Thinking "transactionally", you should use update() all the time. 
>> update_record() would be for a few situations. 
>>
>> > 
>> > 2) Regarding to the delete: 
>> > I'm deleting a row with this code: 
>> > query = db(db.table.field1=='What I am looking for') 
>> > deletedRow = query.delete() 
>>
>> Again, try to db.commit() here, after query.delete() 
>>
>> > The problem is that if I open this table with Database AppAdmin and 
>> refresh 
>> > it, the (supposed deleted) row is still there. 
>> > Is the row really deleted, I guess not, so what could I be doing wrong? 
>>
>> Remind Web2py issues an automatic db.commit() at the end of every 
>> succesful request, but if you're in Web2py shell, there's no "end of 
>> request". So, you should db.commit() by yourself. 
>>
>

-- 





Re: [web2py] Redmine beside web2py with Nginx deployment script

2012-12-30 Thread Arnon Marcus
Is this for the server or desktop flavor ?


On Sun, Dec 30, 2012 at 2:16 PM, Arnon Marcus  wrote:

> Will this work with ubuntu 12.10 ?
>
>
> On Sat, Dec 29, 2012 at 6:12 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Would you suggest we include it in web2py/scripts/?
>>
>>
>> On Friday, 28 December 2012 14:17:12 UTC-6, Richard wrote:
>>>
>>> Hello,
>>>
>>> This is a new year gift for the one who would use Redmine beside
>>> web2py...
>>>
>>> :)
>>>
>>> The script is largely base on new Niphold web2py nginx deployment script
>>> (https://groups.google.com/**forum/?fromgroups=#!searchin/**
>>> web2py/nginx$20niphold/web2py/**15J3T35_K_w/v_t1099dIf4J
>>> ).
>>>
>>> I spend many hours write it, test it and debug Redmine, so I copyright
>>> it and distribute it under CC without commercial use.
>>>
>>> Executing it in a fresh Ubuntu 12.04 server you will get :
>>> - Latest Redmine stable (2.2.0 from http://rubyforge.org),
>>> - Rails (3.2.9 from GEM)
>>> - Ruby (ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]) (Ubuntu
>>> ruby-dev package that should correspond to the latest stable Ruby)
>>> - working with Unicorn (latest stable from GEM),
>>> - web2py (latest stable)
>>> - uWSGI (I think latest stable), start in Emperor mode
>>> - Nginx (Ubuntu default)
>>> - PostgreSQL (Ubuntu default)
>>> - Redmine database will be installed in PostgreSQL
>>> - Self Signed SSL Certificat
>>>
>>> I try to make the script asking all the question at the beginning of the
>>> installation process just after launch it, but there is a confirmation
>>> asked during execution where you have to choose which language to use for
>>> the Redmine default values. Just hit enter you will get English Redmine
>>> default values.
>>>
>>> At the end of the execution, you should access your sever like this :
>>>
>>> http://IPADSRESS/
>>> # web2py Welcome should appear
>>> http://IPADSRESS/redmine
>>> # Redmine!
>>>
>>> Please report issue, submit improvement or post any comment here, and I
>>> will be glad to improve the script.
>>>
>>> Happy new year to all!
>>>
>>> Richard
>>>
>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Redmine beside web2py with Nginx deployment script

2012-12-30 Thread Arnon Marcus
Will this work with ubuntu 12.10 ?


On Sat, Dec 29, 2012 at 6:12 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Would you suggest we include it in web2py/scripts/?
>
>
> On Friday, 28 December 2012 14:17:12 UTC-6, Richard wrote:
>>
>> Hello,
>>
>> This is a new year gift for the one who would use Redmine beside
>> web2py...
>>
>> :)
>>
>> The script is largely base on new Niphold web2py nginx deployment script (
>> https://groups.google.com/**forum/?fromgroups=#!searchin/**
>> web2py/nginx$20niphold/web2py/**15J3T35_K_w/v_t1099dIf4J
>> ).
>>
>> I spend many hours write it, test it and debug Redmine, so I copyright it
>> and distribute it under CC without commercial use.
>>
>> Executing it in a fresh Ubuntu 12.04 server you will get :
>> - Latest Redmine stable (2.2.0 from http://rubyforge.org),
>> - Rails (3.2.9 from GEM)
>> - Ruby (ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]) (Ubuntu
>> ruby-dev package that should correspond to the latest stable Ruby)
>> - working with Unicorn (latest stable from GEM),
>> - web2py (latest stable)
>> - uWSGI (I think latest stable), start in Emperor mode
>> - Nginx (Ubuntu default)
>> - PostgreSQL (Ubuntu default)
>> - Redmine database will be installed in PostgreSQL
>> - Self Signed SSL Certificat
>>
>> I try to make the script asking all the question at the beginning of the
>> installation process just after launch it, but there is a confirmation
>> asked during execution where you have to choose which language to use for
>> the Redmine default values. Just hit enter you will get English Redmine
>> default values.
>>
>> At the end of the execution, you should access your sever like this :
>>
>> http://IPADSRESS/
>> # web2py Welcome should appear
>> http://IPADSRESS/redmine
>> # Redmine!
>>
>> Please report issue, submit improvement or post any comment here, and I
>> will be glad to improve the script.
>>
>> Happy new year to all!
>>
>> Richard
>>
>  --
>
>
>
>

-- 





Re: [web2py] Update and Delete row issue

2012-12-30 Thread Wonton
Hello viniciusban!

The line "db.commit()" solved these 2 problems, thank you very much!

Regarding to why I used "update_record()" without parameters, I took it 
from an example I saw on Internet, maybe the example was wrong or maybe 
(probably) I missunderstood the example.

Thank you very much again!

El domingo, 30 de diciembre de 2012 01:57:15 UTC+1, viniciusban escribió:
>
> On Sat, Dec 29, 2012 at 10:19 PM, Wonton > 
> wrote: 
> > Hello everyone and happy new year! 
>
> Hi. 
>
> > 
> > I'm having an issue regarding the updating and deletion of a row in my 
> > tables and I can't find any solution, so I hope you can help me. 
> > 
> > 1) Regarding to the update: 
> > As far as I know, to update a row I should do something like this: 
> >query = db(db.table.field1=='What I am looking for') 
> >query.update(field2='hello') 
> >rows = query.select() 
>
> Issue a db.commit() here 
>
> > 
> >row = rows[0] 
> >row.update_record() 
> > 
> > But this is not working, it doesn't update the row. 
>
> Probably you have a transaction issue. 
>
> BTW, your update_record() doesn't change any field content. What are 
> you trying to do with it? 
>
>
> > 
> > So, I'm confused about the use of update and update_record, is ok if I 
> only 
> > use update(...)? 
>
> Actually, update() would be preferred over update_record() because it 
> generates a SQL UPDATE statement. On the other hand, update_record() 
> generates a SQL UPDATE after the record has been read, via SQL SELECT. 
>
> Thinking "transactionally", you should use update() all the time. 
> update_record() would be for a few situations. 
>
> > 
> > 2) Regarding to the delete: 
> > I'm deleting a row with this code: 
> > query = db(db.table.field1=='What I am looking for') 
> > deletedRow = query.delete() 
>
> Again, try to db.commit() here, after query.delete() 
>
> > The problem is that if I open this table with Database AppAdmin and 
> refresh 
> > it, the (supposed deleted) row is still there. 
> > Is the row really deleted, I guess not, so what could I be doing wrong? 
>
> Remind Web2py issues an automatic db.commit() at the end of every 
> succesful request, but if you're in Web2py shell, there's no "end of 
> request". So, you should db.commit() by yourself. 
>

--