[web2py] Re: web2py as the best choice for newstarters in web frameworks

2011-04-15 Thread Rahul
+1 (Agreed completely)

On Apr 14, 9:19 pm, mikech mp.ch...@gmail.com wrote:
 Yes very good choice, as a beginner I've found it the most learnable.


Re: [web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-15 Thread howesc
jason,

you will need to join in the user table and adjust your grouping 
accordingly.  somthing like:

 count = db.users_tags.id.count()

 query = db((db.users_tags.user != auth.user.id)   #\/-- isn't 
that the join?

(db.users_tags.tag.belongs(db(db.users_tags.user==
auth.user.id)._select(db.users_tags.tag))) 

(db.auth_user.id==db.user_tags.user))

 rows = query.select(db.users_tags.user, db.auth_user.first_name, 
db.auth_user.last_name

 count,


 groupby=db.users_tags.user|db.auth_user.first_name|db.auth_user.last_name,

 orderby=count)

 for row in rows:

 print row.as_dict()


Re: [web2py] Re: db.xx[0] = dict( a = 'b') against db.xx.insert(a = 'b')

2011-04-15 Thread Johann Spies
On 14 April 2011 15:52, Anthony abasta...@gmail.com wrote:

 Try recnr = db.xx.insert(**x)

 The **x will expand your dictionary into a set of keyword arguments.


Thanks Anthony.

Regards
Johann
-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] geoserver proxyHost with web2py

2011-04-15 Thread Manuele Pesenti

Hi *,
I'm developping a sort of map/gis application using web2py and a local 
geoserver. For some security policy geoserver by default does not share 
data with applications that send their request from another URL even if 
form the same host but a different port. Do you think there's a way to 
use this solution[1] proposed by the openlayers FAQ to a web2py 
installation for develop porposes on port 8000 and that does not use 
apache? After all the proposed script is in python!


Thank you very mutch

Manuele

[1] http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost


Re: [web2py] Re: Implementing id = uuid.uuid4() on an existing database

2011-04-15 Thread Johann Spies
On 14 April 2011 18:26, howesc how...@umich.edu wrote:

 Johann,

 the steps as i see it:
  - add new uuid field for your new primary key, don't drop old one yet
  - fill in the uuid field
  - add a new foreign key field that will store UUID
  - use the old foreign key to lookup the uuid of the reference
  - store that uuid
  - alter tables to make the uuid fields the primary and foreign keys from
 the database's perspective
  - drop the old id columns

 you'll have to do that with some sql scripting, and then update your web2py
 model files accordingly.


Thanks Christian.  That sounds doable.

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] IntegrityError: duplicate key value violates unique constraint x_uuid_key

2011-04-15 Thread Johann Spies
Please help me to understand how to use uuid.

 db.define_table('x',
Field('uuid', length=64, default=uuid.uuid4(), notnull=True,
  writable=False, unique=True, ondelete='CASCADE'),
Field('a'),
Field('b'))


In [4]: db.x[0] = dict(a='a', b= 'b')

In [5]: db.commit()

In [6]: db.x[0] = dict(a='d', b= 'c')
---
IntegrityErrorTraceback (most recent call last)

some traceback code
...
IntegrityError: duplicate key value violates unique constraint x_uuid_key

How did I use uiid wrongly?  I thought it was supposed to be a unique field.

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] passing a list to ...select().last()

2011-04-15 Thread mart
Hi,

Is there a way to pass a list to rows = db(...).select().last() ?

would be a time saver to be able to do something like:

myList = ['dog,
  'cat,
  'kangooroo',
  'fish']

4_legged_pets = []

rows = db((db.animal.id0)(db.animal.paws==4)).select()
last_rows = rows.last(myList)
for pet in last_rows:
if pet['paws'] == 4:  4_legged_pets.append(pet)
elif pet['paws'] == 2:  ...blablabla

this way we get the last_row for all animals in one call (saves tones
of typing time)

is there a built-in way for doing this or is it best to make a
function somewhere? Of course checking  if db.animal.isempty(): before
would also be a time saver :)

thanks,
Mart :)


[web2py] Re: geoserver proxyHost with web2py

2011-04-15 Thread pbreit
I took a crack at it. Since I'm not sure how to test it, I have no idea if 
it works. I'm just learning the str.join() trick so am not that 
comfortable with it yet. At a minimum it returns the openlayers home page if 
you simply go to http://127.0.0.1:8000/app/default/proxy as suggested in the 
FAQ so that's a start. I also verified that it works if you POST to the 
proxy and include the POST var url=http://labs.metacarta.com;.


def proxy():
import urllib, urllib2
import cgi
import sys, os

allowedHosts = ['www.openlayers.org', 'openlayers.org', 
'labs.metacarta.com', 'world.freemap.in', 
'prototype.openmnnd.org', 'geo.openplans.org',
'sigma.openplans.org', 'demo.opengeo.org',
'www.openstreetmap.org', 'sample.azavea.com',
'v2.suite.opengeo.org', 'v-swe.uni-muenster.de:8080', 
'vmap0.tiles.osgeo.org', 'www.openrouteservice.org']

method = request.env.request_method

if method == POST:
if request.vars.url:
url = request.vars.url
else:
url = http://www.openlayers.org;
else:
fs = cgi.FieldStorage()
url = fs.getvalue('url', http://www.openlayers.org;)


host = url.split(/)[2]
if allowedHosts and not host in allowedHosts:
response = '\n'.join([Status: 502 Bad Gateway,
Content-Type: text/plain,
'',
This proxy does not allow you to access that location 
(%s). % (host,),
'',
str(request.env)])
return response

elif url.startswith(http://;) or url.startswith(https://;):
try:
if method == POST:
body = urllib.urlencode(request.post_vars)
r = urllib2.Request(url, body)
y = urllib2.urlopen(r)
else:
y = urllib2.urlopen(url)

# print content type header
i = y.info()
if i.has_key(Content-Type):
response = Content-Type: %s\n\n%s % (i[Content-Type], 
y.read())
else:
response = Content-Type: text/plain\n\n%s % (y.read(),)
y.close()
return response

except Exception, E:
response = '\n'.join([Status: 500 Unexpected Error,
Content-Type: text/plain,
'',
Some unexpected error occurred. Error text was:,
str(E)])
return response

else:
response = '\n'.join([Content-Type: text/plain,
'',
Illegal request.])
return response


[web2py] Re: passing a list to ...select().last()

2011-04-15 Thread DenesL

Hi Mart,

following your example I am not sure what you want but try something
like

rows = db(db.animal.paws==4).select()
last_rows = [rows.find(lambda r: r.species=x).last() for x in myList]



On Apr 15, 4:51 am, mart msenecal...@gmail.com wrote:
 Hi,

 Is there a way to pass a list to rows = db(...).select().last() ?

 would be a time saver to be able to do something like:

         myList = ['dog,
                       'cat,
                       'kangooroo',
                       'fish']

         4_legged_pets = []

         rows = db((db.animal.id0)(db.animal.paws==4)).select()
         last_rows = rows.last(myList)
         for pet in last_rows:
             if pet['paws'] == 4:  4_legged_pets.append(pet)
             elif pet['paws'] == 2:  ...blablabla

 this way we get the last_row for all animals in one call (saves tones
 of typing time)

 is there a built-in way for doing this or is it best to make a
 function somewhere? Of course checking  if db.animal.isempty(): before
 would also be a time saver :)

 thanks,
 Mart :)


