Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Alessandro Iob
No, it does not work. And the problem is not related to the
*_DateTrackerImporter
as I'm not using the track_changes options.*

**I've made some tests and I've found that in _Web2pyImporter.__call__ the
code reaches the "import like 'from x import a, b, ...'" section with the
vars set to:

name = selfgroup.castalia
caller_file_name =
C:\w2p\web2py\applications\castalia\controllers/default.py
self.web2py_path = C:\w2p\web2py
match_app_dir = <_sre.SRE_Match object at 0x018B7420>
modules_prefix = applications.castalia.modules
module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia
fromlist = ('config',)
level = -1

then the call to

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)

raises the ImportError exception (No module named
castalia.modules.selfgroup.castalia).
The sys.path seems correct:

['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py',
'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']

No clue.

On Mon, Jun 6, 2011 at 3:08 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> If this s the problem, I have a possible fix in trunk.Please give it a
> try. Yet I am not convinced this is the problem.
>
> On Jun 4, 5:20 pm, Pierre Thibault  wrote:
> > 2011/6/3 Alessandro Iob 
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > I have tried the new modules import feature (from mymodule import *,
> looks
> > > for mymodule in applications/thisapp/ modules first and then in
> sys.path. No
> > > more need for local_import) and it works wonderfully on OS/X but not at
> all
> > > on Windows. Below you can find the traceback.
> >
> > > web2py™Version 1.96.2 (2011-06-03 16:11:39)PythonPython 2.5.4:
> > > C:\web2py\web2py.exe
> >
> > > Traceback (most recent call last):
> > >   File "gluon/restricted.py", line 184, in restricted
> > >   File "C:/web2py/applications/castalia/controllers/default.py" <
> http://127.0.0.1:8000/admin/default/edit/castalia/controllers/default.py>,
> line 2, in 
> > >   File "gluon/custom_import.py", line 280, in __call__
> > >   File "gluon/custom_import.py", line 125, in __call__
> > > ImportError: No module named selfgroup.castalia
> >
> > > Any suggestion?
> >
> > > Thank you
> >
> > Hello Alessandro,
> >
> > I wrote this code but I don't have Windows to do testing. I suspect it is
> a
> > problem related to os.stat.
> >
> > Can you run this code on your machine and gave me the result?
> >
> > import os
> > print os.stat("*path to the module you want to import*").st_mtime
> > --
> >
> > A+
> >
> > -
> > Pierre
> > My blog and profile
> > (http://pierrethibault.posterous.com)<
> http://pierrethibault.posterous.com>
> > YouTube page (http://www.youtube.com/user/tubetib)<
> http://www.youtube.com/user/tubetib>
> > Twitter (http://twitter.com/pierreth2) 


[web2py] SyntaxError: Object exists and cannot be redefined: lunid

2011-06-06 Thread Mike Veltman

I try to pre populate a form and I think I do something wrong but I stare at 
it for a long time and what I do wrong still does not show up. 

So maybe some people can make my day better.

Error:


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
Traceback (most recent call last):
  File "/home/mv1965/Documents/development/eclipse/adsw2p/gluon/restricted.py", 
line 184, in restricted
exec ccode in environment
  File 
"/home/mv1965/Documents/development/eclipse/adsw2p/applications/adeploy/compiled/controllers_formdb_test_manage_lvstorage.py",
 line 342, in 
  File "/home/mv1965/Documents/development/eclipse/adsw2p/gluon/globals.py", 
line 137, in 
self._caller = lambda f: f()
  File "/home/mv1965/Documents/development/eclipse/adsw2p/gluon/tools.py", line 
2452, in f
return action(*a, **b)
  File 
"/home/mv1965/Documents/development/eclipse/adsw2p/applications/adeploy/compiled/controllers_formdb_test_manage_lvstorage.py",
 line 58, in test_manage_lvstorage
  File "/home/mv1965/Documents/development/eclipse/adsw2p/gluon/dal.py", line 
4630, in __setattr__
raise SyntaxError, 'Object exists and cannot be redefined: %s' % key
SyntaxError: Object exists and cannot be redefined: lunid


Controller

@auth.requires_login()
def test_manage_lvstorage():

db.lvstorage.lunid = 4   
form = SQLFORM(db.lvstorage)
return dict(form=form)

# Logical volume on storage
db.define_table('lvstorage',

Field('setup_id', db.setup,
  default=1,
  label=T('Setup ID')),
Field('lvsize_id', db.lvsize,
  default=2,
  label=T('Size ID')),
Field('lunid', type='integer',
  default=2,
  label=T('Lun ID')),
Field('storagemap_id', db.storagemap,
  default=1,
  label=T('Host Group')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
migrate=settings.migrate)

# Table rules
db.lvstorage.setup_id.requires = IS_IN_DB(db, 'setup.id', 'setup.setupname')
db.lvstorage.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id', 'lvsize.sizename')
db.lvstorage.storagemap_id.requires = IS_IN_DB(db, 'storagemap.id', 
'storagemap.mapping')
db.lvstorage.lunid.requires = 
IS_IN_SET([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70])


[web2py] layout with submenu

2011-06-06 Thread Manuele Pesenti

Hi *,
I realize that most of the layouts available for download do not support 
the submenu, in the sense that it's not managed so if defined it couses 
unwanted behavior... does anybody knows layouts that implements submenu 
managment?


thanks

Manuele


[web2py] response.meta attributes

2011-06-06 Thread Francisco Costa
Hello,

I would like to have some meta tags that look like this:


This is because of the facebook like button:
https://developers.facebook.com/docs/reference/plugins/like/ (Step 2 -
Get Open Graph Tags)

The thing is when you try response.meta.foo = 'bar' it generates


Any help on creating meta tags with the attribute property?


[web2py] Re: SyntaxError: Object exists and cannot be redefined: lunid

2011-06-06 Thread Massimo Di Pierro
db.lvstorage.lunid = 4

should be (I guess)

db.lvstorage.lunid.default = 4

On Jun 6, 4:12 am, Mike Veltman  wrote:
> I try to pre populate a form and I think I do something wrong but I stare at
> it for a long time and what I do wrong still does not show up.
>
> So maybe some people can make my day better.
>
> Error:
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> Traceback (most recent call last):
>   File 
> "/home/mv1965/Documents/development/eclipse/adsw2p/gluon/restricted.py", line 
> 184, in restricted
>     exec ccode in environment
>   File 
> "/home/mv1965/Documents/development/eclipse/adsw2p/applications/adeploy/com 
> piled/controllers_formdb_test_manage_lvstorage.py", line 342, in 
>   File "/home/mv1965/Documents/development/eclipse/adsw2p/gluon/globals.py", 
> line 137, in 
>     self._caller = lambda f: f()
>   File "/home/mv1965/Documents/development/eclipse/adsw2p/gluon/tools.py", 
> line 2452, in f
>     return action(*a, **b)
>   File 
> "/home/mv1965/Documents/development/eclipse/adsw2p/applications/adeploy/com 
> piled/controllers_formdb_test_manage_lvstorage.py", line 58, in 
> test_manage_lvstorage
>   File "/home/mv1965/Documents/development/eclipse/adsw2p/gluon/dal.py", line 
> 4630, in __setattr__
>     raise SyntaxError, 'Object exists and cannot be redefined: %s' % key
> SyntaxError: Object exists and cannot be redefined: lunid
>
> Controller
>
> @auth.requires_login()
> def test_manage_lvstorage():
>
>         db.lvstorage.lunid = 4  
>         form = SQLFORM(db.lvstorage)
>         return dict(form=form)
>
> # Logical volume on storage
> db.define_table('lvstorage',
>
>     Field('setup_id', db.setup,
>           default=1,
>           label=T('Setup ID')),
>     Field('lvsize_id', db.lvsize,
>           default=2,
>           label=T('Size ID')),
>     Field('lunid', type='integer',
>           default=2,
>           label=T('Lun ID')),
>     Field('storagemap_id', db.storagemap,
>           default=1,
>           label=T('Host Group')),
>     Field('created_on','datetime',default=request.now,
>           label=T('Created On'),writable=False,readable=False),
>     Field('modified_on','datetime',default=request.now,
>           label=T('Modified On'),writable=False,readable=False,
>           update=request.now),
>     migrate=settings.migrate)
>
> # Table rules
> db.lvstorage.setup_id.requires = IS_IN_DB(db, 'setup.id', 'setup.setupname')
> db.lvstorage.lvsize_id.requires = IS_IN_DB(db, 'lvsize.id', 'lvsize.sizename')
> db.lvstorage.storagemap_id.requires = IS_IN_DB(db, 'storagemap.id',
> 'storagemap.mapping')
> db.lvstorage.lunid.requires =
> IS_IN_SET([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25, 
> 26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51, 
> 52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70])


[web2py] Re: response.meta attributes

2011-06-06 Thread Massimo Di Pierro
you have to edit the layout.html

On Jun 6, 7:08 am, Francisco Costa  wrote:
> Hello,
>
> I would like to have some meta tags that look like this:
>     
>
> This is because of the facebook like 
> button:https://developers.facebook.com/docs/reference/plugins/like/(Step 2 -
> Get Open Graph Tags)
>
> The thing is when you try response.meta.foo = 'bar' it generates
>     
>
> Any help on creating meta tags with the attribute property?


[web2py] Re: How to Choose the Best Web Hosting Service

2011-06-06 Thread dhmorgan
the 'advice' in article is next to useless; definitely spam (it was
posted to 34 diff groups); hope the poster chokes on the can from
which he spooned it


[web2py] Re: How to render the figure titles?

2011-06-06 Thread Massimo Di Pierro
We need to see the code to help. Looks like some **latex is treated as
a string.


[web2py] 1.96.3 and auth.settings.login_onaccept

2011-06-06 Thread Michele Comitini
Hi Massimo,

Upgraded to 1.96.3 and auth.settings.login_onaccept

this statement does not work anymore...

auth.settings.login_onaccept = lambda form: \
form.vars.update(dict(last_login=request.now))

form is None


The code around line 1650 in tools.py seems to call callback with
form=None and then with form=Auth()?

self.user = user
callback(onaccept,None)
session.flash = self.messages.logged_in
if log and self.user:
self.log_event(log % self.user)

# how to continue
if self.settings.login_form == self:
if accepted_form:
callback(onaccept,form)
if isinstance(next, (list, tuple)):

Ciao,
michele


[web2py] Re: How to not show the "delete file" checkbox

2011-06-06 Thread Ross Peoples
In your SQLFORM call, you should be able to set deletable=False

http://web2py.com/book/default/chapter/07#SQLFORM


Re: [web2py] Re: response.js on regular requests.

2011-06-06 Thread David J.
I tried this it worked on the fields but it seemed to have disabled the 
rest of the web2py_ajax javascript;


Maybe I am doing something wrong;



$("#myfield").valudate(number);





On 6/5/11 7:43 PM, Anthony wrote:
Can't you just include the relevant JS directly in the view template 
for the page, or maybe include the JS string in the dict returned by 
the controller, and insert it as a variable in the view?


On Sunday, June 5, 2011 6:22:13 PM UTC-4, David J wrote:

How do I inject javascript in my controller from a regular web
request?

I read the docs it syas response.js is executed only in a component;

so I have a form and I would like to add JS validators.

so I try adding to the response.js =
'$("myfield").validate("digits");'

Of course this only works in component mode as I tried it;

But now I have a single form page and I want this same javascript
to work;

How do I do that?

Thanks.






Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Pierre Thibault
2011/6/6 Alessandro Iob 

> No, it does not work. And the problem is not related to the 
> *_DateTrackerImporter
> as I'm not using the track_changes options.*
>
> **I've made some tests and I've found that in _Web2pyImporter.__call__ the
> code reaches the "import like 'from x import a, b, ...'" section with the
> vars set to:
>
>  name = selfgroup.castalia
> caller_file_name =
> C:\w2p\web2py\applications\castalia\controllers/default.py
> self.web2py_path = C:\w2p\web2py
> match_app_dir = <_sre.SRE_Match object at 0x018B7420>
> modules_prefix = applications.castalia.modules
> module_prefix + '.' + name =
> applications.castalia.modules.selfgroup.castalia
> fromlist = ('config',)
> level = -1
>
> then the call to
>
> super(_Web2pyImporter, self).__call__(
>  modules_prefix+"."+name, globals, locals, fromlist, level
> )
>
> raises the ImportError exception (No module named
> castalia.modules.selfgroup.castalia).
> The sys.path seems correct:
>
>  ['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py',
> 'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']
>
> No clue.
>

There is something weird here. You said that:

module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia

super(_Web2pyImporter, self).__call__(
 modules_prefix+"."+name, globals, locals, fromlist, level
)


But the error is:

raises the ImportError exception (No module named
castalia.modules.selfgroup.castalia).

I would expect "No module named *applications*
.castalia.modules.selfgroup.castalia".

Why is "applicaitons" missing?

-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)
YouTube page 
(http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2) 


Re: [web2py] Re: response.js on regular requests.

2011-06-06 Thread Ovidio Marinho
you already tried something like that:










The actual script is in an external script file called "xxx.js".





Ovidio Marinho Falcao Neto
 ovidio...@gmail.com
 88269088
   Paraiba-Brasil



2011/6/6 David J. 

>  I tried this it worked on the fields but it seemed to have disabled the
> rest of the web2py_ajax javascript;
>
> Maybe I am doing something wrong;
>
> 
>
> $("#myfield").valudate(number);
>
>
> 
>
>
>
> On 6/5/11 7:43 PM, Anthony wrote:
>
> Can't you just include the relevant JS directly in the view template for
> the page, or maybe include the JS string in the dict returned by the
> controller, and insert it as a variable in the view?
>
> On Sunday, June 5, 2011 6:22:13 PM UTC-4, David J wrote:
>
>> How do I inject javascript in my controller from a regular web request?
>>
>> I read the docs it syas response.js is executed only in a component;
>>
>> so I have a form and I would like to add JS validators.
>>
>> so I try adding to the response.js = '$("myfield").validate("digits");'
>>
>> Of course this only works in component mode as I tried it;
>>
>> But now I have a single form page and I want this same javascript to work;
>>
>>
>> How do I do that?
>>
>> Thanks.
>>
>>
>>
>


Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Alessandro Iob

I really do not know why, but that's the error. A mistery for me.

On 6/6/11 15:42 , Pierre Thibault wrote:

2011/6/6 Alessandro Iob mailto:alessandro@gmail.com>>

No, it does not work. And the problem is not related to the
*_DateTrackerImporter as I'm not using the track_changes options.*

**I've made some tests and I've found that in
_Web2pyImporter.__call__ the code reaches the "import like 'from x
import a, b, ...'" section with the vars set to:

name = selfgroup.castalia
caller_file_name =
C:\w2p\web2py\applications\castalia\controllers/default.py
self.web2py_path = C:\w2p\web2py
match_app_dir = <_sre.SRE_Match object at 0x018B7420>
modules_prefix = applications.castalia.modules
module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia
fromlist = ('config',)
level = -1

then the call to

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)

raises the ImportError exception (No module named
castalia.modules.selfgroup.castalia).
The sys.path seems correct:

['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py',
'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']

No clue.


There is something weird here. You said that:

module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)


But the error is:

raises the ImportError exception (No module named
castalia.modules.selfgroup.castalia).

I would expect "No module named
*applications*.castalia.modules.selfgroup.castalia".

Why is "applicaitons" missing?

--


A+

