[web2py] Re: Tables refrencing each other

2011-04-08 Thread Seeker
Perhaps just add a boolean field in the chapter table: is_first ... or
something to that effect??
On saving an un-flagged chapter you can always check whether any other
chapters for the story have been flagged as first; if not auto flag
the one being saved.
If a subsequent chapter (marked as first) is saved then set all others
to false.

Not perfect but just a thought...


On Apr 8, 8:05 am, guruyaya  wrote:
> I wanted something more generic to work with, for future uses. But I
> guess you're right.
>
> On Apr 7, 11:42 pm, villas  wrote:
>
>
>
>
>
>
>
> > Why not simply write an onvalidation function?
>
> > When you save a record with form accepts this would check to ensure
> > that you only have one first_chapter for that story_id.
>
> > On Apr 6, 9:29 pm,guruyaya wrote:
>
> > > Here's a simplified version of a model I'm working on:
>
> > > db.define_table('story',
> > >     Field('title'),
> > >     Field('description', 'text'),
> > >     Field('first_chapter', db.chapter)
> > > )
>
> > > db.define_table('chapter',
> > >     Field('title'),
> > >     Field('tale', 'text'),
> > >     Field('story_id',db.story)
> > > )
>
> > > As you can imagine, I have a problem here. I cannot reference the
> > > first chapter in the story table, because chapter is not yet defined,
> > > but I cannot write thetablesbackwards, because story won't be
> > > defined.
> > > I was wondering if there's any way of doing this elegantly, or I'll
> > > just have to count on the first chapter written of any story - to be
> > > the first chapter.
> > > Thanks in advance
> > > Yaya


[web2py] Bug in SQLFORM.accepts with onvalidate?

2011-04-08 Thread Jens Örtenholm
Hello everyone,

I believe I've found a bug in SQLFORM.accepts.

When calling with an onvalidation function as:

form = SQLFORM(db.table)
if form.accepts(request.vars, session, onvalidation=function):

And the function sets an error:

def function(form):
form.errors.myfield = 'This is an error'

The form is still accepted, DB is inserted or updated with the record.

As far as I can tell from looking at the code in SQLFORM.accepts, the case
where ret value is False because of form.errors not being empty is not
handled anywhere.

Tested on 1.94.6

//Jens


[web2py] IS_EMPTY_OR(IS_NOT_IN_DB(db, 'person.name'))?

2011-04-08 Thread pbreit
Should this work or is there some other equivalent? I want the field to be 
optional but if filled in, unique in the DB.

IS_EMPTY_OR(IS_NOT_IN_DB(db, 'person.name'))

I got an error stack that I can't really understand and assume it's related.

Traceback (most recent call last):
  File "gluon/restricted.py", line 188, in restricted
  File 
"/Users/pbreit/web2py/web2py.app/Contents/Resources/applications/init/controllers/default.py"
 , line 
88, in 
  File "gluon/globals.py", line 124, in 
  File 
"/Users/pbreit/web2py/web2py.app/Contents/Resources/applications/init/controllers/default.py"
 , line 
70, in user
  File "gluon/tools.py", line 1038, in __call__
  File "gluon/tools.py", line 1653, in register
  File "gluon/sqlhtml.py", line 1031, in accepts
  File "gluon/html.py", line 1720, in accepts
  File "gluon/html.py", line 716, in _traverse
  File "gluon/html.py", line 716, in _traverse
  File "gluon/html.py", line 716, in _traverse
  File "gluon/html.py", line 716, in _traverse
  File "gluon/html.py", line 723, in _traverse
  File "gluon/html.py", line 1493, in _validate
  File "gluon/validators.py", line 2327, in __call__
  File "gluon/validators.py", line 2314, in urlify
AttributeError: 'NoneType' object has no attribute 'decode'



[web2py] Re: datetime, DAL and JSON serialization

2011-04-08 Thread Omri Har-Shemesh
Sorry for the long reply time (I am working at two jobs and didn't have time 
to get to it yet).

I can supply the following simple example:
the data model is:

db.define_table("timestamps", 
Field("by", db.auth_user),
Field("at", "datetime", default=request.now))

and the controller function is:

@service.jsonrpc
def test_json():
data = []
timestamps = db(db.timestamps.id > 0).select()
for ts in timestamps:
data.append(dict(by = ts.by.first_name, at = ts.at))
return data

When I try to call this from my application (qooxdoo app) I receive the 
following JSONRPCError: "TypeError: datetime.datetime(2010, 11, 10, 10, 33, 
22) is not JSON serializable". I think this is different from the behavior 
in previous versions where I simply got a string back in return. 

If I go to the test_json view directly through the browser I get the 
following response: 
{'2 {'at': 2 {'at': datetime.datetime(2010, 11, 10, 10, 56, 58), 'by': 
'Andreas'} 2 {'at': datetime.datetime(2010, 11, 10, 10, 58, 40), 'by': 
'Andreas'} 2 {'at': datetime.datetime(2010, 11, 10, 11, 44, 11), 'by': 
'Andreas'} {'2 {'at': 2 {'at': datetime.datetime(2010, 11, 10, 11, 48, 17), 
'by': 'Andreas'} 2 {'at': datetime.datetime(2010, 11, 10, 11, 55, 12), 'by': 
'Andreas'} 2 {'at': datetime.datetime(2010, 11, 10, 11, 58, 7), 'by': 
'Andreas'} {'2 {'at': 2 {'at': datetime.datetime(2010, 11, 10, 12, 7, 50), 
'by': 'Andreas'} 2 {'at': datetime.datetime(2010, 11, 10, 12, 17, 9), 'by': 
'Andreas'} 2 {'at': datetime.datetime(2010, 11, 10, 12, 20, 20), 'by': 
'Andreas'} 

I think it might be related to the detect_types change nick name has hinted 
at. Am i right? I have tried to look through the Service class source to 
understand if it uses as_list or not, but I haven't been able to ascertain 
when a function receives the as_list attribute.

Any help would be greatly appreciated, and thanks for the extremely good 
work on web2py (it seems I keep saying it, but it is really and truly 
appreciated!)
Omri