[web2py] Re: extending web2py's generic.rss view

2011-04-15 Thread johntynan

Rather than use use gluon.serializers.rss, I am using
gluon.contrib.rss2 to attempt to add an enclosure to an rss feed:

http://code.google.com/p/publicradioroadtrip/source/browse/controllers/default.py?spec=svnd020b7842a1c0a9ba880fb5f94146bbb5ab55524r=d020b7842a1c0a9ba880fb5f94146bbb5ab55524#590

for story in stories:

x = {}
enclosure = {'url': story.audio_url, 'length': '0', 'type':
'audio/mpeg'}
title = story.title
link = story.url
# enclosure = story.audio_url
description = story.description
comments = 'test'
created_on = request.now
x.update(title=title, link=link, enclosure=enclosure,
description=description, comments=comments, created_on=created_on)
entries.append(x)

rss = rss2.RSS2(title=collection.title,
link = scheme + '://' + request.env.http_host +
request.env.path_info,
description = collection.description,
lastBuildDate = request.now,
items = [
rss2.RSSItem(title = entry['title'],
link = entry['link'],
description = entry['description'],
comments = entry['comments'],
# enclosure = entry['enclosure'],
pubDate = request.now) for entry in entries])

response.headers['Content-Type']='application/rss+xml'
return rss2.dumps(rss)

However, i am running into an issue where I am recieving the error:

AttributeError: 'dict' object has no attribute 'publish'

http://pastie.textmate.org/1796751

I copied some additional information here.

http://pastie.textmate.org/1796758

In looking line 310 in contrib.rss2, it appears that enclosure should
contain a dictionary, but I could be wrong:

def publish(self, handler):
_element(handler, 'enclosure', None,
{'url': self.url, 'length': str(self.length), 'type':
self.type})

Any suggestions you might have about getting this to work are most
appreciated.


[web2py] how to produce db select into xml

2011-04-15 Thread 黄祥
hi,

is there anyone knows how to produce db output select into xml please?
my intention is to convert my audio mp3 table into xml and then put it
on web2py apps.

e.g. (source from : http://www.voice2page.com/info/v2ppage_codes.html)

embed allowScriptAccess=neversrc=http://voice2page.com/info/
mp3player.swf menu=false quality=high width=264 height=280
name=index type=application/x-shockwave-flash pluginspage=http://
www.macromedia.com/go/getflashplayer flashvars=playList=http://
***your_url***/
***your_playlist***.xmlShowPlaylist=1ShowEQ=1firstTrack=1initVol=80
wmode=transparent border=0 //embed

or is there any other way to do that?

thanks so much and best regards,

steve van christie


[web2py] Re: launching web2py from script?

2011-04-15 Thread Massimo Di Pierro
Not sure I understand.
Is your problem that you do

python nweb2py.py -a 'password'

and you get?

TypeError: cannot create weak reference to 'classobj' object

I have never seen this before. How do you run it? Which python
version? Do you have a loger traceback?

On Apr 14, 10:47 pm, mart msenecal...@gmail.com wrote:
 Hi,

 thought it would simple enough to do, but ... surprise , surprise on
 me!

 here's the gist: i have some scripts, that do a good part of my day to
 day. functions, modules, etc... are called through a set of navigable
 menus (everything is interactive @ the cmd line) . they look like
 below. What I am trying to do is get option 11 (below) to work...
 option 11 is supposed to bring me to a web2py menu where I can
 configure its settings (like, password, Cron (True or False), which
 app to open once the server is running, etc) works like an ascii
 looking wizard, which works great! but... but I can not get web2py to
 launch. I tried pretty much everything I can think of like 'python
 web2py.py -i 127.0.0.1 -p 8000 -a blabla --nogui', importing widget,
 etc... and using many different options to launch (subprocess,
 os.system, exec, popen, etc...). Ideally, web2py would start without
 invoking the UI.

 Now that I have DAL stand-alone and web2py sharing and playing with
 the same tables, I wanted to start making things interesting...

 the jam is the weak reference exception popping up...

                 TypeError: cannot create weak reference to 'classobj'
 object

 Anybody have a trick handy??? :)

 thanks in advance,
 Mart :)

 No. | option
 
 1.   | kick off a full build
 2.   | kick off a partial build (specify CMD)
 3.   | create new build_spec
 4.   | interactive shell
 5.   | interface to P4
 6.   | blueFTP client
 7.   | dump tables to...(xml or csv)
 8.   | setup local_user
 9.   | view local_user table
 10. | view storage info
 11. | launch web2py

 12. | back to MAIN MENU
 13. | quit


[web2py] Re: IntegrityError: duplicate key value violates unique constraint x_uuid_key

2011-04-15 Thread Massimo Di Pierro
You are passing a uuid, not a uuid function therefore it is always the
same value:

try replace

default=uuid.uuid4()

with

default=uuid.uuid4
or
default=lambda:uuid.uuid4()
or
default=lambda:str(uuid.uuid4())

they should all work.

On Apr 15, 2:20 am, Johann Spies johann.sp...@gmail.com wrote:
 Please help me to understand how to use uuid.

  db.define_table('x',
                 Field('uuid', length=64, default=uuid.uuid4(), notnull=True,
                       writable=False, unique=True, ondelete='CASCADE'),
                 Field('a'),
                 Field('b'))

 In [4]: db.x[0] = dict(a='a', b= 'b')

 In [5]: db.commit()

 In [6]: db.x[0] = dict(a='d', b= 'c')
 ---
 IntegrityError                            Traceback (most recent call last)
 
 some traceback code
 ...
 IntegrityError: duplicate key value violates unique constraint x_uuid_key

 How did I use uiid wrongly?  I thought it was supposed to be a unique field.

 Regards
 Johann

 --
  May grace and peace be yours in abundance through the full knowledge of God
 and of Jesus our Lord!  His divine power has given us everything we need for
 life and godliness through the full knowledge of the one who called us by
 his own glory and excellence.
                                                     2 Pet. 1:2b,3a


[web2py] Re: how to produce db select into xml

2011-04-15 Thread Anthony
Let's say you have:
 
def mp3():
rows = db(your_query).select(your_select)
return dict(rows=rows)
 
If you go to /app/controller/mp3.xml it will use the 'generic.xml' view to 
render the rows as XML. If you want to convert the rows to XML within your 
controller and then do something else with the XML, you can do:
 