-
Pierre
My blog and profile (http://pierrethibault.posterous.com)

YouTube page (http://www.youtube.com/user/tubetib)

Twitter (http://twitter.com/pierreth2) 



Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Pierre Thibault
2011/6/6 Alessandro Iob 

> I really do not know why, but that's the error. A mistery for me.
>
>
>
Can you trace the super call?


> On 6/6/11 15:42 , Pierre Thibault wrote:
>
>> 2011/6/6 Alessandro Iob > >
>>
>>
>>No, it does not work. And the problem is not related to the
>>*_DateTrackerImporter as I'm not using the track_changes options.*
>>
>>**I've made some tests and I've found that in
>>_Web2pyImporter.__call__ the code reaches the "import like 'from x
>>import a, b, ...'" section with the vars set to:
>>
>>name = selfgroup.castalia
>>caller_file_name =
>>C:\w2p\web2py\applications\castalia\controllers/default.py
>>self.web2py_path = C:\w2p\web2py
>>match_app_dir = <_sre.SRE_Match object at 0x018B7420>
>>modules_prefix = applications.castalia.modules
>>module_prefix + '.' + name =
>>applications.castalia.modules.selfgroup.castalia
>>fromlist = ('config',)
>>level = -1
>>
>>then the call to
>>
>>super(_Web2pyImporter, self).__call__(
>>modules_prefix+"."+name, globals, locals, fromlist, level
>>)
>>
>>raises the ImportError exception (No module named
>>castalia.modules.selfgroup.castalia).
>>The sys.path seems correct:
>>
>>['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py',
>>'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']
>>
>>No clue.
>>
>>
>> There is something weird here. You said that:
>>
>> module_prefix + '.' + name =
>> applications.castalia.modules.selfgroup.castalia
>>
>> super(_Web2pyImporter, self).__call__(
>> modules_prefix+"."+name, globals, locals, fromlist, level
>> )
>>
>>
>> But the error is:
>>
>> raises the ImportError exception (No module named
>> castalia.modules.selfgroup.castalia).
>>
>> I would expect "No module named
>> *applications*.castalia.modules.selfgroup.castalia".
>>
>> Why is "applicaitons" missing?
>>
>> --
>>
>>
>> A+
>>
>> -
>> Pierre
>> My blog and profile (http://pierrethibault.posterous.com)
>> 
>> YouTube page (http://www.youtube.com/user/tubetib)
>> 
>> Twitter (http://twitter.com/pierreth2) 
>>
>>


-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)
YouTube page 
(http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2) 


[web2py] Re: response.meta attributes

2011-06-06 Thread Francisco Costa
> you have to edit the layout.html

I suppose I could but I won't get a like button in every pages and I'm
trying to have a clean code.

That's why I would like to be able to define those meta tags in
controllers or views.


[web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Massimo Di Pierro
I do not understand this line:

module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia

does not look like a valid Python statement to me.

On Jun 6, 9:05 am, Pierre Thibault  wrote:
> 2011/6/6 Alessandro Iob 
>
> > I really do not know why, but that's the error. A mistery for me.
>
> Can you trace the super call?
>
>
>
>
>
>
>
>
>
> > On 6/6/11 15:42 , Pierre Thibault wrote:
>
> >> 2011/6/6 Alessandro Iob  >> >
>
> >>    No, it does not work. And the problem is not related to the
> >>    *_DateTrackerImporter as I'm not using the track_changes options.*
>
> >>    **I've made some tests and I've found that in
> >>    _Web2pyImporter.__call__ the code reaches the "import like 'from x
> >>    import a, b, ...'" section with the vars set to:
>
> >>    name = selfgroup.castalia
> >>    caller_file_name =
> >>    C:\w2p\web2py\applications\castalia\controllers/default.py
> >>    self.web2py_path = C:\w2p\web2py
> >>    match_app_dir = <_sre.SRE_Match object at 0x018B7420>
> >>    modules_prefix = applications.castalia.modules
> >>    module_prefix + '.' + name =
> >>    applications.castalia.modules.selfgroup.castalia
> >>    fromlist = ('config',)
> >>    level = -1
>
> >>    then the call to
>
> >>    super(_Web2pyImporter, self).__call__(
> >>    modules_prefix+"."+name, globals, locals, fromlist, level
> >>    )
>
> >>    raises the ImportError exception (No module named
> >>    castalia.modules.selfgroup.castalia).
> >>    The sys.path seems correct:
>
> >>    ['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py',
> >>    'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']
>
> >>    No clue.
>
> >> There is something weird here. You said that:
>
> >> module_prefix + '.' + name =
> >> applications.castalia.modules.selfgroup.castalia
>
> >> super(_Web2pyImporter, self).__call__(
> >> modules_prefix+"."+name, globals, locals, fromlist, level
> >> )
>
> >> But the error is:
>
> >> raises the ImportError exception (No module named
> >> castalia.modules.selfgroup.castalia).
>
> >> I would expect "No module named
> >> *applications*.castalia.modules.selfgroup.castalia".
>
> >> Why is "applicaitons" missing?
>
> >> --
>
> >> A+
>
> >> -
> >> Pierre
> >> My blog and profile (http://pierrethibault.posterous.com)
> >> 
> >> YouTube page (http://www.youtube.com/user/tubetib)
> >> 
> >> Twitter (http://twitter.com/pierreth2) 
>
> --
>
> A+
>
> -
> Pierre
> My blog and profile
> (http://pierrethibault.posterous.com)
> YouTube page 
> (http://www.youtube.com/user/tubetib)
> Twitter (http://twitter.com/pierreth2) 


Re: [web2py] Re: App-generating wizard crashes

2011-06-06 Thread Jonathan Lundell
On Jun 5, 2011, at 5:28 PM, Massimo Di Pierro wrote:
> 
> On Jun 4, 4:08 pm, weheh  wrote:
>> On 1.96.3 I tried the new app wizard for kicks. I let everything
>> default except for the app name, "foobar". Wizard crashed.
>> 
>> Traceback (most recent call last):
>>   File "N:\web2py\gluon\restricted.py", line 188, in restricted
>> exec ccode in environment
>>   File "N:/web2py/applications/admin/controllers/wizard.py", line 572,
>> in 
>>   File "N:\web2py\gluon\globals.py", line 96, in 
>> self._caller = lambda f: f()
>>   File "N:/web2py/applications/admin/controllers/wizard.py", line 200,
>> in step6
>> create(form.vars)
>>   File "N:/web2py/applications/admin/controllers/wizard.py", line 489,
>> in create
>> file=open(meta,'wb')
>> IOError: [Errno 2] No such file or directory: 'N:\\web2py\\applications
>> \\admin/..\\foobar\\wizard.metadata'

Something else is a little odd. Where is the slash coming from? 

I don't think it's causing trouble, since Windows is generally OK with slashes, 
but we've tried to use Python's OS-specific separators.

There are three places in gluon.admin that still use explicit slashes. But 
request.folder gets terminated with os.sep, and I assume that's what's being 
used here. So: why the slash? Just curious.

Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Alessandro Iob
"applications.castalia.modules.selfgroup.castalia" is just the value you 
get from "module_prefix + '.' + name", that's the value passed to the 
__import__ call.


On 6/6/11 16:23 , Massimo Di Pierro wrote:

I do not understand this line:

module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia

does not look like a valid Python statement to me.

On Jun 6, 9:05 am, Pierre Thibault  wrote:

2011/6/6 Alessandro Iob


I really do not know why, but that's the error. A mistery for me.


Can you trace the super call?










On 6/6/11 15:42 , Pierre Thibault wrote:



2011/6/6 Alessandro Iobmailto:alessandro@gmail.com>>



No, it does not work. And the problem is not related to the
*_DateTrackerImporter as I'm not using the track_changes options.*



**I've made some tests and I've found that in
_Web2pyImporter.__call__ the code reaches the "import like 'from x
import a, b, ...'" section with the vars set to:



name = selfgroup.castalia
caller_file_name =
C:\w2p\web2py\applications\castalia\controllers/default.py
self.web2py_path = C:\w2p\web2py
match_app_dir =<_sre.SRE_Match object at 0x018B7420>
modules_prefix = applications.castalia.modules
module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia
fromlist = ('config',)
level = -1



then the call to



super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)



raises the ImportError exception (No module named
castalia.modules.selfgroup.castalia).
The sys.path seems correct:



['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py',
'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']



No clue.



There is something weird here. You said that:



module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia



super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)



But the error is:



raises the ImportError exception (No module named
castalia.modules.selfgroup.castalia).



I would expect "No module named
*applications*.castalia.modules.selfgroup.castalia".



Why is "applicaitons" missing?



--



A+



-
Pierre
My blog and profile (http://pierrethibault.posterous.com)

YouTube page (http://www.youtube.com/user/tubetib)

Twitter (http://twitter.com/pierreth2)


--

A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)
YouTube page 
(http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2)




Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Pierre Thibault
2011/6/6 Massimo Di Pierro 

> I do not understand this line:
>
> module_prefix + '.' + name =
> applications.castalia.modules.selfgroup.castalia
>
> does not look like a valid Python statement to me.
> --
>

I interpreted this as the value of the expression module_prefix + '.' + nameis
"applications.castalia.modules.selfgroup.castalia". I think this what
Alessandro wanted to express.

A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)
YouTube page 
(http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2) 


Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Alessandro Iob

I'll try, but the super is really just the standard __import__ method.

On 6/6/11 16:05 , Pierre Thibault wrote:

2011/6/6 Alessandro Iob mailto:alessandro@gmail.com>>

I really do not know why, but that's the error. A mistery for me.



Can you trace the super call?

On 6/6/11 15:42 , Pierre Thibault wrote:

2011/6/6 Alessandro Iob mailto:alessandro@gmail.com>
>>


No, it does not work. And the problem is not related to the
*_DateTrackerImporter as I'm not using the track_changes
options.*

**I've made some tests and I've found that in
_Web2pyImporter.__call__ the code reaches the "import like
'from x
import a, b, ...'" section with the vars set to:

name = selfgroup.castalia
caller_file_name =
C:\w2p\web2py\applications\castalia\controllers/default.py
self.web2py_path = C:\w2p\web2py
match_app_dir = <_sre.SRE_Match object at 0x018B7420>
modules_prefix = applications.castalia.modules
module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia
fromlist = ('config',)
level = -1

then the call to

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)

raises the ImportError exception (No module named
castalia.modules.selfgroup.castalia).
The sys.path seems correct:

['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py',
'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']

No clue.


There is something weird here. You said that:

module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)


But the error is:

raises the ImportError exception (No module named
castalia.modules.selfgroup.castalia).

I would expect "No module named
*applications*.castalia.modules.selfgroup.castalia".

Why is "applicaitons" missing?

--


A+

-
Pierre
My blog and profile (http://pierrethibault.posterous.com)

YouTube page (http://www.youtube.com/user/tubetib)

Twitter (http://twitter.com/pierreth2)





--


A+

-
Pierre
My blog and profile (http://pierrethibault.posterous.com)

YouTube page (http://www.youtube.com/user/tubetib)

Twitter (http://twitter.com/pierreth2) 



Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Pierre Thibault
2011/6/6 Alessandro Iob 

> I'll try, but the super is really just the standard __import__ method.
>
>
>
What is the value of name there?
-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)
YouTube page 
(http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2) 


Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Alessandro Iob

the name arg passed to _PYTHON_STANDARD_IMPORTER has value
"applications.castalia.modules.selfgroup.castalia".

On 6/6/11 16:37 , Pierre Thibault wrote:

2011/6/6 Alessandro Iob mailto:alessandro@gmail.com>>

I'll try, but the super is really just the standard __import__ method.



What is the value of name there?
--


A+

-
Pierre
My blog and profile (http://pierrethibault.posterous.com)

YouTube page (http://www.youtube.com/user/tubetib)

Twitter (http://twitter.com/pierreth2) 



Re: [web2py] layout with submenu

2011-06-06 Thread Richard Vézina
I am not sure to understand what you need, but you can nest you stuff like
this :

response.menu = [
 [T('root1').capitalize(),
 False,
 '',
 [
 [T('level1-1').capitalize(),
 False,
 URL(request.application,
 'controller',
 'function'),
 [
 [T('level2-1').capitalize(),
 False,
 URL(request.application,
 'controller',
 'function'),
 []],
 ]],
 [T('level1-2').capitalize(),
 False,
 URL(request.application,
 'controller',
 'function'),
 []],
 [T('level1-3').capitalize(),
 False,
 URL(request.application,
 'controller',
 'function'),
 []],

 ]],


 [T('root2').capitalize(),
 False,
 '',
 [
 [T('level1-1').capitalize(),
 False,
 URL(request.application,
 'controller',
 'function'),
 []],
 [T('level1-2').capitalize(),
 False,
 URL(request.application,
 'controller',
 'function'),
 []],
 ]],
]

Take care of proper indentation and open and closing your bracket correctly.

Richard

On Mon, Jun 6, 2011 at 7:13 AM, Manuele Pesenti
wrote:

> Hi *,
> I realize that most of the layouts available for download do not support
> the submenu, in the sense that it's not managed so if defined it couses
> unwanted behavior... does anybody knows layouts that implements submenu
> managment?
>
> thanks
>
>Manuele
>


Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Pierre Thibault
2011/6/6 Alessandro Iob 

> the name arg passed to _PYTHON_STANDARD_IMPORTER has value
> "applications.castalia.modules.selfgroup.castalia".
>
>
OK. If you open a Python console, what does give you:

import sys

sys.path.append("C:\w2p\web2py")

import applications.castalia.modules.selfgroup.castalia

?


-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)
YouTube page 
(http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2) 


[web2py] OAuth2.0 and Facebook (as from the book)

2011-06-06 Thread Sebastian E. Ovide
Hi All,

just wondering if the section "OAuth2.0 and Facebook" of the book is up to
date?

I following it's instructions but I'm getting an "Internal error"

to reproduce

1) get last web2py 1.196.3
2) follow the instructions from the book
2.a) get facebook and place it in modules
2.b) copy the code from the book
2.c) replace "from facebook import GraphAPI" with "facebook =
local_import('facebook')"
2.d) replace facebook. to GraphAPIError and GraphAPI
2.e) replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with real data
3) set your app URL to http://localhost:8000/welcome/

Is something missing ?

When I click login, it redirect me to facebook, where I can login, and then
it redirects me to http://localhost:8000/welcome/

At that point I get an error:

 TRACEBACK


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.


Traceback (most recent call last):

  File "/home/sebas/Downloads/web2py/gluon/restricted.py", line 184,
in restricted

exec ccode in environment

  File 
"/home/sebas/Downloads/web2py/applications/welcome/controllers/default.py"
,
line 71, in 

  File "/home/sebas/Downloads/web2py/gluon/globals.py", line 137, in 

  /  self._caller = lambda f: f()

  File 
"/home/sebas/Downloads/web2py/applications/welcome/controllers/default.py"
,
line 33, in user

return dict(form=auth())

  File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1070, in __call__

return getattr(self,args[0])()

  File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1626, in login

user = self.get_or_create_user(table_user._filter_fields(cas_user))

  File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1360, in
get_or_create_user

user = self.db(table_user[username] == keys[username]).select().first()
KeyError: 'email'

any ideas , thanks

-- 
Sebastian E. Ovide


Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Alessandro Iob
I've tested it with a python 2.6 interpreter. It returns the same error 
as in web2py.


I've also created a simple module under applications/castalia/modules 
but I can not import it too.


On 6/6/11 17:06 , Pierre Thibault wrote:

import sys

sys.path.append("C:\w2p\web2py")

import applications.castalia.modules.selfgroup.castalia


Re: [web2py] Re: component refresh with jQuery UI tab plugin

2011-06-06 Thread Richard Vézina
Hello Massimo,

Was it available in 1.94.6??

I try all sort of things and can't makes it work... No refresh.

Richard

On Fri, Jun 3, 2011 at 10:02 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Give a name to your components
>
> {{=LOAD(...,target='one')}}
> {{=LOAD(...,target='two')}}
> {{=LOAD(...,target='three')}}
>
> now any action can trigger a component reload
>
> response.js="web2py_component('action','target')"
>
> where action is the URL of the component and 'target' is 'one', 'two',
> 'three'', etc.
>
>
>
> On Jun 2, 4:21 pm, Richard Vézina  wrote:
> > Hello,
> >
> > Here my view code :
> >
> > {{extend 'layout_form.html'}}
> >
> > 
> > @import
> >
> "{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/th
> emes/base/jquery.ui.all.css')}}";
> > 
> >
> >  >
> src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/js/jquery-1.4.4.m
> in.js')}}">
> >  >
> src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundl
> e/ui/jquery.ui.core.js')}}">
> >  >
> src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundl
> e/ui/jquery.ui.widget.js')}}">
> >  >
> src="{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundl
> e/ui/jquery.ui.tabs.js')}}">
> > 
> > $(function() {
> > $( "#tabs" ).tabs();});
> >
> > 
> >
> > 
> > 
> > 
> > 
> > 
> > 
> > {{=T('folder').capitalize()}}
> > {{=T('volume').capitalize()}}
> > {{=T('tome').capitalize()}}
> > {{=T('report').capitalize()}}
> > 
> > 
> > 
> >
> >
> {{=LOAD(c='ref',f='create_fvte',args='ref_fnaregistry',extension='load',aja
> x=True,ajax_trap=False)}}
> > 
> > 
> > 
> >
> >
> {{=LOAD(c='ref',f='create_fvte',args='ref_vregistry',extension='load',ajax=
> True,ajax_trap=False)}}
> > 
> > 
> > 
> >
> >
> {{=LOAD(c='ref',f='create_fvte',args='ref_tregistry',extension='load',ajax=
> True,ajax_trap=False)}}
> > 
> > 
> > 
> >
> >
> {{=LOAD(c='ref',f='create_fvte',args='ref_eregistry',extension='load',ajax=
> True,ajax_trap=False)}}
> > 
> > 
> >
> > 
> >
> > The problem is that when the form loaded with component in tab-1 is
> submited
> > and the user clic on tab-2 to fill the following form... The component is
> > not up to date... So the new entry just made into the preceding form is
> not
> > available to be pick in the second form dropbox...
> >
> > Is there a way to send a refresh component command on tab-2 clic or
> > something?? Or the only solution be to add a refresh button that to force
> > component reload??
> >
> > Thanks
> >
> > Richard
>


Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Alessandro Iob
Found something: the application folder is named 'Castalia' with the 
first char in uppercase, while the importer tries to import it as 
'applications.castalia', in lowercase.


I've tried from the python shell to import using 
applications.Castalia. and it worked.


On 6/6/11 17:06 , Pierre Thibault wrote:

import sys

sys.path.append("C:\w2p\web2py")

import applications.castalia.modules.selfgroup.castalia


Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Pierre Thibault
2011/6/6 Alessandro Iob 

> Found something: the application folder is named 'Castalia' with the first
> char in uppercase, while the importer tries to import it as
> 'applications.castalia', in lowercase.
>
> I've tried from the python shell to import using applications.Castalia.
> and it worked.
>

Problem solved?


-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)
YouTube page 
(http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2) 


[web2py] Re: See a new GAE site that we developed with some web2py...

2011-06-06 Thread sebastian
I'd like to try it but granting access to me wall. m... 

Re: [web2py] Re: Using web2py's view/template engine in a standalone application

2011-06-06 Thread Thadeus Burgess
What you really want is template.parse_template. Still requires restricted
but only for the exception raising.

Very simple.

from template import parse_template

print parse_template('main.html', path='/path/to/custom/views/',
context=dict())

--
Thadeus




On Mon, Jun 6, 2011 at 12:55 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> It is LGPL not GPL. very different. ;-)
>
> On Jun 6, 12:36 am, Karel Antonio Verdecia Ortiz 
> wrote:
> > Hi,
> >
> > I've been using the web2py template engine for a while. I don't remember
> > if I had to make some change to the template.py module nor the version
> > of the web2py this module comes from so I attach it in this email. This
> > was the way I could make it work (there is probably a simpler one):
> >
> >  from template import TemplateParser
> >
> >  context = {}
> >  output = cStringIO.StringIO()
> >  def response_writer(data, escape=False):
> >  output.write(unicode(data))
> >  context['response_writer'] = response_writer
> >  source = self._template()
> >  exec(str(TemplateParser(source, context=context,
> >  writer='response_writer'))) in context
> >  content = output.getvalue()
> >
> > I have a question about this module. It's GPL3 license. If I modify it
> > an ditribute it in an application, do this application have to be GPL3
> > licensed?
> >
> > I apologize if my english if very bad. My language is spanish.
> >
> > El 06/06/11 00:59, Ryan Seto escribi�:
> >
> >
> >
> >
> >
> >
> >
> > > Thanks! That does solve the import restricted dependency.
> >
> > > The import globals for the Response() object is still an issue.
> >
> > > I tried fiddling with my copy to build a mock Response() object if we
> > > can't import globals.
> >
> > > This is what I have so far:
> >
> > > gluon/template.py | line 867
> > > ~
> > >  # Here to avoid circular Imports
> > >  try:
> > >  from globals import Response
> > >  except:
> > >  import cStringIO
> > >  from xml.sax.saxutils import escape, quoteattr
> > >  class Response():
> > >  def __init__(self):
> > >  self.body = cStringIO.StringIO()
> > >  def write(self, data, escape=True):
> > >  if not escape:
> > >  self.body.write(str(data))
> > >  elif hasattr(data,'xml') and callable(data.xml):
> > >  self.body.write(data.xml())
> > >  else:
> > >  # otherwise, make it a string
> > >  if not isinstance(data, (str, unicode)):
> > >  data = str(data)
> > >  elif isinstance(data, unicode):
> > >  data = data.encode('utf8',
> 'xmlcharrefreplace')
> > >  self.body.write(data)
> > > ~
> >
> > > I was planning to escape the data with the escape and quoteattr
> > > provided from xml.sax.saxutils, but I wasn't successful with that, so
> > > I left it out for now.
> >
> > > Here's my code snippet:
> >
> > > nixie/util/text.py | line 19
> > > ~
> > > import os, subprocess, paths, template
> >
> > > def render(inFile):
> > >  content = pandoc(str(inFile))
> > >  templateFile = os.path.join(paths.get_prog_root(), 'templates',
> 'view.html')
> > >  styles = []
> > >  styles.append(os.path.join(paths.get_prog_root(), 'css',
> 'style.css'))
> > >  return template.render(
> > >  filename=templateFile,
> > >  context=dict(content=content, styles=styles)
> > >  )
> > > ~
> >
> > > templates/view.html
> > > ~
> > > 
> > > 
> > >{{for css in styles:}}
> > >  
> > >{{pass}}
> > > 
> > > 
> > >{{=content}}
> > > 
> > > 
> > > ~
> >
> > > When I run this, I get an error message that doesn't really help me
> > > much.  Here's the output:
> >
> > > ~
> > > C:\projects\nixie>c:\Python26\python.exe Nixie.py README.txt
> > > Traceback (most recent call last):
> > >File "C:\projects\nixie\nixie\qt\NixieAccessManager.py", line 41, in
> > > createRequest
> > >  reply = NixieReply(request.url(), self.GetOperation, parent=self)
> > >File "C:\projects\nixie\nixie\qt\NixieReply.py", line 30, in
> __init__
> > >  self.content = text.render(url.toLocalFile())
> > >File "C:\projects\nixie\nixie\util\text.py", line 22, in render
> > >  content = pandoc(str(inFile))
> > >File "C:\projects\nixie\nixie\util\text.py", line 63, in pandoc
> > >  cwd = cwd
> > >File "c:\Python26\lib\subprocess.py", line 623, in __init__
> > >  errread, errwrite)
> > >File "c:\Python26\lib\subprocess.py", line 833, in _execute_child
> > >  startupinfo)
> > > WindowsError: [Error 123] The filename, directory name, or volume
> > > label syntax is incorrect
> > > ~
> >
> > > Although it looks like pandoc(str(inFile)) might be the culprit from
> > 

Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Alessandro Iob
No, because the web2py code (under Windows only) keeps trying to import 
it in lowercase. I can just rename the application (and it works that 
way), but I think this is just a workaround and not a solution to a 
problem that should not exist.


On 6/6/11 17:44 , Pierre Thibault wrote:

2011/6/6 Alessandro Iob mailto:alessandro@gmail.com>>

Found something: the application folder is named 'Castalia' with the
first char in uppercase, while the importer tries to import it as
'applications.castalia', in lowercase.

I've tried from the python shell to import using
applications.Castalia. and it worked.


Problem solved?


--


A+

-
Pierre
My blog and profile (http://pierrethibault.posterous.com)

YouTube page (http://www.youtube.com/user/tubetib)

Twitter (http://twitter.com/pierreth2) 



[web2py] custom form with validation

2011-06-06 Thread David J.

I am trying to figure out how I can do validation on a custom form

I have an order form;

I need to set credit card expiration date as MM


I have 2 fields 'expire_month' and 'expire_year'

In my layout I manually added 2 select boxes;


Jan
...



2011
...


I need some idea how to validate this input to make sure it is not past 
the current date and obviously put the appropriate error message under 
the field like the rest of the errors being display.


Any help would be appreciated.

Thanks.



[web2py] Re: Merging multiple accounts

2011-06-06 Thread sebastian
I guess that you need to implement it for your self...

Re: [web2py] Re: still with problems at 1.96.3: is_active column not found

2011-06-06 Thread danto
2011/6/5 danto 

> 2011/6/5 Massimo Di Pierro 
>
>> You have migrations set to False. web2py needs to create a field
>> called is_active. Before it was called active and that created
>> problems.
>>
>>
> but my app is not that old... :3 I developed the application little time
> ago (1.94~95) and the is_active column of auth.signature was already there
> and working flawlessly.
>
> I logged in with the shell (-S and -M) throught ssh and
> db.categoria.fields() says that the 'is_active' column is already there! so
> I don't get it :(
>

I solved this manually adding the 'is_active' column in phpmyadmin. as I
said before, shell access to the app showme that db.categoria.fields() HAD
'is_active' column but in fact wasn't exist in db (I checked from
phpmyadmin). this was very weird.


[web2py] Re: How to not show the "delete file" checkbox

2011-06-06 Thread Luis Goncalves
Thanks for the reply! 

I tried that, but it didn't do what I want.

I wasn't very clear in explaining what I'm trying to do (sorry about that!). 
 I have a file upload field in my SQLFORM, and it has a "choose file" 
button, and right next to it a [file| (chk-box) delete]  element..  I want 
to get rid of that element with the checkbox so that you can't delete the 
file.

Maybe that's not possible easily? It's part of the 'upload' field type?

Thanks!!
Luis.


[web2py] Re: custom form with validation

2011-06-06 Thread Anthony
Maybe you could use an onvalidation function (see 
http://web2py.com/book/default/chapter/07#onvalidation). You might also 
consider adding the extra fields directly to the form object (see 
http://web2py.com/book/default/chapter/07#Adding-extra-form-elements-to-SQLFORM)
 
instead of in the view, which may make it easier to add/display errors.
 
Another option might be using SQLFORM.factory (see 
http://web2py.com/book/default/chapter/07#SQLFORM.factory) and creating a 
custom validator (
http://web2py.com/book/default/chapter/07#Custom-Validators).
 
Anthony

On Monday, June 6, 2011 11:55:36 AM UTC-4, David J wrote:

> I am trying to figure out how I can do validation on a custom form 
>
> I have an order form; 
>
> I need to set credit card expiration date as MM 
>
>
> I have 2 fields 'expire_month' and 'expire_year' 
>
> In my layout I manually added 2 select boxes; 
>
> 
> Jan
> ...
>  
>
> 
> 2011
> ...
>  
>
> I need some idea how to validate this input to make sure it is not past 
> the current date and obviously put the appropriate error message under 
> the field like the rest of the errors being display. 
>
> Any help would be appreciated. 
>
> Thanks. 
>
> 

Re: [web2py] Re: How to not show the "delete file" checkbox

2011-06-06 Thread Richard Vézina
Maybe you could try autodelete :
http://web2py.com/book/default/chapter/07?search=upload+#autodelete

Really
not sure it will work, but you could try... But if your record is deleted
you file will be deleted too no matter if it is referenced by an other
record.

http://web2py.com/book/default/chapter/07?search=upload+#autodelete

Richard

On Mon, Jun 6, 2011 at 12:13 PM, Luis Goncalves wrote:

> Thanks for the reply!
>
> I tried that, but it didn't do what I want.
>
> I wasn't very clear in explaining what I'm trying to do (sorry about
> that!).  I have a file upload field in my SQLFORM, and it has a "choose
> file" button, and right next to it a [file| (chk-box) delete]  element..  I
> want to get rid of that element with the checkbox so that you can't delete
> the file.
>
> Maybe that's not possible easily? It's part of the 'upload' field type?
>
> Thanks!!
> Luis.
>


[web2py] Re: RFC: validator IS_NOT_IN_SET

2011-06-06 Thread Rip Ryness
I was looking for IS_NOT_IN_SET today and found this.  Thanks.


[web2py] Re: RFC: validator IS_NOT_IN_SET

2011-06-06 Thread pbreit
Do validators have an opposite such as "not IS_IN_SET()"?

[web2py] Janrain with existing accounts...

2011-06-06 Thread Jason Brower
I have created an auth system with over 100+ users.  They are happy to 
sign in with what they have, but I would like to use janrain as well.  
Is it possible to have both normal login or use a janrain signon?

BR,
Jason Brower



[web2py] About auth.requires_membership()

2011-06-06 Thread Cesar Bustios
Hi, is there a way to use this decorator with more than one group? For
example if i need function X to be use with groups A and B:

@auth.requires_membership('A', 'B')
def X(): ...

That doesn't work. How can I do that?

Thanks


Re: [web2py] Janrain with existing accounts...

2011-06-06 Thread Bruno Rocha
On Mon, Jun 6, 2011 at 1:59 PM, Jason Brower  wrote:

> I have created an auth system with over 100+ users.  They are happy to sign
> in with what they have, but I would like to use janrain as well.  Is it
> possible to have both normal login or use a janrain signon?
> BR,
> Jason Brower


Yes, it is possible, web2py will detect the user as the same of using the
same email for janrain and auth_account

http://web2pyslices.com/main/slices/take_slice/124


Re: [web2py] Re: How to not show the "delete file" checkbox

2011-06-06 Thread Luis Goncalves
Hi Richard!

I'm displaying the form to the user for them to update it.  There are 
several fields in the form, and one of them is an image ('upload' field).  

I just don't want to display the  "delete file" checkbox for the image,  so 
that the user can't delete the image.  They can upload a new one, but they 
can't delete it to not have an image. 

The record itself is not to be deleted either, but that's not even an option 
for the user right now.

Thanks!!

Luis


Re: [web2py] Re: Using web2py's view/template engine in a standalone application

2011-06-06 Thread Ryan Seto
Hm, that doesn't seem to be it either.  I don't get a requirement for
the globals module, but what I get back is this:

~
>>> print parse_template('view.html', path='templates', 
>>> context=dict(content='test'))
response.write(content)
response.write('\r\n', escape=False)
~

Am I supposed to execute what parse_template returns?

Thank you for your help.

On Mon, Jun 6, 2011 at 11:53 AM, Thadeus Burgess  wrote:
> What you really want is template.parse_template. Still requires restricted
> but only for the exception raising.
>
> Very simple.
>
> from template import parse_template
>
> print parse_template('main.html', path='/path/to/custom/views/',
> context=dict())
>
> --
> Thadeus
>
>
>
>
> On Mon, Jun 6, 2011 at 12:55 AM, Massimo Di Pierro
>  wrote:
>>
>> It is LGPL not GPL. very different. ;-)
>>
>> On Jun 6, 12:36 am, Karel Antonio Verdecia Ortiz 
>> wrote:
>> > Hi,
>> >
>> > I've been using the web2py template engine for a while. I don't remember
>> > if I had to make some change to the template.py module nor the version
>> > of the web2py this module comes from so I attach it in this email. This
>> > was the way I could make it work (there is probably a simpler one):
>> >
>> >          from template import TemplateParser
>> >
>> >          context = {}
>> >          output = cStringIO.StringIO()
>> >          def response_writer(data, escape=False):
>> >              output.write(unicode(data))
>> >          context['response_writer'] = response_writer
>> >          source = self._template()
>> >          exec(str(TemplateParser(source, context=context,
>> >              writer='response_writer'))) in context
>> >          content = output.getvalue()
>> >
>> > I have a question about this module. It's GPL3 license. If I modify it
>> > an ditribute it in an application, do this application have to be GPL3
>> > licensed?
>> >
>> > I apologize if my english if very bad. My language is spanish.
>> >
>> > El 06/06/11 00:59, Ryan Seto escribi�:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > Thanks! That does solve the import restricted dependency.
>> >
>> > > The import globals for the Response() object is still an issue.
>> >
>> > > I tried fiddling with my copy to build a mock Response() object if we
>> > > can't import globals.
>> >
>> > > This is what I have so far:
>> >
>> > > gluon/template.py | line 867
>> > > ~
>> > >      # Here to avoid circular Imports
>> > >      try:
>> > >          from globals import Response
>> > >      except:
>> > >          import cStringIO
>> > >          from xml.sax.saxutils import escape, quoteattr
>> > >          class Response():
>> > >              def __init__(self):
>> > >                  self.body = cStringIO.StringIO()
>> > >              def write(self, data, escape=True):
>> > >                  if not escape:
>> > >                      self.body.write(str(data))
>> > >                  elif hasattr(data,'xml') and callable(data.xml):
>> > >                      self.body.write(data.xml())
>> > >                  else:
>> > >                      # otherwise, make it a string
>> > >                      if not isinstance(data, (str, unicode)):
>> > >                          data = str(data)
>> > >                      elif isinstance(data, unicode):
>> > >                          data = data.encode('utf8',
>> > > 'xmlcharrefreplace')
>> > >                      self.body.write(data)
>> > > ~
>> >
>> > > I was planning to escape the data with the escape and quoteattr
>> > > provided from xml.sax.saxutils, but I wasn't successful with that, so
>> > > I left it out for now.
>> >
>> > > Here's my code snippet:
>> >
>> > > nixie/util/text.py | line 19
>> > > ~
>> > > import os, subprocess, paths, template
>> >
>> > > def render(inFile):
>> > >      content = pandoc(str(inFile))
>> > >      templateFile = os.path.join(paths.get_prog_root(), 'templates',
>> > > 'view.html')
>> > >      styles = []
>> > >      styles.append(os.path.join(paths.get_prog_root(), 'css',
>> > > 'style.css'))
>> > >      return template.render(
>> > >              filename=templateFile,
>> > >              context=dict(content=content, styles=styles)
>> > >          )
>> > > ~
>> >
>> > > templates/view.html
>> > > ~
>> > > 
>> > > 
>> > >    {{for css in styles:}}
>> > >      
>> > >    {{pass}}
>> > > 
>> > > 
>> > >    {{=content}}
>> > > 
>> > > 
>> > > ~
>> >
>> > > When I run this, I get an error message that doesn't really help me
>> > > much.  Here's the output:
>> >
>> > > ~
>> > > C:\projects\nixie>c:\Python26\python.exe Nixie.py README.txt
>> > > Traceback (most recent call last):
>> > >    File "C:\projects\nixie\nixie\qt\NixieAccessManager.py", line 41,
>> > > in
>> > > createRequest
>> > >      reply = NixieReply(request.url(), self.GetOperation, parent=self)
>> > >    File "C:\projects\nixie\nixie\qt\NixieReply.py", line 30, in
>> > > __init__
>> > >      self.content = text.render(url.toLocalFile())
>> > >    File "C:\projects\nixie\nix

Re: [web2py] Re: How to not show the "delete file" checkbox

2011-06-06 Thread Anthony
It looks like the upload widget only displays the 'delete' checkbox if 
requires==[] or requires is IS_EMPTY_OR. So, if you set requires to any 
other validator, such as IS_IMAGE or IS_UPLOAD_FILENAME (or maybe a custom 
dummy validator if you don't really want/need any validation), the delete 
checkbox will not appear (the reason is that if you delete the file when 
there is another validator present, it would cause the validation to fail -- 
so the delete checkbox is only shown when there are no validators or the 
IS_EMPTY_OR validator is used).
 
Alternatively, you could use server side DOM parsing to remove the delete 
checkbox (
http://web2py.com/book/default/chapter/05#Server-side-DOM-and-Parsing), or 
write a custom upload widget.
 
Anthony
 
On Monday, June 6, 2011 12:38:19 PM UTC-4, Luis Goncalves wrote:

> Hi Richard!
>
> I'm displaying the form to the user for them to update it.  There are 
> several fields in the form, and one of them is an image ('upload' field).  
>
> I just don't want to display the  "delete file" checkbox for the image,  so 
> that the user can't delete the image.  They can upload a new one, but they 
> can't delete it to not have an image. 
>
> The record itself is not to be deleted either, but that's not even an 
> option for the user right now.
>
> Thanks!!
>
> Luis
>


Re: [web2py] Re: How to not show the "delete file" checkbox

2011-06-06 Thread Richard Vézina
I understand your need!!

I just don't know neither how to do it... It was the only piece of the book
I come up with after few reading and searching...

I thought the option could make the file/delete box to desapered...

Work around could to use jQuery to make the whole block to desapeare... Just
look to the source html render view to know what the ID of the div or other
element it could be and add this jQuery into your view :

$(".class" or ".id").remove();

Richard

On Mon, Jun 6, 2011 at 12:38 PM, Luis Goncalves wrote:

> Hi Richard!
>
> I'm displaying the form to the user for them to update it.  There are
> several fields in the form, and one of them is an image ('upload' field).
>
> I just don't want to display the  "delete file" checkbox for the image,  so
> that the user can't delete the image.  They can upload a new one, but they
> can't delete it to not have an image.
>
> The record itself is not to be deleted either, but that's not even an
> option for the user right now.
>
> Thanks!!
>
> Luis
>


Re: [web2py] About auth.requires_membership()

2011-06-06 Thread Joaquin Orbe
On Mon, Jun 6, 2011 at 2:03 PM, Cesar Bustios  wrote:
> Hi, is there a way to use this decorator with more than one group? For
> example if i need function X to be use with groups A and B:
>
> @auth.requires_membership('A', 'B')
> def X(): ...
>
> That doesn't work. How can I do that?
>
> Thanks
>
Hi,
try this:

@auth.requires(auth.requires_membership('A') or auth.requires_membership('B'))
def X(): ...


Joaquin.


[web2py] Re: About auth.requires_membership()

2011-06-06 Thread Anthony
You may need to do:
 
@auth.requires(auth.has_membership('A') or auth.has_membership('B'))
 
See http://web2py.com/book/default/chapter/08#Combining-Requirements.
 
Anthony

On Monday, June 6, 2011 1:03:54 PM UTC-4, César Bustíos Benites wrote:

> Hi, is there a way to use this decorator with more than one group? For 
> example if i need function X to be use with groups A and B: 
>
> @auth.requires_membership('A', 'B') 
> def X(): ... 
>
> That doesn't work. How can I do that? 
>
> Thanks 
>


[web2py] Re: About auth.requires_membership()

2011-06-06 Thread Cesar Bustios
It's not working :(

On Jun 6, 12:35 pm, Joaquin Orbe  wrote:
> On Mon, Jun 6, 2011 at 2:03 PM, Cesar Bustios  wrote:
> > Hi, is there a way to use this decorator with more than one group? For
> > example if i need function X to be use with groups A and B:
>
> > @auth.requires_membership('A', 'B')
> > def X(): ...
>
> > That doesn't work. How can I do that?
>
> > Thanks
>
> Hi,
> try this:
>
> @auth.requires(auth.requires_membership('A') or auth.requires_membership('B'))
> def X(): ...
>
> Joaquin.


Re: [web2py] About auth.requires_membership()

2011-06-06 Thread Anthony
On Monday, June 6, 2011 1:35:23 PM UTC-4, Joaquin Orbe wrote: 
>
> Hi,
> try this: 
>
> @auth.requires(auth.requires_membership('A') or 
> auth.requires_membership('B'))
> def X(): ...
>
I think it would need to be auth.has_membership, not 
auth.requires_membership (the latter is intended to be used as a decorator 
and therefore returns a function, not a True/False result).
 
Anthony


[web2py] Re: About auth.requires_membership()

2011-06-06 Thread Cesar Bustios
You were right Anthony. Thanks both of you

On Jun 6, 12:42 pm, Cesar Bustios  wrote:
> Wait, but it worked this way:
>
> @auth.requires(auth.has_membership('A') or auth.has_membership('B'))
>
> Thank you,
>
> Cesar B.
>
> On Jun 6, 12:40 pm, Cesar Bustios  wrote:
>
>
>
>
>
>
>
> > It's not working :(
>
> > On Jun 6, 12:35 pm, Joaquin Orbe  wrote:
>
> > > On Mon, Jun 6, 2011 at 2:03 PM, Cesar Bustios  
> > > wrote:
> > > > Hi, is there a way to use this decorator with more than one group? For
> > > > example if i need function X to be use with groups A and B:
>
> > > > @auth.requires_membership('A', 'B')
> > > > def X(): ...
>
> > > > That doesn't work. How can I do that?
>
> > > > Thanks
>
> > > Hi,
> > > try this:
>
> > > @auth.requires(auth.requires_membership('A') or 
> > > auth.requires_membership('B'))
> > > def X(): ...
>
> > > Joaquin.


[web2py] Re: About auth.requires_membership()

2011-06-06 Thread Cesar Bustios
Wait, but it worked this way:

@auth.requires(auth.has_membership('A') or auth.has_membership('B'))

Thank you,

Cesar B.

On Jun 6, 12:40 pm, Cesar Bustios  wrote:
> It's not working :(
>
> On Jun 6, 12:35 pm, Joaquin Orbe  wrote:
>
>
>
>
>
>
>
> > On Mon, Jun 6, 2011 at 2:03 PM, Cesar Bustios  
> > wrote:
> > > Hi, is there a way to use this decorator with more than one group? For
> > > example if i need function X to be use with groups A and B:
>
> > > @auth.requires_membership('A', 'B')
> > > def X(): ...
>
> > > That doesn't work. How can I do that?
>
> > > Thanks
>
> > Hi,
> > try this:
>
> > @auth.requires(auth.requires_membership('A') or 
> > auth.requires_membership('B'))
> > def X(): ...
>
> > Joaquin.


Re: [web2py] Re: Using web2py's view/template engine in a standalone application

2011-06-06 Thread Thadeus Burgess
Yes..

You need some sort of response class that has a .write method... this can be
a hacked up cStringIO or other.

Alternatively you can perform the same thing manually by passing in writer,
which instead of the template engine writing ``response.write("%s")`` it
could write whatever you want as a callable function.


So for example, say you defined your ``CustomResponse`` class as earlier in
the list...

context['response'] = CustomReponse()
exec(parse_template(...)) in context
print context['response'].body.getvalue()

SO yeah... in the end if we implemented your suggestion of overriding the
response class on import, then the render function would work as expected.

--
Thadeus




On Mon, Jun 6, 2011 at 12:26 PM, Ryan Seto  wrote:

> Hm, that doesn't seem to be it either.  I don't get a requirement for
> the globals module, but what I get back is this:
>
> ~
> >>> print parse_template('view.html', path='templates',
> context=dict(content='test'))
> response.write(content)
> response.write('\r\n', escape=False)
> ~
>
> Am I supposed to execute what parse_template returns?
>
> Thank you for your help.
>
> On Mon, Jun 6, 2011 at 11:53 AM, Thadeus Burgess 
> wrote:
> > What you really want is template.parse_template. Still requires
> restricted
> > but only for the exception raising.
> >
> > Very simple.
> >
> > from template import parse_template
> >
> > print parse_template('main.html', path='/path/to/custom/views/',
> > context=dict())
> >
> > --
> > Thadeus
> >
> >
> >
> >
> > On Mon, Jun 6, 2011 at 12:55 AM, Massimo Di Pierro
> >  wrote:
> >>
> >> It is LGPL not GPL. very different. ;-)
> >>
> >> On Jun 6, 12:36 am, Karel Antonio Verdecia Ortiz 
> >> wrote:
> >> > Hi,
> >> >
> >> > I've been using the web2py template engine for a while. I don't
> remember
> >> > if I had to make some change to the template.py module nor the version
> >> > of the web2py this module comes from so I attach it in this email.
> This
> >> > was the way I could make it work (there is probably a simpler one):
> >> >
> >> >  from template import TemplateParser
> >> >
> >> >  context = {}
> >> >  output = cStringIO.StringIO()
> >> >  def response_writer(data, escape=False):
> >> >  output.write(unicode(data))
> >> >  context['response_writer'] = response_writer
> >> >  source = self._template()
> >> >  exec(str(TemplateParser(source, context=context,
> >> >  writer='response_writer'))) in context
> >> >  content = output.getvalue()
> >> >
> >> > I have a question about this module. It's GPL3 license. If I modify it
> >> > an ditribute it in an application, do this application have to be GPL3
> >> > licensed?
> >> >
> >> > I apologize if my english if very bad. My language is spanish.
> >> >
> >> > El 06/06/11 00:59, Ryan Seto escribi�:
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > > Thanks! That does solve the import restricted dependency.
> >> >
> >> > > The import globals for the Response() object is still an issue.
> >> >
> >> > > I tried fiddling with my copy to build a mock Response() object if
> we
> >> > > can't import globals.
> >> >
> >> > > This is what I have so far:
> >> >
> >> > > gluon/template.py | line 867
> >> > > ~
> >> > >  # Here to avoid circular Imports
> >> > >  try:
> >> > >  from globals import Response
> >> > >  except:
> >> > >  import cStringIO
> >> > >  from xml.sax.saxutils import escape, quoteattr
> >> > >  class Response():
> >> > >  def __init__(self):
> >> > >  self.body = cStringIO.StringIO()
> >> > >  def write(self, data, escape=True):
> >> > >  if not escape:
> >> > >  self.body.write(str(data))
> >> > >  elif hasattr(data,'xml') and callable(data.xml):
> >> > >  self.body.write(data.xml())
> >> > >  else:
> >> > >  # otherwise, make it a string
> >> > >  if not isinstance(data, (str, unicode)):
> >> > >  data = str(data)
> >> > >  elif isinstance(data, unicode):
> >> > >  data = data.encode('utf8',
> >> > > 'xmlcharrefreplace')
> >> > >  self.body.write(data)
> >> > > ~
> >> >
> >> > > I was planning to escape the data with the escape and quoteattr
> >> > > provided from xml.sax.saxutils, but I wasn't successful with that,
> so
> >> > > I left it out for now.
> >> >
> >> > > Here's my code snippet:
> >> >
> >> > > nixie/util/text.py | line 19
> >> > > ~
> >> > > import os, subprocess, paths, template
> >> >
> >> > > def render(inFile):
> >> > >  content = pandoc(str(inFile))
> >> > >  templateFile = os.path.join(paths.get_prog_root(), 'templates',
> >> > > 'view.html')
> >> > >  styles = []
> >> > >  styles.append(os.path.join(paths.get_prog_root(), 'css',
> >> 

[web2py] issue with field name id

2011-06-06 Thread Richard Vézina
Hello,

I just try my app with the 1.96.3 and I got a strange error :

Traceback (most recent call last):
  File "/version_196-3/web2py/gluon/restricted.py", line 184, in restricted
exec ccode in environment
  File "/version_196-3/web2py/applications/sgddms/controllers/test.py", line
1334, in 
  File "/version_196-3/web2py/gluon/globals.py", line 137, in 
self._caller = lambda f: f()
  File "/version_196-3/web2py/gluon/tools.py", line 2452, in f
return action(*a, **b)
  File "/version_196-3/web2py/applications/sgddms/controllers/test.py", line
654, in verify
if form.accepts(request.vars, session):
  File "/version_196-3/web2py/gluon/sqlhtml.py", line 1203, in accepts
self.table._db(self.table.id == self.record.id).update(**fields)
  File "/version_196-3/web2py/gluon/dal.py", line 5369, in update
fields = self.db[tablename]._listify(update_fields,update=True)
  File "/version_196-3/web2py/gluon/dal.py", line 4656, in _listify
raise SyntaxError, 'Field %s does not belong to the table' % name
SyntaxError: Field id does not belong to the table

  def _listify(self,fields,update=False):
new_fields = []
new_fields_names = []
for name in fields:
if not name in self.fields:
raise SyntaxError, 'Field %s does not belong to the
table' % name

new_fields.append((self[name],fields[name]))
new_fields_names.append(name)
for ofield in self:
if not ofield.name in new_fields_names:



*I use a old app and a feature for Postgres that Massimo added in the
pass that never been documented and i don't think it was official :*

*
*

*MODEL :*

*Field('table_id','id'), # My legacy database used the same name as PK
and FK so I had to define them in the model like this*

*sequence_name='test_activity_activity_id_seq' # Postgres has it on
automation rule to create the sequence name base on the PK name and
because I where using legacy database PK name I had also to define the
sequence name in my model...*

*
*

*Not sure if there is a link.*

*
*

*Thanks*

*
*

*Richard*

*
*

*
*


Re: [web2py] Re: Using web2py's view/template engine in a standalone application

2011-06-06 Thread Ryan Seto
I see.

Would you like me to try and come up with a patch for this?

On Mon, Jun 6, 2011 at 1:53 PM, Thadeus Burgess  wrote:
> Yes..
>
> You need some sort of response class that has a .write method... this can be
> a hacked up cStringIO or other.
>
> Alternatively you can perform the same thing manually by passing in writer,
> which instead of the template engine writing ``response.write("%s")`` it
> could write whatever you want as a callable function.
>
>
> So for example, say you defined your ``CustomResponse`` class as earlier in
> the list...
>
> context['response'] = CustomReponse()
> exec(parse_template(...)) in context
> print context['response'].body.getvalue()
>
> SO yeah... in the end if we implemented your suggestion of overriding the
> response class on import, then the render function would work as expected.
>
> --
> Thadeus
>
>
>
>
> On Mon, Jun 6, 2011 at 12:26 PM, Ryan Seto  wrote:
>>
>> Hm, that doesn't seem to be it either.  I don't get a requirement for
>> the globals module, but what I get back is this:
>>
>> ~
>> >>> print parse_template('view.html', path='templates',
>> >>> context=dict(content='test'))
>> response.write(content)
>> response.write('\r\n', escape=False)
>> ~
>>
>> Am I supposed to execute what parse_template returns?
>>
>> Thank you for your help.
>>
>> On Mon, Jun 6, 2011 at 11:53 AM, Thadeus Burgess 
>> wrote:
>> > What you really want is template.parse_template. Still requires
>> > restricted
>> > but only for the exception raising.
>> >
>> > Very simple.
>> >
>> > from template import parse_template
>> >
>> > print parse_template('main.html', path='/path/to/custom/views/',
>> > context=dict())
>> >
>> > --
>> > Thadeus
>> >
>> >
>> >
>> >
>> > On Mon, Jun 6, 2011 at 12:55 AM, Massimo Di Pierro
>> >  wrote:
>> >>
>> >> It is LGPL not GPL. very different. ;-)
>> >>
>> >> On Jun 6, 12:36 am, Karel Antonio Verdecia Ortiz 
>> >> wrote:
>> >> > Hi,
>> >> >
>> >> > I've been using the web2py template engine for a while. I don't
>> >> > remember
>> >> > if I had to make some change to the template.py module nor the
>> >> > version
>> >> > of the web2py this module comes from so I attach it in this email.
>> >> > This
>> >> > was the way I could make it work (there is probably a simpler one):
>> >> >
>> >> >          from template import TemplateParser
>> >> >
>> >> >          context = {}
>> >> >          output = cStringIO.StringIO()
>> >> >          def response_writer(data, escape=False):
>> >> >              output.write(unicode(data))
>> >> >          context['response_writer'] = response_writer
>> >> >          source = self._template()
>> >> >          exec(str(TemplateParser(source, context=context,
>> >> >              writer='response_writer'))) in context
>> >> >          content = output.getvalue()
>> >> >
>> >> > I have a question about this module. It's GPL3 license. If I modify
>> >> > it
>> >> > an ditribute it in an application, do this application have to be
>> >> > GPL3
>> >> > licensed?
>> >> >
>> >> > I apologize if my english if very bad. My language is spanish.
>> >> >
>> >> > El 06/06/11 00:59, Ryan Seto escribi�:
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > > Thanks! That does solve the import restricted dependency.
>> >> >
>> >> > > The import globals for the Response() object is still an issue.
>> >> >
>> >> > > I tried fiddling with my copy to build a mock Response() object if
>> >> > > we
>> >> > > can't import globals.
>> >> >
>> >> > > This is what I have so far:
>> >> >
>> >> > > gluon/template.py | line 867
>> >> > > ~
>> >> > >      # Here to avoid circular Imports
>> >> > >      try:
>> >> > >          from globals import Response
>> >> > >      except:
>> >> > >          import cStringIO
>> >> > >          from xml.sax.saxutils import escape, quoteattr
>> >> > >          class Response():
>> >> > >              def __init__(self):
>> >> > >                  self.body = cStringIO.StringIO()
>> >> > >              def write(self, data, escape=True):
>> >> > >                  if not escape:
>> >> > >                      self.body.write(str(data))
>> >> > >                  elif hasattr(data,'xml') and callable(data.xml):
>> >> > >                      self.body.write(data.xml())
>> >> > >                  else:
>> >> > >                      # otherwise, make it a string
>> >> > >                      if not isinstance(data, (str, unicode)):
>> >> > >                          data = str(data)
>> >> > >                      elif isinstance(data, unicode):
>> >> > >                          data = data.encode('utf8',
>> >> > > 'xmlcharrefreplace')
>> >> > >                      self.body.write(data)
>> >> > > ~
>> >> >
>> >> > > I was planning to escape the data with the escape and quoteattr
>> >> > > provided from xml.sax.saxutils, but I wasn't successful with that,
>> >> > > so
>> >> > > I left it out for now.
>> >> >
>> >> > > Here's my code snippet:
>> >> >
>> >> > > nixie/util/text.py | line 19
>>

[web2py] Working with Select Boxes.

2011-06-06 Thread David J.

How do I persist the values in my Select Box?

In my view I did

{{=SELECT(range(10)) }}

When I submit the form it returns to the first value.

Thanks.




Re: [web2py] Working with Select Boxes.

2011-06-06 Thread Richard Vézina
It could help if you show us your view and controller code...

Richard

On Mon, Jun 6, 2011 at 2:17 PM, David J.  wrote:

> How do I persist the values in my Select Box?
>
> In my view I did
>
> {{=SELECT(range(10)) }}
>
> When I submit the form it returns to the first value.
>
> Thanks.
>
>
>


Re: [web2py] Re: Using web2py's view/template engine in a standalone application

2011-06-06 Thread Thadeus Burgess
What you have looked good. The exception looks like its pandocs fault not
the template system.

--
Thadeus




On Mon, Jun 6, 2011 at 1:03 PM, Ryan Seto  wrote:

> I see.
>
> Would you like me to try and come up with a patch for this?
>
> On Mon, Jun 6, 2011 at 1:53 PM, Thadeus Burgess 
> wrote:
> > Yes..
> >
> > You need some sort of response class that has a .write method... this can
> be
> > a hacked up cStringIO or other.
> >
> > Alternatively you can perform the same thing manually by passing in
> writer,
> > which instead of the template engine writing ``response.write("%s")`` it
> > could write whatever you want as a callable function.
> >
> >
> > So for example, say you defined your ``CustomResponse`` class as earlier
> in
> > the list...
> >
> > context['response'] = CustomReponse()
> > exec(parse_template(...)) in context
> > print context['response'].body.getvalue()
> >
> > SO yeah... in the end if we implemented your suggestion of overriding the
> > response class on import, then the render function would work as
> expected.
> >
> > --
> > Thadeus
> >
> >
> >
> >
> > On Mon, Jun 6, 2011 at 12:26 PM, Ryan Seto 
> wrote:
> >>
> >> Hm, that doesn't seem to be it either.  I don't get a requirement for
> >> the globals module, but what I get back is this:
> >>
> >> ~
> >> >>> print parse_template('view.html', path='templates',
> >> >>> context=dict(content='test'))
> >> response.write(content)
> >> response.write('\r\n', escape=False)
> >> ~
> >>
> >> Am I supposed to execute what parse_template returns?
> >>
> >> Thank you for your help.
> >>
> >> On Mon, Jun 6, 2011 at 11:53 AM, Thadeus Burgess  >
> >> wrote:
> >> > What you really want is template.parse_template. Still requires
> >> > restricted
> >> > but only for the exception raising.
> >> >
> >> > Very simple.
> >> >
> >> > from template import parse_template
> >> >
> >> > print parse_template('main.html', path='/path/to/custom/views/',
> >> > context=dict())
> >> >
> >> > --
> >> > Thadeus
> >> >
> >> >
> >> >
> >> >
> >> > On Mon, Jun 6, 2011 at 12:55 AM, Massimo Di Pierro
> >> >  wrote:
> >> >>
> >> >> It is LGPL not GPL. very different. ;-)
> >> >>
> >> >> On Jun 6, 12:36 am, Karel Antonio Verdecia Ortiz 
> >> >> wrote:
> >> >> > Hi,
> >> >> >
> >> >> > I've been using the web2py template engine for a while. I don't
> >> >> > remember
> >> >> > if I had to make some change to the template.py module nor the
> >> >> > version
> >> >> > of the web2py this module comes from so I attach it in this email.
> >> >> > This
> >> >> > was the way I could make it work (there is probably a simpler one):
> >> >> >
> >> >> >  from template import TemplateParser
> >> >> >
> >> >> >  context = {}
> >> >> >  output = cStringIO.StringIO()
> >> >> >  def response_writer(data, escape=False):
> >> >> >  output.write(unicode(data))
> >> >> >  context['response_writer'] = response_writer
> >> >> >  source = self._template()
> >> >> >  exec(str(TemplateParser(source, context=context,
> >> >> >  writer='response_writer'))) in context
> >> >> >  content = output.getvalue()
> >> >> >
> >> >> > I have a question about this module. It's GPL3 license. If I modify
> >> >> > it
> >> >> > an ditribute it in an application, do this application have to be
> >> >> > GPL3
> >> >> > licensed?
> >> >> >
> >> >> > I apologize if my english if very bad. My language is spanish.
> >> >> >
> >> >> > El 06/06/11 00:59, Ryan Seto escribi�:
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > > Thanks! That does solve the import restricted dependency.
> >> >> >
> >> >> > > The import globals for the Response() object is still an issue.
> >> >> >
> >> >> > > I tried fiddling with my copy to build a mock Response() object
> if
> >> >> > > we
> >> >> > > can't import globals.
> >> >> >
> >> >> > > This is what I have so far:
> >> >> >
> >> >> > > gluon/template.py | line 867
> >> >> > > ~
> >> >> > >  # Here to avoid circular Imports
> >> >> > >  try:
> >> >> > >  from globals import Response
> >> >> > >  except:
> >> >> > >  import cStringIO
> >> >> > >  from xml.sax.saxutils import escape, quoteattr
> >> >> > >  class Response():
> >> >> > >  def __init__(self):
> >> >> > >  self.body = cStringIO.StringIO()
> >> >> > >  def write(self, data, escape=True):
> >> >> > >  if not escape:
> >> >> > >  self.body.write(str(data))
> >> >> > >  elif hasattr(data,'xml') and callable(data.xml):
> >> >> > >  self.body.write(data.xml())
> >> >> > >  else:
> >> >> > >  # otherwise, make it a string
> >> >> > >  if not isinstance(data, (str, unicode)):
> >> >> > >  data = str(data)
> >> >> > >  elif isinstance(data, unicode)

Re: [web2py] Re: Using web2py's view/template engine in a standalone application

2011-06-06 Thread Ryan Seto
If you could, let me try and get my solution to work.

When I'm done, should I post a patch here in the group or should I
email it directly to you?

On Mon, Jun 6, 2011 at 2:26 PM, Thadeus Burgess  wrote:
> What you have looked good. The exception looks like its pandocs fault not
> the template system.
>
> --
> Thadeus
>
>
>
>
> On Mon, Jun 6, 2011 at 1:03 PM, Ryan Seto  wrote:
>>
>> I see.
>>
>> Would you like me to try and come up with a patch for this?
>>
>> On Mon, Jun 6, 2011 at 1:53 PM, Thadeus Burgess 
>> wrote:
>> > Yes..
>> >
>> > You need some sort of response class that has a .write method... this
>> > can be
>> > a hacked up cStringIO or other.
>> >
>> > Alternatively you can perform the same thing manually by passing in
>> > writer,
>> > which instead of the template engine writing ``response.write("%s")`` it
>> > could write whatever you want as a callable function.
>> >
>> >
>> > So for example, say you defined your ``CustomResponse`` class as earlier
>> > in
>> > the list...
>> >
>> > context['response'] = CustomReponse()
>> > exec(parse_template(...)) in context
>> > print context['response'].body.getvalue()
>> >
>> > SO yeah... in the end if we implemented your suggestion of overriding
>> > the
>> > response class on import, then the render function would work as
>> > expected.
>> >
>> > --
>> > Thadeus
>> >
>> >
>> >
>> >
>> > On Mon, Jun 6, 2011 at 12:26 PM, Ryan Seto 
>> > wrote:
>> >>
>> >> Hm, that doesn't seem to be it either.  I don't get a requirement for
>> >> the globals module, but what I get back is this:
>> >>
>> >> ~
>> >> >>> print parse_template('view.html', path='templates',
>> >> >>> context=dict(content='test'))
>> >> response.write(content)
>> >> response.write('\r\n', escape=False)
>> >> ~
>> >>
>> >> Am I supposed to execute what parse_template returns?
>> >>
>> >> Thank you for your help.
>> >>
>> >> On Mon, Jun 6, 2011 at 11:53 AM, Thadeus Burgess
>> >> 
>> >> wrote:
>> >> > What you really want is template.parse_template. Still requires
>> >> > restricted
>> >> > but only for the exception raising.
>> >> >
>> >> > Very simple.
>> >> >
>> >> > from template import parse_template
>> >> >
>> >> > print parse_template('main.html', path='/path/to/custom/views/',
>> >> > context=dict())
>> >> >
>> >> > --
>> >> > Thadeus
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On Mon, Jun 6, 2011 at 12:55 AM, Massimo Di Pierro
>> >> >  wrote:
>> >> >>
>> >> >> It is LGPL not GPL. very different. ;-)
>> >> >>
>> >> >> On Jun 6, 12:36 am, Karel Antonio Verdecia Ortiz 
>> >> >> wrote:
>> >> >> > Hi,
>> >> >> >
>> >> >> > I've been using the web2py template engine for a while. I don't
>> >> >> > remember
>> >> >> > if I had to make some change to the template.py module nor the
>> >> >> > version
>> >> >> > of the web2py this module comes from so I attach it in this email.
>> >> >> > This
>> >> >> > was the way I could make it work (there is probably a simpler
>> >> >> > one):
>> >> >> >
>> >> >> >          from template import TemplateParser
>> >> >> >
>> >> >> >          context = {}
>> >> >> >          output = cStringIO.StringIO()
>> >> >> >          def response_writer(data, escape=False):
>> >> >> >              output.write(unicode(data))
>> >> >> >          context['response_writer'] = response_writer
>> >> >> >          source = self._template()
>> >> >> >          exec(str(TemplateParser(source, context=context,
>> >> >> >              writer='response_writer'))) in context
>> >> >> >          content = output.getvalue()
>> >> >> >
>> >> >> > I have a question about this module. It's GPL3 license. If I
>> >> >> > modify
>> >> >> > it
>> >> >> > an ditribute it in an application, do this application have to be
>> >> >> > GPL3
>> >> >> > licensed?
>> >> >> >
>> >> >> > I apologize if my english if very bad. My language is spanish.
>> >> >> >
>> >> >> > El 06/06/11 00:59, Ryan Seto escribi�:
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > > Thanks! That does solve the import restricted dependency.
>> >> >> >
>> >> >> > > The import globals for the Response() object is still an issue.
>> >> >> >
>> >> >> > > I tried fiddling with my copy to build a mock Response() object
>> >> >> > > if
>> >> >> > > we
>> >> >> > > can't import globals.
>> >> >> >
>> >> >> > > This is what I have so far:
>> >> >> >
>> >> >> > > gluon/template.py | line 867
>> >> >> > > ~
>> >> >> > >      # Here to avoid circular Imports
>> >> >> > >      try:
>> >> >> > >          from globals import Response
>> >> >> > >      except:
>> >> >> > >          import cStringIO
>> >> >> > >          from xml.sax.saxutils import escape, quoteattr
>> >> >> > >          class Response():
>> >> >> > >              def __init__(self):
>> >> >> > >                  self.body = cStringIO.StringIO()
>> >> >> > >              def write(self, data, escape=True):
>> >> >> > >                  if not escape:
>> >> >> > >                      self.body.write(str(data))
>> >> >> > > 

[web2py] How to start web2py server permanently

2011-06-06 Thread Pradeesh
I have installed web2py on a remote opensuse server 10.3 and I am
using a Putty to start the web2py server. But when i am closing the
Putty session in my machine, the web2py server is also closing. How do
I start web2py server permanantly.


Re: [web2py] How to start web2py server permanently

2011-06-06 Thread danto
2011/6/6 Pradeesh 

> I have installed web2py on a remote opensuse server 10.3 and I am
> using a Putty to start the web2py server. But when i am closing the
> Putty session in my machine, the web2py server is also closing. How do
> I start web2py server permanantly.


you should set up a server as cherokee, apache or nginx. but for what you
say, run 'screen' and then web2py on it. exit with ctrl+a+d


[web2py] Re: issue with field name id

2011-06-06 Thread Massimo Di Pierro
I think I fixed this in trunk. Can you please check it?

On Jun 6, 1:03 pm, Richard Vézina  wrote:
> Hello,
>
> I just try my app with the 1.96.3 and I got a strange error :
>
> Traceback (most recent call last):
>   File "/version_196-3/web2py/gluon/restricted.py", line 184, in restricted
>     exec ccode in environment
>   File "/version_196-3/web2py/applications/sgddms/controllers/test.py", line
> 1334, in 
>   File "/version_196-3/web2py/gluon/globals.py", line 137, in 
>     self._caller = lambda f: f()
>   File "/version_196-3/web2py/gluon/tools.py", line 2452, in f
>     return action(*a, **b)
>   File "/version_196-3/web2py/applications/sgddms/controllers/test.py", line
> 654, in verify
>     if form.accepts(request.vars, session):
>   File "/version_196-3/web2py/gluon/sqlhtml.py", line 1203, in accepts
>     self.table._db(self.table.id == self.record.id).update(**fields)
>   File "/version_196-3/web2py/gluon/dal.py", line 5369, in update
>     fields = self.db[tablename]._listify(update_fields,update=True)
>   File "/version_196-3/web2py/gluon/dal.py", line 4656, in _listify
>     raise SyntaxError, 'Field %s does not belong to the table' % name
> SyntaxError: Field id does not belong to the table
>
>   def _listify(self,fields,update=False):
>         new_fields = []
>         new_fields_names = []
>         for name in fields:
>             if not name in self.fields:
>                 raise SyntaxError, 'Field %s does not belong to the
> table' % name
>
>             new_fields.append((self[name],fields[name]))
>             new_fields_names.append(name)
>         for ofield in self:
>             if not ofield.name in new_fields_names:
>
> *I use a old app and a feature for Postgres that Massimo added in the
> pass that never been documented and i don't think it was official :*
>
> *
> *
>
> *MODEL :*
>
> *Field('table_id','id'), # My legacy database used the same name as PK
> and FK so I had to define them in the model like this*
>
> *sequence_name='test_activity_activity_id_seq' # Postgres has it on
> automation rule to create the sequence name base on the PK name and
> because I where using legacy database PK name I had also to define the
> sequence name in my model...*
>
> *
> *
>
> *Not sure if there is a link.*
>
> *
> *
>
> *Thanks*
>
> *
> *
>
> *Richard*
>
> *
> *
>
> *
> *


[web2py] using the DAL standalone

2011-06-06 Thread apple
I would like to be able to use the DAL to run standalone scripts to
query a database. I have managed to get this working by adding a "from
gluon import *" to mymodel and running the code below:

import sys
sys.path.append("c:/web2py")
sys.path.append("c:/web2py/applications/crm/models")
from gluon import *
from mymodel import *
result = db(db["customer"]).select()
print(result)

However if there is a reference to auth then I need to also change
mymodel to include:
  from gluon.tools import *
  auth = Auth(globals(),db)
This fails because there is no request. Is there a way round this to
make web2py think it is running a server?


[web2py] Re: Using web2py's view/template engine in a standalone application

2011-06-06 Thread Massimo Di Pierro
somebody email me the patch. :-)

On Jun 6, 1:26 pm, Thadeus Burgess  wrote:
> What you have looked good. The exception looks like its pandocs fault not
> the template system.
>
> --
> Thadeus
>
>
>
>
>
>
>
> On Mon, Jun 6, 2011 at 1:03 PM, Ryan Seto  wrote:
> > I see.
>
> > Would you like me to try and come up with a patch for this?
>
> > On Mon, Jun 6, 2011 at 1:53 PM, Thadeus Burgess 
> > wrote:
> > > Yes..
>
> > > You need some sort of response class that has a .write method... this can
> > be
> > > a hacked up cStringIO or other.
>
> > > Alternatively you can perform the same thing manually by passing in
> > writer,
> > > which instead of the template engine writing ``response.write("%s")`` it
> > > could write whatever you want as a callable function.
>
> > > So for example, say you defined your ``CustomResponse`` class as earlier
> > in
> > > the list...
>
> > > context['response'] = CustomReponse()
> > > exec(parse_template(...)) in context
> > > print context['response'].body.getvalue()
>
> > > SO yeah... in the end if we implemented your suggestion of overriding the
> > > response class on import, then the render function would work as
> > expected.
>
> > > --
> > > Thadeus
>
> > > On Mon, Jun 6, 2011 at 12:26 PM, Ryan Seto 
> > wrote:
>
> > >> Hm, that doesn't seem to be it either.  I don't get a requirement for
> > >> the globals module, but what I get back is this:
>
> > >> ~
> > >> >>> print parse_template('view.html', path='templates',
> > >> >>> context=dict(content='test'))
> > >> response.write(content)
> > >> response.write('\r\n', escape=False)
> > >> ~
>
> > >> Am I supposed to execute what parse_template returns?
>
> > >> Thank you for your help.
>
> > >> On Mon, Jun 6, 2011 at 11:53 AM, Thadeus Burgess 
> > >> wrote:
> > >> > What you really want is template.parse_template. Still requires
> > >> > restricted
> > >> > but only for the exception raising.
>
> > >> > Very simple.
>
> > >> > from template import parse_template
>
> > >> > print parse_template('main.html', path='/path/to/custom/views/',
> > >> > context=dict())
>
> > >> > --
> > >> > Thadeus
>
> > >> > On Mon, Jun 6, 2011 at 12:55 AM, Massimo Di Pierro
> > >> >  wrote:
>
> > >> >> It is LGPL not GPL. very different. ;-)
>
> > >> >> On Jun 6, 12:36 am, Karel Antonio Verdecia Ortiz 
> > >> >> wrote:
> > >> >> > Hi,
>
> > >> >> > I've been using the web2py template engine for a while. I don't
> > >> >> > remember
> > >> >> > if I had to make some change to the template.py module nor the
> > >> >> > version
> > >> >> > of the web2py this module comes from so I attach it in this email.
> > >> >> > This
> > >> >> > was the way I could make it work (there is probably a simpler one):
>
> > >> >> >          from template import TemplateParser
>
> > >> >> >          context = {}
> > >> >> >          output = cStringIO.StringIO()
> > >> >> >          def response_writer(data, escape=False):
> > >> >> >              output.write(unicode(data))
> > >> >> >          context['response_writer'] = response_writer
> > >> >> >          source = self._template()
> > >> >> >          exec(str(TemplateParser(source, context=context,
> > >> >> >              writer='response_writer'))) in context
> > >> >> >          content = output.getvalue()
>
> > >> >> > I have a question about this module. It's GPL3 license. If I modify
> > >> >> > it
> > >> >> > an ditribute it in an application, do this application have to be
> > >> >> > GPL3
> > >> >> > licensed?
>
> > >> >> > I apologize if my english if very bad. My language is spanish.
>
> > >> >> > El 06/06/11 00:59, Ryan Seto escribi�:
>
> > >> >> > > Thanks! That does solve the import restricted dependency.
>
> > >> >> > > The import globals for the Response() object is still an issue.
>
> > >> >> > > I tried fiddling with my copy to build a mock Response() object
> > if
> > >> >> > > we
> > >> >> > > can't import globals.
>
> > >> >> > > This is what I have so far:
>
> > >> >> > > gluon/template.py | line 867
> > >> >> > > ~
> > >> >> > >      # Here to avoid circular Imports
> > >> >> > >      try:
> > >> >> > >          from globals import Response
> > >> >> > >      except:
> > >> >> > >          import cStringIO
> > >> >> > >          from xml.sax.saxutils import escape, quoteattr
> > >> >> > >          class Response():
> > >> >> > >              def __init__(self):
> > >> >> > >                  self.body = cStringIO.StringIO()
> > >> >> > >              def write(self, data, escape=True):
> > >> >> > >                  if not escape:
> > >> >> > >                      self.body.write(str(data))
> > >> >> > >                  elif hasattr(data,'xml') and callable(data.xml):
> > >> >> > >                      self.body.write(data.xml())
> > >> >> > >                  else:
> > >> >> > >                      # otherwise, make it a string
> > >> >> > >                      if not isinstance(data, (str, unicode)):
> > >> >> > >                          data = str(data)
> > >> >> > >

Re: [web2py] using the DAL standalone

2011-06-06 Thread Martín Mulone
I don't think you can do this now or soon I think because auth depends too
much from session, response, and request and all of this are core of web2py.
But you can access to the auth_user table using dal.

2011/6/6 apple 

> I would like to be able to use the DAL to run standalone scripts to
> query a database. I have managed to get this working by adding a "from
> gluon import *" to mymodel and running the code below:
>
> import sys
> sys.path.append("c:/web2py")
> sys.path.append("c:/web2py/applications/crm/models")
> from gluon import *
> from mymodel import *
> result = db(db["customer"]).select()
> print(result)
>
> However if there is a reference to auth then I need to also change
> mymodel to include:
>  from gluon.tools import *
>  auth = Auth(globals(),db)
> This fails because there is no request. Is there a way round this to
> make web2py think it is running a server?




-- 
 http://martin.tecnodoc.com.ar


[web2py] Re: using the DAL standalone

2011-06-06 Thread Massimo Di Pierro
import sys
sys.path.append("c:/web2py")
from gluon import *

db = DAL('sqlite://...', folder="c:/web2py/applications/crm/
models",auto_import=True)

result = db(db["customer"]).select()
print(result)

On Jun 6, 2:05 pm, apple  wrote:
> I would like to be able to use the DAL to run standalone scripts to
> query a database. I have managed to get this working by adding a "from
> gluon import *" to mymodel and running the code below:
>
> import sys
> sys.path.append("c:/web2py")
> sys.path.append("c:/web2py/applications/crm/models")
> from gluon import *
> from mymodel import *
> result = db(db["customer"]).select()
> print(result)
>
> However if there is a reference to auth then I need to also change
> mymodel to include:
>       from gluon.tools import *
>       auth = Auth(globals(),db)
> This fails because there is no request. Is there a way round this to
> make web2py think it is running a server?


[web2py] Re: using the DAL standalone

2011-06-06 Thread apple
I ran that (assuming you meant refer to the databases folder). However
it gives an error:

Traceback (most recent call last):
  File "C:\web2py\applications\crm\controllers\querytest.py", line 4,
in 
db = DAL('sqlite://storage.sqlite', folder='c:/web2py/applications/
crm/databases', auto_import=True)
  File "c:/web2py\gluon\dal.py", line 3903, in __init__
self.import_table_definitions(adapter.folder)
  File "c:/web2py\gluon\dal.py", line 3913, in
import_table_definitions
mf.sort()
  File "c:/web2py\gluon\dal.py", line 4919, in __eq__
return Query(self.db, self.db._adapter.EQ, self, value)
AttributeError: 'NoneType' object has no attribute '_adapter'

On Jun 6, 8:14 pm, Massimo Di Pierro 
wrote:
> import sys
> sys.path.append("c:/web2py")
> from gluon import *
>
> db = DAL('sqlite://...', folder="c:/web2py/applications/crm/
> models",auto_import=True)
>
> result = db(db["customer"]).select()
> print(result)
>
> On Jun 6, 2:05 pm, apple  wrote:
>
>
>
>
>
>
>
> > I would like to be able to use the DAL to run standalone scripts to
> > query a database. I have managed to get this working by adding a "from
> > gluon import *" to mymodel and running the code below:
>
> > import sys
> > sys.path.append("c:/web2py")
> > sys.path.append("c:/web2py/applications/crm/models")
> > from gluon import *
> > from mymodel import *
> > result = db(db["customer"]).select()
> > print(result)
>
> > However if there is a reference to auth then I need to also change
> > mymodel to include:
> >       from gluon.tools import *
> >       auth = Auth(globals(),db)
> > This fails because there is no request. Is there a way round this to
> > make web2py think it is running a server?


Re: [web2py] Re: using the DAL standalone

2011-06-06 Thread Martín Mulone
No the model folders. I didn't know this exists.

2011/6/6 apple 

> I ran that (assuming you meant refer to the databases folder). However
> it gives an error:
>
> Traceback (most recent call last):
>  File "C:\web2py\applications\crm\controllers\querytest.py", line 4,
> in 
>db = DAL('sqlite://storage.sqlite', folder='c:/web2py/applications/
> crm/databases', auto_import=True)
>  File "c:/web2py\gluon\dal.py", line 3903, in __init__
>self.import_table_definitions(adapter.folder)
>  File "c:/web2py\gluon\dal.py", line 3913, in
> import_table_definitions
>mf.sort()
>  File "c:/web2py\gluon\dal.py", line 4919, in __eq__
>return Query(self.db, self.db._adapter.EQ, self, value)
> AttributeError: 'NoneType' object has no attribute '_adapter'
>
> On Jun 6, 8:14 pm, Massimo Di Pierro 
> wrote:
> > import sys
> > sys.path.append("c:/web2py")
> > from gluon import *
> >
> > db = DAL('sqlite://...', folder="c:/web2py/applications/crm/
> > models",auto_import=True)
> >
> > result = db(db["customer"]).select()
> > print(result)
> >
> > On Jun 6, 2:05 pm, apple  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > I would like to be able to use the DAL to run standalone scripts to
> > > query a database. I have managed to get this working by adding a "from
> > > gluon import *" to mymodel and running the code below:
> >
> > > import sys
> > > sys.path.append("c:/web2py")
> > > sys.path.append("c:/web2py/applications/crm/models")
> > > from gluon import *
> > > from mymodel import *
> > > result = db(db["customer"]).select()
> > > print(result)
> >
> > > However if there is a reference to auth then I need to also change
> > > mymodel to include:
> > >   from gluon.tools import *
> > >   auth = Auth(globals(),db)
> > > This fails because there is no request. Is there a way round this to
> > > make web2py think it is running a server?
>



-- 
 http://martin.tecnodoc.com.ar


Re: [web2py] Re: issue with field name id

2011-06-06 Thread Richard Vézina
Nop! Still there...

Maybe I have wrong build :
Version 1.96.3 (2011-06-06 13:58:28)

Richard

On Mon, Jun 6, 2011 at 3:04 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I think I fixed this in trunk. Can you please check it?
>
> On Jun 6, 1:03 pm, Richard Vézina  wrote:
> > Hello,
> >
> > I just try my app with the 1.96.3 and I got a strange error :
> >
> > Traceback (most recent call last):
> >   File "/version_196-3/web2py/gluon/restricted.py", line 184, in
> restricted
> > exec ccode in environment
> >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> line
> > 1334, in 
> >   File "/version_196-3/web2py/gluon/globals.py", line 137, in 
> > self._caller = lambda f: f()
> >   File "/version_196-3/web2py/gluon/tools.py", line 2452, in f
> > return action(*a, **b)
> >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> line
> > 654, in verify
> > if form.accepts(request.vars, session):
> >   File "/version_196-3/web2py/gluon/sqlhtml.py", line 1203, in accepts
> > self.table._db(self.table.id == self.record.id).update(**fields)
> >   File "/version_196-3/web2py/gluon/dal.py", line 5369, in update
> > fields = self.db[tablename]._listify(update_fields,update=True)
> >   File "/version_196-3/web2py/gluon/dal.py", line 4656, in _listify
> > raise SyntaxError, 'Field %s does not belong to the table' % name
> > SyntaxError: Field id does not belong to the table
> >
> >   def _listify(self,fields,update=False):
> > new_fields = []
> > new_fields_names = []
> > for name in fields:
> > if not name in self.fields:
> > raise SyntaxError, 'Field %s does not belong to the
> > table' % name
> >
> > new_fields.append((self[name],fields[name]))
> > new_fields_names.append(name)
> > for ofield in self:
> > if not ofield.name in new_fields_names:
> >
> > *I use a old app and a feature for Postgres that Massimo added in the
> > pass that never been documented and i don't think it was official :*
> >
> > *
> > *
> >
> > *MODEL :*
> >
> > *Field('table_id','id'), # My legacy database used the same name as PK
> > and FK so I had to define them in the model like this*
> >
> > *sequence_name='test_activity_activity_id_seq' # Postgres has it on
> > automation rule to create the sequence name base on the PK name and
> > because I where using legacy database PK name I had also to define the
> > sequence name in my model...*
> >
> > *
> > *
> >
> > *Not sure if there is a link.*
> >
> > *
> > *
> >
> > *Thanks*
> >
> > *
> > *
> >
> > *Richard*
> >
> > *
> > *
> >
> > *
> > *


[web2py] Re: using the DAL standalone

2011-06-06 Thread Massimo Di Pierro
I think I fixed this in trunk. Please check.

On Jun 6, 2:25 pm, apple  wrote:
> I ran that (assuming you meant refer to the databases folder). However
> it gives an error:
>
> Traceback (most recent call last):
>   File "C:\web2py\applications\crm\controllers\querytest.py", line 4,
> in 
>     db = DAL('sqlite://storage.sqlite', folder='c:/web2py/applications/
> crm/databases', auto_import=True)
>   File "c:/web2py\gluon\dal.py", line 3903, in __init__
>     self.import_table_definitions(adapter.folder)
>   File "c:/web2py\gluon\dal.py", line 3913, in
> import_table_definitions
>     mf.sort()
>   File "c:/web2py\gluon\dal.py", line 4919, in __eq__
>     return Query(self.db, self.db._adapter.EQ, self, value)
> AttributeError: 'NoneType' object has no attribute '_adapter'
>
> On Jun 6, 8:14 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > import sys
> > sys.path.append("c:/web2py")
> > from gluon import *
>
> > db = DAL('sqlite://...', folder="c:/web2py/applications/crm/
> > models",auto_import=True)
>
> > result = db(db["customer"]).select()
> > print(result)
>
> > On Jun 6, 2:05 pm, apple  wrote:
>
> > > I would like to be able to use the DAL to run standalone scripts to
> > > query a database. I have managed to get this working by adding a "from
> > > gluon import *" to mymodel and running the code below:
>
> > > import sys
> > > sys.path.append("c:/web2py")
> > > sys.path.append("c:/web2py/applications/crm/models")
> > > from gluon import *
> > > from mymodel import *
> > > result = db(db["customer"]).select()
> > > print(result)
>
> > > However if there is a reference to auth then I need to also change
> > > mymodel to include:
> > >       from gluon.tools import *
> > >       auth = Auth(globals(),db)
> > > This fails because there is no request. Is there a way round this to
> > > make web2py think it is running a server?


Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Pierre Thibault
2011/6/6 Alessandro Iob 

> No, it does not work. And the problem is not related to the 
> *_DateTrackerImporter
> as I'm not using the track_changes options.*
>
> **I've made some tests and I've found that in _Web2pyImporter.__call__ the
> code reaches the "import like 'from x import a, b, ...'" section with the
> vars set to:
>
>  name = selfgroup.castalia
> caller_file_name =
> C:\w2p\web2py\applications\castalia\controllers/default.py
> self.web2py_path = C:\w2p\web2py
> match_app_dir = <_sre.SRE_Match object at 0x018B7420>
> modules_prefix = applications.castalia.modules
> module_prefix + '.' + name =
> applications.castalia.modules.selfgroup.castalia
> fromlist = ('config',)
> level = -1
>
> then the call to
>
> super(_Web2pyImporter, self).__call__(
>  modules_prefix+"."+name, globals, locals, fromlist, level
> )
>
> raises the ImportError exception (No module named
> castalia.modules.selfgroup.castalia).
> The sys.path seems correct:
>
>  ['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py',
> 'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']
>
> No clue.
>
>
>
When you are using "Castalia" as the name of your application, is all code
values above appears with "castalia" in lower case?

-- 


A+

-
Pierre
My blog and profile
(http://pierrethibault.posterous.com)
YouTube page 
(http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2) 


[web2py] Re: using the DAL standalone

2011-06-06 Thread Massimo Di Pierro
was released with 1.96.1 but perhaps broken soon after. SHould now be
fixed again.

On Jun 6, 2:27 pm, Martín Mulone  wrote:
> No the model folders. I didn't know this exists.
>
> 2011/6/6 apple 
>
>
>
>
>
>
>
>
>
> > I ran that (assuming you meant refer to the databases folder). However
> > it gives an error:
>
> > Traceback (most recent call last):
> >  File "C:\web2py\applications\crm\controllers\querytest.py", line 4,
> > in 
> >    db = DAL('sqlite://storage.sqlite', folder='c:/web2py/applications/
> > crm/databases', auto_import=True)
> >  File "c:/web2py\gluon\dal.py", line 3903, in __init__
> >    self.import_table_definitions(adapter.folder)
> >  File "c:/web2py\gluon\dal.py", line 3913, in
> > import_table_definitions
> >    mf.sort()
> >  File "c:/web2py\gluon\dal.py", line 4919, in __eq__
> >    return Query(self.db, self.db._adapter.EQ, self, value)
> > AttributeError: 'NoneType' object has no attribute '_adapter'
>
> > On Jun 6, 8:14 pm, Massimo Di Pierro 
> > wrote:
> > > import sys
> > > sys.path.append("c:/web2py")
> > > from gluon import *
>
> > > db = DAL('sqlite://...', folder="c:/web2py/applications/crm/
> > > models",auto_import=True)
>
> > > result = db(db["customer"]).select()
> > > print(result)
>
> > > On Jun 6, 2:05 pm, apple  wrote:
>
> > > > I would like to be able to use the DAL to run standalone scripts to
> > > > query a database. I have managed to get this working by adding a "from
> > > > gluon import *" to mymodel and running the code below:
>
> > > > import sys
> > > > sys.path.append("c:/web2py")
> > > > sys.path.append("c:/web2py/applications/crm/models")
> > > > from gluon import *
> > > > from mymodel import *
> > > > result = db(db["customer"]).select()
> > > > print(result)
>
> > > > However if there is a reference to auth then I need to also change
> > > > mymodel to include:
> > > >       from gluon.tools import *
> > > >       auth = Auth(globals(),db)
> > > > This fails because there is no request. Is there a way round this to
> > > > make web2py think it is running a server?
>
> --
>  http://martin.tecnodoc.com.ar


Re: [web2py] Re: web2py 1.96.1 is OUT

2011-06-06 Thread Alessandro Iob

Yes

On 6/6/11 21:35 , Pierre Thibault wrote:

2011/6/6 Alessandro Iob mailto:alessandro@gmail.com>>

No, it does not work. And the problem is not related to the
*_DateTrackerImporter as I'm not using the track_changes options.*

**I've made some tests and I've found that in
_Web2pyImporter.__call__ the code reaches the "import like 'from x
import a, b, ...'" section with the vars set to:

name = selfgroup.castalia
caller_file_name =
C:\w2p\web2py\applications\castalia\controllers/default.py
self.web2py_path = C:\w2p\web2py
match_app_dir = <_sre.SRE_Match object at 0x018B7420>
modules_prefix = applications.castalia.modules
module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia
fromlist = ('config',)
level = -1

then the call to

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)

raises the ImportError exception (No module named
castalia.modules.selfgroup.castalia).
The sys.path seems correct:

['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py',
'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']

No clue.



When you are using "Castalia" as the name of your application, is all
code values above appears with "castalia" in lower case?

--


A+

-
Pierre
My blog and profile (http://pierrethibault.posterous.com)

YouTube page (http://www.youtube.com/user/tubetib)

Twitter (http://twitter.com/pierreth2) 



[web2py] Re: using the DAL standalone

2011-06-06 Thread apple
I am on latest release 1.96.3

On Jun 6, 8:35 pm, Massimo Di Pierro 
wrote:
> was released with 1.96.1 but perhaps broken soon after. SHould now be
> fixed again.
>
> On Jun 6, 2:27 pm, Martín Mulone  wrote:
>
>
>
>
>
>
>
> > No the model folders. I didn't know this exists.
>
> > 2011/6/6 apple 
>
> > > I ran that (assuming you meant refer to the databases folder). However
> > > it gives an error:
>
> > > Traceback (most recent call last):
> > >  File "C:\web2py\applications\crm\controllers\querytest.py", line 4,
> > > in 
> > >    db = DAL('sqlite://storage.sqlite', folder='c:/web2py/applications/
> > > crm/databases', auto_import=True)
> > >  File "c:/web2py\gluon\dal.py", line 3903, in __init__
> > >    self.import_table_definitions(adapter.folder)
> > >  File "c:/web2py\gluon\dal.py", line 3913, in
> > > import_table_definitions
> > >    mf.sort()
> > >  File "c:/web2py\gluon\dal.py", line 4919, in __eq__
> > >    return Query(self.db, self.db._adapter.EQ, self, value)
> > > AttributeError: 'NoneType' object has no attribute '_adapter'
>
> > > On Jun 6, 8:14 pm, Massimo Di Pierro 
> > > wrote:
> > > > import sys
> > > > sys.path.append("c:/web2py")
> > > > from gluon import *
>
> > > > db = DAL('sqlite://...', folder="c:/web2py/applications/crm/
> > > > models",auto_import=True)
>
> > > > result = db(db["customer"]).select()
> > > > print(result)
>
> > > > On Jun 6, 2:05 pm, apple  wrote:
>
> > > > > I would like to be able to use the DAL to run standalone scripts to
> > > > > query a database. I have managed to get this working by adding a "from
> > > > > gluon import *" to mymodel and running the code below:
>
> > > > > import sys
> > > > > sys.path.append("c:/web2py")
> > > > > sys.path.append("c:/web2py/applications/crm/models")
> > > > > from gluon import *
> > > > > from mymodel import *
> > > > > result = db(db["customer"]).select()
> > > > > print(result)
>
> > > > > However if there is a reference to auth then I need to also change
> > > > > mymodel to include:
> > > > >       from gluon.tools import *
> > > > >       auth = Auth(globals(),db)
> > > > > This fails because there is no request. Is there a way round this to
> > > > > make web2py think it is running a server?
>
> > --
> >  http://martin.tecnodoc.com.ar


[web2py] Re: issue with field name id

2011-06-06 Thread Massimo Di Pierro
Can you try again?

On Jun 6, 2:29 pm, Richard Vézina  wrote:
> Nop! Still there...
>
> Maybe I have wrong build :
> Version 1.96.3 (2011-06-06 13:58:28)
>
> Richard
>
> On Mon, Jun 6, 2011 at 3:04 PM, Massimo Di Pierro <
>
>
>
>
>
>
>
> massimo.dipie...@gmail.com> wrote:
> > I think I fixed this in trunk. Can you please check it?
>
> > On Jun 6, 1:03 pm, Richard Vézina  wrote:
> > > Hello,
>
> > > I just try my app with the 1.96.3 and I got a strange error :
>
> > > Traceback (most recent call last):
> > >   File "/version_196-3/web2py/gluon/restricted.py", line 184, in
> > restricted
> > >     exec ccode in environment
> > >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> > line
> > > 1334, in 
> > >   File "/version_196-3/web2py/gluon/globals.py", line 137, in 
> > >     self._caller = lambda f: f()
> > >   File "/version_196-3/web2py/gluon/tools.py", line 2452, in f
> > >     return action(*a, **b)
> > >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> > line
> > > 654, in verify
> > >     if form.accepts(request.vars, session):
> > >   File "/version_196-3/web2py/gluon/sqlhtml.py", line 1203, in accepts
> > >     self.table._db(self.table.id == self.record.id).update(**fields)
> > >   File "/version_196-3/web2py/gluon/dal.py", line 5369, in update
> > >     fields = self.db[tablename]._listify(update_fields,update=True)
> > >   File "/version_196-3/web2py/gluon/dal.py", line 4656, in _listify
> > >     raise SyntaxError, 'Field %s does not belong to the table' % name
> > > SyntaxError: Field id does not belong to the table
>
> > >   def _listify(self,fields,update=False):
> > >         new_fields = []
> > >         new_fields_names = []
> > >         for name in fields:
> > >             if not name in self.fields:
> > >                 raise SyntaxError, 'Field %s does not belong to the
> > > table' % name
>
> > >             new_fields.append((self[name],fields[name]))
> > >             new_fields_names.append(name)
> > >         for ofield in self:
> > >             if not ofield.name in new_fields_names:
>
> > > *I use a old app and a feature for Postgres that Massimo added in the
> > > pass that never been documented and i don't think it was official :*
>
> > > *
> > > *
>
> > > *MODEL :*
>
> > > *Field('table_id','id'), # My legacy database used the same name as PK
> > > and FK so I had to define them in the model like this*
>
> > > *sequence_name='test_activity_activity_id_seq' # Postgres has it on
> > > automation rule to create the sequence name base on the PK name and
> > > because I where using legacy database PK name I had also to define the
> > > sequence name in my model...*
>
> > > *
> > > *
>
> > > *Not sure if there is a link.*
>
> > > *
> > > *
>
> > > *Thanks*
>
> > > *
> > > *
>
> > > *Richard*
>
> > > *
> > > *
>
> > > *
> > > *


Re: [web2py] Re: issue with field name id

2011-06-06 Thread Richard Vézina
It does the problem on update... My create form work well, deletion also
works.

Richard

On Mon, Jun 6, 2011 at 3:29 PM, Richard Vézina
wrote:

> Nop! Still there...
>
> Maybe I have wrong build :
> Version 1.96.3 (2011-06-06 13:58:28)
>
> Richard
>
>
> On Mon, Jun 6, 2011 at 3:04 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> I think I fixed this in trunk. Can you please check it?
>>
>> On Jun 6, 1:03 pm, Richard Vézina  wrote:
>> > Hello,
>> >
>> > I just try my app with the 1.96.3 and I got a strange error :
>> >
>> > Traceback (most recent call last):
>> >   File "/version_196-3/web2py/gluon/restricted.py", line 184, in
>> restricted
>> > exec ccode in environment
>> >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
>> line
>> > 1334, in 
>> >   File "/version_196-3/web2py/gluon/globals.py", line 137, in 
>> > self._caller = lambda f: f()
>> >   File "/version_196-3/web2py/gluon/tools.py", line 2452, in f
>> > return action(*a, **b)
>> >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
>> line
>> > 654, in verify
>> > if form.accepts(request.vars, session):
>> >   File "/version_196-3/web2py/gluon/sqlhtml.py", line 1203, in accepts
>> > self.table._db(self.table.id == self.record.id).update(**fields)
>> >   File "/version_196-3/web2py/gluon/dal.py", line 5369, in update
>> > fields = self.db[tablename]._listify(update_fields,update=True)
>> >   File "/version_196-3/web2py/gluon/dal.py", line 4656, in _listify
>> > raise SyntaxError, 'Field %s does not belong to the table' % name
>> > SyntaxError: Field id does not belong to the table
>> >
>> >   def _listify(self,fields,update=False):
>> > new_fields = []
>> > new_fields_names = []
>> > for name in fields:
>> > if not name in self.fields:
>> > raise SyntaxError, 'Field %s does not belong to the
>> > table' % name
>> >
>> > new_fields.append((self[name],fields[name]))
>> > new_fields_names.append(name)
>> > for ofield in self:
>> > if not ofield.name in new_fields_names:
>> >
>> > *I use a old app and a feature for Postgres that Massimo added in the
>> > pass that never been documented and i don't think it was official :*
>> >
>> > *
>> > *
>> >
>> > *MODEL :*
>> >
>> > *Field('table_id','id'), # My legacy database used the same name as PK
>> > and FK so I had to define them in the model like this*
>> >
>> > *sequence_name='test_activity_activity_id_seq' # Postgres has it on
>> > automation rule to create the sequence name base on the PK name and
>> > because I where using legacy database PK name I had also to define the
>> > sequence name in my model...*
>> >
>> > *
>> > *
>> >
>> > *Not sure if there is a link.*
>> >
>> > *
>> > *
>> >
>> > *Thanks*
>> >
>> > *
>> > *
>> >
>> > *Richard*
>> >
>> > *
>> > *
>> >
>> > *
>> > *
>
>
>


[web2py] How to implement flags?

2011-06-06 Thread pbreit
Does anyone have any advice for the best way to implement flags? For 
example, auth_user.do_not_email=True

Some options:
1) db.flags.do_not_email = True
2) db.auth_user.do_not_email = True
3) db.auth_user.flags={'do_not_email': True}
4) others?

Does the "list" data type help out?

I know in the "old days" people used bitwise operations for flags. Is that 
still done? Thanks for any suggestions.


Re: [web2py] Re: issue with field name id

2011-06-06 Thread Richard Vézina
Still there : Version 1.96.3 (2011-06-06 14:35:14)

Richard

On Mon, Jun 6, 2011 at 3:49 PM, Richard Vézina
wrote:

> It does the problem on update... My create form work well, deletion also
> works.
>
> Richard
>
>
> On Mon, Jun 6, 2011 at 3:29 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Nop! Still there...
>>
>> Maybe I have wrong build :
>> Version 1.96.3 (2011-06-06 13:58:28)
>>
>> Richard
>>
>>
>> On Mon, Jun 6, 2011 at 3:04 PM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> I think I fixed this in trunk. Can you please check it?
>>>
>>> On Jun 6, 1:03 pm, Richard Vézina  wrote:
>>> > Hello,
>>> >
>>> > I just try my app with the 1.96.3 and I got a strange error :
>>> >
>>> > Traceback (most recent call last):
>>> >   File "/version_196-3/web2py/gluon/restricted.py", line 184, in
>>> restricted
>>> > exec ccode in environment
>>> >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
>>> line
>>> > 1334, in 
>>> >   File "/version_196-3/web2py/gluon/globals.py", line 137, in 
>>> > self._caller = lambda f: f()
>>> >   File "/version_196-3/web2py/gluon/tools.py", line 2452, in f
>>> > return action(*a, **b)
>>> >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
>>> line
>>> > 654, in verify
>>> > if form.accepts(request.vars, session):
>>> >   File "/version_196-3/web2py/gluon/sqlhtml.py", line 1203, in accepts
>>> > self.table._db(self.table.id == self.record.id).update(**fields)
>>> >   File "/version_196-3/web2py/gluon/dal.py", line 5369, in update
>>> > fields = self.db[tablename]._listify(update_fields,update=True)
>>> >   File "/version_196-3/web2py/gluon/dal.py", line 4656, in _listify
>>> > raise SyntaxError, 'Field %s does not belong to the table' % name
>>> > SyntaxError: Field id does not belong to the table
>>> >
>>> >   def _listify(self,fields,update=False):
>>> > new_fields = []
>>> > new_fields_names = []
>>> > for name in fields:
>>> > if not name in self.fields:
>>> > raise SyntaxError, 'Field %s does not belong to the
>>> > table' % name
>>> >
>>> > new_fields.append((self[name],fields[name]))
>>> > new_fields_names.append(name)
>>> > for ofield in self:
>>> > if not ofield.name in new_fields_names:
>>> >
>>> > *I use a old app and a feature for Postgres that Massimo added in the
>>> > pass that never been documented and i don't think it was official :*
>>> >
>>> > *
>>> > *
>>> >
>>> > *MODEL :*
>>> >
>>> > *Field('table_id','id'), # My legacy database used the same name as PK
>>> > and FK so I had to define them in the model like this*
>>> >
>>> > *sequence_name='test_activity_activity_id_seq' # Postgres has it on
>>> > automation rule to create the sequence name base on the PK name and
>>> > because I where using legacy database PK name I had also to define the
>>> > sequence name in my model...*
>>> >
>>> > *
>>> > *
>>> >
>>> > *Not sure if there is a link.*
>>> >
>>> > *
>>> > *
>>> >
>>> > *Thanks*
>>> >
>>> > *
>>> > *
>>> >
>>> > *Richard*
>>> >
>>> > *
>>> > *
>>> >
>>> > *
>>> > *
>>
>>
>>
>


Re: [web2py] layout with submenu

2011-06-06 Thread Manuele Pesenti
thank you Richard but the problem is the css code that in most or quite 
all layouts does not defines proper classes to manage sub menu so if you 
use it you will obtain ugly effects... I'm not so skilled with css and I 
was looking for some layout that contains classes for submenu


Sorry if my quest was not so clear

cheers

Manuele

On 06/06/2011 16:51, Richard Vézina wrote:

I am not sure to understand what you need, but you can nest you stuff
like this :

 response.menu = [
  [T('root1').capitalize(),
  False,
'',
  [
  [T('level1-1').capitalize(),
  False,
  URL(request.application,
'controller',
'function'),
  [
  [T('level2-1').capitalize(),
  False,
  URL(request.application,
'controller',
'function'),
  []],
  ]],
  [T('level1-2').capitalize(),
  False,
  URL(request.application,
'controller',
'function'),
  []],
  [T('level1-3').capitalize(),
  False,
  URL(request.application,
'controller',
'function'),
  []],
  ]],

  [T('root2').capitalize(),
  False,
'',
  [
  [T('level1-1').capitalize(),
  False,
  URL(request.application,
'controller',
'function'),
  []],
  [T('level1-2').capitalize(),
  False,
  URL(request.application,
'controller',
'function'),
  []],
  ]],
 ]

Take care of proper indentation and open and closing your bracket correctly.

Richard

On Mon, Jun 6, 2011 at 7:13 AM, Manuele Pesenti
mailto:manuele.pese...@gmail.com>> wrote:

Hi *,
I realize that most of the layouts available for download do not
support the submenu, in the sense that it's not managed so if
defined it couses unwanted behavior... does anybody knows layouts
that implements submenu managment?

thanks

Manuele






Re: [web2py] layout with submenu

2011-06-06 Thread Richard Vézina
Do you have a example (screenshot) of the glitch... I don't see any problem
in the welcome app?

Richard

On Mon, Jun 6, 2011 at 4:15 PM, Manuele Pesenti
wrote:

> thank you Richard but the problem is the css code that in most or quite all
> layouts does not defines proper classes to manage sub menu so if you use it
> you will obtain ugly effects... I'm not so skilled with css and I was
> looking for some layout that contains classes for submenu
>
> Sorry if my quest was not so clear
>
> cheers
>
>Manuele
>
>
> On 06/06/2011 16:51, Richard Vézina wrote:
>
>> I am not sure to understand what you need, but you can nest you stuff
>> like this :
>>
>> response.menu = [
>>  [T('root1').capitalize(),
>>  False,
>> '',
>>  [
>>  [T('level1-1').capitalize(),
>>  False,
>>  URL(request.application,
>> 'controller',
>> 'function'),
>>  [
>>  [T('level2-1').capitalize(),
>>  False,
>>  URL(request.application,
>> 'controller',
>> 'function'),
>>  []],
>>  ]],
>>  [T('level1-2').capitalize(),
>>  False,
>>  URL(request.application,
>> 'controller',
>> 'function'),
>>  []],
>>  [T('level1-3').capitalize(),
>>  False,
>>  URL(request.application,
>> 'controller',
>> 'function'),
>>  []],
>>  ]],
>>
>>  [T('root2').capitalize(),
>>  False,
>> '',
>>  [
>>  [T('level1-1').capitalize(),
>>  False,
>>  URL(request.application,
>> 'controller',
>> 'function'),
>>  []],
>>  [T('level1-2').capitalize(),
>>  False,
>>  URL(request.application,
>> 'controller',
>> 'function'),
>>  []],
>>  ]],
>> ]
>>
>> Take care of proper indentation and open and closing your bracket
>> correctly.
>>
>> Richard
>>
>> On Mon, Jun 6, 2011 at 7:13 AM, Manuele Pesenti
>> mailto:manuele.pese...@gmail.com>> wrote:
>>
>>Hi *,
>>I realize that most of the layouts available for download do not
>>support the submenu, in the sense that it's not managed so if
>>defined it couses unwanted behavior... does anybody knows layouts
>>that implements submenu managment?
>>
>>thanks
>>
>>Manuele
>>
>>
>>
>


[web2py] Re: issue with field name id

2011-06-06 Thread Massimo Di Pierro
please re-send me the traceback sine that line in sqlhtml is not
there.

On Jun 6, 3:04 pm, Richard Vézina  wrote:
> Still there : Version 1.96.3 (2011-06-06 14:35:14)
>
> Richard
>
> On Mon, Jun 6, 2011 at 3:49 PM, Richard Vézina
> wrote:
>
>
>
>
>
>
>
> > It does the problem on update... My create form work well, deletion also
> > works.
>
> > Richard
>
> > On Mon, Jun 6, 2011 at 3:29 PM, Richard Vézina <
> > ml.richard.vez...@gmail.com> wrote:
>
> >> Nop! Still there...
>
> >> Maybe I have wrong build :
> >> Version 1.96.3 (2011-06-06 13:58:28)
>
> >> Richard
>
> >> On Mon, Jun 6, 2011 at 3:04 PM, Massimo Di Pierro <
> >> massimo.dipie...@gmail.com> wrote:
>
> >>> I think I fixed this in trunk. Can you please check it?
>
> >>> On Jun 6, 1:03 pm, Richard Vézina  wrote:
> >>> > Hello,
>
> >>> > I just try my app with the 1.96.3 and I got a strange error :
>
> >>> > Traceback (most recent call last):
> >>> >   File "/version_196-3/web2py/gluon/restricted.py", line 184, in
> >>> restricted
> >>> >     exec ccode in environment
> >>> >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> >>> line
> >>> > 1334, in 
> >>> >   File "/version_196-3/web2py/gluon/globals.py", line 137, in 
> >>> >     self._caller = lambda f: f()
> >>> >   File "/version_196-3/web2py/gluon/tools.py", line 2452, in f
> >>> >     return action(*a, **b)
> >>> >   File "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> >>> line
> >>> > 654, in verify
> >>> >     if form.accepts(request.vars, session):
> >>> >   File "/version_196-3/web2py/gluon/sqlhtml.py", line 1203, in accepts
> >>> >     self.table._db(self.table.id == self.record.id).update(**fields)
> >>> >   File "/version_196-3/web2py/gluon/dal.py", line 5369, in update
> >>> >     fields = self.db[tablename]._listify(update_fields,update=True)
> >>> >   File "/version_196-3/web2py/gluon/dal.py", line 4656, in _listify
> >>> >     raise SyntaxError, 'Field %s does not belong to the table' % name
> >>> > SyntaxError: Field id does not belong to the table
>
> >>> >   def _listify(self,fields,update=False):
> >>> >         new_fields = []
> >>> >         new_fields_names = []
> >>> >         for name in fields:
> >>> >             if not name in self.fields:
> >>> >                 raise SyntaxError, 'Field %s does not belong to the
> >>> > table' % name
>
> >>> >             new_fields.append((self[name],fields[name]))
> >>> >             new_fields_names.append(name)
> >>> >         for ofield in self:
> >>> >             if not ofield.name in new_fields_names:
>
> >>> > *I use a old app and a feature for Postgres that Massimo added in the
> >>> > pass that never been documented and i don't think it was official :*
>
> >>> > *
> >>> > *
>
> >>> > *MODEL :*
>
> >>> > *Field('table_id','id'), # My legacy database used the same name as PK
> >>> > and FK so I had to define them in the model like this*
>
> >>> > *sequence_name='test_activity_activity_id_seq' # Postgres has it on
> >>> > automation rule to create the sequence name base on the PK name and
> >>> > because I where using legacy database PK name I had also to define the
> >>> > sequence name in my model...*
>
> >>> > *
> >>> > *
>
> >>> > *Not sure if there is a link.*
>
> >>> > *
> >>> > *
>
> >>> > *Thanks*
>
> >>> > *
> >>> > *
>
> >>> > *Richard*
>
> >>> > *
> >>> > *
>
> >>> > *
> >>> > *


Re: [web2py] Re: issue with field name id

2011-06-06 Thread Richard Vézina
Traceback (most recent call last):
  File "/trunk/web2py/gluon/restricted.py", line 184, in restricted
exec ccode in environment
  File "/trunk/web2py/applications/sgddms/controllers/test.py", line 1334,
in 
  File "/trunk/web2py/gluon/globals.py", line 137, in 
self._caller = lambda f: f()
  File "/trunk/web2py/gluon/tools.py", line 2444, in f
return action(*a, **b)
  File "/trunk/web2py/applications/sgddms/controllers/test.py", line 461, in
update
if form.accepts(request.vars, session):
  File "/trunk/web2py/gluon/sqlhtml.py", line 1203, in accepts
self.table._db(self.table._id == self.record.id).update(**fields)
  File "/trunk/web2py/gluon/dal.py", line 5369, in update
fields = self.db[tablename]._listify(update_fields,update=True)
  File "/trunk/web2py/gluon/dal.py", line 4656, in _listify
raise SyntaxError, 'Field %s does not belong to the table' % name
SyntaxError: Field id does not belong to the table


1198.
1199.
1200.
1201.
1202.
1203.

1204.
1205.
1206.
1207.

ret = False
else:
if record_id:
self.vars.id = self.record.id
if fields:
self.table._db(self.table._id ==
self.record.id).update(**fields)

else:
self.vars.id = self.table.insert(**fields)
return ret


Is what you need?

Richard

On Mon, Jun 6, 2011 at 4:34 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> please re-send me the traceback sine that line in sqlhtml is not
> there.
>
> On Jun 6, 3:04 pm, Richard Vézina  wrote:
> > Still there : Version 1.96.3 (2011-06-06 14:35:14)
> >
> > Richard
> >
> > On Mon, Jun 6, 2011 at 3:49 PM, Richard Vézina
> > wrote:
> >
> >
> >
> >
> >
> >
> >
> > > It does the problem on update... My create form work well, deletion
> also
> > > works.
> >
> > > Richard
> >
> > > On Mon, Jun 6, 2011 at 3:29 PM, Richard Vézina <
> > > ml.richard.vez...@gmail.com> wrote:
> >
> > >> Nop! Still there...
> >
> > >> Maybe I have wrong build :
> > >> Version 1.96.3 (2011-06-06 13:58:28)
> >
> > >> Richard
> >
> > >> On Mon, Jun 6, 2011 at 3:04 PM, Massimo Di Pierro <
> > >> massimo.dipie...@gmail.com> wrote:
> >
> > >>> I think I fixed this in trunk. Can you please check it?
> >
> > >>> On Jun 6, 1:03 pm, Richard Vézina 
> wrote:
> > >>> > Hello,
> >
> > >>> > I just try my app with the 1.96.3 and I got a strange error :
> >
> > >>> > Traceback (most recent call last):
> > >>> >   File "/version_196-3/web2py/gluon/restricted.py", line 184, in
> > >>> restricted
> > >>> > exec ccode in environment
> > >>> >   File
> "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> > >>> line
> > >>> > 1334, in 
> > >>> >   File "/version_196-3/web2py/gluon/globals.py", line 137, in
> 
> > >>> > self._caller = lambda f: f()
> > >>> >   File "/version_196-3/web2py/gluon/tools.py", line 2452, in f
> > >>> > return action(*a, **b)
> > >>> >   File
> "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> > >>> line
> > >>> > 654, in verify
> > >>> > if form.accepts(request.vars, session):
> > >>> >   File "/version_196-3/web2py/gluon/sqlhtml.py", line 1203, in
> accepts
> > >>> > self.table._db(self.table.id == self.record.id
> ).update(**fields)
> > >>> >   File "/version_196-3/web2py/gluon/dal.py", line 5369, in update
> > >>> > fields = self.db[tablename]._listify(update_fields,update=True)
> > >>> >   File "/version_196-3/web2py/gluon/dal.py", line 4656, in _listify
> > >>> > raise SyntaxError, 'Field %s does not belong to the table' %
> name
> > >>> > SyntaxError: Field id does not belong to the table
> >
> > >>> >   def _listify(self,fields,update=False):
> > >>> > new_fields = []
> > >>> > new_fields_names = []
> > >>> > for name in fields:
> > >>> > if not name in self.fields:
> > >>> > raise SyntaxError, 'Field %s does not belong to the
> > >>> > table' % name
> >
> > >>> > new_fields.append((self[name],fields[name]))
> > >>> > new_fields_names.append(name)
> > >>> > for ofield in self:
> > >>> > if not ofield.name in new_fields_names:
> >
> > >>> > *I use a old app and a feature for Postgres that Massimo added in
> the
> > >>> > pass that never been documented and i don't think it was official
> :*
> >
> > >>> > *
> > >>> > *
> >
> > >>> > *MODEL :*
> >
> > >>> > *Field('table_id','id'), # My legacy database used the same name as
> PK
> > >>> > and FK so I had to define them in the model like this*
> >
> > >>> > *sequence_name='test_activity_activity_id_seq' # Postgres has it on
> > >>> > automation rule to create the sequence name base on the PK name and
> > >>> > because I where using legacy database PK name I had also to define
> the
> > >>> > sequence name in my model...*
> >
> > >>> > *
> > >>> > *
> >
> > >>> > *Not sure if there is a link.*
> >
> > >>> > *
> > >>> > *
> >
> > >>>

[web2py] Re: issue with field name id

2011-06-06 Thread Massimo Di Pierro
can you please try once more...

P.S. I keep answering posts by my messages do not show up. :-(

On Jun 6, 3:43 pm, Richard Vézina  wrote:
> Traceback (most recent call last):
>   File "/trunk/web2py/gluon/restricted.py", line 184, in restricted
>     exec ccode in environment
>   File "/trunk/web2py/applications/sgddms/controllers/test.py", line 1334,
> in 
>   File "/trunk/web2py/gluon/globals.py", line 137, in 
>     self._caller = lambda f: f()
>   File "/trunk/web2py/gluon/tools.py", line 2444, in f
>     return action(*a, **b)
>   File "/trunk/web2py/applications/sgddms/controllers/test.py", line 461, in
> update
>     if form.accepts(request.vars, session):
>   File "/trunk/web2py/gluon/sqlhtml.py", line 1203, in accepts
>     self.table._db(self.table._id == self.record.id).update(**fields)
>   File "/trunk/web2py/gluon/dal.py", line 5369, in update
>     fields = self.db[tablename]._listify(update_fields,update=True)
>   File "/trunk/web2py/gluon/dal.py", line 4656, in _listify
>     raise SyntaxError, 'Field %s does not belong to the table' % name
> SyntaxError: Field id does not belong to the table
>
> 1198.
> 1199.
> 1200.
> 1201.
> 1202.
> 1203.
>
> 1204.
> 1205.
> 1206.
> 1207.
>
>                         ret = False
>             else:
>                 if record_id:
>                     self.vars.id = self.record.id
>                     if fields:
>                         self.table._db(self.table._id ==
> self.record.id).update(**fields)
>
>                 else:
>                     self.vars.id = self.table.insert(**fields)
>         return ret
>
> Is what you need?
>
> Richard
>
> On Mon, Jun 6, 2011 at 4:34 PM, Massimo Di Pierro <
>
>
>
>
>
>
>
> massimo.dipie...@gmail.com> wrote:
> > please re-send me the traceback sine that line in sqlhtml is not
> > there.
>
> > On Jun 6, 3:04 pm, Richard Vézina  wrote:
> > > Still there : Version 1.96.3 (2011-06-06 14:35:14)
>
> > > Richard
>
> > > On Mon, Jun 6, 2011 at 3:49 PM, Richard Vézina
> > > wrote:
>
> > > > It does the problem on update... My create form work well, deletion
> > also
> > > > works.
>
> > > > Richard
>
> > > > On Mon, Jun 6, 2011 at 3:29 PM, Richard Vézina <
> > > > ml.richard.vez...@gmail.com> wrote:
>
> > > >> Nop! Still there...
>
> > > >> Maybe I have wrong build :
> > > >> Version 1.96.3 (2011-06-06 13:58:28)
>
> > > >> Richard
>
> > > >> On Mon, Jun 6, 2011 at 3:04 PM, Massimo Di Pierro <
> > > >> massimo.dipie...@gmail.com> wrote:
>
> > > >>> I think I fixed this in trunk. Can you please check it?
>
> > > >>> On Jun 6, 1:03 pm, Richard Vézina 
> > wrote:
> > > >>> > Hello,
>
> > > >>> > I just try my app with the 1.96.3 and I got a strange error :
>
> > > >>> > Traceback (most recent call last):
> > > >>> >   File "/version_196-3/web2py/gluon/restricted.py", line 184, in
> > > >>> restricted
> > > >>> >     exec ccode in environment
> > > >>> >   File
> > "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> > > >>> line
> > > >>> > 1334, in 
> > > >>> >   File "/version_196-3/web2py/gluon/globals.py", line 137, in
> > 
> > > >>> >     self._caller = lambda f: f()
> > > >>> >   File "/version_196-3/web2py/gluon/tools.py", line 2452, in f
> > > >>> >     return action(*a, **b)
> > > >>> >   File
> > "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> > > >>> line
> > > >>> > 654, in verify
> > > >>> >     if form.accepts(request.vars, session):
> > > >>> >   File "/version_196-3/web2py/gluon/sqlhtml.py", line 1203, in
> > accepts
> > > >>> >     self.table._db(self.table.id == self.record.id
> > ).update(**fields)
> > > >>> >   File "/version_196-3/web2py/gluon/dal.py", line 5369, in update
> > > >>> >     fields = self.db[tablename]._listify(update_fields,update=True)
> > > >>> >   File "/version_196-3/web2py/gluon/dal.py", line 4656, in _listify
> > > >>> >     raise SyntaxError, 'Field %s does not belong to the table' %
> > name
> > > >>> > SyntaxError: Field id does not belong to the table
>
> > > >>> >   def _listify(self,fields,update=False):
> > > >>> >         new_fields = []
> > > >>> >         new_fields_names = []
> > > >>> >         for name in fields:
> > > >>> >             if not name in self.fields:
> > > >>> >                 raise SyntaxError, 'Field %s does not belong to the
> > > >>> > table' % name
>
> > > >>> >             new_fields.append((self[name],fields[name]))
> > > >>> >             new_fields_names.append(name)
> > > >>> >         for ofield in self:
> > > >>> >             if not ofield.name in new_fields_names:
>
> > > >>> > *I use a old app and a feature for Postgres that Massimo added in
> > the
> > > >>> > pass that never been documented and i don't think it was official
> > :*
>
> > > >>> > *
> > > >>> > *
>
> > > >>> > *MODEL :*
>
> > > >>> > *Field('table_id','id'), # My legacy database used the same name as
> > PK
> > > >>> > and FK so I had to define them in the model like this*
>
> > > >>> > *sequence_name='test_activity_activity_id_seq' # Postg

Re: [web2py] OAuth2.0 and Facebook (as from the book)

2011-06-06 Thread Michele Comitini
Hi Sebastian,

copy from this example:

http://code.google.com/r/michelecomitini-facebookaccess/source/browse/#hg%2Fapplications%2FhelloFacebook

and
let me know

mic

2011/6/6 Sebastian E. Ovide 

> Hi All,
>
> just wondering if the section "OAuth2.0 and Facebook" of the book is up to
> date?
>
> I following it's instructions but I'm getting an "Internal error"
>
> to reproduce
>
> 1) get last web2py 1.196.3
> 2) follow the instructions from the book
> 2.a) get facebook and place it in modules
> 2.b) copy the code from the book
> 2.c) replace "from facebook import GraphAPI" with "facebook =
> local_import('facebook')"
> 2.d) replace facebook. to GraphAPIError and GraphAPI
> 2.e) replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with real data
> 3) set your app URL to http://localhost:8000/welcome/
>
> Is something missing ?
>
> When I click login, it redirect me to facebook, where I can login, and then
> it redirects me to http://localhost:8000/welcome/
>
> At that point I get an error:
>
>  TRACEBACK
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
>
> Traceback (most recent call last):
>
>
>   File "/home/sebas/Downloads/web2py/gluon/restricted.py", line 184, in 
> restricted
>
>
> exec ccode in environment
>
>
>   File 
> "/home/sebas/Downloads/web2py/applications/welcome/controllers/default.py" 
> , 
> line 71, in 
>
>
>   File "/home/sebas/Downloads/web2py/gluon/globals.py", line 137, in 
>
>
>   /  self._caller = lambda f: f()
>
>
>   File 
> "/home/sebas/Downloads/web2py/applications/welcome/controllers/default.py" 
> , 
> line 33, in user
>
>
> return dict(form=auth())
>
>
>   File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1070, in __call__
>
>
> return getattr(self,args[0])()
>
>
>   File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1626, in login
>
>
> user = self.get_or_create_user(table_user._filter_fields(cas_user))
>
>
>   File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1360, in 
> get_or_create_user
>
>
> user = self.db(table_user[username] == keys[username]).select().first()
>
> KeyError: 'email'
>
> any ideas , thanks
>
> --
> Sebastian E. Ovide
>
>
>
>
>


[web2py] Re: issue with field name id

2011-06-06 Thread Massimo Di Pierro
Try again please. If this is fix, please close the thread. If not,
let'a take this private and report when fixed.

On Jun 6, 4:10 pm, Richard Vézina  wrote:
> We progress...
>
> Traceback (most recent call last):
>   File "/trunk/web2py/gluon/restricted.py", line 184, in restricted
>     exec ccode in environment
>   File "/trunk/web2py/applications/sgddms/controllers/test.py", line
> 1334, in 
>   File "/trunk/web2py/gluon/globals.py", line 137, in 
>     self._caller = lambda f: f()
>   File "/trunk/web2py/gluon/tools.py", line 2444, in f
>     return action(*a, **b)
>   File "/trunk/web2py/applications/sgddms/controllers/test.py", line
> 173, in read
>     request.args[1])
>   File "/trunk/web2py/gluon/tools.py", line 3134, in read
>     formstyle=self.settings.formstyle
>   File "/trunk/web2py/gluon/sqlhtml.py", line 793, in __init__
>     inp = field.represent(default)
>   File "/trunk/web2py/gluon/dal.py", line 3634, in list_ref_repr
>     return (refs and ', '.join(str(f(r,ref._id)) for ref in refs) or '')
>   File "/trunk/web2py/gluon/dal.py", line 3634, in 
>     return (refs and ', '.join(str(f(r,ref._id)) for ref in refs) or '')
>   File "/trunk/web2py/gluon/dal.py", line 3691, in __getattr__
>     return self[key]
>   File "/trunk/web2py/gluon/dal.py", line 3682, in __getitem__
>     return dict.__getitem__(self, key)
> KeyError: '_id'
>
> Now it submit... But my read function not working...
>
> I found this after send the issue... My select function also not
> functionning...
>
> It seems all to be related...
>
> Richard
>
> On Mon, Jun 6, 2011 at 5:00 PM, Massimo Di Pierro <
>
>
>
>
>
>
>
> massimo.dipie...@gmail.com> wrote:
> > can you please try once more...
>
> > P.S. I keep answering posts by my messages do not show up. :-(
>
> > On Jun 6, 3:43 pm, Richard Vézina  wrote:
> > > Traceback (most recent call last):
> > >   File "/trunk/web2py/gluon/restricted.py", line 184, in restricted
> > >     exec ccode in environment
> > >   File "/trunk/web2py/applications/sgddms/controllers/test.py", line
> > 1334,
> > > in 
> > >   File "/trunk/web2py/gluon/globals.py", line 137, in 
> > >     self._caller = lambda f: f()
> > >   File "/trunk/web2py/gluon/tools.py", line 2444, in f
> > >     return action(*a, **b)
> > >   File "/trunk/web2py/applications/sgddms/controllers/test.py", line 461,
> > in
> > > update
> > >     if form.accepts(request.vars, session):
> > >   File "/trunk/web2py/gluon/sqlhtml.py", line 1203, in accepts
> > >     self.table._db(self.table._id == self.record.id).update(**fields)
> > >   File "/trunk/web2py/gluon/dal.py", line 5369, in update
> > >     fields = self.db[tablename]._listify(update_fields,update=True)
> > >   File "/trunk/web2py/gluon/dal.py", line 4656, in _listify
> > >     raise SyntaxError, 'Field %s does not belong to the table' % name
> > > SyntaxError: Field id does not belong to the table
>
> > > 1198.
> > > 1199.
> > > 1200.
> > > 1201.
> > > 1202.
> > > 1203.
>
> > > 1204.
> > > 1205.
> > > 1206.
> > > 1207.
>
> > >                         ret = False
> > >             else:
> > >                 if record_id:
> > >                     self.vars.id = self.record.id
> > >                     if fields:
> > >                         self.table._db(self.table._id ==
> > > self.record.id).update(**fields)
>
> > >                 else:
> > >                     self.vars.id = self.table.insert(**fields)
> > >         return ret
>
> > > Is what you need?
>
> > > Richard
>
> > > On Mon, Jun 6, 2011 at 4:34 PM, Massimo Di Pierro <
>
> > > massimo.dipie...@gmail.com> wrote:
> > > > please re-send me the traceback sine that line in sqlhtml is not
> > > > there.
>
> > > > On Jun 6, 3:04 pm, Richard Vézina  wrote:
> > > > > Still there : Version 1.96.3 (2011-06-06 14:35:14)
>
> > > > > Richard
>
> > > > > On Mon, Jun 6, 2011 at 3:49 PM, Richard Vézina
> > > > > wrote:
>
> > > > > > It does the problem on update... My create form work well, deletion
> > > > also
> > > > > > works.
>
> > > > > > Richard
>
> > > > > > On Mon, Jun 6, 2011 at 3:29 PM, Richard Vézina <
> > > > > > ml.richard.vez...@gmail.com> wrote:
>
> > > > > >> Nop! Still there...
>
> > > > > >> Maybe I have wrong build :
> > > > > >> Version 1.96.3 (2011-06-06 13:58:28)
>
> > > > > >> Richard
>
> > > > > >> On Mon, Jun 6, 2011 at 3:04 PM, Massimo Di Pierro <
> > > > > >> massimo.dipie...@gmail.com> wrote:
>
> > > > > >>> I think I fixed this in trunk. Can you please check it?
>
> > > > > >>> On Jun 6, 1:03 pm, Richard Vézina 
> > > > wrote:
> > > > > >>> > Hello,
>
> > > > > >>> > I just try my app with the 1.96.3 and I got a strange error :
>
> > > > > >>> > Traceback (most recent call last):
> > > > > >>> >   File "/version_196-3/web2py/gluon/restricted.py", line 184,
> > in
> > > > > >>> restricted
> > > > > >>> >     exec ccode in environment
> > > > > >>> >   File
> > > > "/version_196-3/web2py/applications/sgddms/controllers/test.py",
> > > > > >>> line
> > > > > >>> > 1334, in 
> > > > > >>> >

Re: [web2py] Re: issue with field name id

2011-06-06 Thread Richard Vézina
GONE!

Thanks Massimo!

I appreciate.

Richard

On Mon, Jun 6, 2011 at 5:16 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Try again please. If this is fix, please close the thread. If not,
> let'a take this private and report when fixed.
>
> On Jun 6, 4:10 pm, Richard Vézina  wrote:
> > We progress...
> >
> > Traceback (most recent call last):
> >   File "/trunk/web2py/gluon/restricted.py", line 184, in restricted
> > exec ccode in environment
> >   File "/trunk/web2py/applications/sgddms/controllers/test.py", line
> > 1334, in 
> >   File "/trunk/web2py/gluon/globals.py", line 137, in 
> > self._caller = lambda f: f()
> >   File "/trunk/web2py/gluon/tools.py", line 2444, in f
> > return action(*a, **b)
> >   File "/trunk/web2py/applications/sgddms/controllers/test.py", line
> > 173, in read
> > request.args[1])
> >   File "/trunk/web2py/gluon/tools.py", line 3134, in read
> > formstyle=self.settings.formstyle
> >   File "/trunk/web2py/gluon/sqlhtml.py", line 793, in __init__
> > inp = field.represent(default)
> >   File "/trunk/web2py/gluon/dal.py", line 3634, in list_ref_repr
> > return (refs and ', '.join(str(f(r,ref._id)) for ref in refs) or '')
> >   File "/trunk/web2py/gluon/dal.py", line 3634, in 
> > return (refs and ', '.join(str(f(r,ref._id)) for ref in refs) or '')
> >   File "/trunk/web2py/gluon/dal.py", line 3691, in __getattr__
> > return self[key]
> >   File "/trunk/web2py/gluon/dal.py", line 3682, in __getitem__
> > return dict.__getitem__(self, key)
> > KeyError: '_id'
> >
> > Now it submit... But my read function not working...
> >
> > I found this after send the issue... My select function also not
> > functionning...
> >
> > It seems all to be related...
> >
> > Richard
> >
> > On Mon, Jun 6, 2011 at 5:00 PM, Massimo Di Pierro <
> >
> >
> >
> >
> >
> >
> >
> > massimo.dipie...@gmail.com> wrote:
> > > can you please try once more...
> >
> > > P.S. I keep answering posts by my messages do not show up. :-(
> >
> > > On Jun 6, 3:43 pm, Richard Vézina  wrote:
> > > > Traceback (most recent call last):
> > > >   File "/trunk/web2py/gluon/restricted.py", line 184, in restricted
> > > > exec ccode in environment
> > > >   File "/trunk/web2py/applications/sgddms/controllers/test.py", line
> > > 1334,
> > > > in 
> > > >   File "/trunk/web2py/gluon/globals.py", line 137, in 
> > > > self._caller = lambda f: f()
> > > >   File "/trunk/web2py/gluon/tools.py", line 2444, in f
> > > > return action(*a, **b)
> > > >   File "/trunk/web2py/applications/sgddms/controllers/test.py", line
> 461,
> > > in
> > > > update
> > > > if form.accepts(request.vars, session):
> > > >   File "/trunk/web2py/gluon/sqlhtml.py", line 1203, in accepts
> > > > self.table._db(self.table._id == self.record.id
> ).update(**fields)
> > > >   File "/trunk/web2py/gluon/dal.py", line 5369, in update
> > > > fields = self.db[tablename]._listify(update_fields,update=True)
> > > >   File "/trunk/web2py/gluon/dal.py", line 4656, in _listify
> > > > raise SyntaxError, 'Field %s does not belong to the table' % name
> > > > SyntaxError: Field id does not belong to the table
> >
> > > > 1198.
> > > > 1199.
> > > > 1200.
> > > > 1201.
> > > > 1202.
> > > > 1203.
> >
> > > > 1204.
> > > > 1205.
> > > > 1206.
> > > > 1207.
> >
> > > > ret = False
> > > > else:
> > > > if record_id:
> > > > self.vars.id = self.record.id
> > > > if fields:
> > > > self.table._db(self.table._id ==
> > > > self.record.id).update(**fields)
> >
> > > > else:
> > > > self.vars.id = self.table.insert(**fields)
> > > > return ret
> >
> > > > Is what you need?
> >
> > > > Richard
> >
> > > > On Mon, Jun 6, 2011 at 4:34 PM, Massimo Di Pierro <
> >
> > > > massimo.dipie...@gmail.com> wrote:
> > > > > please re-send me the traceback sine that line in sqlhtml is not
> > > > > there.
> >
> > > > > On Jun 6, 3:04 pm, Richard Vézina 
> wrote:
> > > > > > Still there : Version 1.96.3 (2011-06-06 14:35:14)
> >
> > > > > > Richard
> >
> > > > > > On Mon, Jun 6, 2011 at 3:49 PM, Richard Vézina
> > > > > > wrote:
> >
> > > > > > > It does the problem on update... My create form work well,
> deletion
> > > > > also
> > > > > > > works.
> >
> > > > > > > Richard
> >
> > > > > > > On Mon, Jun 6, 2011 at 3:29 PM, Richard Vézina <
> > > > > > > ml.richard.vez...@gmail.com> wrote:
> >
> > > > > > >> Nop! Still there...
> >
> > > > > > >> Maybe I have wrong build :
> > > > > > >> Version 1.96.3 (2011-06-06 13:58:28)
> >
> > > > > > >> Richard
> >
> > > > > > >> On Mon, Jun 6, 2011 at 3:04 PM, Massimo Di Pierro <
> > > > > > >> massimo.dipie...@gmail.com> wrote:
> >
> > > > > > >>> I think I fixed this in trunk. Can you please check it?
> >
> > > > > > >>> On Jun 6, 1:03 pm, Richard Vézina <
> ml.richard.vez...@gmail.com>
> > > > > wrote:
> > > > 

[web2py] web2py corrupted files @ vps.net

2011-06-06 Thread Carlos
Hi,

I was testing my server environment (successfully) and all of the sudden I 
started to get errors.

After some analysis I can see that several of web2py files somehow got 
*corrupted* !

These corrupted files retained the same size and date, but when you open 
them it's all NULL values !

For reference:

   http://216.119.148.170/gluon/contrib/simplejson/LICENSE.txt
   http://216.119.148.170/gluon/contrib/simplejson/decoder.py

I'm using ubuntu server 10.04 lts (lucid), nginx, uwsgi, postgresql, latest 
web2py, mercurial.

Even if I do "hg update -C" on web2py, it detects NO changes.

The only fix that so far works (which I've tried with one .py file) is to 
manually delete the file, and then do "hg update", which reinstalls the file 
correctly.

I'm very afraid this will happen again once I'm in production.

Do you have any recommendations on what to do?, what to check?, any ideas of 
why this happened?.

Please help me to prevent this from happening again.

Thanks,

   Carlos



Re: [web2py] OAuth2.0 and Facebook (as from the book)

2011-06-06 Thread Sebastian E. Ovide
Hi Mic,

thanks for that.

actually I've debugged web2py and figure it out for myself. There are two
easy ways to fix it (I've tried to add them to the book, but my account
doesn't allow me to edit it)

1) set username=False in auth.define_tables()
2) add  email = user['username']+"@facebook.com" in the return of def
get_user



On Mon, Jun 6, 2011 at 10:02 PM, Michele Comitini <
michele.comit...@gmail.com> wrote:

> Hi Sebastian,
>
> copy from this example:
>
>
> http://code.google.com/r/michelecomitini-facebookaccess/source/browse/#hg%2Fapplications%2FhelloFacebook
>
>
> and
> let me know
>
> mic
>
> 2011/6/6 Sebastian E. Ovide 
>
> Hi All,
>>
>> just wondering if the section "OAuth2.0 and Facebook" of the book is up to
>> date?
>>
>> I following it's instructions but I'm getting an "Internal error"
>>
>> to reproduce
>>
>> 1) get last web2py 1.196.3
>> 2) follow the instructions from the book
>> 2.a) get facebook and place it in modules
>> 2.b) copy the code from the book
>> 2.c) replace "from facebook import GraphAPI" with "facebook =
>> local_import('facebook')"
>> 2.d) replace facebook. to GraphAPIError and GraphAPI
>> 2.e) replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with real data
>> 3) set your app URL to http://localhost:8000/welcome/
>>
>> Is something missing ?
>>
>> When I click login, it redirect me to facebook, where I can login, and
>> then it redirects me to http://localhost:8000/welcome/
>>
>> At that point I get an error:
>>
>>  TRACEBACK
>>
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>>
>>
>> Traceback (most recent call last):
>>
>>
>>
>>
>>   File "/home/sebas/Downloads/web2py/gluon/restricted.py", line 184, in 
>> restricted
>>
>>
>>
>>
>> exec ccode in environment
>>
>>
>>
>>
>>   File 
>> "/home/sebas/Downloads/web2py/applications/welcome/controllers/default.py" 
>> , 
>> line 71, in 
>>
>>
>>
>>
>>   File "/home/sebas/Downloads/web2py/gluon/globals.py", line 137, in 
>>
>>
>>
>>
>>   /  self._caller = lambda f: f()
>>
>>
>>
>>
>>   File 
>> "/home/sebas/Downloads/web2py/applications/welcome/controllers/default.py" 
>> , 
>> line 33, in user
>>
>>
>>
>>
>> return dict(form=auth())
>>
>>
>>
>>
>>   File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1070, in __call__
>>
>>
>>
>>
>> return getattr(self,args[0])()
>>
>>
>>
>>
>>   File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1626, in login
>>
>>
>>
>>
>> user = self.get_or_create_user(table_user._filter_fields(cas_user))
>>
>>
>>
>>
>>   File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1360, in 
>> get_or_create_user
>>
>>
>>
>>
>> user = self.db(table_user[username] == keys[username]).select().first()
>>
>>
>>
>> KeyError: 'email'
>>
>> any ideas , thanks
>>
>> --
>> Sebastian E. Ovide
>>
>>
>>
>>
>>
>


-- 
Sebastian E. Ovide


[web2py] Now everyone is Exec'ing :)

2011-06-06 Thread mikech
... As the blog entry goes on to point out, namedtuple is implemented by 
generating and exec'ing code for the classes it creates. I have a natural 
developer's distrust of exec, but as Raymond pointed out in a recent talk: 
execing code is not a security risk, execing untrusted code *is*. ...


http://www.voidspace.org.uk/python/weblog/arch_d7_2011_05_28.shtml#e1215


[web2py] components and timers

2011-06-06 Thread blackthorne
hi

Let's say I have a component that gets the last 10 tweets from some
list or that shows current CPU and memory metrics and requires to be
cyclically reloaded once every 5 mins for example. How can I do this?

Thank you
Best regards


[web2py] Re: web2py corrupted files @ vps.net

2011-06-06 Thread Massimo Di Pierro
I assume you are talking about your vps.net account. Not about the
web2py.com account.
This is a filesystem issue. I cannot help. Perhaps this help?
http://linux.die.net/man/8/fsck

On Jun 6, 4:22 pm, Carlos  wrote:
> Hi,
>
> I was testing my server environment (successfully) and all of the sudden I
> started to get errors.
>
> After some analysis I can see that several of web2py files somehow got
> *corrupted* !
>
> These corrupted files retained the same size and date, but when you open
> them it's all NULL values !
>
> For reference:
>
>    http://216.119.148.170/gluon/contrib/simplejson/LICENSE.txt
>    http://216.119.148.170/gluon/contrib/simplejson/decoder.py
>
> I'm using ubuntu server 10.04 lts (lucid), nginx, uwsgi, postgresql, latest
> web2py, mercurial.
>
> Even if I do "hg update -C" on web2py, it detects NO changes.
>
> The only fix that so far works (which I've tried with one .py file) is to
> manually delete the file, and then do "hg update", which reinstalls the file
> correctly.
>
> I'm very afraid this will happen again once I'm in production.
>
> Do you have any recommendations on what to do?, what to check?, any ideas of
> why this happened?.
>
> Please help me to prevent this from happening again.
>
> Thanks,
>
>    Carlos


[web2py] Re: components and timers

2011-06-06 Thread Massimo Di Pierro
look into gluon/contrib/comet_messaging.py

On Jun 6, 5:08 pm, blackthorne  wrote:
> hi
>
> Let's say I have a component that gets the last 10 tweets from some
> list or that shows current CPU and memory metrics and requires to be
> cyclically reloaded once every 5 mins for example. How can I do this?
>
> Thank you
> Best regards


[web2py] Re: OAuth2.0 and Facebook (as from the book)

2011-06-06 Thread Massimo Di Pierro
if there is agreement on one, please send me a patch.

On Jun 6, 4:31 pm, "Sebastian E. Ovide" 
wrote:
> Hi Mic,
>
> thanks for that.
>
> actually I've debugged web2py and figure it out for myself. There are two
> easy ways to fix it (I've tried to add them to the book, but my account
> doesn't allow me to edit it)
>
> 1) set username=False in auth.define_tables()
> 2) add  email = user['username']+"@facebook.com" in the return of def
> get_user
>
> On Mon, Jun 6, 2011 at 10:02 PM, Michele Comitini <
>
>
>
>
>
>
>
>
>
> michele.comit...@gmail.com> wrote:
> > Hi Sebastian,
>
> > copy from this example:
>
> >http://code.google.com/r/michelecomitini-facebookaccess/source/browse...
>
> > and
> > let me know
>
> > mic
>
> > 2011/6/6 Sebastian E. Ovide 
>
> > Hi All,
>
> >> just wondering if the section "OAuth2.0 and Facebook" of the book is up to
> >> date?
>
> >> I following it's instructions but I'm getting an "Internal error"
>
> >> to reproduce
>
> >> 1) get last web2py 1.196.3
> >> 2) follow the instructions from the book
> >> 2.a) get facebook and place it in modules
> >> 2.b) copy the code from the book
> >> 2.c) replace "from facebook import GraphAPI" with "facebook =
> >> local_import('facebook')"
> >> 2.d) replace facebook. to GraphAPIError and GraphAPI
> >> 2.e) replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with real data
> >> 3) set your app URL tohttp://localhost:8000/welcome/
>
> >> Is something missing ?
>
> >> When I click login, it redirect me to facebook, where I can login, and
> >> then it redirects me tohttp://localhost:8000/welcome/
>
> >> At that point I get an error:
>
> >>  TRACEBACK
>
> >> 1.
> >> 2.
> >> 3.
> >> 4.
> >> 5.
> >> 6.
> >> 7.
> >> 8.
> >> 9.
> >> 10.
> >> 11.
> >> 12.
> >> 13.
> >> 14.
> >> 15.
> >> 16.
>
> >> Traceback (most recent call last):
>
> >>   File "/home/sebas/Downloads/web2py/gluon/restricted.py", line 184, in 
> >> restricted
>
> >>     exec ccode in environment
>
> >>   File 
> >> "/home/sebas/Downloads/web2py/applications/welcome/controllers/default.py" 
> >> , 
> >> line 71, in 
>
> >>   File "/home/sebas/Downloads/web2py/gluon/globals.py", line 137, in 
> >> 
>
> >>   /  self._caller = lambda f: f()
>
> >>   File 
> >> "/home/sebas/Downloads/web2py/applications/welcome/controllers/default.py" 
> >> , 
> >> line 33, in user
>
> >>     return dict(form=auth())
>
> >>   File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1070, in 
> >> __call__
>
> >>     return getattr(self,args[0])()
>
> >>   File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1626, in login
>
> >>     user = self.get_or_create_user(table_user._filter_fields(cas_user))
>
> >>   File "/home/sebas/Downloads/web2py/gluon/tools.py", line 1360, in 
> >> get_or_create_user
>
> >>     user = self.db(table_user[username] == keys[username]).select().first()
>
> >> KeyError: 'email'
>
> >> any ideas , thanks
>
> >> --
> >> Sebastian E. Ovide
>
> --
> Sebastian E. Ovide