[web2py] crud.create and SQLFORM: different behaviour

2011-04-08 Thread Johann Spies
I have two controllers using the same table.  One for the logged in user to
register for a course and the  other for the administrator to register a
user for a course overriding the 'writable=False in the model:
The  model has:

db.define_table('t_registration_form',
   Field('f_attendee', db.auth_user,default=auth.user_id,
  label=T('Attendee'),writable=False,readable=True),

The only difference between the two controllers is this:

 form=crud.create(db.t_registration_form,next='registration_form_read/[id]')
# for the logged in user

 form=SQLFORM(db.t_registration_form,next='registration_form_read/[id]',
ignore_rw=True) # for the administrator

Both use identical views using a custom form layout.

My problem is that the second controller never inserts the form in the table
and does not complain while the first one works as expected.

Why would that be.  BTW, using response.flash(form.errors) does not help in
this case.


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] web2py shell error?

2011-04-08 Thread puercoespin
web2py Shell Version 1.94.6 (2011-03-27 18:20:38)
In [1] : stack=[2,3,4]

In [2] : stack.append(5)

In [3] : stack
[2, 3, 4]

In the python2.5 shell:

ActivePython 2.5.5.7 (ActiveState Software Inc.) based on
Python 2.5.5 (r255:77872, Jan 31 2010, 15:49:35) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> stack=[2,3,4]
>>> stack.append(5)
>>> stack
[2, 3, 4, 5]


Re: [web2py] Re: My First Application on Web2py is Now Live.... www.beunick.com

2011-04-08 Thread Martín Mulone
Congrats! +1. And the invitation key?

2011/4/8 cjrh 

> On Apr 8, 4:14 am, Yannick  wrote:
> > Cheers and thanks in advance for your feedback
>
> Works in Opera 11 :)




-- 
My blog: http://martin.tecnodoc.com.ar
Expert4Solution: http://www.experts4solutions.com/e4s/default/expert/6
http://www.cvstash.com/profile/Xzi5bWCdD


[web2py] Re: Bug in SQLFORM.accepts with onvalidate?

2011-04-08 Thread DenesL

Hello Jens,

onvalidation is called *after* the validation, so setting form.errors
does not have any effect.


On Apr 8, 3:31 am, Jens Örtenholm  wrote:
> Hello everyone,
>
> I believe I've found a bug in SQLFORM.accepts.
>
> When calling with an onvalidation function as:
>
> form = SQLFORM(db.table)
> if form.accepts(request.vars, session, onvalidation=function):
>
> And the function sets an error:
>
> def function(form):
>     form.errors.myfield = 'This is an error'
>
> The form is still accepted, DB is inserted or updated with the record.
>
> As far as I can tell from looking at the code in SQLFORM.accepts, the case
> where ret value is False because of form.errors not being empty is not
> handled anywhere.
>
> Tested on 1.94.6
>
> //Jens


[web2py] Re: crud.create and SQLFORM: different behaviour

2011-04-08 Thread DenesL

What do you have in the form.accepts?.