from gluon.serializers import xml
xmlrows = xml(rows)
 
The above is what the 'generic.xml' view file does.
 
Anthony

On Friday, April 15, 2011 8:49:07 AM UTC-4, 黄祥 wrote:

 hi, 

 is there anyone knows how to produce db output select into xml please? 
 my intention is to convert my audio mp3 table into xml and then put it 
 on web2py apps. 

 e.g. (source from : http://www.voice2page.com/info/v2ppage_codes.html) 

 embed allowScriptAccess=neversrc=http://voice2page.com/info/ 
 mp3player.swf menu=false quality=high width=264 height=280 
 name=index type=application/x-shockwave-flash pluginspage=http:// 
 www.macromedia.com/go/getflashplayer flashvars=playList=http:// 
 ***your_url***/ 
 ***your_playlist***.xmlShowPlaylist=1ShowEQ=1firstTrack=1initVol=80 
 wmode=transparent border=0 //embed 

 or is there any other way to do that? 

 thanks so much and best regards, 

 steve van christie



[web2py] Re: how to produce db select into xml

2011-04-15 Thread Anthony
Note, the book recommends first converting the Rows object to a list using 
as_list(), though converting to XML seems to work for me without doing that:
http://web2py.com/book/default/chapter/09?search=serializer#Rendering-Rows
 
Also, see 
http://web2py.com/book/default/chapter/06#HTML/XML-(one-table-at-a-time), 
particularly if you need custom XML tags.
 
Anthony

On Friday, April 15, 2011 9:43:13 AM UTC-4, Anthony wrote:

 Let's say you have:
  
 def mp3():
 rows = db(your_query).select(your_select)
 return dict(rows=rows)
  
 If you go to /app/controller/mp3.xml it will use the 'generic.xml' view to 
 render the rows as XML. If you want to convert the rows to XML within your 
 controller and then do something else with the XML, you can do:
  
 from gluon.serializers import xml
 xmlrows = xml(rows)
  
 The above is what the 'generic.xml' view file does.
  
 Anthony

 On Friday, April 15, 2011 8:49:07 AM UTC-4, 黄祥 wrote:

 hi, 

 is there anyone knows how to produce db output select into xml please? 
 my intention is to convert my audio mp3 table into xml and then put it 
 on web2py apps. 

 e.g. (source from : http://www.voice2page.com/info/v2ppage_codes.html) 

 embed allowScriptAccess=neversrc=http://voice2page.com/info/ 
 mp3player.swf menu=false quality=high width=264 height=280 
 name=index type=application/x-shockwave-flash pluginspage=http:// 
 www.macromedia.com/go/getflashplayer flashvars=playList=http:// 
 ***your_url***/ 
 ***your_playlist***.xmlShowPlaylist=1ShowEQ=1firstTrack=1initVol=80 
 wmode=transparent border=0 //embed 

 or is there any other way to do that? 

 thanks so much and best regards, 

 steve van christie



[web2py] Re: launching web2py from script?

2011-04-15 Thread Arun K.Rajeevan
can you give code segment for option 11

to start web2py without gui, use '--nogui' option


[web2py] Re: Use bpython with web2py

2011-04-15 Thread Arun K.Rajeevan
I do came to notice that why reverting back to ipython while bpython is not 
installed.
It should be reverting back to plain python shell.

Fix for is that is fairly simple. An else clause.

I'll submit new patch.

@niknok: Can you reproduce the crashes? 



[web2py] Re: submit forms to press the enter key

2011-04-15 Thread luifran
yes, my crud form has only two drop down list.

On 15 abr, 00:29, Stifan Kristi steve.van.chris...@gmail.com wrote:
 is your focus is on the text area, check box or drop down list?

 best regards,

 steve van christie


Re: [web2py] Re: Use bpython with web2py

2011-04-15 Thread Arun K.Rajeevan
I'm using 10.10, I can't see this problem happening.
Is it that Ubuntu 11.04 beta, and some package may be unstable???

what's your bpython version?
import bpython; print bpython.__version__

mine is 0.9.6.2


[web2py] Re: Use bpython with web2py

2011-04-15 Thread Arun K.Rajeevan
In response to the events in which bpython isn't installed/crashed, my 
previous patch will revert back to ipython (if installed).
The attached patch will revert straight into plain python shell, instead of 
checking for ipython.

Apply, if others think, that's appropriate

Thanks, 
Arun
215,226c215,226
 
 try:
 import IPython
 # following 2 lines fix a problem with IPython; thanks Michael Toomim
 if '__builtins__' in _env:
 del _env['__builtins__']
 shell = IPython.Shell.IPShell(argv=[], user_ns=_env)
 shell.mainloop()
 return
 except:
 logger.warning(
 'import IPython error; use default python shell')
---
 else:
 try:
 import IPython
 # following 2 lines fix a problem with IPython; thanks Michael Toomim
 if '__builtins__' in _env:
 del _env['__builtins__']
 shell = IPython.Shell.IPShell(argv=[], user_ns=_env)
 shell.mainloop()
 return
 except:
 logger.warning(
 'import IPython error; use default python shell')


Re: [web2py] Re: how to share my apps in web2py appliance

2011-04-15 Thread Arun K.Rajeevan
your system doesn't have python-dev package.
If you are compiling mercurial from source you need that.
Install that first and try again.

(on debian based systems)
$ sudo apt-get install python-dev

I prefer this, because, one in ubuntu repo is older than latest version 
available, 
And since some of my repo's are created with newer version, older versions 
of mercurial can't operate on them.


[web2py] Re: web2py as the best choice for newstarters in web frameworks

2011-04-15 Thread Arun K.Rajeevan
Java - Python
Ask why?
- web2py!


Re: [web2py] Re: how to share my apps in web2py appliance

2011-04-15 Thread Stifan Kristi
a, i c, thank you so much for your adviced, arun.

best regards,

steve van christie

On Fri, Apr 15, 2011 at 9:52 PM, Arun K.Rajeevan the1.a...@gmail.comwrote:

 your system doesn't have python-dev package.
 If you are compiling mercurial from source you need that.
 Install that first and try again.

 (on debian based systems)
 $ sudo apt-get install python-dev

 I prefer this, because, one in ubuntu repo is older than latest version
 available,
 And since some of my repo's are created with newer version, older versions
 of mercurial can't operate on them.



[web2py] Re: blank entry in SELECT using values from a database table

2011-04-15 Thread Arun K.Rajeevan
https://bitbucket.org/kra3/visual-lingua-website/src/8ac2627b0a19/applications/init/controllers/default.py

see line 24.

It's like this,
populate option list first,
insert a blank entry (in my case ALL Languages), into first position.
Use that list in form


[web2py] Re: how to produce db select into xml

2011-04-15 Thread Anthony
On Friday, April 15, 2011 9:50:01 AM UTC-4, Anthony wrote: 

 Note, the book recommends first converting the Rows object to a list using 
 as_list(), though converting to XML seems to work for me without doing that:
 http://web2py.com/book/default/chapter/09?search=serializer#Rendering-Rows

 
It looks like the xml serializer automatically converts Rows objects to 
lists via as_list(), so when using the 'generic.xml' view or the xml 
serializer directly, you do not have to first call as_list().
 
Anthony


[web2py] Re: How easy is it to replace JQuery in Web2py?

2011-04-15 Thread Arun K.Rajeevan
see around web2py_ajax.html,
Once, you converted all those functions starting with web2py_* from jquery 
to dojo (or any other)
you are done.


[web2py] Re: Netbeans

2011-04-15 Thread Arun K.Rajeevan
load netbeans just for web2py is a lot for me.

btw., the best IDE I've seen working is Wing IDE,
Also, PyDev too work well, (not as good as Wing)


Re: [web2py] Re: how to produce db select into xml

2011-04-15 Thread Stifan Kristi
thank you so much for your help, anthony, i've already tested your code, and
it works fine.
def mp3():
rows = db().select(db.audio.ALL)
from gluon.serializers import xml
xmlrows = xml(rows)
return dict(xmlrows = xmlrows)

i'll try to pass the xml output into the views but, the player didn't work
because of what i passed is xml content not xml file (*.xml), the error said
'can't find xml file', do you have any solutions to produce xml file?

i'm tryin to use jquerygrid too, refer to the radiologs appliances.
any suggestion about it?

thank you so much and best regards,

steve van christie


[web2py] What's the utility of auth.settings.alternate_requires_registration?

2011-04-15 Thread José L .
I've tried to use it to avoid registering automatically users in the 
database after a login using ldap, but the result is almost the opposite.
If auth.settings.alternate_requires_registration=True, then only database 
users are allowed, and the alternate_login_methods are ignored.
Is it a bug or am I missing some other utility for this variable?



Regards.


[web2py] web2py in Web Project

2011-04-15 Thread contatogilson...@gmail.com
Hello,

As I said before, I believe a system and stayed in webfaction.com. When I
create theapplication there, they already have a script to download the
web2py and prepare itwith Apache. But those weeks while using the
system it gives
the following error:

502 - Bad Gateway


Reported that they were using too much memory, so why the server goes down.
Onlyhas 2 to 4 users accessing the system, and specifically access a list of
records thathave a total of 2000, and is paged using the plugin called
jQuery Javascript DataTable. How do I use the MySQL database, I checked that
 was not using commit, andinsert after the queries, insertions and data
edits. Still continued with the error. I askeveryone's help on this, because
 I will develop another web application, and I'mtraumatized about what
happened and wanted to use the web2py for this project. What should I do when
I play in production? What best practices should I play in the project to
avoid this memory leaks with Apache and avoid excessive use of memory in
queriesto the database?
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*


Re: [web2py] Re: how to produce db select into xml

2011-04-15 Thread Stifan Kristi
thank you so much for your info, arun, but it return an error when i execute
it :

This page contains the following errors:
error on line 162 at column 10: Opening and ending tag mismatch: link line 0
and head error on line 162 at column 10: Encoding error
Below is a rendering of the page up to the first error.do you have any
solution for this?

thanks and best regards,

steve van christie

On Fri, Apr 15, 2011 at 10:38 PM, Arun K.Rajeevan the1.a...@gmail.comwrote:

 def mp3():
 import gluon.contenttype
 response.headers['Content-Type']
 = gluon.contenttype.contenttype('.xml')
 rows = db().select(db.audio.ALL)
 from gluon.serializers import xml
 xmlrows = xml(rows)
 return dict(xmlrows = xmlrows)



[web2py] Re: Use bpython with web2py

2011-04-15 Thread Massimo Di Pierro

Thanks. Will apply it shortly.


On Apr 15, 2011, at 9:36 AM, Arun K.Rajeevan wrote:

In response to the events in which bpython isn't installed/crashed,  
my previous patch will revert back to ipython (if installed).
The attached patch will revert straight into plain python shell,  
instead of checking for ipython.


Apply, if others think, that's appropriate

Thanks,
Arunshell.patch




Re: [web2py] Re: blank entry in SELECT using values from a database table

2011-04-15 Thread Miguel Miranda
Great Arun, it did the trick.

Why do you do:?

options_added=options[:]

I just did it:

options.insert(0, OPTION('', _value=''))

and it worked fine,
kind regards


On Fri, Apr 15, 2011 at 9:00 AM, Arun K.Rajeevan the1.a...@gmail.comwrote:


 https://bitbucket.org/kra3/visual-lingua-website/src/8ac2627b0a19/applications/init/controllers/default.py

 see line 24.

 It's like this,
 populate option list first,
 insert a blank entry (in my case ALL Languages), into first position.
 Use that list in form



[web2py] Re: Args, form, rows logic in a function.

2011-04-15 Thread annet
Hi Denes,

Thanks for your reply. What about the logic of redirecting after a
form submit on the index page to a function in a locator controller,
and redefining the form and retrieving data from the database based on
the args in the URL.


Kind regards,

Annet.


[web2py] Re: Problem with tables of n:m relationsships

2011-04-15 Thread Arun K.Rajeevan
First of all, I'm not sure about it, but out of curiosity

Isn't it that* InternalError: (1048, uColumn 'country_id' cannot be null) 
*caused by trying to insert something into table w/o giving a value to 
country_id field???
A primary field cannot be empty.

forget, if I'm wrong in my assumptions. 


Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-15 Thread Arun K.Rajeevan
It should not be.
After caching, it must not hit database, until cache expires.

So, after the cache is set and you insert something, then it'll take time 
until cache expires, to have another db hit.
Unless db is queried again, new data will not be there.

It's as simple as that.

As others said, you probably don't need caching, but if you do, set an 
expire time considering how fast the data in db get changed.


Re: [web2py] Re: cache.ram didn't show data immediately

2011-04-15 Thread Stifan Kristi
a, i c, thank you so much for your adviced, arun.
i'll use the cache.ram, but lower the time in my dev learning.

kind regards,

steve van christie


On Fri, Apr 15, 2011 at 11:05 PM, Arun K.Rajeevan the1.a...@gmail.comwrote:

 It should not be.
 After caching, it must not hit database, until cache expires.

 So, after the cache is set and you insert something, then it'll take time
 until cache expires, to have another db hit.
 Unless db is queried again, new data will not be there.

 It's as simple as that.

 As others said, you probably don't need caching, but if you do, set an
 expire time considering how fast the data in db get changed.



Re: [web2py] Re: how to produce db select into xml

2011-04-15 Thread Arun K.Rajeevan
set content type before returning.

def mp3():
import gluon.contenttype
response.headers['Content-Type'] = gluon.contenttype.contenttype('.xml')
rows = db().select(db.audio.ALL)
from gluon.serializers import xml
xmlrows = xml(rows)
return dict(xmlrows = xmlrows)


Re: [web2py] Re: passing a list to ...select().last()

2011-04-15 Thread Vasile Ermicioi
db(...).select().first() gives only one record ( the same as
db(...).select()[0]
 )

db(...).select().last() :

rows = db(...).select()
last = len(rows) and rows[-1] or None


[web2py] Facebook redirection after authentication

2011-04-15 Thread berubejd
I am having the hardest time determining what the correct way is to
set the URL that a user will be redirected to after the authentication/
authorization redirect to Facebook.  What I am currently seeing is
that a user who has not yet authenticated with Facebook will be
properly forwarded for authentication but they are returned to:

   /myapp/default/index

Since nearly the entire app is doing partial page loads with AJAX, I
need them to be returned to:

  /myapp/

If they have authenticated previously, and don't require re-
authentication, that is where subsequent application loads end up and
everything works fine.  If they get returned to the former (/myapp/
default/index) then a later AJAX request, for index2 as an example,
ends up at:

  /myapp/default/default/index2

This, as you can imagine, is not going to work.  Might anyone be able
to give me an idea of what I need to do to get this to work properly?
Will I need to patch one of the underlying files in order for me to
override the default?

Thanks!


[web2py] Re: Netbeans

2011-04-15 Thread ron_m
Doesn't look good for Python support in Netbeans 7 according to this

https://groups.google.com/forum/#!topic/comp.lang.python/JQQWJCARh9U




Re: [web2py] web2py in Web Project

2011-04-15 Thread Bruno Rocha
Datatable plugin or powerTable does not paginate the data on server, it
loads all the records in to memory and the pagination is done in client side
DOM.

I guess you dont need to commit() or close connection because web2py does
that for you on each request.

webfaction is a very nice hosting service, but it crashes too much using
web2py when you run with less than 200MB, you can try to customize the
apache configuration to run with low number of threads. You can put the data
in to a cache or paginate in server side using limitby=(x,y) in your
queries.

Do you have a local test server (the same config as in webfaction) to run
the same application and make a stress test?

Can you share your code(where you are doing Bb IO) ?



On Fri, Apr 15, 2011 at 12:25 PM, contatogilson...@gmail.com 
contatogilson...@gmail.com wrote:

 Hello,

 As I said before, I believe a system and stayed in webfaction.com. When I
 create theapplication there, they already have a script to download the
 web2py and prepare itwith Apache. But those weeks while using the system
 it gives the following error:

 502 - Bad Gateway


 Reported that they were using too much memory, so why the server goes down
 . Onlyhas 2 to 4 users accessing the system, and specifically access a list
 of records thathave a total of 2000, and is paged using the plugin called
 jQuery Javascript DataTable. How do I use the MySQL database, I checked
 that was not using commit, andinsert after the queries, insertions and data
 edits. Still continued with the error. I askeveryone's help on this,
 because I will develop another web application, and I'mtraumatized about
 what happened and wanted to use the web2py for this project. What should I
  do when I play in production? What best practices should I play in the
 project toavoid this memory leaks with Apache and avoid excessive use of
 memory in queriesto the database?
 _
 *Gilson Filho*
 *Web Developer
 http://gilsondev.com*




[web2py] Re: Args, form, rows logic in a function.

2011-04-15 Thread DenesL
Hi Annet,

could you explain what you want to do?.


On Apr 15, 11:57 am, annet annet.verm...@gmail.com wrote:
 Hi Denes,

 Thanks for your reply. What about the logic of redirecting after a
 form submit on the index page to a function in a locator controller,
 and redefining the form and retrieving data from the database based on
 the args in the URL.

 Kind regards,

 Annet.


[web2py] A quiz-like app

2011-04-15 Thread Drise
I am looking display a page that allows users to take a simple quiz.
The databases I have defined work. The part that isn't so clear for me
is how to display and receive the results from the quiz. I need to
display radio buttons for each choice in of answers relating to the
question.

My databases:

db.define_table('quiz',
   Field('title'),
   Field('is_published', 'boolean', default=False))

db.define_table('question',
   Field('quiz_id', db.quiz),
   Field('question'))

db.define_table('answers',
   Field('question_id', db.question),
   Field('answer'),
   Field('weight', default=1))

db.question.quiz_id.requires = IS_IN_DB(db, db.quiz.id, '%(title)s')

db.answers.question_id.requires = IS_IN_DB(db, db.question.id, '%
(question)s')

How should I go by this?


[web2py] Re: passing a list to ...select().last()

2011-04-15 Thread mart
yeah, I see what you mean... Should have waited a bit. So much for
clever 4am analogies... ;) Wasn't really for animals ;)

I think what you have works for this. I wanted to be able to throw a
list at '.last()' because the same set of 50 to 60 rows get generated
every time a build is run. sometimes all fields in a given row change,
sometimes none, and sometimes some change, with an average  of 50 to
60 new rows get inserted at each build.

SO this was just to make it easy to do : get the the last values we
have for items in this list. I can have a func that will do it, I
just didn't want to re-invent if there was something like it
already :).

I will wrap what you posted in a function. That should do  it:)

