[web2py] Re: "race" keyword?

2011-04-19 Thread niknok
Thanks. I decided to rename it permanently. No issues so far.

On Apr 19, 9:19 pm, Massimo Di Pierro 
wrote:
> pretty sure this is not a python keyword, not a web2py keyword, not
> unsed internally and not a sqlite reserved keyword.
>
> I cannot tell what the problem is without seeing the code.
>
> On Apr 19, 7:46 am, niknok  wrote:
>
>
>
>
>
>
>
> > >From the ticket:
>
> > Traceback (most recent call last):
> >   File "/home/nrg/Projects/web2py/gluon/restricted.py", line 188, in 
> > restricted
> >     exec ccode in environment
> >   File "/home/nrg/Projects/web2py/applications/bbc/models/db_donor.py", 
> > line 419, in 
> >     initializer.fillup(db)
> >   File "applications/bbc/modules/initializer.py", line 5, in fillup
> >     if not db(db.release_version.id>0).count():
> >   File "/home/nrg/Projects/web2py/gluon/dal.py", line 3904, in __getattr__
> >     return self[key]
> >   File "/home/nrg/Projects/web2py/gluon/dal.py", line 3898, in __getitem__
> >     return dict.__getitem__(self, str(key))
> > KeyError: 'race'
>
> > For the life of me, I couldn't find a reference to "race" in the model
> > file db_donor.py or the module initializer.py. I used the term in
> > another model, but that model is working fine.
>
> > Out of desperation, I renamed all references to "race" in my code and
> > behold, the error disappeared. Renamed it back to "race" and I get the
> > error again.
>
> > Is "race" a reserved word? I'm using sqlite.


[web2py] plugin_wiki as help system

2011-04-19 Thread niknok
I'm wondering if there's any way to implement a help system in the
context of a field in conjunction with plugin_wiki.

Conceptual use:

Table('myTable',
Field('myField', help='slug_to_help_page_sub-section')
help='slug_to_help_page_section_index')

In a form, the user will see a help icon beside the input field, which
they can click to view a popup to display more information, and perhaps
with additional link to the main help page for detailed information. 

If plugin_wiki is not installed, then "help" is ignored. 

Seems like a nice feature to add to web2py. What do you think? Has
anyone customized w2p to do something like this?



[web2py] Re: cas_auth.py

2011-04-19 Thread Massimo Di Pierro
When you use cas you should disable local registration

auth.settings.actions_disabled.append('register')

and somewhere you need to manually add a link to cas registration.

This cannot be automated because most cas services do not allow user
to register. At my university for example the accounts are pulled from
a peopleosoft database.

On Apr 19, 10:18 pm, Triquetra 
wrote:
> I'm having this same issue using cas_auth.  I'm running my own CAS
> appliance.
>
> My applications successfully redirects to CAS on login, but not on
> registration.  When I try to login, I get an "invalid login" error, I
> presume because the registration was never entered into CAS, but only in the
> local application.
>
> Has this been fixed?


Re: [web2py] Re: cas_auth.py

2011-04-19 Thread Triquetra
I'm having this same issue using cas_auth.  I'm running my own CAS 
appliance.

My applications successfully redirects to CAS on login, but not on 
registration.  When I try to login, I get an "invalid login" error, I 
presume because the registration was never entered into CAS, but only in the 
local application.

Has this been fixed?


[web2py] Re: impersonate any user

2011-04-19 Thread Massimo Di Pierro
I think this is a bug.



On Apr 19, 5:54 pm, pbreit  wrote:
> OK, thanks.
>
> I'm getting a "Not Authorized" when I GET /impersonate. Removing "or not
> self.environment.request.post_vars" seems to fix it.
>
>     if not self.is_logged_in() or not self.environment.request.post_vars:
>         raise HTTP(401, "Not Authorized")


Re: [web2py] Re: performance impact using record versioning

2011-04-19 Thread Stifan Kristi
a, it's more wisely, thank you so much for your shared, howesc

On Wed, Apr 20, 2011 at 7:45 AM, howesc  wrote:

> i use versioning selectively on tables depending on if i need that audit
> trail or not.  not all tables need it.
>