On Apr 8, 5:05 am, Johann Spies  wrote:
> I have two controllers using the same table.  One for the logged in user to
> register for a course and the  other for the administrator to register a
> user for a course overriding the 'writable=False in the model:
> The  model has:
>
> db.define_table('t_registration_form',
>        Field('f_attendee', db.auth_user,default=auth.user_id,
>           label=T('Attendee'),writable=False,readable=True),
>
> The only difference between the two controllers is this:
>
>  form=crud.create(db.t_registration_form,next='registration_form_read/[id]')
> # for the logged in user
>
>  form=SQLFORM(db.t_registration_form,next='registration_form_read/[id]',
> ignore_rw=True) # for the administrator
>
> Both use identical views using a custom form layout.
>
> My problem is that the second controller never inserts the form in the table
> and does not complain while the first one works as expected.
>
> Why would that be.  BTW, using response.flash(form.errors) does not help in
> this case.
>
> 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: IS_EMPTY_OR(IS_NOT_IN_DB(db, 'person.name'))?

2011-04-08 Thread DenesL

It works fine in 1.94.5

On Apr 8, 3:51 am, pbreit  wrote:
> Should this work or is there some other equivalent? I want the field to be
> optional but if filled in, unique in the DB.
>
> IS_EMPTY_OR(IS_NOT_IN_DB(db, 'person.name'))
>
> I got an error stack that I can't really understand and assume it's related.
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 188, in restricted
>   File 
> "/Users/pbreit/web2py/web2py.app/Contents/Resources/applications/init/controllers/default.py"
>  , line 
> 88, in 
>   File "gluon/globals.py", line 124, in 
>   File 
> "/Users/pbreit/web2py/web2py.app/Contents/Resources/applications/init/controllers/default.py"
>  , line 
> 70, in user
>   File "gluon/tools.py", line 1038, in __call__
>   File "gluon/tools.py", line 1653, in register
>   File "gluon/sqlhtml.py", line 1031, in accepts
>   File "gluon/html.py", line 1720, in accepts
>   File "gluon/html.py", line 716, in _traverse
>   File "gluon/html.py", line 716, in _traverse
>   File "gluon/html.py", line 716, in _traverse
>   File "gluon/html.py", line 716, in _traverse
>   File "gluon/html.py", line 723, in _traverse
>   File "gluon/html.py", line 1493, in _validate
>   File "gluon/validators.py", line 2327, in __call__
>   File "gluon/validators.py", line 2314, in urlify
> AttributeError: 'NoneType' object has no attribute 'decode'


[web2py] Re: web2py shell error?

2011-04-08 Thread Massimo Di Pierro
This is a known error with the web shell. Notice that we use this:

http://shell.appspot.com/

and it has the same problem.

On Apr 8, 5:06 am, puercoespin 
wrote:
> web2py Shell Version 1.94.6 (2011-03-27 18:20:38)
> In [1] : stack=[2,3,4]
>
> In [2] : stack.append(5)
>
> In [3] : stack
> [2, 3, 4]
>
> In the python2.5 shell:
>
> ActivePython 2.5.5.7 (ActiveState Software Inc.) based on
> Python 2.5.5 (r255:77872, Jan 31 2010, 15:49:35) [MSC v.1310 32 bit
> (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> stack=[2,3,4]
> >>> stack.append(5)
> >>> stack
>
> [2, 3, 4, 5]


[web2py] is web2py support html 5 and css 3?

2011-04-08 Thread 黄祥
Hi,

i want to create audio n video controller like on web2py applicances,
n try to using html 5 for audio n video, but it can't run, is web2py
support html 5 and css 3?

thanks


Re: [web2py] Re: crud.create and SQLFORM: different behaviour

2011-04-08 Thread Johann Spies
On 8 April 2011 12:56, DenesL  wrote:

>
> What do you have in the form.accepts?.


Nothing.

I have tried:

if form.accepts(request
.vars, session
):
session
.flash = 'form
accepted'
redirect
(URL
('next'))
elif form.errors:
response
.flash = 'form has
errors'
else:
response
.flash = 'please
fill the form'



but then it just flashes 'please fill the form'  and gives back an
empty form.  This happens in both cases.

Without this at least the crud-form works.

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] change default controller into another controller

2011-04-08 Thread 黄祥
hi,

is it possible to change default controller into another controller, i
mean, when i click my application on http://127.0.0.1:8000/admin/default/site,
is it possible to redirect to another controller?

thanks


[web2py] Re: change default controller into another controller

2011-04-08 Thread Anthony
On Friday, April 8, 2011 7:45:40 AM UTC-4, 黄祥 wrote: 
>
> hi, 
>
> is it possible to change default controller into another controller, i 
> mean, when i click my application on 
> http://127.0.0.1:8000/admin/default/site, 
> is it possible to redirect to another controller?

 
The links to the apps on the admin 'site' page explicitly point to the 
/default/index page of each app (whether it exists or not). That's set in a 
'for' loop in the /views/default/site.html view of the admin application, so 
it's the same for every app. I suppose you could edit that line to something 
like:
 
{{=A(a,_href='/'+a)}} 
 
That should create a link with just the app name, which will normally go to 
/default/index, but can be changed for specific apps via routes.py (
http://web2py.com/book/default/chapter/04#URL-Rewrite).
 
Note, if you go to your app's 'edit' page in admin, you can easily click to 
any URL by clicking the functions linked in the "Controllers" section.
 
Anthony


Re: [web2py] change default controller into another controller

2011-04-08 Thread Stifan Kristi
it's clear for me now, thank you so much for your detail explaination.


Re: [web2py] is web2py support html 5 and css 3?

2011-04-08 Thread Vasile Ermicioi
web2py is a server side framework, html5 and css3 are client side
technologies, and  they should be supported by browsers not by servers


[web2py] embed not work in web2py

2011-04-08 Thread 黄祥
hi,

i try to embed avi video file into web2py (tested in chrome n
firefox), in my model :

db.define_table('video',
Field('video',
  'upload',
  requires = IS_NOT_EMPTY()
  )
)

my controller :

def video_show():
videos = db.video(request.args(0)) or redirect(URL('video'))
return dict(videos = videos)

and my view :

{{=EMBED(_src = URL('download', args = videos.video)}}

when i try in standard html i put on the same path with upload
directory, it work:



did anyone know where is my fault code?

Thanks so much


[web2py] Re: Bug in SQLFORM.accepts with onvalidate?

2011-04-08 Thread VP


On Apr 8, 5:49 am, DenesL  wrote:
> Hello Jens,
>
> onvalidation is called *after* the validation, so setting form.errors
> does not have any effect.
>


Wait    Then what is the purpose of onvalidation?   I have thought
all along by reading the book that onvalidation is to provide
additional validation.

I have a similar problem with Jens (but on update, not on creation).

Jens, do you have an upload field?  Does the particular entry that you
want to validate use ajax?



[web2py] Re: Unit test and request object

2011-04-08 Thread Jérémie
Some more points.

I finally succeeded to reset request thanks to matclab's comments and
code on the slice (http://www.web2pyslices.com/main/slices/take_slice/
67) :
>> "note that without pickling at init and unpickling at setup, the session and 
>> request was not cleaned up before each test."

class DefaultController(unittest.TestCase):
def __init__(self, p):
global auth, session, request
unittest.TestCase.__init__(self, p)
self.session = pickle.dumps(session)
request.application = 'appname'
request.controller = 'default'
self.request = pickle.dumps(request)


def setUp(self):
global response, session, request, auth
session = pickle.loads(self.session)
request = pickle.loads(self.request)
auth = Auth(globals(), db)
auth.define_tables()


In case anybody would need it.

Jérémie


Re: [web2py] is web2py support html 5 and css 3?

2011-04-08 Thread Stifan Kristi
a, i c, i mean is it support the python format for html 5 and css 3 tags,
like :
e.g.
{{=BR()}}

thank you

On Fri, Apr 8, 2011 at 8:46 PM, Vasile Ermicioi  wrote:

> web2py is a server side framework, html5 and css3 are client side
> technologies, and  they should be supported by browsers not by servers


Re: [web2py] IS_EMPTY_OR(IS_NOT_IN_DB(db, 'person.name'))?

2011-04-08 Thread Richard Vézina
Zero option!!

Or

Read this thread :

http://groups.google.com/group/web2py/browse_thread/thread/974cb71a3eb297f6/fe9299eb54ad032a#fe9299eb54ad032a


Richard

On Fri, Apr 8, 2011 at 3:51 AM, pbreit  wrote:

> Should this work or is there some other equivalent? I want the field to be
> optional but if filled in, unique in the DB.
>
> IS_EMPTY_OR(IS_NOT_IN_DB(db, 'person.name'))
>
> I got an error stack that I can't really understand and assume it's
> related.
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 188, in restricted
>   File 
> "/Users/pbreit/web2py/web2py.app/Contents/Resources/applications/init/controllers/default.py"
>  , line 
> 88, in 
>   File "gluon/globals.py", line 124, in 
>   File 
> "/Users/pbreit/web2py/web2py.app/Contents/Resources/applications/init/controllers/default.py"
>  , line 
> 70, in user
>   File "gluon/tools.py", line 1038, in __call__
>   File "gluon/tools.py", line 1653, in register
>   File "gluon/sqlhtml.py", line 1031, in accepts
>   File "gluon/html.py", line 1720, in accepts
>   File "gluon/html.py", line 716, in _traverse
>   File "gluon/html.py", line 716, in _traverse
>   File "gluon/html.py", line 716, in _traverse
>   File "gluon/html.py", line 716, in _traverse
>   File "gluon/html.py", line 723, in _traverse
>   File "gluon/html.py", line 1493, in _validate
>   File "gluon/validators.py", line 2327, in __call__
>   File "gluon/validators.py", line 2314, in urlify
> AttributeError: 'NoneType' object has no attribute 'decode'
>
>


Re: [web2py] is web2py support html 5 and css 3?

2011-04-08 Thread Jonathan Lundell
On Apr 8, 2011, at 7:02 AM, Stifan Kristi wrote:
> a, i c, i mean is it support the python format for html 5 and css 3 tags, 
> like :
> e.g.
> {{=BR()}}

web2py always generates  for BR(), which is OK for html5 (though not 
really great for html4...).

Just be sure to generate an html5 doctype:

> 
> thank you
> 
> On Fri, Apr 8, 2011 at 8:46 PM, Vasile Ermicioi  wrote:
> web2py is a server side framework, html5 and css3 are client side 
> technologies, and  they should be supported by browsers not by servers
> 




Re: [web2py] is web2py support html 5 and css 3?

2011-04-08 Thread Stifan Kristi
no, i mean html 5 tag is it support to be converted by python format,
actually, i've tried to convert audio and video tag using html 5 (references
from w3schools), but it's not goin to work (audio n video), any solution for
this problem?

thanks very much


On Fri, Apr 8, 2011 at 9:27 PM, Jonathan Lundell  wrote:

> On Apr 8, 2011, at 7:02 AM, Stifan Kristi wrote:
>
> a, i c, i mean is it support the python format for html 5 and css 3 tags,
> like :
> e.g.
> {{=BR()}}
>
>
> web2py always generates  for BR(), which is OK for html5 (though not
> really great for html4...).
>
> Just be sure to generate an html5 doctype:
>
>
> thank you
>
> On Fri, Apr 8, 2011 at 8:46 PM, Vasile Ermicioi  wrote:
>
>> web2py is a server side framework, html5 and css3 are client side
>> technologies, and  they should be supported by browsers not by servers
>
>
>
>
>


[web2py] Re: Bug in SQLFORM.accepts with onvalidate?

2011-04-08 Thread Massimo Di Pierro
This may be a bug. Will look into it...

On Apr 8, 2:31 am, Jens Örtenholm  wrote:
> Hello everyone,
>
> I believe I've found a bug in SQLFORM.accepts.
>
> When calling with an onvalidation function as:
>
> form = SQLFORM(db.table)
> if form.accepts(request.vars, session, onvalidation=function):
>
> And the function sets an error:
>
> def function(form):
>     form.errors.myfield = 'This is an error'
>
> The form is still accepted, DB is inserted or updated with the record.
>
> As far as I can tell from looking at the code in SQLFORM.accepts, the case
> where ret value is False because of form.errors not being empty is not
> handled anywhere.
>
> Tested on 1.94.6
>
> //Jens


Re: [web2py] is web2py support html 5 and css 3?

2011-04-08 Thread Jonathan Lundell
On Apr 8, 2011, at 7:37 AM, Stifan Kristi wrote:
> no, i mean html 5 tag is it support to be converted by python format, 
> actually, i've tried to convert audio and video tag using html 5 (references 
> from w3schools), but it's not goin to work (audio n video), any solution for 
> this problem?

Do you mean, for example, something like =VIDEO()? Not yet, but you can use 
TAG.video()



> 
> thanks very much
> 
> 
> On Fri, Apr 8, 2011 at 9:27 PM, Jonathan Lundell  wrote:
> On Apr 8, 2011, at 7:02 AM, Stifan Kristi wrote:
>> a, i c, i mean is it support the python format for html 5 and css 3 tags, 
>> like :
>> e.g.
>> {{=BR()}}
> 
> web2py always generates  for BR(), which is OK for html5 (though not 
> really great for html4...).
> 
> Just be sure to generate an html5 doctype:
> 
>> 
>> thank you
>> 
>> On Fri, Apr 8, 2011 at 8:46 PM, Vasile Ermicioi  wrote:
>> web2py is a server side framework, html5 and css3 are client side 
>> technologies, and  they should be supported by browsers not by servers
>> 
> 
> 
> 




[web2py] Re: is web2py support html 5 and css 3?

2011-04-08 Thread Massimo Di Pierro
We have no plan to add more tags since you can generate any tag you
need as Jonathan suggests.
If we need to change the behavior of some tags, please let me know
with a concrete example.

Massimo

On Apr 8, 9:57 am, Jonathan Lundell  wrote:
> On Apr 8, 2011, at 7:37 AM, Stifan Kristi wrote:
>
> > no, i mean html 5 tag is it support to be converted by python format, 
> > actually, i've tried to convert audio and video tag using html 5 
> > (references from w3schools), but it's not goin to work (audio n video), any 
> > solution for this problem?
>
> Do you mean, for example, something like =VIDEO()? Not yet, but you can use 
> TAG.video()
>
>
>
>
>
>
>
>
>
> > thanks very much
>
> > On Fri, Apr 8, 2011 at 9:27 PM, Jonathan Lundell  wrote:
> > On Apr 8, 2011, at 7:02 AM, Stifan Kristi wrote:
> >> a, i c, i mean is it support the python format for html 5 and css 3 tags, 
> >> like :
> >> e.g.
> >> {{=BR()}}
>
> > web2py always generates  for BR(), which is OK for html5 (though not 
> > really great for html4...).
>
> > Just be sure to generate an html5 doctype:
>
> >> thank you
>
> >> On Fri, Apr 8, 2011 at 8:46 PM, Vasile Ermicioi  wrote:
> >> web2py is a server side framework, html5 and css3 are client side 
> >> technologies, and  they should be supported by browsers not by servers


[web2py] Re: proposal - extend auth_membership with

2011-04-08 Thread Will Stevens
Has anything become of this?  I am also looking for this functionality. 
Has any work been done on this?

Thanks,

Will



[web2py] Re: Change IPython to BPython in shell mode

2011-04-08 Thread Bruno Rocha
No idea?
Em 07/04/2011 11:13, "Bruno Rocha"  escreveu:
> hi,
>
> does anybody knows how to run the web2py shell using BPython instead of
> IPython?
>
> I saw a line in gluon/shell.py but I did not find argument to pass in
> console.
>
> Would be great a way to run:
>
> $python web2py.py - S appname -M -bpython
>
> Is it possible or even changing in code?
>
> Thanks
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]


[web2py] Re: Change IPython to BPython in shell mode

2011-04-08 Thread Massimo Di Pierro
talking about this?

http://wiki.blender.org/index.php/Dev_talk:Source/BPython/API/bpy_api

It should be easy..
open the shell and type:

from gluon.globals import Request, Response, Session
from gluon.compileapp import build_environment(
request=Request()
response=Response()
session=Session()
request.application = ''
globals().update(build_environment(request,response,session))



On Apr 8, 10:37 am, Bruno Rocha  wrote:
> No idea?
> Em 07/04/2011 11:13, "Bruno Rocha"  escreveu:
>
>
>
>
>
>
>
> > hi,
>
> > does anybody knows how to run the web2py shell using BPython instead of
> > IPython?
>
> > I saw a line in gluon/shell.py but I did not find argument to pass in
> > console.
>
> > Would be great a way to run:
>
> > $python web2py.py - S appname -M -bpython
>
> > Is it possible or even changing in code?
>
> > Thanks
> > --
> > Bruno Rocha
> > [ About me:http://zerp.ly/rochacbruno]


[web2py] speaking of css3

2011-04-08 Thread Jonathan Lundell
...here's a very pretty css3 menu:

http://www.webdesignerwall.com/demo/css3-dropdown-menu/css-gradient-dropdown.html

Re: [web2py] Re: is web2py support html 5 and css 3?

2011-04-08 Thread Stifan Kristi
actually, my intention is to embed audio or video file into web2py apps,
i've tried embed and object but it's not going to work, so that i tried to
use html 5 tags audio and video, but got the same result, i ever posted to
this forum too about my detail error using embed tag. pardon me, what do u
mean with TAG.video() is it same like {{=TAG.video()}} ?
do you have any documentation for that tag?
thank you so much

On Fri, Apr 8, 2011 at 10:13 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> We have no plan to add more tags since you can generate any tag you
> need as Jonathan suggests.
> If we need to change the behavior of some tags, please let me know
> with a concrete example.
>
> Massimo
>
> On Apr 8, 9:57 am, Jonathan Lundell  wrote:
> > On Apr 8, 2011, at 7:37 AM, Stifan Kristi wrote:
> >
> > > no, i mean html 5 tag is it support to be converted by python format,
> actually, i've tried to convert audio and video tag using html 5 (references
> from w3schools), but it's not goin to work (audio n video), any solution for
> this problem?
> >
> > Do you mean, for example, something like =VIDEO()? Not yet, but you can
> use TAG.video()
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > thanks very much
> >
> > > On Fri, Apr 8, 2011 at 9:27 PM, Jonathan Lundell 
> wrote:
> > > On Apr 8, 2011, at 7:02 AM, Stifan Kristi wrote:
> > >> a, i c, i mean is it support the python format for html 5 and css 3
> tags, like :
> > >> e.g.
> > >> {{=BR()}}
> >
> > > web2py always generates  for BR(), which is OK for html5 (though
> not really great for html4...).
> >
> > > Just be sure to generate an html5 doctype:
> >
> > >> thank you
> >
> > >> On Fri, Apr 8, 2011 at 8:46 PM, Vasile Ermicioi 
> wrote:
> > >> web2py is a server side framework, html5 and css3 are client side
> technologies, and  they should be supported by browsers not by servers
>


Re: [web2py] Re: is web2py support html 5 and css 3?

2011-04-08 Thread pbreit
Don't forget you can always just use regular HTML tags in your views as well 
(which is what many prefer to do anyway).

Example:

your browser does not support the video tag



Re: [web2py] Re: is web2py support html 5 and css 3?

2011-04-08 Thread Jonathan Lundell
On Apr 8, 2011, at 10:04 AM, Stifan Kristi wrote:
> actually, my intention is to embed audio or video file into web2py apps, i've 
> tried embed and object but it's not going to work, so that i tried to use 
> html 5 tags audio and video, but got the same result, i ever posted to this 
> forum too about my detail error using embed tag. pardon me, what do u mean 
> with TAG.video() is it same like {{=TAG.video()}} ?
> do you have any documentation for that tag?
> 

http://web2py.com/book/default/chapter/05#Custom-Helpers

[web2py] MARKMIN() not working...

2011-04-08 Thread Jason Brower

It seems when I do the following:
{{=MARKMIN(page.content)}} It ignores it and simply prints the text.  Is 
there something I am doing wrong?

Best Regards,
Jason Brower



Re: [web2py] Re: Change IPython to BPython in shell mode

2011-04-08 Thread Bruno Rocha
I Dont know if I am talking about the same thing.

When using web2py shell form console, if IPython is installed web2py shell
runs in IPython interactive console.

I wqas wondering about change it to BPython by command line.

$python web2py.py -S appname -M
>>> IPython shell running


$python web2py.py -S appname -M -bpython
>>>BPython shell running (if installed)



On Fri, Apr 8, 2011 at 1:07 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> talking about this?
>
> http://wiki.blender.org/index.php/Dev_talk:Source/BPython/API/bpy_api
>
> It should be easy..
> open the shell and type:
>
> from gluon.globals import Request, Response, Session
> from gluon.compileapp import build_environment(
> request=Request()
> response=Response()
> session=Session()
> request.application = ''
> globals().update(build_environment(request,response,session))
>
>
>
> On Apr 8, 10:37 am, Bruno Rocha  wrote:
> > No idea?
> > Em 07/04/2011 11:13, "Bruno Rocha"  escreveu:
> >
> >
> >
> >
> >
> >
> >
> > > hi,
> >
> > > does anybody knows how to run the web2py shell using BPython instead of
> > > IPython?
> >
> > > I saw a line in gluon/shell.py but I did not find argument to pass in
> > > console.
> >
> > > Would be great a way to run:
> >
> > > $python web2py.py - S appname -M -bpython
> >
> > > Is it possible or even changing in code?
> >
> > > Thanks
> > > --
> > > Bruno Rocha
> > > [ About me:http://zerp.ly/rochacbruno]
>


Re: [web2py] Re: Change IPython to BPython in shell mode

2011-04-08 Thread Jason Brower

+1 BPython kicks some seriouls python console!
BR,
Jason
On 04/08/2011 08:50 PM, Bruno Rocha wrote:

I Dont know if I am talking about the same thing.

When using web2py shell form console, if IPython is installed web2py 
shell runs in IPython interactive console.


I wqas wondering about change it to BPython by command line.

$python web2py.py -S appname -M
>>> IPython shell running


$python web2py.py -S appname -M -bpython
>>>BPython shell running (if installed)



On Fri, Apr 8, 2011 at 1:07 PM, Massimo Di Pierro 
mailto:massimo.dipie...@gmail.com>> wrote:


talking about this?

http://wiki.blender.org/index.php/Dev_talk:Source/BPython/API/bpy_api

It should be easy..
open the shell and type:

from gluon.globals import Request, Response, Session
from gluon.compileapp import build_environment(
request=Request()
response=Response()
session=Session()
request.application = ''
globals().update(build_environment(request,response,session))



On Apr 8, 10:37 am, Bruno Rocha mailto:rochacbr...@gmail.com>> wrote:
> No idea?
> Em 07/04/2011 11:13, "Bruno Rocha" mailto:rochacbr...@gmail.com>> escreveu:
>
>
>
>
>
>
>
> > hi,
>
> > does anybody knows how to run the web2py shell using BPython
instead of
> > IPython?
>
> > I saw a line in gluon/shell.py but I did not find argument to
pass in
> > console.
>
> > Would be great a way to run:
>
> > $python web2py.py - S appname -M -bpython
>
> > Is it possible or even changing in code?
>
> > Thanks
> > --
> > Bruno Rocha
> > [ About me:http://zerp.ly/rochacbruno]






Re: [web2py] Re: is web2py support html 5 and css 3?

2011-04-08 Thread Anthony
On Friday, April 8, 2011 1:04:36 PM UTC-4, 黄祥 wrote: 
>
> actually, my intention is to embed audio or video file into web2py apps, 
> i've tried embed and object but it's not going to work, so that i tried to 
> use html 5 tags audio and video, but got the same result, i ever posted to 
> this forum too about my detail error using embed tag. pardon me, what do u 
> mean with TAG.video() is it same like {{=TAG.video()}} ? 
> do you have any documentation for that tag?
>
 
There is no specific TAG.video tag. Rather, the TAG helper can be used to 
create custom tags -- so TAG.video() would be a custom tag. This is 
documented here: http://web2py.com/book/default/chapter/05#Custom-Helpers
 
web2py doesn't specifically support or not support embedding video or HTML5 
tags -- those are browser issues. You can put any HTML/CSS you want in your 
web2py view files -- whether it works or not will depend on the browser, not 
web2py. Note, though, that you do NOT have to build all of your HTML using 
the web2py HTML helpers -- instead, you can simply include regular HTML 
markup in your views (interspersed with Python code, as explained in the 
book).
 
Anthony


[web2py] Re: Tables refrencing each other

2011-04-08 Thread Anthony
You might find this thread of interest: 
https://groups.google.com/d/topic/web2py/vXETf06TfwI/discussion


[web2py] Re: Tables refrencing each other

2011-04-08 Thread guruyaya
I don't like this option, because I'll have to make sure I have only
one of this group manually. I thought of a validator that will do the
job for me, but it got very complicted.
I acctually had an idea of using IS_IN_DB, but leave the field as an
integer, instead of a reference. Yet, I'm too tierd to try it now.
I'll probably do it in the morning.

On Apr 8, 10:25 am, Seeker  wrote:
> Perhaps just add a boolean field in the chapter table: is_first ... or
> something to that effect??
> On saving an un-flagged chapter you can always check whether any other
> chapters for the story have been flagged as first; if not auto flag
> the one being saved.
> If a subsequent chapter (marked as first) is saved then set all others
> to false.
>
> Not perfect but just a thought...
>
> On Apr 8, 8:05 am,guruyaya wrote:
>
>
>
>
>
>
>
> > I wanted something more generic to work with, for future uses. But I
> > guess you're right.
>
> > On Apr 7, 11:42 pm, villas  wrote:
>
> > > Why not simply write an onvalidation function?
>
> > > When you save a record with form accepts this would check to ensure
> > > that you only have one first_chapter for that story_id.
>
> > > On Apr 6, 9:29 pm,guruyaya wrote:
>
> > > > Here's a simplified version of a model I'm working on:
>
> > > > db.define_table('story',
> > > >     Field('title'),
> > > >     Field('description', 'text'),
> > > >     Field('first_chapter', db.chapter)
> > > > )
>
> > > > db.define_table('chapter',
> > > >     Field('title'),
> > > >     Field('tale', 'text'),
> > > >     Field('story_id',db.story)
> > > > )
>
> > > > As you can imagine, I have a problem here. I cannot reference the
> > > > first chapter in the story table, because chapter is not yet defined,
> > > > but I cannot write thetablesbackwards, because story won't be
> > > > defined.
> > > > I was wondering if there's any way of doing this elegantly, or I'll
> > > > just have to count on the first chapter written of any story - to be
> > > > the first chapter.
> > > > Thanks in advance
> > > > Yaya


[web2py] Re: Tables refrencing each other

2011-04-08 Thread Anthony
On Friday, April 8, 2011 3:01:31 PM UTC-4, guruyaya wrote: 
>
> I don't like this option, because I'll have to make sure I have only 
> one of this group manually. I thought of a validator that will do the 
> job for me, but it got very complicted. 
> I acctually had an idea of using IS_IN_DB, but leave the field as an 
> integer, instead of a reference.

 
Yes, that was Massimo's suggestion a previous time this came up: 
https://groups.google.com/d/msg/web2py/vXETf06TfwI/-IhhyaO93AoJ
 


[web2py] Migrations Problem: two fields added, two not added

2011-04-08 Thread Lennon
I added the follow fields to my table:

Field('rooming_requests','string', length=500, label='Do you have any
rooming requests?', widget=SQLFORM.widgets.text.widget,
requires=[IS_LENGTH(500)]),

Field('misc_info','string', length=500, label='Anything else you would
like us to know?', widget=SQLFORM.widgets.text.widget,
requires=[IS_LENGTH(500)]),

Field('us_citizen','boolean', label='Are you a US citizen?',
requires=IS_IN_SET(['T', 'F'],zero='Choose One')),

Field('dietary_restrict','string', length=500, label='Do you have any
dietary restrictions?', widget=SQLFORM.widgets.text.widget,
requires=[IS_LENGTH(500)]),



When I did a migrate, the "rooming_requests" field and the "misc_info"
fields were added to the table file and to the MySQL database but the
"us_citizen" field and the "dietary_restrict" field was not.

Subsequent migration attempts have had no effect.

Please advise,

~Lennon


[web2py] Re: Migrations Problem: two fields added, two not added

2011-04-08 Thread Massimo Di Pierro
1) get trunk
2) comment the missing fields
3) run with DAL(...,fake_migrate_all=True)
4) visit appadmin
5) uncomment the missing fields
6) remove fake_migrate_all=True from DAL(...)
7) visit appadmin