rows = db(db.animal.paws==4).select()
last_rows = [rows.find(lambda r: r.species=x).last() for x in myList]


Thanks for the help/reply,
Mart :)

On Apr 15, 5:53 am, DenesL denes1...@yahoo.ca wrote:
 Hi Mart,

 following your example I am not sure what you want but try something
 like

 rows = db(db.animal.paws==4).select()
 last_rows = [rows.find(lambda r: r.species=x).last() for x in myList]

 On Apr 15, 4:51 am, mart msenecal...@gmail.com wrote:







  Hi,

  Is there a way to pass a list to rows = db(...).select().last() ?

  would be a time saver to be able to do something like:

          myList = ['dog,
                        'cat,
                        'kangooroo',
                        'fish']

          4_legged_pets = []

          rows = db((db.animal.id0)(db.animal.paws==4)).select()
          last_rows = rows.last(myList)
          for pet in last_rows:
              if pet['paws'] == 4:  4_legged_pets.append(pet)
              elif pet['paws'] == 2:  ...blablabla

  this way we get the last_row for all animals in one call (saves tones
  of typing time)

  is there a built-in way for doing this or is it best to make a
  function somewhere? Of course checking  if db.animal.isempty(): before
  would also be a time saver :)

  thanks,
  Mart :)


[web2py] Re: web2py in Web Project