[web2py] Re: web2py corrupted files @ vps.net

2011-06-06 Thread Carlos
Yes, I'm talking about my vps.net environment.

Any ideas about why / how this type of corruption occurs?.

Has anyone else experienced this problem before?.

I'll check that utility, thanks Massimo.

   Carlos



[web2py] Re: components and timers

2011-06-06 Thread blackthorne
thank you

On Jun 6, 11:15 pm, Massimo Di Pierro 
wrote:
> look into gluon/contrib/comet_messaging.py
>
> On Jun 6, 5:08 pm, blackthorne  wrote:
>
>
>
> > hi
>
> > Let's say I have a component that gets the last 10 tweets from some
> > list or that shows current CPU and memory metrics and requires to be
> > cyclically reloaded once every 5 mins for example. How can I do this?
>
> > Thank you
> > Best regards


Re: [web2py] Re: components and timers

2011-06-06 Thread Stifan Kristi
hi, massimo

did you have the documentation for do this?

thank you so much

On Tue, Jun 7, 2011 at 5:15 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> look into gluon/contrib/comet_messaging.py
>
> On Jun 6, 5:08 pm, blackthorne  wrote:
> > hi
> >
> > Let's say I have a component that gets the last 10 tweets from some
> > list or that shows current CPU and memory metrics and requires to be
> > cyclically reloaded once every 5 mins for example. How can I do this?
> >
> > Thank you
> > Best regards
>


Re: [web2py] Re: components and timers

2011-06-06 Thread David J
Seeing that comet is not widely supportted I was wondering if there was an
ajax poll example?
On Jun 6, 2011 6:15 PM, "Massimo Di Pierro" 
wrote:
> look into gluon/contrib/comet_messaging.py
>
> On Jun 6, 5:08 pm, blackthorne  wrote:
>> hi
>>
>> Let's say I have a component that gets the last 10 tweets from some
>> list or that shows current CPU and memory metrics and requires to be
>> cyclically reloaded once every 5 mins for example. How can I do this?
>>
>> Thank you
>> Best regards


[web2py] Pre-fill email address on failed login?

2011-06-06 Thread pbreit
I'm trying to pre-fill the email address field on a failed login but can't 
seem to figure out if the default/user() function can access any of the 
submitted inputs. That probably should be default functionality anyway.

  1   2   >