did it fix it?



On Apr 8, 2:21 pm, Lennon  wrote:
> I added the follow fields to my table:
>
> Field('rooming_requests','string', length=500, label='Do you have any
> rooming requests?', widget=SQLFORM.widgets.text.widget,
> requires=[IS_LENGTH(500)]),
>
> Field('misc_info','string', length=500, label='Anything else you would
> like us to know?', widget=SQLFORM.widgets.text.widget,
> requires=[IS_LENGTH(500)]),
>
> Field('us_citizen','boolean', label='Are you a US citizen?',
> requires=IS_IN_SET(['T', 'F'],zero='Choose One')),
>
> Field('dietary_restrict','string', length=500, label='Do you have any
> dietary restrictions?', widget=SQLFORM.widgets.text.widget,
> requires=[IS_LENGTH(500)]),
>
> When I did a migrate, the "rooming_requests" field and the "misc_info"
> fields were added to the table file and to the MySQL database but the
> "us_citizen" field and the "dietary_restrict" field was not.
>
> Subsequent migration attempts have had no effect.
>
> Please advise,
>
> ~Lennon


[web2py] Re: Migrations Problem: two fields added, two not added

2011-04-08 Thread Lennon
Editing DAL() like that gets me this error:

Traceback (most recent call last):
  File "C:\Users\Lennon\workspace\web2py_source\gluon\restricted.py",