2011-04-15 Thread Massimo Di Pierro
plugin_wiki uses he jqGrid plugin and it paginates on server.

On Apr 15, 1:27 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Datatable plugin or powerTable does not paginate the data on server, it
 loads all the records in to memory and the pagination is done in client side
 DOM.

 I guess you dont need to commit() or close connection because web2py does
 that for you on each request.

 webfaction is a very nice hosting service, but it crashes too much using
 web2py when you run with less than 200MB, you can try to customize the
 apache configuration to run with low number of threads. You can put the data
 in to a cache or paginate in server side using limitby=(x,y) in your
 queries.

 Do you have a local test server (the same config as in webfaction) to run
 the same application and make a stress test?

 Can you share your code(where you are doing Bb IO) ?

 On Fri, Apr 15, 2011 at 12:25 PM, contatogilson...@gmail.com 







 contatogilson...@gmail.com wrote:
  Hello,

  As I said before, I believe a system and stayed in webfaction.com. When I
  create theapplication there, they already have a script to download the
  web2py and prepare itwith Apache. But those weeks while using the system
  it gives the following error:

  502 - Bad Gateway

  Reported that they were using too much memory, so why the server goes down
  . Onlyhas 2 to 4 users accessing the system, and specifically access a list
  of records thathave a total of 2000, and is paged using the plugin called
  jQuery Javascript DataTable. How do I use the MySQL database, I checked
  that was not using commit, andinsert after the queries, insertions and data
  edits. Still continued with the error. I askeveryone's help on this,
  because I will develop another web application, and I'mtraumatized about
  what happened and wanted to use the web2py for this project. What should I
   do when I play in production? What best practices should I play in the
  project toavoid this memory leaks with Apache and avoid excessive use of
  memory in queriesto the database?
  _
  *Gilson Filho*
  *Web Developer
 http://gilsondev.com*