Re: [web2py] Re: performance impact using record versioning

2011-04-19 Thread howesc
i use versioning selectively on tables depending on if i need that audit 
trail or not.  not all tables need it.


Re: [web2py] Re: performance impact using record versioning

2011-04-19 Thread Stifan Kristi
thank you so much for your suggestion, pbreit.

On Wed, Apr 20, 2011 at 5:58 AM, pbreit  wrote:

> Totally depends on your situation. For most systems, performance is a
> non-issue. Improving performance is easy. Making a system that people want
> to use is hard. Focus on that.


[web2py] Re: impersonate any user

2011-04-19 Thread pbreit
Can someone help me understand if I want to leave the default behavior of 
each user being in its own group? It seems excessive to me but I'm afraid to 
turn it off. I'm assuming this would enable me to set permissions as 
granularly as per-user. I'm just not sure when I would ever do that.

[web2py] Re: DB design question . Gmail like schema

2011-04-19 Thread pbreit
That's a tricky question. To begin with, keep it simple. Web2py gives you a 
lot of flexibility to play around with your DB schema. While developing, you 
can easily modify schema or even throw it out and start over. Once you're in 
production, you have to be much more careful.

You could start with a single table and see how far you get.

db.define_table('message',
   Field('from_email'), # sender
   Field('to_email'), # recipient
   Field('subject'),
   Field('body', 'text'),
   Field('ref_id'),
   auth.signature)

The "ref_id" would relate to a prior message so you could build a thread. 
Alternatively, you might need a "thread" table to tie them together. 
"auth_signature" automatically provides a timestamp and user info (if 
someone is logged in).


Re: [web2py] Re: performance impact using record versioning

2011-04-19 Thread pbreit
Totally depends on your situation. For most systems, performance is a 
non-issue. Improving performance is easy. Making a system that people want 
to use is hard. Focus on that.

[web2py] Re: impersonate any user

2011-04-19 Thread pbreit
OK, thanks.

I'm getting a "Not Authorized" when I GET /impersonate. Removing "or not 
self.environment.request.post_vars" seems to fix it.

if not self.is_logged_in() or not self.environment.request.post_vars:
raise HTTP(401, "Not Authorized")


Re: [web2py] Re: performance impact using record versioning

2011-04-19 Thread Stifan Kristi
a, i c, thank you so much for your explaination, massimo. so, record
versioning, is not recommended to be implemented on production environment,
is it?

On Tue, Apr 19, 2011 at 11:49 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> About a factor 2 I guess. because you need to perform one update and
> one insert as opposed to one update only.
>
> On Apr 19, 9:46 am, 黄祥  wrote:
> > hi,
> >
> > is there any performance impact using record versioning?
> http://web2py.com/book/default/chapter/07?search=crud.archive#Record-...
> > or is there anybody have another suggestion?
> >
> > thank you so much


[web2py] DB design question . Gmail like schema

2011-04-19 Thread Manu
Hi ,
I really like web2py as a framework as I can quickly come up with
something working(controller and views are so easy to write). But as i
am not a seasoned developper i feel weak when it comes to design the
database. DAL is great but unfortunatley it can define the schema for
me ( yet :) )
 I would like to know if someone would suggest me a sound design for
the db so that my users can exchange messages that can be organised in
threads like Gmail .

Any help or pointer to some appliance that would help me starting the
db will be appreciated

Thx
Manu


[web2py] Re: impersonate any user

2011-04-19 Thread Massimo Di Pierro
First at some point do

gid = auth.add_group('impersonators')
auth.add_permission(gid,'impersonate','auth_user')
auth.add_membership(gid,your_authuser_id)

then just visit

http://.../user/impersonate

and it prompt you a form about which user you want to impersonate. 0
for reverting back to yourself.