line 188, in restricted
exec ccode in environment
  File "C:/Users/Lennon/workspace/web2py_source/applications/sos_test/
models/a_db.py", line 55, in 
db = DAL([Removed for Security],fake_migrate_all=True)
TypeError: __init__() got an unexpected keyword argument
'fake_migrate_all'

On Apr 8, 4:04 pm, Massimo Di Pierro 
wrote:
> 1) get trunk
> 2) comment the missing fields
> 3) run with DAL(...,fake_migrate_all=True)
> 4) visit appadmin
> 5) uncomment the missing fields
> 6) remove fake_migrate_all=True from DAL(...)
> 7) visit appadmin
>
> did it fix it?
>
> On Apr 8, 2:21 pm, Lennon  wrote:
>
>
>
>
>
>
>
> > I added the follow fields to my table:
>
> > Field('rooming_requests','string', length=500, label='Do you have any
> > rooming requests?', widget=SQLFORM.widgets.text.widget,
> > requires=[IS_LENGTH(500)]),
>
> > Field('misc_info','string', length=500, label='Anything else you would
> > like us to know?', widget=SQLFORM.widgets.text.widget,
> > requires=[IS_LENGTH(500)]),
>
> > Field('us_citizen','boolean', label='Are you a US citizen?',
> > requires=IS_IN_SET(['T', 'F'],zero='Choose One')),
>
> > Field('dietary_restrict','string', length=500, label='Do you have any
> > dietary restrictions?', widget=SQLFORM.widgets.text.widget,
> > requires=[IS_LENGTH(500)]),
>
> > When I did a migrate, the "rooming_requests" field and the "misc_info"
> > fields were added to the table file and to the MySQL database but the
> > "us_citizen" field and the "dietary_restrict" field was not.
>
> > Subsequent migration attempts have had no effect.
>
> > Please advise,
>
> > ~Lennon