[web2py] Re: A quiz-like app

2011-04-15 Thread Massimo Di Pierro
Needs work but does not use auth, but it is a good starting point.
http://web2py.com/appliances/default/show/66

On Apr 15, 1:59 pm, Drise dris...@gmail.com wrote:
 I am looking display a page that allows users to take a simple quiz.
 The databases I have defined work. The part that isn't so clear for me
 is how to display and receive the results from the quiz. I need to
 display radio buttons for each choice in of answers relating to the
 question.

 My databases:

 db.define_table('quiz',
    Field('title'),
    Field('is_published', 'boolean', default=False))

 db.define_table('question',
    Field('quiz_id', db.quiz),
    Field('question'))

 db.define_table('answers',
    Field('question_id', db.question),
    Field('answer'),
    Field('weight', default=1))

 db.question.quiz_id.requires = IS_IN_DB(db, db.quiz.id, '%(title)s')

 db.answers.question_id.requires = IS_IN_DB(db, db.question.id, '%
 (question)s')

 How should I go by this?


Re: [web2py] Re: A quiz-like app

2011-04-15 Thread Bruno Rocha
Here is a version that I am using
https://bitbucket.org/rochacbruno/surveycloud
(does not store cpickle and has user-password control)
--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]



On Fri, Apr 15, 2011 at 4:05 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Needs work but does not use auth, but it is a good starting point.
 http://web2py.com/appliances/default/show/66

 On Apr 15, 1:59 pm, Drise dris...@gmail.com wrote:
  I am looking display a page that allows users to take a simple quiz.
  The databases I have defined work. The part that isn't so clear for me
  is how to display and receive the results from the quiz. I need to
  display radio buttons for each choice in of answers relating to the
  question.
 
  My databases:
 
  db.define_table('quiz',
 Field('title'),
 Field('is_published', 'boolean', default=False))
 
  db.define_table('question',
 Field('quiz_id', db.quiz),
 Field('question'))
 
  db.define_table('answers',
 Field('question_id', db.question),
 Field('answer'),
 Field('weight', default=1))
 
  db.question.quiz_id.requires = IS_IN_DB(db, db.quiz.id, '%(title)s')
 
  db.answers.question_id.requires = IS_IN_DB(db, db.question.id, '%
  (question)s')
 
  How should I go by this?



[web2py] Re: launching web2py from script?

2011-04-15 Thread mart
Hi,

so, this is happening on Macos 10.6x, python is 2.7 and web2py is
latest (although it tells me I have latest, but I also get the active
link to update to latest,...)

Which ever module I use, I get the same error. This example is with
subprocess and the cmd  string is 'python ./blueLite/pyUtils/web/
web2py.py -a blabla'

tried to cd to the directory first, and have the same results.

Just thought of something... I changed the folder name from 'web2py'
to 'web' because I am experimenting with structure and location, that
wouldn't impact, would it?

Thanks for the help! :)

'import site' failed; use -v for traceback
Traceback (most recent call last):
  File web2py.py, line 4, in module
import os
  File /Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/os.py, line 398, in module
import UserDict
  File /Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/UserDict.py, line 84, in module
_abcoll.MutableMapping.register(IterableUserDict)
  File /Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/abc.py, line 109, in register
if issubclass(subclass, cls):
  File /Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/abc.py, line 151, in __subclasscheck__
if subclass in cls._abc_cache:
  File /Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/_weakrefset.py, line 69, in __contains__
return ref(item) in self.data
TypeError: cannot create weak reference to 'classobj' object



On Apr 15, 10:13 am, Arun K.Rajeevan the1.a...@gmail.com wrote:
 can you give code segment for option 11

 to start web2py without gui, use '--nogui' option


[web2py] Re: Args, form, rows logic in a function.

2011-04-15 Thread pbreit
Redirecting should work. Can you get it to work with just one form? Once you 
get one form working, then try adding the second form. Start simply.

[web2py] Re: launching web2py from script?

2011-04-15 Thread pbreit
It looks to me like it might be stuck at the very beginning with import 
os. In MacOS terminal, can you do a simple import os in Python shell?

$ python
 import os



[web2py] Re: launching web2py from script?

2011-04-15 Thread mart
yup, no problem doing import os

I figured, there was a call to weakref somewhere in web2py libs, but I
don't see it...

On Apr 15, 3:29 pm, pbreit pbreitenb...@gmail.com wrote:
 It looks to me like it might be stuck at the very beginning with import
 os. In MacOS terminal, can you do a simple import os in Python shell?

 $ python







  import os


[web2py] Re: A quiz-like app

2011-04-15 Thread pbreit
You probably need 'answers' to reference auth_user or come up with a scheme 
to track the person answering.

Then, select() a question and build a form. Perhaps:

question = db.question(1) #or however you want to pick the question
form = SQLFORM(db.answers)
form.vars.question_id = question.id
return dict(question=question, form=form)

To hide the form elements you don't want, you might need to either customize 
the form or set readable/writable.

Q: {{=question.question}}br
A: {{=form}}


[web2py] Re: launching web2py from script?

2011-04-15 Thread mart
found the problem sorry for the ruckus!

the problem is aptana. Doing this outside of aptana works fine... not
sure why yet.

so, the problem is narrowed down. Once I figure out why aptana is mis-
behaving, I'll post results

Thanks for you help!!
Mart :()

On Apr 15, 3:29 pm, pbreit pbreitenb...@gmail.com wrote:
 It looks to me like it might be stuck at the very beginning with import
 os. In MacOS terminal, can you do a simple import os in Python shell?

 $ python







  import os