On Apr 19, 4:20 pm, pbreit  wrote:
> I'm looking to set up my customer support scheme and so would like to use
> Impersonate. But I'm not quite sure how to do it.
>
> 1. Can it be set up so that I can impersonate any auth_user?
> 2. I believe there was a change so that instead of
> /user/impersonate/[user_id], the "user_id" now needs to be POSTed to
> /user/impersonate?
> 3. Do I set up an auth_permission with name='impersonate'?
> 4. For group_id, I have a group that includes the user who I want to grant
> Impersonate privileges?
> 5. What do I put in group_id, table_name and record_id? The Book says these
> are optional but the system requires them.
>
> Also, I have a lingering question about why each user automatically gets a
> group? What do I lose if I turn this off?


[web2py] Re: impersonate any user

2011-04-19 Thread pbreit
I'm looking to set up my customer support scheme and so would like to use 
Impersonate. But I'm not quite sure how to do it.

1. Can it be set up so that I can impersonate any auth_user?
2. I believe there was a change so that instead of 
/user/impersonate/[user_id], the "user_id" now needs to be POSTed to 
/user/impersonate?
3. Do I set up an auth_permission with name='impersonate'?
4. For group_id, I have a group that includes the user who I want to grant 
Impersonate privileges?
5. What do I put in group_id, table_name and record_id? The Book says these 
are optional but the system requires them.

Also, I have a lingering question about why each user automatically gets a 
group? What do I lose if I turn this off?


[web2py] Re: Access Control not in db.py?? How to modify?

2011-04-19 Thread Keith Pettit
That was my bad I was looking at the wrong application.  I have too many 
test apps that I'm playing around with :)

Also I just tried the 
web2py.plugin.useradmin.w2p
 which 
I think is OK.  It's very basic but has a nice single ajax page for adding 
user/group and modifying the basics. 

Thanks,

-Keith


[web2py] Re: Access Control not in db.py?? How to modify?

2011-04-19 Thread Anthony
On Tuesday, April 19, 2011 3:07:25 PM UTC-4, Keith Pettit wrote: 
>
> I appreciate the help.  I'll give the plugin a try and read through the 
> docs you suggested. 
>
> One note.  auth_user was in db.py if I created a "New simple application" 
> or went through the "New Application Wizard".  Which I is part of what was 
> confusing me.
>
 
Hmm, what version are you using? On 1.94.6, when I use "New simple 
application", it does NOT include a custom table definition for auth_user in 
db.py (it simply copies the 'welcome' app, which doesn't include a custom 
'auth_user' either). However, the "New Application Wizard" does generate a 
custom auth_user table.
 
Anthony


[web2py] Re: Access Control not in db.py?? How to modify?

2011-04-19 Thread Keith Pettit
I appreciate the help.  I'll give the plugin a try and read through the docs 
you suggested.

One note.  auth_user was in db.py if I created a "New simple application" or 
went through the "New Application Wizard".  Which I is part of what was 
confusing me.  

Thanks,
-Keith


[web2py] Re: Access Control not in db.py?? How to modify?

2011-04-19 Thread Anthony
Also, I haven't tried it, but here's a link to a web2py user admin plugin: 
http://jaguar.biologie.hu-berlin.de/~fkrause/web2py.plugin.useradmin.w2p.
 
You might also check some of the appliances here: 
http://www.web2py.com/appliances/
 
Anthony

On Tuesday, April 19, 2011 2:48:05 PM UTC-4, Anthony wrote:

> On Tuesday, April 19, 2011 2:16:47 PM UTC-4, Keith Pettit wrote: 
>>
>> I'm still learning web2py, I'm working on access control and was confused 
>> by a few things I was hoping to understand better. 
>>
>> 1 - Why is auth_user in db.py, but none of the other auth_ tables are?
>>
>  
> Once you create the auth object, when you call:
>  
> auth.define_tables()
>  
> all of the auth tables are automatically defined/created for you, so you 
> don't need to define any of them in db.py. If you're using the web2py 
> wizard, I believe it does create a custom auth_user table in db.py, which is 
> probably what you're seeing.
>  
>
>>  
>> 2 - If I wanted to add or modify any of the auth tables, how would I do 
>> that?  auth_user is in db.py but the other auth_ tables aren't.  Previously 
>> when I tried to define a auth_group or similar access control table I got 
>> all sorts of errors but I can't find anywhere else to modify them.
>>
>  
> Follow the instructions at 
> http://web2py.com/book/default/chapter/08#Customizing-Auth. Note, you have 
> to define your custom tables *after* you have created the auth object, but 
> *before* you call auth.define_tables() -- because the latter automatically 
> defines all tables that have not already been defined.
>  
> To see what the default version of each table looks like, look at the 
> define_tables() method of the Auth class in /gluon/tools.py: 
> http://code.google.com/p/web2py/source/browse/gluon/tools.py#1116
>  
>
>>  
>> 3- Are there any plugin's or appliances for web2py with a admin already 
>> done for user/group management?
>>
>  
> Well, for starters, you can just use 'appadmin' to add/edit/delete users, 
> groups, and permissions (see 
> http://web2py.com/book/default/chapter/03#More-on-appadmin).
>  
> Anthony
>  
>


[web2py] Re: Access Control not in db.py?? How to modify?

2011-04-19 Thread Anthony
On Tuesday, April 19, 2011 2:16:47 PM UTC-4, Keith Pettit wrote: 
>
> I'm still learning web2py, I'm working on access control and was confused 
> by a few things I was hoping to understand better. 
>
> 1 - Why is auth_user in db.py, but none of the other auth_ tables are?
>
 
Once you create the auth object, when you call:
 
auth.define_tables()
 
all of the auth tables are automatically defined/created for you, so you 
don't need to define any of them in db.py. If you're using the web2py 
wizard, I believe it does create a custom auth_user table in db.py, which is 
probably what you're seeing.
 

>  
> 2 - If I wanted to add or modify any of the auth tables, how would I do 
> that?  auth_user is in db.py but the other auth_ tables aren't.  Previously 
> when I tried to define a auth_group or similar access control table I got 
> all sorts of errors but I can't find anywhere else to modify them.
>
 
Follow the instructions at 
http://web2py.com/book/default/chapter/08#Customizing-Auth. Note, you have 
to define your custom tables *after* you have created the auth object, but *
before* you call auth.define_tables() -- because the latter automatically 
defines all tables that have not already been defined.
 
To see what the default version of each table looks like, look at the 
define_tables() method of the Auth class in /gluon/tools.py: 
http://code.google.com/p/web2py/source/browse/gluon/tools.py#1116
 

>  
> 3- Are there any plugin's or appliances for web2py with a admin already 
> done for user/group management?
>
 
Well, for starters, you can just use 'appadmin' to add/edit/delete users, 
groups, and permissions (see 
http://web2py.com/book/default/chapter/03#More-on-appadmin).
 
Anthony
 


[web2py] Re: Interesting tool, Maqetta

2011-04-19 Thread mikech
Yes interesting, and it looks like it uses Dojo.

[web2py] Access Control not in db.py?? How to modify?

2011-04-19 Thread Keith Pettit
I'm still learning web2py, I'm working on access control and was confused by 
a few things I was hoping to understand better.

1 - Why is auth_user in db.py, but none of the other auth_ tables are?

2 - If I wanted to add or modify any of the auth tables, how would I do 
that?  auth_user is in db.py but the other auth_ tables aren't.  Previously 
when I tried to define a auth_group or similar access control table I got 
all sorts of errors but I can't find anywhere else to modify them.

3- Are there any plugin's or appliances for web2py with a admin already done 
for user/group management?  

Thanks,


Re: [web2py] importing CSV / NameError: global name 'request' is not defined"

2011-04-19 Thread Anthony
Also, you call 'initialize.fillup(db)' (i.e., you pass 'db' as an argument 
to 'fillup'), but your function definition for 'fillup' does not include any 
arguments.

On Tuesday, April 19, 2011 8:56:07 AM UTC-4, 黄祥 wrote:

> please add request variable as parameter on your modules and your function, 
> because the modules can't pass global name like (response, request, db, t, 
> crud, etc) so that you must add it: 
> (not tested)
> e.g. 
> initialize = local_import('initialize')
> initialize.fillup(db, response)
>
> please let me know if you still have this problem.
>
> On Tue, Apr 19, 2011 at 3:56 PM, niknok  wrote:
>
>> I am trying to call this module that contains a series of import_csv_file 
>> statement like so: 
>>
>> from my model, db_history.py I call up a module to import a series of csv 
>> files: 
>>
>> initialize=local_import('initialize')
>> initialize.fillup(db)
>>
>>
>> my modules/fillup.py looks like this: 
>>
>> import os
>>
>> def fillup():
>> try:
>> 
>> db.question.import_from_csv_file(open(os.path.join(request.folder,'private/db_question.csv'),'r'))
>> except Exception, e:
>> print 'oops: %s' % e #XXX
>> raise e
>>
>> ...
>>
>>
>> Then I get: "NameError: global name 'request' is not defined"
>>
>> What's weird is that those import statements run from the shell.  They 
>> also work fine if I put them in the model that calls it. But, I'm hoping to 
>> database initialization by CSV from a single module file.
>>
>> I'm pretty sure I'm missing something here. Anyone?
>>
>>
>>
>>
>

[web2py] importing CSV / NameError: global name 'request' is not defined"

2011-04-19 Thread pbreit
Modules have no access to models or the request. You have to pass in everything 
the module needs.


[web2py] Re: performance impact using record versioning

2011-04-19 Thread Massimo Di Pierro
About a factor 2 I guess. because you need to perform one update and
one insert as opposed to one update only.

On Apr 19, 9:46 am, 黄祥  wrote:
> hi,
>
> is there any performance impact using record 
> versioning?http://web2py.com/book/default/chapter/07?search=crud.archive#Record-...
> or is there anybody have another suggestion?
>
> thank you so much


[web2py] performance impact using record versioning

2011-04-19 Thread 黄祥
hi,

is there any performance impact using record versioning?
http://web2py.com/book/default/chapter/07?search=crud.archive#Record-Versioning
or is there anybody have another suggestion?

thank you so much


[web2py] Re: "race" keyword?

2011-04-19 Thread Massimo Di Pierro
pretty sure this is not a python keyword, not a web2py keyword, not
unsed internally and not a sqlite reserved keyword.

I cannot tell what the problem is without seeing the code.

On Apr 19, 7:46 am, niknok  wrote:
> >From the ticket:
>
> Traceback (most recent call last):
>   File "/home/nrg/Projects/web2py/gluon/restricted.py", line 188, in 
> restricted
>     exec ccode in environment
>   File "/home/nrg/Projects/web2py/applications/bbc/models/db_donor.py", line 
> 419, in 
>     initializer.fillup(db)
>   File "applications/bbc/modules/initializer.py", line 5, in fillup
>     if not db(db.release_version.id>0).count():
>   File "/home/nrg/Projects/web2py/gluon/dal.py", line 3904, in __getattr__
>     return self[key]
>   File "/home/nrg/Projects/web2py/gluon/dal.py", line 3898, in __getitem__
>     return dict.__getitem__(self, str(key))
> KeyError: 'race'
>
> For the life of me, I couldn't find a reference to "race" in the model
> file db_donor.py or the module initializer.py. I used the term in
> another model, but that model is working fine.
>
> Out of desperation, I renamed all references to "race" in my code and
> behold, the error disappeared. Renamed it back to "race" and I get the
> error again.
>
> Is "race" a reserved word? I'm using sqlite.


[web2py] Re: Strange behavior in DAL x CRUD

2011-04-19 Thread Massimo Di Pierro
I think this is a bug. Can you please open a ticket on google code?

On Apr 19, 5:42 am, Allan Daemon  wrote:
> Hi.
>
> I'm new by here, as also in web2py. I'm from Brazil.
>
> I created a table with this field:
>
>     Field('userid', db.auth_user, unique=True, required=True,
> writable=False, readable=False)
>
> Just logged users can submit, with 1 record per user, and I need to keep
> the user id in each record.
>
> In the controller I put this in the CRUD creation:
>
> # coding: utf8#
> from gluon.tools import Crud
> crud = Crud(globals(), db)
>
> crud.settings.formstyle = "divs"
> crud.messages.submit_button = 'Enviar'
>
> @auth.requires_login()
> def index():
>     uid = auth.user_id
>     current_records = db(db.guys.userid == uid)
>     if current_records.count(): #user already registry
>         gid = current_records.select().first().id
>         f = crud.update(db.guys, gid, audit_guys,
> onaccept=crud.archive) #To be fixed
>     else: # New regisry
>         db.guys.pg.readable = False
>         db.guys.nome.default = auth.user.first_name+ ' ' + auth.user.last_name
>         db.guys.email.default = auth.user.email
>         #db.guys.userid.default = auth.user_id
>         db.guys.userid.compute = lambda f: uid
>         f = crud.create(db.guys)
>     return dict(msg='',form=f)
>
> But when I insert a record, it's raises this error:
>
> Traceback (most recent call last):
>   File "/var/www/web2py/gluon/restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "/var/www/web2py/applications/jornada/controllers/inscricao.py",
> line 59, in 
>   File "/var/www/web2py/gluon/globals.py", line 124, in 
>     self._caller = lambda f: f()
>   File "/var/www/web2py/gluon/tools.py", line 2331, in f
>     return action(*a, **b)
>   File "/var/www/web2py/applications/jornada/controllers/inscricao.py",
> line 31, in index
>     f = crud.create(db.guys)
>   File "/var/www/web2py/gluon/tools.py", line 2960, in create
>     formname=formname,
>   File "/var/www/web2py/gluon/tools.py", line 2901, in update
>     detect_record_change = self.settings.detect_record_change):
>   File "/var/www/web2py/gluon/sqlhtml.py", line 1201, in accepts
>     self.vars.id = self.table.insert(**fields)
>   File "/var/www/web2py/gluon/dal.py", line 4429, in insert
>     return self._db._adapter.insert(self,self._listify(fields))
>   File "/var/www/web2py/gluon/dal.py", line 4422, in _listify
>     raise SyntaxError,'Table: missing required field: %s' % ofield.name
> SyntaxError: Table: missing required field: userid
>
> Both
> db.guys.userid.default = auth.user_id
> OR
> db.guys.userid.compute = lambda f: uid
> OR both together didn't worked.
> When I set writable=True, the insertion was successful.
>
> Then I changed the required=False:
>
> Field('userid', db.auth_user, unique=True, required=False,
> writable=False, readable=False)
>
> And it worked correctly, saving the user. Is this the expected
> behavior? Now its working, but I thing this really strange to me.
>
> Allan Daemon
>
> -BEGIN GEEK CODE BLOCK-
> Version: 3.1
> GAT/CS/CM/ED/IT/MC/CA/SS/G/H d-- s++:+ a--(?) C++() UBS+++>$ P++
> Py+++>+$ L+ E---
> W++ N++ o- K+ w++ !O M++ V-- PS++ PE- Y++ PGP++>+++ t 5? X R>+++ tv--() b DI+
> D+ G++> e+> h r-->+++ y++**>$?
> --END GEEK CODE BLOCK--