[web2py] Web2py and the Elements of Style

2011-04-08 Thread mikech
Initially I thought this was another blog bashing web2py, but instead its 
just the opposite.  Nice article.

http://www.pythonprogramming.info/web2py/elements-of-style.html


[web2py] Re: Web2py and the Elements of Style

2011-04-08 Thread Anthony
It's actually simply taken from the book: 
http://web2py.com/book/default/chapter/01#Elements-of-Style

On Friday, April 8, 2011 4:41:19 PM UTC-4, mikech wrote:

> Initially I thought this was another blog bashing web2py, but instead its 
> just the opposite.  Nice article.
>
> http://www.pythonprogramming.info/web2py/elements-of-style.html
>


[web2py] Re: Web2py and the Elements of Style

2011-04-08 Thread mikech
Ooops...

[web2py] How to create custom 404 and other error pages

2011-04-08 Thread Pystar
Hi,
I would like to know how to design custom 404 and other error pages.
Thanks


[web2py] Running web2py source on Mac

2011-04-08 Thread pbreit
How hard would it be to set up my Mac to run web2py from source? Would 
Rocket be the simplest to set up? And sqlite3 is already available in MacOS, 
right?

Any tips appreciated.


[web2py] Re: Running web2py source on Mac

2011-04-08 Thread pbreit
That was...how shall I say it...ridiculously easy!