[web2py] Re: launching web2py from script?

2011-04-15 Thread mart
From what I can tell, there is a port conflict between aptana (or one
of its plugins) and web2py. Still drilling down to find the culprit.

If I open aptana first, and let it load up properly, i can not launch
web2py. but, I can launch web2py, then aptana without issue.

Seems something in aptana (or a plugin I have installed) will not
share.

ALthough, even if i launch aptana first, then web2py, nothing tells me
that there is a weak reference issue. so this is a little strange.

GLobals and its use of dict that's where I am headed next. Would
that make any sense?

Thanks,
Mart :)



On Apr 15, 3:41 pm, mart msenecal...@gmail.com wrote:
 found the problem sorry for the ruckus!

 the problem is aptana. Doing this outside of aptana works fine... not
 sure why yet.

 so, the problem is narrowed down. Once I figure out why aptana is mis-
 behaving, I'll post results

 Thanks for you help!!
 Mart :()

 On Apr 15, 3:29 pm, pbreit pbreitenb...@gmail.com wrote:







  It looks to me like it might be stuck at the very beginning with import
  os. In MacOS terminal, can you do a simple import os in Python shell?

  $ python

   import os


[web2py] Re: Problem with tables of n:m relationsships

2011-04-15 Thread Steffen Rhinow
Hi,
no the values should not be empty. In the given example, you can
choose available items from the drop-down-boxes and they can just be
there, if there is content behind these keys.
The problem must be somewhere else.


On 15 Apr., 17:58, Arun K.Rajeevan the1.a...@gmail.com wrote:
 First of all, I'm not sure about it, but out of curiosity

 Isn't it that* InternalError: (1048, uColumn 'country_id' cannot be null)
 *caused by trying to insert something into table w/o giving a value to
 country_id field???
 A primary field cannot be empty.

 forget, if I'm wrong in my assumptions.


[web2py] Show image or image name when editing record

2011-04-15 Thread pbreit
I have a page that serves both for creating and updating records. One 
element is an image. When I go to edit a record that has an image, the image 
upload widgets don't indicate that the record already has an image.

Is there an easy way to show the image or image filename 
with form.custom.widget.image?


[web2py] Migrations for altering data?

2011-04-15 Thread pbreit
It's not possible to create a migration manually to alter database data, is 
it? Has this capability been discussed? Do people generally just create a 
controller or something?

I was thinking like South and Rails:
http://south.aeracode.org/docs/index.html
http://guides.rubyonrails.org/migrations.html


[web2py] Web2py: the top notch productivity platform

2011-04-15 Thread DJ
!-- Note of appreciation to Massimo and team --

I have been using web2py for the past few years and I feel it is one the 
Python world's hidden gems. While most people argue about Django and the 
like, what matters most when it comes to application development is 
deployment speed, reliability and low cost of maintenance. If you are in the 
software development business, you want to put things in your customers 
hands early (agile development), provide full web functionality (logins, 
security, https) all of which come inbuilt and the ability to work with 
legacy systems (Oracle, MySQL) on multiple platforms (Linux, Windows). 
Web2py does all of this without making you sweat and worry about library 
incompatibilities and platform specific issues.The range of deployments is 
amazing - GAE to EC2. For this alone, the team deserves a huge round of 
applause!

The recent tool CSVstudio is a complete life saver. I recently delivered a 
project where I had to convert Excel files running into a few hundred 
columns and thousands of rows into searchable databases. Imagine doing this 
by hand - forget it! I initially used CloverETL (a leading enterprise ETL 
solution), but still had to ensure column compatibilities and fix Excel 
issues which were time consuming. Well, half-way into the project, client 
changes Excel formats, adds new files to the mix - typical scenario right? 
Enter CSVstudio. It not only cleans your Excel files, but recognizes column 
data types and the best part - it generates the Web2py model file for you. I 
went from Excel file to searchable web database in less than 5 minutes. This 
is a killer tool for application developers!

I'm sure there are a number of volunteers from around the world along with 
Massimo who contribute to the Web2py project and I would like to say - thank 
you, keep up the good work and make Web2py the #1 application development 
platform out there! 

For those of you who are contemplating using this platform or need 
assistance deploying this within your networks (academic or commercial), 
feel free to talk to the mailing list or ping me for corporate specific 
advise. I have deployed web2py in corporate settings, hospitals and research 
labs successfully and would be happy to help you. 

There's lots of good applications like Sahana people are building with 
Web2py and the recent news that our mailing list traffic has overtaken 
Django and Ruby is indication that people are moving in the right direction. 
Let the work talk, not the hype. And that's where web2py is the silent 
assassin.

-Sebastian





Re: [web2py] Web2py: the top notch productivity platform

2011-04-15 Thread Stifan Kristi
web2py is awesome, a lot of feature that can be use for all programmers.

best regards,

steve van christie

On Sat, Apr 16, 2011 at 6:19 AM, DJ sebastianjaya...@gmail.com wrote:

 !-- Note of appreciation to Massimo and team --

 I have been using web2py for the past few years and I feel it is one the
 Python world's hidden gems. While most people argue about Django and the
 like, what matters most when it comes to application development is
 deployment speed, reliability and low cost of maintenance. If you are in the
 software development business, you want to put things in your customers
 hands early (agile development), provide full web functionality (logins,
 security, https) all of which come inbuilt and the ability to work with
 legacy systems (Oracle, MySQL) on multiple platforms (Linux, Windows).
 Web2py does all of this without making you sweat and worry about library
 incompatibilities and platform specific issues.The range of deployments is
 amazing - GAE to EC2. For this alone, the team deserves a huge round of
 applause!

 The recent tool CSVstudio is a complete life saver. I recently delivered a
 project where I had to convert Excel files running into a few hundred
 columns and thousands of rows into searchable databases. Imagine doing this
 by hand - forget it! I initially used CloverETL (a leading enterprise ETL
 solution), but still had to ensure column compatibilities and fix Excel
 issues which were time consuming. Well, half-way into the project, client
 changes Excel formats, adds new files to the mix - typical scenario right?
 Enter CSVstudio. It not only cleans your Excel files, but recognizes column
 data types and the best part - it generates the Web2py model file for you. I
 went from Excel file to searchable web database in less than 5 minutes. This
 is a killer tool for application developers!

 I'm sure there are a number of volunteers from around the world along with
 Massimo who contribute to the Web2py project and I would like to say - thank
 you, keep up the good work and make Web2py the #1 application development
 platform out there!

 For those of you who are contemplating using this platform or need
 assistance deploying this within your networks (academic or commercial),
 feel free to talk to the mailing list or ping me for corporate specific
 advise. I have deployed web2py in corporate settings, hospitals and research
 labs successfully and would be happy to help you.

 There's lots of good applications like Sahana people are building with
 Web2py and the recent news that our mailing list traffic has overtaken
 Django and Ruby is indication that people are moving in the right direction.
 Let the work talk, not the hype. And that's where web2py is the silent
 assassin.

 -Sebastian