Re: [web2py] importing CSV / NameError: global name 'request' is not defined"

2011-04-19 Thread Stifan Kristi
please add request variable as parameter on your modules and your function,
because the modules can't pass global name like (response, request, db, t,
crud, etc) so that you must add it:
(not tested)
e.g.
initialize = local_import('initialize')
initialize.fillup(db, response)

please let me know if you still have this problem.

On Tue, Apr 19, 2011 at 3:56 PM, niknok  wrote:

>  I am trying to call this module that contains a series of import_csv_file
> statement like so:
>
> from my model, db_history.py I call up a module to import a series of csv
> files:
>
> initialize=local_import('initialize')
> initialize.fillup(db)
>
>
> my modules/fillup.py looks like this:
>
> import os
>
> def fillup():
> try:
> 
> db.question.import_from_csv_file(open(os.path.join(request.folder,'private/db_question.csv'),'r'))
> except Exception, e:
> print 'oops: %s' % e #XXX
> raise e
>
> ...
>
>
> Then I get: "NameError: global name 'request' is not defined"
>
> What's weird is that those import statements run from the shell.  They also
> work fine if I put them in the model that calls it. But, I'm hoping to
> database initialization by CSV from a single module file.
>
> I'm pretty sure I'm missing something here. Anyone?
>
>
>
>