1. Download Rocket
2. python setup.py install
3. set up an admin password (i copied an existing parameters_###.py file)
4. python anyserver.py -s rocket -p 8080

No more binaries!


Re: [web2py] Re: Running web2py source on Mac

2011-04-08 Thread Jonathan Lundell
On Apr 8, 2011, at 4:32 PM, pbreit wrote:
> That was...how shall I say it...ridiculously easy!
> 
> 1. Download Rocket
> 2. python setup.py install
> 3. set up an admin password (i copied an existing parameters_###.py file)
> 4. python anyserver.py -s rocket -p 8080
> 
> No more binaries!

No need to download Rocket; it's already built in to web2py. Just download 
web2py source and: python web2py.py ...

It's also easy to grab (and update) the trunk via hg. 

[web2py] Re: Running web2py source on Mac

2011-04-08 Thread Anthony
Rocket is already included in the source package -- why did you have to 
download it separately? As long as you've got Python installed, I think you 
should simply be able to download and unzip source, and then do 'python 
web2py.py' to run Python (it will start the Rocket server). At least, that's 
how it works on Windows.
 
Anthony

On Friday, April 8, 2011 7:32:50 PM UTC-4, pbreit wrote:

> That was...how shall I say it...ridiculously easy! 
>
> 1. Download Rocket
> 2. python setup.py install
> 3. set up an admin password (i copied an existing parameters_###.py file)
> 4. python anyserver.py -s rocket -p 8080
>
> No more binaries!
>


[web2py] Re: Running web2py source on Mac

2011-04-08 Thread Anthony
On Friday, April 8, 2011 8:05:07 PM UTC-4, Anthony wrote: 
>
> Rocket is already included in the source package -- why did you have to 
> download it separately? As long as you've got Python installed, I think you 
> should simply be able to download and unzip source, and then do 'python 
> web2py.py' to run Python (it will start the Rocket server). At least, that's 
> how it works on Windows.
>
 
Oops, I meant "to run web2py".


[web2py] Re: How to create custom 404 and other error pages

2011-04-08 Thread Anthony
Have you tried routes_onerror -- 
http://web2py.com/book/default/chapter/04#Routes-on-Error
 

On Friday, April 8, 2011 7:03:53 PM UTC-4, Pystar wrote:

> Hi, 
> I would like to know how to design custom 404 and other error pages. 
> Thanks



[web2py] IS_UPLOAD_FILENAME validator

2011-04-08 Thread 黄祥
hi,

i have a problem using validator IS_UPLOAD_FILENAME() to check upload
file neither avi or flv extension, is it support to check multiple
extension like on IS_IMAGE()
e.g.
IS_IMAGE(extensions = ('jpeg', 'png'))
is it support to use
IS_UPLOAD_FILENAME(extensions = ('avi', 'flv'))
thank you


[web2py] Quick Admin Suggestion

2011-04-08 Thread ra3don
Is there any way we can have a "View" button added on the Header of
the Admin site? The button could take the user to the index in a new
tab.

I personally would find this very useful because It is sometimes A
pain to navigate to a page where you can click and get to the site
home page. I find myself doing this quite often.


[web2py] Re: Running web2py source on Mac

2011-04-08 Thread pbreit
Wow, I guess I totally missed this in the documentation. For some reason I 
only thought it came with the Mac binary download. I don't know why I've 
been using the web2py.app all this time!

[web2py] Re: Running web2py source on Mac

2011-04-08 Thread pbreit
Do I feel like an idiot! Not the first time...and not the last.

[web2py] Re: Quick Admin Suggestion

2011-04-08 Thread Anthony
If you're on the "site" page that lists all the applications, clicking an 
application name takes you to the /default/index page for the app. If you're 
on the "edit" page for a given app, clicking on the app name at the top 
(next to the words "EDIT APPLICATION") takes you to the /default/index page. 
Also, next to each controller file link it lists all the functions within 
the controller, and clicking on any of those takes you to the associated 
URL. Are you looking for something else?

On Friday, April 8, 2011 8:55:07 PM UTC-4, ra3don wrote:

> Is there any way we can have a "View" button added on the Header of 
> the Admin site? The button could take the user to the index in a new 
> tab. 
>
> I personally would find this very useful because It is sometimes A 
> pain to navigate to a page where you can click and get to the site 
> home page. I find myself doing this quite often.



[web2py] Re: Bug in Dal: import for csv

2011-04-08 Thread DJ
Same issues here - I installed the latest version for a project and I am not 
able to import csv files from web2py command line.

Does import_from_csv work in the older versions?

-Seb


[web2py] Error trying to use PolyModel

2011-04-08 Thread RipRyness
Dug up some code I did last summer.  Thought I'd dust it off and
upgrade it's web2py libraries.  It is a GAE app.  I am getting an
error on the following code:

db.define_table('regform',
Field('form_type'),
Field('url_id', requires=[IS_NOT_IN_DB(db, 'account.org_id',
error_message=T('id taken; choose another')),
IS_NOT_EMPTY(error_message=T('value required')), IS_MATCH('^[a-zA-
Z0-9_]+$', error_message='can only contain characters A-Z, 0-9, or
_')], label='Church ID'),
Field('url_id_norm',compute=lambda r: r['org_id'].lower()),
 
Field('created_by',db.auth_user,default=me,writable=False,readable=False),
 
Field('modified_on','datetime',default=request.now,update=request.now,writable=False,readable=False),
Field('account', db.account, default=session.account,
writable=False,readable=False),
Field('version',default=db_version,writable=False,readable=False),
polymodel=True)

Error is:
invalid table "regform" attribute: polymodel