[web2py] Re: A quiz-like app

2011-04-15 Thread ra3don
I'm collaborating with Drise on this project.
This is driving me up the wall. I took at the survey app (Thanks Bruno
and Massimo!)

Here's what i've got:

def take():
quiz = db().select(db.quiz.ALL).first()
questions=db(db.question.quiz_id==quiz.id).select()
answer_value=0
for question in questions:
options=[question['option_'+c] for c in ['A','B','C','D'] if
question['option_'+c].strip()]
 
stuff=TABLE(*[TR(INPUT(_type=radio,_name=value,_value=str(i),
value=answer_value),item) for i,item in enumerate(options)])
form=FORM(H2('Your answer'),stuff,BR(),BR(),
  INPUT(_type='submit',
_value=str(T('Submit answer'))
)
  )
return dict(questions=questions,stuff=stuff,form=form)

When I pull this up in the browser, it works just fine, but only for
the last question in the database. It appears that for question in
questions: is not looping. There are multiple questions in the
database. Also, I can manually specify question=questions[0] or
question=questions[1] and it pulls up the respective questions.

On Apr 15, 2:38 pm, pbreit pbreitenb...@gmail.com wrote:
 You probably need 'answers' to reference auth_user or come up with a scheme
 to track the person answering.

 Then, select() a question and build a form. Perhaps:

 question = db.question(1) #or however you want to pick the question
 form = SQLFORM(db.answers)
 form.vars.question_id = question.id
 return dict(question=question, form=form)

 To hide the form elements you don't want, you might need to either customize
 the form or set readable/writable.

 Q: {{=question.question}}br
 A: {{=form}}


[web2py] Re: extending web2py's generic.rss view

2011-04-15 Thread johntynan
Got it! :)

stories = {}
collection_id=request.args(0)
collection = db.collection[collection_id] or redirect(error_page)
 
stories=db(db.story.collection.contains(collection_id)).select(orderby=db.story.title)
length=len(stories);
scheme = request.env.get('WSGI_URL_SCHEME', 'http').lower()

rss = rss2.RSS2(title=collection.title,
link = scheme + '://' + request.env.http_host +
request.env.path_info,
description = collection.description,
lastBuildDate = collection.modified_on,
items = [
rss2.RSSItem(title = story.title,
link = story.url,
enclosure = rss2.Enclosure(story.audio_url, 0, 'audio/
mpeg'),
description = story.description,
comments = 'test',
pubDate = story.date) for story in stories])

response.headers['Content-Type']='application/rss+xml'
return rss2.dumps(rss)


[web2py] xml()

2011-04-15 Thread 黄祥
hi,

pardon me, i want to ask what's the meaning of this :
URL('default','index').xml()==URL().xml()

here's the complete code:

response.menu = [
 
(T('Index'),URL('default','index').xml()==URL().xml(),URL('default','index'),
[]),
]

i mean it is convert the url into xml format page?

thanks and best regards,

steve van christie


[web2py] Any way to prompt for password for sensitive pages?

2011-04-15 Thread Brian M
Is there any easy way to re-prompt the user for their password before 
displaying certain sensitive pages? Here's what I'm thinking - the user logs 
in with auth and has access to most features of the site. But, when they go 
to a more important page they're first asked to re-enter their password - 
for example before changing certain settings or maybe purchasing something - 
in order to prove it's still them.  Any ideas?

~Brian


[web2py] Re: xml()

2011-04-15 Thread Massimo Di Pierro
This was a bad idea and it does not work with recent web2py. Should be

URL('default','index')==URL()

Is basically check  whether /app/default/index is the current
requested path.

On Apr 15, 8:07 pm, 黄祥 steve.van.chris...@gmail.com wrote:
 hi,

 pardon me, i want to ask what's the meaning of this :
 URL('default','index').xml()==URL().xml()

 here's the complete code:

 response.menu = [

 (T('Index'),URL('default','index').xml()==URL().xml(),URL('default','index' ),
 []),
 ]

 i mean it is convert the url into xml format page?

 thanks and best regards,

 steve van christie


[web2py] Re: Show image or image name when editing record

2011-04-15 Thread Massimo Di Pierro
You need to pass the URL('default','download') to SQLFORM(..) as in

SQLFORM(...,upload=URL('default','download'))

and the widget should have it automatically.

On Apr 15, 4:56 pm, pbreit pbreitenb...@gmail.com wrote:
 I have a page that serves both for creating and updating records. One
 element is an image. When I go to edit a record that has an image, the image
 upload widgets don't indicate that the record already has an image.

 Is there an easy way to show the image or image filename
 with form.custom.widget.image?


[web2py] Re: Migrations for altering data?

2011-04-15 Thread Massimo Di Pierro
I do not feel the necessity.

What I do is simply version control the files (specifically models).
Any change (whether in the future or reverting to a past version)
result in an automatic migration.

massimo


On Apr 15, 5:58 pm, pbreit pbreitenb...@gmail.com wrote:
 It's not possible to create a migration manually to alter database data, is
 it? Has this capability been discussed? Do people generally just create a
 controller or something?

 I was thinking like South and 
 Rails:http://south.aeracode.org/docs/index.htmlhttp://guides.rubyonrails.org/migrations.html


Re: [web2py] Re: xml()

2011-04-15 Thread Stifan Kristi
a, i c, thank you so much for your explaination, massimo. i got it when i
use web2py wizard on 1.94.6 version.

best regards,

steve van christie

On Sat, Apr 16, 2011 at 9:12 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 This was a bad idea and it does not work with recent web2py. Should be

 URL('default','index')==URL()

 Is basically check  whether /app/default/index is the current
 requested path.

 On Apr 15, 8:07 pm, 黄祥 steve.van.chris...@gmail.com wrote:
  hi,
 
  pardon me, i want to ask what's the meaning of this :
  URL('default','index').xml()==URL().xml()
 
  here's the complete code:
 
  response.menu = [
 
 
 (T('Index'),URL('default','index').xml()==URL().xml(),URL('default','index'
 ),
  []),
  ]
 
  i mean it is convert the url into xml format page?
 
  thanks and best regards,
 
  steve van christie


[web2py] Re: Any way to prompt for password for sensitive pages?

2011-04-15 Thread pbreit
Maybe similar to changing password?

return dict(form=auth())

{{=form.custom.begin}}
plabel for=emailOld Password/labelbr
{{=form.custom.widget.old_password}}/p
plabel for=passwordNew Password/labelbr
{{=form.custom.widget.new_password}}/p
plabel for=passwordRepeat New Password/labelbr
{{=form.custom.widget.new_password2}}/p
pinput type=submit value=save new password //p
{{=form.custom.end}}