[web2py] "race" keyword?

2011-04-19 Thread niknok
>From the ticket: 

Traceback (most recent call last):
  File "/home/nrg/Projects/web2py/gluon/restricted.py", line 188, in restricted
exec ccode in environment
  File "/home/nrg/Projects/web2py/applications/bbc/models/db_donor.py", line 
419, in 
initializer.fillup(db)
  File "applications/bbc/modules/initializer.py", line 5, in fillup
if not db(db.release_version.id>0).count():
  File "/home/nrg/Projects/web2py/gluon/dal.py", line 3904, in __getattr__
return self[key]
  File "/home/nrg/Projects/web2py/gluon/dal.py", line 3898, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'race'


For the life of me, I couldn't find a reference to "race" in the model
file db_donor.py or the module initializer.py. I used the term in
another model, but that model is working fine.

Out of desperation, I renamed all references to "race" in my code and
behold, the error disappeared. Renamed it back to "race" and I get the
error again.

Is "race" a reserved word? I'm using sqlite. 


[web2py] "race" keyword?

2011-04-19 Thread niknok
>From the ticket: 

Traceback (most recent call last):
  File "/home/nrg/Projects/web2py/gluon/restricted.py", line 188, in restricted
exec ccode in environment
  File "/home/nrg/Projects/web2py/applications/bbc/models/db_donor.py", line 
419, in 
initializer.fillup(db)
  File "applications/bbc/modules/initializer.py", line 5, in fillup
if not db(db.release_version.id>0).count():
  File "/home/nrg/Projects/web2py/gluon/dal.py", line 3904, in __getattr__
return self[key]
  File "/home/nrg/Projects/web2py/gluon/dal.py", line 3898, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'race'


For the life of me, I couldn't find a reference to "race" in the model
file db_donor.py or the module initializer.py. I used the term in
another model, but that model is working fine.

Out of desperation, I renamed all references to "race" in my code and
behold, the error disappeared. Renamed it back to "race" and I get the
error again.

Is "race" a reserved word? I'm using sqlite.


[web2py] importing CSV / NameError: global name 'request' is not defined"

2011-04-19 Thread niknok
I am trying to call this module that contains a series of
import_csv_file statement like so: 

from my model, db_history.py I call up a module to import a series of
csv files: 

initialize=local_import('initialize')
initialize.fillup(db)


my modules/fillup.py looks like this: 

import os

def fillup():
try:

db.question.import_from_csv_file(open(os.path.join(request.folder,'private/db_question.csv'),'r'))
except Exception, e:
print 'oops: %s' % e #XXX
raise e

...


Then I get: "NameError: global name 'request' is not defined"

What's weird is that those import statements run from the shell.  They
also work fine if I put them in the model that calls it. But, I'm hoping
to database initialization by CSV from a single module file.

I'm pretty sure I'm missing something here. Anyone?





[web2py] using bpython

2011-04-19 Thread niknok
bpython as a shell is a bit unforgiving for newbies. Attempting to use
non-existing methods (or use it wrongly) will cause it to fail, and then
uncremoniously drop you back to ipython. For example, I typed:
"db.field(" 

Despite this, I still find it quite useful, but wish that if it would
handle these errors more gracefully. 


[web2py] Mail.Attachment and Blob

2011-04-19 Thread Bob
Can Mail.Attachment work with blob field data instead of a file path?
I guess I can just write the file and give the path then but wondered
if there is more elegant solution like passing the blob data directly
to Mail

Thanks


Re: [web2py] Interesting tool, Maqetta

2011-04-19 Thread Stifan Kristi
nice info, thanks

On Tue, Apr 19, 2011 at 5:01 PM, Jason (spot) Brower wrote:

> http://maqetta.org/
> It's integration into web2py might be fun, and a monstorous challenge.
> BR,
> Jason
>


Re: [web2py] Re: geoserver proxyHost with web2py

2011-04-19 Thread Manuele Pesenti

On 18/04/2011 13:55, GoldenTiger wrote:

Instead of using a Http proxy, you can use web2py as a lower level
proxy, as a TCP proxy  (http://www.example-code.com/python/
socket_http_proxy.asp)


this does not resolve because the request through the proxy is performed 
by the js library called openlayers and the replay is even returned to 
it. So I have to return information in the same way as in the cgi script 
is done beacuse I cannot change the openlayers behaviour in reading the 
replay I get for him to geoserver. I hope I've been clear :)


thanks anyway
cheers

Manuele


Try to modify a single char of Http traffic from client in real time,
if it works then it could be easier than investigating processes data
exchange




[web2py] Strange behavior in DAL x CRUD

2011-04-19 Thread Allan Daemon
Hi.

I'm new by here, as also in web2py. I'm from Brazil.

I created a table with this field:

Field('userid', db.auth_user, unique=True, required=True,
writable=False, readable=False)

Just logged users can submit, with 1 record per user, and I need to keep
the user id in each record.

In the controller I put this in the CRUD creation:

# coding: utf8#
from gluon.tools import Crud
crud = Crud(globals(), db)

crud.settings.formstyle = "divs"
crud.messages.submit_button = 'Enviar'

@auth.requires_login()
def index():
uid = auth.user_id
current_records = db(db.guys.userid == uid)
if current_records.count(): #user already registry
gid = current_records.select().first().id
f = crud.update(db.guys, gid, audit_guys,
onaccept=crud.archive) #To be fixed
else: # New regisry
db.guys.pg.readable = False
db.guys.nome.default = auth.user.first_name+ ' ' + auth.user.last_name
db.guys.email.default = auth.user.email
#db.guys.userid.default = auth.user_id
db.guys.userid.compute = lambda f: uid
f = crud.create(db.guys)
return dict(msg='',form=f)

But when I insert a record, it's raises this error:

Traceback (most recent call last):
  File "/var/www/web2py/gluon/restricted.py", line 188, in restricted
exec ccode in environment
  File "/var/www/web2py/applications/jornada/controllers/inscricao.py",
line 59, in 
  File "/var/www/web2py/gluon/globals.py", line 124, in 
self._caller = lambda f: f()
  File "/var/www/web2py/gluon/tools.py", line 2331, in f
return action(*a, **b)
  File "/var/www/web2py/applications/jornada/controllers/inscricao.py",
line 31, in index
f = crud.create(db.guys)
  File "/var/www/web2py/gluon/tools.py", line 2960, in create
formname=formname,
  File "/var/www/web2py/gluon/tools.py", line 2901, in update
detect_record_change = self.settings.detect_record_change):
  File "/var/www/web2py/gluon/sqlhtml.py", line 1201, in accepts
self.vars.id = self.table.insert(**fields)
  File "/var/www/web2py/gluon/dal.py", line 4429, in insert
return self._db._adapter.insert(self,self._listify(fields))
  File "/var/www/web2py/gluon/dal.py", line 4422, in _listify
raise SyntaxError,'Table: missing required field: %s' % ofield.name
SyntaxError: Table: missing required field: userid

Both
db.guys.userid.default = auth.user_id
OR
db.guys.userid.compute = lambda f: uid
OR both together didn't worked.
When I set writable=True, the insertion was successful.

Then I changed the required=False:

Field('userid', db.auth_user, unique=True, required=False,
writable=False, readable=False)

And it worked correctly, saving the user. Is this the expected
behavior? Now its working, but I thing this really strange to me.


Allan Daemon


-BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/CS/CM/ED/IT/MC/CA/SS/G/H d-- s++:+ a--(?) C++() UBS+++>$ P++
Py+++>+$ L+ E---
W++ N++ o- K+ w++ !O M++ V-- PS++ PE- Y++ PGP++>+++ t 5? X R>+++ tv--() b DI+
D+ G++> e+> h r-->+++ y++**>$?
--END GEEK CODE BLOCK--


[web2py] Interesting tool, Maqetta

2011-04-19 Thread Jason (spot) Brower
http://maqetta.org/
It's integration into web2py might be fun, and a monstorous challenge.
BR,
Jason