Re: [web2py] How to list:reference users ?

2012-03-11 Thread Bruno Rocha
Field('user_id', "list:reference auth_user")


On Sun, Mar 11, 2012 at 12:36 AM, bussiere adrien wrote:

> maybe Field('Auth','list:reference Auth'),
> or ('Auth','list:reference User'),
>
> Regards
> Bussiere
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] represent

2012-03-11 Thread Annet
In db.py I have:

db.define_table('Node',
Field('createdOn',type='datetime',writable=False,readable=False),
Field('modifiedOn',type='datetime',writable=
False,readable=False),
migrate=False)

db.define_table('Organization',
 
Field('nodeID',db.Node,default='',notnull=True,ondelete='RESTRICT',writable=False,readable=False),
Field('name',length=128,default='',notnull=True),
...
migrate=False)

db.define_table('NodeRelatedCard',
 
Field('sourceID',db.Node,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False),
 
Field('targetID',db.Node,default='',notnull=True,ondelete='CASCADE'),
...
migrate=False)

In a function I have:

row=db(db.NodeRelatedCard.id==request.args(1)).select().first()

In the update form of this function I would like targetID to be
represented by Organization.name. I tried:

db.NodeRelatedCard.targetID.represent= lambda targetID, row:
db.Organization(targetID).name

but that doesn't work. What is the correct syntax to get this to work.


Kind regards,

Annet.


[web2py] Re: How to list:reference users ?

2012-03-11 Thread bussiere adrien
thanks

Le dimanche 11 mars 2012 04:36:37 UTC+1, bussiere adrien a écrit :
>
> maybe Field('Auth','list:reference Auth'),
> or ('Auth','list:reference User'),
>
> Regards
> Bussiere
>


[web2py] (Field: unknown field type: float for Price)

2012-03-11 Thread bussiere adrien
here is my error :

Traceback (most recent call last):
  File "gluon/restricted.py", line 205, in restricted
  File 
"C:/Users/Bussiere/Dropbox/Projets/Yuki/web2py/applications/init/models/db.py" 
, line 327, in 

  File "gluon/dal.py", line 6320, in define_table
  File "gluon/dal.py", line 638, in create_table
SyntaxError: Field: unknown field type: float for Price


(Field: unknown field type: float for Price)




db.define_table('Cour',
Field ('id'),
Field ('Price', 'float'),
format = '%(Price)d')

db.define_table('Currency',
   Field ('Name', 
unique=True),
   Field ('Cour', db.Cour),
   format = '%(Name)s')
   
   
db.define_table('Price',
   Field ('Name'),
   Field ('Currency', 
db.Currency),
   Field ('Amount', 'float'),
   format = '%(Price,Currency)s')


I ruly don't understand i did as in the tutorial 



Re: [web2py] (Field: unknown field type: float for Price)

2012-03-11 Thread Bruno Rocha
There is no float, it is double in web2py


 Field ('Price', 'double'),



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] (Field: unknown field type: float for Price)

2012-03-11 Thread bussiere adrien
i owe you one.

But on the web i see float ?

http://web2py.wordpress.com/ 

Le dimanche 11 mars 2012 10:26:29 UTC+1, rochacbruno a écrit :
>
> There is no float, it is double in web2py
>
>
>
>  Field ('Price', 'double'),
>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

[web2py] using form in same page?

2012-03-11 Thread juvi1
Hello sorry my bad english and i hope that you understand my problem. 

I want show in one page all pictures which are saved in database.
In page i want that i can upload new picture and update it whit forms 
(override old one)
My code are

in controller:
def jobs():
images=db().select(db.ref.id,db.ref.file)
for img in  images:
formname = "upload_f_%s"%img.id
form = FORM(INPUT(_type="file",_name=formname), 
INPUT(_type='submit'))

if form.accepts(request.vars, _name=formname):
response.flash = form.vars

return dict(form=form, img=img, formname=formname, images=images)

in views:
{{for img in images:}}
   
 
{{=img}}
{{formname=img.id}}
{{=formname}}
{{=form}}
{{pass}}{{pass}}

please help!


Re: [web2py] using form in same page?

2012-03-11 Thread Martín Mulone
I don't know why you have two {{pass}} in your view. I think you can do:

def jobs():
images=db().select(db.ref.id,db.ref.file)
form = SQLFORM(db.ref)
if form.process().accepted:
response.flash = "Image uploaded"

return dict(form=form, images=images)

in views:
{{for img in images:}}
   
 
{{=img}}
{{=img.id}}
{{=form}}
{{pass}}

2012/3/11 juvi1 

> Hello sorry my bad english and i hope that you understand my problem.
>
> I want show in one page all pictures which are saved in database.
> In page i want that i can upload new picture and update it whit forms
> (override old one)
> My code are
>
> in controller:
> def jobs():
> images=db().select(db.ref.id,db.ref.file)
> for img in  images:
> formname = "upload_f_%s"%img.id
> form = FORM(INPUT(_type="file",_name=formname),
> INPUT(_type='submit'))
>
> if form.accepts(request.vars, _name=formname):
> response.flash = form.vars
>
> return dict(form=form, img=img, formname=formname, images=images)
>
> in views:
> {{for img in images:}}
>  src="{{=URL('download', args=img.file)}}" />
>  
> {{=img}}
> {{formname=img.id}}
> {{=formname}}
> {{=form}}
> {{pass}}{{pass}}
>
> please help!
>



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


[web2py] custom css

2012-03-11 Thread frasse
Hi

I like to use my custom css and add it to my application base.css mess
my application. I have remove base.css and move  classes .flash
and .error to my custom css file. when I do that it is not working in
FireFox 10 in windows but it works in all other browser and OS (mac
Ubuntu , win).

Can you please help me with that ?

/F


[web2py] Re: Website doesn't show up.

2012-03-11 Thread Alan Etkin
> What exactly does that do? Where does it get sent to?

It is explained in the book (available online): 1.3 "Model-View-
Controller"

"... The data in the dictionary is rendered by a view. If the visitor
requests an HTML page (the default), the dictionary is rendered into
an
HTML page ..."

For more details see 10.1 "Rendering a dictionary"


Re: [web2py] custom css

2012-03-11 Thread Martín Mulone
What is not working?, you change views/layout.html?

2012/3/11 frasse 

> Hi
>
> I like to use my custom css and add it to my application base.css mess
> my application. I have remove base.css and move  classes .flash
> and .error to my custom css file. when I do that it is not working in
> FireFox 10 in windows but it works in all other browser and OS (mac
> Ubuntu , win).
>
> Can you please help me with that ?
>
> /F




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


[web2py] Re: represent

2012-03-11 Thread Alan Etkin
> db.Organization(targetID).name

I'd use db.Organization[targetID].name

Not sure the first syntax is supported, (tables should have a __call__
attribute for that purpose)


[web2py] Re: Translations in custom classes

2012-03-11 Thread Alan Etkin
When messages object is instantiated, T is passed as argument
probabbly to process default auth values for translation.
Then .password_reset_button is set without T(...), so for automatic
translation, there should be some operator overloading for the Message
instance to translate the text without explicit T call, otherwise, the
attribute will just be set without further actions.

On 11 mar, 01:26, Bruce Wade  wrote:
> Hi,
>
> I was looking at the Auth class, why are settings like the following not
> showing in the language translations files by default?
>
>         # ## these are messages that can be customized
>         messages = self.messages = Messages(current.T)
>         messages.password_reset_button = 'Request reset password'
>
> I have no idea what Messages(current.T) is supposed to do however the above
> string is not found in the languages files.
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


[web2py] Re: represent

2012-03-11 Thread Anthony


On Sunday, March 11, 2012 4:07:46 AM UTC-4, Annet wrote:
>
> In db.py I have: 
>
> db.define_table('Node', 
> Field('createdOn',type='datetime',writable=False,readable=False), 
> Field('modifiedOn',type='datetime',writable= 
> False,readable=False), 
> migrate=False) 
>
> db.define_table('Organization', 
>   
> Field('nodeID',db.Node,default='',notnull=True,ondelete='RESTRICT',writable=False,readable=False),
>  
>
> Field('name',length=128,default='',notnull=True), 
> ... 
> migrate=False) 
>
> db.define_table('NodeRelatedCard', 
>   
> Field('sourceID',db.Node,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False),
>  
>
>   
> Field('targetID',db.Node,default='',notnull=True,ondelete='CASCADE'), 
> ... 
> migrate=False) 
>
> In a function I have: 
>
> row=db(db.NodeRelatedCard.id==request.args(1)).select().first() 
>
> In the update form of this function I would like targetID to be 
> represented by Organization.name. I tried: 
>
> db.NodeRelatedCard.targetID.represent= lambda targetID, row: 
> db.Organization(targetID).name 
>
 
db.Organization(targetID) is equivalent to db(db.Organization.id == 
targetID).select().first(), but you want to equate targetID 
with Organization.nodeID, not with Organization.id, so instead do:

db.NodeRelatedCard.targetID.represent = lambda targetID, row:
db(db.Organization.nodeID == targetID).select().first().name

Anthony



> but that doesn't work. What is the correct syntax to get this to work. 
>
>
> Kind regards, 
>
> Annet.



[web2py] Re: represent

2012-03-11 Thread Anthony

>
> > db.Organization(targetID).name 
>
> I'd use db.Organization[targetID].name 
>
> Not sure the first syntax is supported, (tables should have a __call__ 
> attribute for that purpose)


Yes, the first syntax is supported -- it's just not the right query in this 
case.

Anthony 


[web2py] Re: represent

2012-03-11 Thread Anthony

>
> > db.Organization(targetID).name 
>>
>> I'd use db.Organization[targetID].name 
>>
>> Not sure the first syntax is supported, (tables should have a __call__ 
>> attribute for that purpose)
>
>
> Yes, the first syntax is supported -- it's just not the right query in 
> this case.
>

Note, the difference is that the first syntax (i.e., with the parentheses) 
won't trigger an exception even if the id submitted is not an int, and it 
allows multiple conditions to be submitted rather than just an id. For 
example:

db.Organization(db.Organization.nodeID == targetID).name

See http://web2py.com/books/default/chapter/29/6#Fetching-a-Row.

Anthony 


Re: [web2py] Re: Website doesn't show up.

2012-03-11 Thread Anthony

>
> Putting in return dict() made it work. Thanks.
>
> What exactly does that do? Where does it get sent to?
>

When myfunc() in mycontroller.py returns a dict (even an empty one), that 
tells web2py to render the view associated with myfunc, which by default 
will be /views/mycontroller/myfunc.html (if the requested URL has an 
extension other than "html", then it will look for a view file with the 
associated extension instead). If the expected view file doesn't exist, 
web2py will attempt to use /views/generic.html, but only if generic views 
are enabled (they are disabled by default, except for local requests). If 
myfunc() returns anything other than a dict, whatever it returns will be 
sent directly as the HTTP response body without first rendering any view.

See http://web2py.com/books/default/chapter/29/4#Workflow.

Anthony 


Re: [web2py] (Field: unknown field type: float for Price)

2012-03-11 Thread Anthony

>
> i owe you one.
>
> But on the web i see float ?
>
> http://web2py.wordpress.com/ 
>

That blog entry appears to be incorrect. 


[web2py] Re: custom css

2012-03-11 Thread frasse
color for .error is not change and .flash move to left with no border.
/F

On 11 mar, 12:53, Martín Mulone  wrote:
> What is not working?, you change views/layout.html?
>
> 2012/3/11 frasse 
>
> > Hi
>
> > I like to use my custom css and add it to my application base.css mess
> > my application. I have remove base.css and move  classes .flash
> > and .error to my custom css file. when I do that it is not working in
> > FireFox 10 in windows but it works in all other browser and OS (mac
> > Ubuntu , win).
>
> > Can you please help me with that ?
>
> > /F
>
> --
>  http://www.tecnodoc.com.ar


[web2py] Re: custom css

2012-03-11 Thread frasse
One more think. yes I change the layout.html

On 11 mar, 15:38, frasse  wrote:
> color for .error is not change and .flash move to left with no border.
> /F
>
> On 11 mar, 12:53, Martín Mulone  wrote:
>
>
>
>
>
>
>
> > What is not working?, you change views/layout.html?
>
> > 2012/3/11 frasse 
>
> > > Hi
>
> > > I like to use my custom css and add it to my application base.css mess
> > > my application. I have remove base.css and move  classes .flash
> > > and .error to my custom css file. when I do that it is not working in
> > > FireFox 10 in windows but it works in all other browser and OS (mac
> > > Ubuntu , win).
>
> > > Can you please help me with that ?
>
> > > /F
>
> > --
> >  http://www.tecnodoc.com.ar


Re: [web2py] (Field: unknown field type: float for Price)

2012-03-11 Thread pbreit
Also decimal is good for prices.


Re: [web2py] Re: Translations in custom classes

2012-03-11 Thread Bruce Wade
Okay,

Well maybe it is just me but I think when you click the update translations
button in admin, it should automatically grab ALL
strings especially default strings in admin so we can translate them. For
example with pyramid you use python setup.py extract_messages this will go
through every single file in the project to pull out the translate able
strings.

Would it be difficult to change the way translation works to do this?

On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin  wrote:

> When messages object is instantiated, T is passed as argument
> probabbly to process default auth values for translation.
> Then .password_reset_button is set without T(...), so for automatic
> translation, there should be some operator overloading for the Message
> instance to translate the text without explicit T call, otherwise, the
> attribute will just be set without further actions.
>
> On 11 mar, 01:26, Bruce Wade  wrote:
> > Hi,
> >
> > I was looking at the Auth class, why are settings like the following not
> > showing in the language translations files by default?
> >
> > # ## these are messages that can be customized
> > messages = self.messages = Messages(current.T)
> > messages.password_reset_button = 'Request reset password'
> >
> > I have no idea what Messages(current.T) is supposed to do however the
> above
> > string is not found in the languages files.
> >
> > --
> > --
> > Regards,
> > Bruce Wadehttp://
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: Translations in custom classes

2012-03-11 Thread Bruce Wade
How would we update this method so it also gets all the strings from the
gluon package? When you click update all languages it only looks in the
specific language folders. This should also look in the gluon package and
ideally there should be away to add locations for it to look.

def findT(path, language='en-us'):
"""
must be run by the admin app
"""
filename = os.path.join(path, 'languages', '%s.py' % language)
sentences = read_dict(filename)
mp = os.path.join(path, 'models')
cp = os.path.join(path, 'controllers')
vp = os.path.join(path, 'views')
for file in listdir(mp, '.+\.py', 0) + listdir(cp, '.+\.py', 0)\
 + listdir(vp, '.+\.html', 0):
fp = portalocker.LockedFile(file, 'r')
data = fp.read()
fp.close()
items = regex_translate.findall(data)
for item in items:
try:
message = eval(item)
if not message.startswith('#') and not '\n' in message:
tokens = message.rsplit('##', 1)
else:
# this allows markmin syntax in translations
tokens = [message]
if len(tokens) == 2:
message = tokens[0].strip() + '##' + tokens[1].strip()
if message and not message in sentences:
sentences[message] = message
except:
pass
write_dict(filename, sentences)

On Sun, Mar 11, 2012 at 8:39 AM, Bruce Wade  wrote:

> Okay,
>
> Well maybe it is just me but I think when you click the update
> translations button in admin, it should automatically grab ALL
> strings especially default strings in admin so we can translate them. For
> example with pyramid you use python setup.py extract_messages this will go
> through every single file in the project to pull out the translate able
> strings.
>
> Would it be difficult to change the way translation works to do this?
>
>
> On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin  wrote:
>
>> When messages object is instantiated, T is passed as argument
>> probabbly to process default auth values for translation.
>> Then .password_reset_button is set without T(...), so for automatic
>> translation, there should be some operator overloading for the Message
>> instance to translate the text without explicit T call, otherwise, the
>> attribute will just be set without further actions.
>>
>> On 11 mar, 01:26, Bruce Wade  wrote:
>> > Hi,
>> >
>> > I was looking at the Auth class, why are settings like the following not
>> > showing in the language translations files by default?
>> >
>> > # ## these are messages that can be customized
>> > messages = self.messages = Messages(current.T)
>> > messages.password_reset_button = 'Request reset password'
>> >
>> > I have no idea what Messages(current.T) is supposed to do however the
>> above
>> > string is not found in the languages files.
>> >
>> > --
>> > --
>> > Regards,
>> > Bruce Wadehttp://
>> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
>>
>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: Translations in custom classes

2012-03-11 Thread Bruce Wade
""Looks in specific folders in the current application""

On Sun, Mar 11, 2012 at 8:49 AM, Bruce Wade  wrote:

> How would we update this method so it also gets all the strings from the
> gluon package? When you click update all languages it only looks in the
> specific language folders. This should also look in the gluon package and
> ideally there should be away to add locations for it to look.
>
> def findT(path, language='en-us'):
> """
> must be run by the admin app
> """
> filename = os.path.join(path, 'languages', '%s.py' % language)
> sentences = read_dict(filename)
> mp = os.path.join(path, 'models')
> cp = os.path.join(path, 'controllers')
> vp = os.path.join(path, 'views')
> for file in listdir(mp, '.+\.py', 0) + listdir(cp, '.+\.py', 0)\
>  + listdir(vp, '.+\.html', 0):
> fp = portalocker.LockedFile(file, 'r')
> data = fp.read()
> fp.close()
> items = regex_translate.findall(data)
> for item in items:
> try:
> message = eval(item)
> if not message.startswith('#') and not '\n' in message:
> tokens = message.rsplit('##', 1)
> else:
> # this allows markmin syntax in translations
> tokens = [message]
> if len(tokens) == 2:
> message = tokens[0].strip() + '##' + tokens[1].strip()
> if message and not message in sentences:
> sentences[message] = message
> except:
> pass
> write_dict(filename, sentences)
>
> On Sun, Mar 11, 2012 at 8:39 AM, Bruce Wade  wrote:
>
>> Okay,
>>
>> Well maybe it is just me but I think when you click the update
>> translations button in admin, it should automatically grab ALL
>> strings especially default strings in admin so we can translate them. For
>> example with pyramid you use python setup.py extract_messages this will go
>> through every single file in the project to pull out the translate able
>> strings.
>>
>> Would it be difficult to change the way translation works to do this?
>>
>>
>> On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin  wrote:
>>
>>> When messages object is instantiated, T is passed as argument
>>> probabbly to process default auth values for translation.
>>> Then .password_reset_button is set without T(...), so for automatic
>>> translation, there should be some operator overloading for the Message
>>> instance to translate the text without explicit T call, otherwise, the
>>> attribute will just be set without further actions.
>>>
>>> On 11 mar, 01:26, Bruce Wade  wrote:
>>> > Hi,
>>> >
>>> > I was looking at the Auth class, why are settings like the following
>>> not
>>> > showing in the language translations files by default?
>>> >
>>> > # ## these are messages that can be customized
>>> > messages = self.messages = Messages(current.T)
>>> > messages.password_reset_button = 'Request reset password'
>>> >
>>> > I have no idea what Messages(current.T) is supposed to do however the
>>> above
>>> > string is not found in the languages files.
>>> >
>>> > --
>>> > --
>>> > Regards,
>>> > Bruce Wadehttp://
>>> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
>>>
>>
>>
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.warplydesigned.com
>> http://www.fitnessfriendsfinder.com
>>
>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] web2py and LGPLv3 License

2012-03-11 Thread Bruce Wade
Hi,

Looking through the code base, there is a file in
pyfpdf/designer.py licensed under: GNU General Public License. Wont this
force web2py to be GPL consider it contains code under that license?

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Custom register form with personnalised Auth

2012-03-11 Thread bussiere adrien
here is my auth table :
(the beginning my table is correct)
db.define_table(
auth.settings.table_user_name,
   Field('Nom'),
   Field('Prenom'),
   Field('Telephone'),
   # NOte on user is intern and the user don't hve to see it.
   Field('Note on user'), 

How to make a custom sqlform from it ?
like :
def user():
# i just want some things what is needed (passwd name and all but NOT 
note on user on the form
form = SQLFORM([auth.settings.Nom,auth.settings.Prenom])
return dict(form=form)

Regards
Bussiere


[web2py] Re: web2py and LGPLv3 License

2012-03-11 Thread Anthony
Good catch. I assume that is an error, as the project as a whole says it's 
licensed under LGPL: http://code.google.com/p/pyfpdf/. Perhaps the license 
was changed at some point but the change wasn't made to this file.

Anthony

On Sunday, March 11, 2012 12:07:47 PM UTC-4, Detectedstealth wrote:
>
> Hi,
>
> Looking through the code base, there is a file in 
> pyfpdf/designer.py licensed under: GNU General Public License. Wont this 
> force web2py to be GPL consider it contains code under that license?
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>  


[web2py] PDF rendering without spaces

2012-03-11 Thread Bruce Wade
Hi,

A while back I reported a problem with PDF's being generated without
spaces. IE: 'This would render' as 'Thiswouldrender'

This is actually a bug with chrome not with the PDF library:
http://code.google.com/p/chromium/issues/detail?id=86306

Just wanted to point that out if anyone else was confused by this.

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Translations in custom classes

2012-03-11 Thread Alan Etkin
> it should automatically grab ALL
> strings especially default strings in admin so we can translate them

I don't understand completely how does the web2py translator works
internally, but, why to translate every string in a module?
Sometimes there are strings that the core developer is not interested
to translate as string literals not exposed to the user. It also would
add processing time for the server to translate strings not meant for
translation.

On 11 mar, 12:39, Bruce Wade  wrote:
> Okay,
>
> Well maybe it is just me but I think when you click the update translations
> button in admin, it should automatically grab ALL
> strings especially default strings in admin so we can translate them. For
> example with pyramid you use python setup.py extract_messages this will go
> through every single file in the project to pull out the translate able
> strings.
>
> Would it be difficult to change the way translation works to do this?
>
>
>
>
>
>
>
>
>
> On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin  wrote:
> > When messages object is instantiated, T is passed as argument
> > probabbly to process default auth values for translation.
> > Then .password_reset_button is set without T(...), so for automatic
> > translation, there should be some operator overloading for the Message
> > instance to translate the text without explicit T call, otherwise, the
> > attribute will just be set without further actions.
>
> > On 11 mar, 01:26, Bruce Wade  wrote:
> > > Hi,
>
> > > I was looking at the Auth class, why are settings like the following not
> > > showing in the language translations files by default?
>
> > >         # ## these are messages that can be customized
> > >         messages = self.messages = Messages(current.T)
> > >         messages.password_reset_button = 'Request reset password'
>
> > > I have no idea what Messages(current.T) is supposed to do however the
> > above
> > > string is not found in the languages files.
>
> > > --
> > > --
> > > Regards,
> > > Bruce Wadehttp://
> > ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f...
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


[web2py] Re: Pycon Streaming

2012-03-11 Thread Alan Etkin
Lost the first part. I hope it will be posted somewhere later.

On 11 mar, 16:33, Bruno Rocha  wrote:
> in one hour at:http://streamti.me/track-5
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]


[web2py] Re: Translations file

2012-03-11 Thread Alan Etkin
With a first look at the code, I don't realize how to use it in the
new admin.
I am thinking of a multi-translators plugin to store and manage per-
user translations without patching the admin app.
Does web2py for GAE support translations? (I belive GAE python runtime
doesn't allow file IO)

On 6 mar, 21:33, Massimo Di Pierro  wrote:
> Actually I made that long ago ago:
>
>    http://dl.dropbox.com/u/18065445/Tmp/web2py.app.translatoradmin.w2p
>
> But it predates auth and the new admin design.
>
> It should be possible to merge with new admin add auth easily.
>
> massimo
>
>
>
>
>
>
>
> On Tuesday, 6 March 2012 16:43:29 UTC-6, Alan Etkin wrote:
>
> > It would be great that web2py had a multi-user translation (for non-
> > administrators). I have no idea about how could be implemented. I
> > suppose that it can be accomplished imitating the admin code that
> > handles the translation interface and adding support for Auth.
>
> > On 6 mar, 18:26, Bruce Wade  wrote:
> > > Yeah I am not worried about editing it myself, but when I get non-tech
> > > people to edit the files that is when things go bad :D.
>
> > > I think I am just going to write a standalone editor like the web based
> > one
> > > that I can give to others when editing a file.
>
> > > On Tue, Mar 6, 2012 at 1:18 PM, Bruno Rocha 
> > wrote:
>
> > > > On Tue, Mar 6, 2012 at 4:48 PM, Bruce Wade 
> > wrote:
>
> > > >> Any suggestions on the best way to update languages.py to prevent
> > this
> > > >> from happening?
>
> > > > You can use an editor with Pylinter and PEP8 modules (Sublime-Text-2,
> > > > Geany, etc), so it will show live syntax errors and prevent problems
> > with
> > > > syntax.
>
> > > > --
>
> > > > Bruno Rocha
> > > > [http://rochacbruno.com.br]
>
> > > --
> > > --
> > > Regards,
> > > Bruce Wadehttp://
> > ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f...


Re: [web2py] using form in same page?

2012-03-11 Thread juvi1
thanks, but now form create always new image in database, and i want update 
image.
how it can be done??

sunnuntaina 11. maaliskuuta 2012 13.37.36 UTC+2 Martin.Mulone kirjoitti:
>
> I don't know why you have two {{pass}} in your view. I think you can do:
>
> def jobs():
> images=db().select(db.ref.id,db.ref.file)
> form = SQLFORM(db.ref) 
> if form.process().accepted:
> response.flash = "Image uploaded"  
> 
> return dict(form=form, images=images)
>
> in views:
> {{for img in images:}}
>  src="{{=URL('download', args=img.file)}}" />
>  
> {{=img}}
> {{=img.id}}
> {{=form}}
> {{pass}}
>
> 2012/3/11 juvi1 
>
>> Hello sorry my bad english and i hope that you understand my problem. 
>>
>> I want show in one page all pictures which are saved in database.
>> In page i want that i can upload new picture and update it whit forms 
>> (override old one)
>> My code are
>>
>> in controller:
>> def jobs():
>> images=db().select(db.ref.id,db.ref.file)
>> for img in  images:
>> formname = "upload_f_%s"%img.id
>> form = FORM(INPUT(_type="file",_name=formname), 
>> INPUT(_type='submit'))
>> 
>> if form.accepts(request.vars, _name=formname):
>> response.flash = form.vars
>> 
>> return dict(form=form, img=img, formname=formname, images=images)
>>
>> in views:
>> {{for img in images:}}
>>>  src="{{=URL('download', args=img.file)}}" />
>>  
>> {{=img}}
>> {{formname=img.id}}
>> {{=formname}}
>> {{=form}}
>> {{pass}}{{pass}}
>>
>> please help!
>>
>
>
>
> -- 
>  http://www.tecnodoc.com.ar
>
>  

Re: [web2py] Re: how to set a default user group

2012-03-11 Thread Vasile Ermicioi
auth.settings.register_onaccept =  post_register

it works, thank you :)

On Sat, Mar 10, 2012 at 2:44 PM, Alan Etkin  wrote:

> This is one way of solving it (by binding a function to an
> auth.settings attribute):
>
> # model code
>
> def post_register(form):
># the new user id is stored in auth.user_id
>pass
>
> auth.settings.register_onaccept = give_create_permission
>
> On registration, you can perform auth management by accessing the new
> user id
>
> On 10 mar, 09:37, Vasile Ermicioi  wrote:
> > hi,
> >
> > currently a new user group is created for each new user after
> registration,
> > I disabled new groups to be created
> > auth.settings.create_user_groups = False
> >
> > but actually I need to set all new users to a default user group
> >
> > I know I will get a response, :) thank you in advance
>


Re: [web2py] Re: Translations in custom classes

2012-03-11 Thread Bruce Wade
I was referring to all strings visible to the end user. Primarily the
customizable setting stringsstrings
On Mar 11, 2012 2:22 PM, "Alan Etkin"  wrote:

> > it should automatically grab ALL
> > strings especially default strings in admin so we can translate them
>
> I don't understand completely how does the web2py translator works
> internally, but, why to translate every string in a module?
> Sometimes there are strings that the core developer is not interested
> to translate as string literals not exposed to the user. It also would
> add processing time for the server to translate strings not meant for
> translation.
>
> On 11 mar, 12:39, Bruce Wade  wrote:
> > Okay,
> >
> > Well maybe it is just me but I think when you click the update
> translations
> > button in admin, it should automatically grab ALL
> > strings especially default strings in admin so we can translate them. For
> > example with pyramid you use python setup.py extract_messages this will
> go
> > through every single file in the project to pull out the translate able
> > strings.
> >
> > Would it be difficult to change the way translation works to do this?
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Sun, Mar 11, 2012 at 5:21 AM, Alan Etkin  wrote:
> > > When messages object is instantiated, T is passed as argument
> > > probabbly to process default auth values for translation.
> > > Then .password_reset_button is set without T(...), so for automatic
> > > translation, there should be some operator overloading for the Message
> > > instance to translate the text without explicit T call, otherwise, the
> > > attribute will just be set without further actions.
> >
> > > On 11 mar, 01:26, Bruce Wade  wrote:
> > > > Hi,
> >
> > > > I was looking at the Auth class, why are settings like the following
> not
> > > > showing in the language translations files by default?
> >
> > > > # ## these are messages that can be customized
> > > > messages = self.messages = Messages(current.T)
> > > > messages.password_reset_button = 'Request reset password'
> >
> > > > I have no idea what Messages(current.T) is supposed to do however the
> > > above
> > > > string is not found in the languages files.
> >
> > > > --
> > > > --
> > > > Regards,
> > > > Bruce Wadehttp://
> > >
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f.
> ..
> >
> > --
> > --
> > Regards,
> > Bruce Wadehttp://
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


[web2py] Re: how to set a default user group

2012-03-11 Thread Alan Etkin
Yes, my bad. I copy-pasted the example from the book and modified it
partially.

On 11 mar, 19:43, Vasile Ermicioi  wrote:
> auth.settings.register_onaccept =  post_register
>
> it works, thank you :)
>
>
>
>
>
>
>
> On Sat, Mar 10, 2012 at 2:44 PM, Alan Etkin  wrote:
> > This is one way of solving it (by binding a function to an
> > auth.settings attribute):
>
> > # model code
>
> > def post_register(form):
> >    # the new user id is stored in auth.user_id
> >    pass
>
> > auth.settings.register_onaccept = give_create_permission
>
> > On registration, you can perform auth management by accessing the new
> > user id
>
> > On 10 mar, 09:37, Vasile Ermicioi  wrote:
> > > hi,
>
> > > currently a new user group is created for each new user after
> > registration,
> > > I disabled new groups to be created
> > > auth.settings.create_user_groups = False
>
> > > but actually I need to set all new users to a default user group
>
> > > I know I will get a response, :) thank you in advance


[web2py] Re: Support for PyPy

2012-03-11 Thread Francisco Costa
They say its incompatible 
https://bitbucket.org/pypy/compatibility/wiki/web2py

Could someone run some tests?


On Tuesday, February 28, 2012 5:41:41 PM UTC, Massimo Di Pierro wrote:
>
> I have fixed all pypy bugs that have been reported but I did not run 
> it myself. Please report any problems if any. 
>
> On Feb 11, 3:51 am, Phyo Arkar  wrote: 
> > has anyone tested with Pypy 1.8 ? Seems good this time. 
> > 
> > Previous tests fails web2py , 
> > 
> > On Fri, Feb 10, 2012 at 10:05 PM, Sathvik Ponangi 
> > wrote: 
>
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Is there some way to run Web2Py on PyPy ?



[web2py] Re: Latest version unable to connect to DB

2012-03-11 Thread Massimo Di Pierro
fixing in trunk (while at PyCon print)

On Saturday, 10 March 2012 17:16:57 UTC-6, Alan Etkin wrote:
>
> Line 1999 in trunk: 
> self.driver = drivers.get('pg8000') 
> Should be: 
> self.driver = self.drivers.get('pg8000') 
>
> On Mar 10, 8:07 pm, Alan Etkin  wrote: 
> > If something changed (as now pg adapter supports pg8000 driver), old 
> > uri strings would have to be accepted also. I'd say it's is a bug. 
> > There seems to be a list/dict conflict in dal. 
> > 
> > On Mar 10, 2:16 pm, Bruce Wade  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > db_users = 
> DAL('postgres://warplyde_fto:password@localhost/warplyde_fto') 
> > 
> > > Has something been changed in how we need to make database connections 
> > > to postgres? 
> > 
> > > Traceback (most recent call last): 
> > >   File 
> "/home/bruce/Development/wct_dev/web2py_dev/projects/fto/gluon/restricted.py",
>  
>
> > > line 205, in restricted 
> > > exec ccode in environment 
> > >   File 
> "/home/bruce/Development/wct_dev/web2py_dev/projects/fto/applications/signon/models/db.py"
>  
>
> > > , line 14, in 
> > >  
> > > db_users = 
> DAL('postgres://warplyde_fto:password@localhost/warplyde_fto') 
> > >   File 
> "/home/bruce/Development/wct_dev/web2py_dev/projects/fto/gluon/dal.py", 
> > > line 5968, in __init__ 
> > > raise RuntimeError, "Failure to connect, tried %d times:\n%s" % 
> > > (attempts, tb) 
> > > RuntimeError: Failure to connect, tried 5 times: 
> > > Traceback (most recent call last): 
> > >   File 
> "/home/bruce/Development/wct_dev/web2py_dev/projects/fto/gluon/dal.py", 
> > > line 5955, in __init__ 
> > > self._adapter = ADAPTERS[self._dbname](*args) 
> > >   File 
> "/home/bruce/Development/wct_dev/web2py_dev/projects/fto/gluon/dal.py", 
> > > line 1999, in __init__ 
> > > self.driver = drivers.get('pg8000') 
> > > AttributeError: 'list' object has no attribute 'get' 
> > 
> > > -- 
> > > -- 
> > > Regards, 
> > > Bruce Wadehttp://
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp:...



[web2py] Re: Errors creating/reading tickets

2012-03-11 Thread Massimo Di Pierro
Please email me one of the tickets that causes the problem and one of the 
tickets generated by admin as consequence.

On Saturday, 10 March 2012 20:48:04 UTC-6, Brian M wrote:
>
> This has actually been plaguing me for a while but finally annoyed me 
> enough to ask.  I have several web2py (1.99.4) apps running under 
> Apache/2.2.17 (Win32) , mod_wsgi/3.3 and Python/2.6.4.  More often than 
> not when an error happens and a ticket is generated, the ticket seems to be 
> corrupt.  Attempting to view the ticket creates another error for which the 
> ticket says something like:
>
>  Version  web2py™ (1, 99, 4, 
> datetime.datetime(2011, 12, 22, 11, 20, 45), 'stable')  Python Python 
> 2.6.4: C:\vantage_dashboard\xampp\apache\bin\httpd.exe  Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
>
> Traceback (most recent call last):
>   File "C:\vantage_dashboard\xampp\web2py\gluon\restricted.py", line 204, in 
> restricted
> exec ccode in environment
>   File 
> "C:/vantage_dashboard/xampp/web2py/applications/admin/controllers/default.py" 
> , line 
> 1341, in 
>   File "C:\vantage_dashboard\xampp\web2py\gluon\globals.py", line 172, in 
> 
> self._caller = lambda f: f()
>   File 
> "C:/vantage_dashboard/xampp/web2py/applications/admin/controllers/default.py" 
> , line 
> 1082, in errors
> error = pickle.load(fullpath_file)
>   File "C:\Python26\Lib\pickle.py", line 1370, in load
> return Unpickler(file).load()
>   File "C:\Python26\Lib\pickle.py", line 858, in load
> dispatch[key](self)
>   File "C:\Python26\Lib\pickle.py", line 880, in load_eof
> raise EOFError
> EOFError
>
>
> Which means that I have to attempt to read the original error ticket in a 
> text editor which is just slightly less than idea.  Any ideas what might be 
> happening? This problem doesn't seem to happen in my dev environment (also 
> Windows but just using rocket instead of apache/mod_wsgi).
>
> Thanks,
> Brian
>


[web2py] Re: Custom register form with personnalised Auth

2012-03-11 Thread Massimo Di Pierro
you the fields you do not want to db.table.field.writeable=False and the 
use the regular SQLFORM(db.table)

On Sunday, 11 March 2012 11:15:41 UTC-5, bussiere adrien wrote:
>
> here is my auth table :
> (the beginning my table is correct)
> db.define_table(
> auth.settings.table_user_name,
>Field('Nom'),
>Field('Prenom'),
>Field('Telephone'),
># NOte on user is intern and the user don't hve to see it.
>Field('Note on user'), 
>
> How to make a custom sqlform from it ?
> like :
> def user():
> # i just want some things what is needed (passwd name and all but NOT 
> note on user on the form
> form = SQLFORM([auth.settings.Nom,auth.settings.Prenom])
> return dict(form=form)
>
> Regards
> Bussiere
>


[web2py] Re: web2py and LGPLv3 License

2012-03-11 Thread Massimo Di Pierro


On Sunday, 11 March 2012 11:07:47 UTC-5, Detectedstealth wrote:
>
> Hi,
>
> Looking through the code base, there is a file in 
> pyfpdf/designer.py licensed under: GNU General Public License. Wont this 
> force web2py to be GPL consider it contains code under that license?
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>  


[web2py] Re: web2py and LGPLv3 License

2012-03-11 Thread Massimo Di Pierro
I am sitting in front of Mariano at PyCon. He is the authors. He said he 
will change it to LGPL.

Anyway, having a GPL file into contrib does not change web2py to be GPL 
because the file is not linked and not required by web2py to run. This is a 
debatable issue. Since I like to avoid ambiguities I require all files in 
contrib be MIT, BSD or LGPL or Apache.

massimo

On Sunday, 11 March 2012 11:27:28 UTC-5, Anthony wrote:
>
> Good catch. I assume that is an error, as the project as a whole says it's 
> licensed under LGPL: http://code.google.com/p/pyfpdf/. Perhaps the 
> license was changed at some point but the change wasn't made to this file.
>
> Anthony
>
> On Sunday, March 11, 2012 12:07:47 PM UTC-4, Detectedstealth wrote:
>>
>> Hi,
>>
>> Looking through the code base, there is a file in 
>> pyfpdf/designer.py licensed under: GNU General Public License. Wont this 
>> force web2py to be GPL consider it contains code under that license?
>>
>> -- 
>> -- 
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.warplydesigned.com
>> http://www.fitnessfriendsfinder.com
>>  
>
On Sunday, 11 March 2012 11:27:28 UTC-5, Anthony wrote:
>
> Good catch. I assume that is an error, as the project as a whole says it's 
> licensed under LGPL: http://code.google.com/p/pyfpdf/. Perhaps the 
> license was changed at some point but the change wasn't made to this file.
>
> Anthony
>
> On Sunday, March 11, 2012 12:07:47 PM UTC-4, Detectedstealth wrote:
>>
>> Hi,
>>
>> Looking through the code base, there is a file in 
>> pyfpdf/designer.py licensed under: GNU General Public License. Wont this 
>> force web2py to be GPL consider it contains code under that license?
>>
>> -- 
>> -- 
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.warplydesigned.com
>> http://www.fitnessfriendsfinder.com
>>  
>

[web2py] Re: Translations file

2012-03-11 Thread Massimo Di Pierro
You have to translate locally and then push.

On Sunday, 11 March 2012 16:33:01 UTC-5, Alan Etkin wrote:
>
> With a first look at the code, I don't realize how to use it in the 
> new admin. 
> I am thinking of a multi-translators plugin to store and manage per- 
> user translations without patching the admin app. 
> Does web2py for GAE support translations? (I belive GAE python runtime 
> doesn't allow file IO) 
>
> On 6 mar, 21:33, Massimo Di Pierro  wrote: 
> > Actually I made that long ago ago: 
> > 
> >http://dl.dropbox.com/u/18065445/Tmp/web2py.app.translatoradmin.w2p 
> > 
> > But it predates auth and the new admin design. 
> > 
> > It should be possible to merge with new admin add auth easily. 
> > 
> > massimo 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Tuesday, 6 March 2012 16:43:29 UTC-6, Alan Etkin wrote: 
> > 
> > > It would be great that web2py had a multi-user translation (for non- 
> > > administrators). I have no idea about how could be implemented. I 
> > > suppose that it can be accomplished imitating the admin code that 
> > > handles the translation interface and adding support for Auth. 
> > 
> > > On 6 mar, 18:26, Bruce Wade  wrote: 
> > > > Yeah I am not worried about editing it myself, but when I get 
> non-tech 
> > > > people to edit the files that is when things go bad :D. 
> > 
> > > > I think I am just going to write a standalone editor like the web 
> based 
> > > one 
> > > > that I can give to others when editing a file. 
> > 
> > > > On Tue, Mar 6, 2012 at 1:18 PM, Bruno Rocha  
> > > wrote: 
> > 
> > > > > On Tue, Mar 6, 2012 at 4:48 PM, Bruce Wade  
> > > wrote: 
> > 
> > > > >> Any suggestions on the best way to update languages.py to prevent 
> > > this 
> > > > >> from happening? 
> > 
> > > > > You can use an editor with Pylinter and PEP8 modules 
> (Sublime-Text-2, 
> > > > > Geany, etc), so it will show live syntax errors and prevent 
> problems 
> > > with 
> > > > > syntax. 
> > 
> > > > > -- 
> > 
> > > > > Bruno Rocha 
> > > > > [http://rochacbruno.com.br] 
> > 
> > > > -- 
> > > > -- 
> > > > Regards, 
> > > > Bruce Wadehttp:// 
> > > 
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f.
> ..



Re: [web2py] Re: Support for PyPy

2012-03-11 Thread Bruno Rocha
And I have to say! it is very very fast! and you can see the different even
running welcome app.

I am planning to put a web2py app to run in production for some time to
test it.


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Web2Py Version 1.99.7 giving the trace back during run the Cron

2012-03-11 Thread Sanjeet Kumar
I am using the following model for test the cron :

db.define_table(('emp'),
   Field('name'))
and in crontab file inside the welcome app i am using the :

*/1  *  *  *  * root *applications/welcome/modules/background_updater.py

and makes the file inside the modules folder background_updater.py and used 
the code :

db.emp.insert(name = 'Alex')

this code is inserting the Alex in the table emp within 1 minutes interval

this code is working in the version of web2py 1.99.4 perfectly but when i 
try this same code in the version 1.99.7 i got the following error :-

RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
  File "/home/tls-sanjeet/Desktop/web2py/gluon/dal.py", line 5955, in 
__init__
self._adapter = ADAPTERS[self._dbname](*args)
  File "/home/tls-sanjeet/Desktop/web2py/gluon/dal.py", line 1732, in 
__init__
self.pool_connection(connect)
  File "/home/tls-sanjeet/Desktop/web2py/gluon/dal.py", line 465, in 
pool_connection
self.connection = f()
  File "/home/tls-sanjeet/Desktop/web2py/gluon/dal.py", line 1731, in 
connect
return self.driver.Connection(dbpath, **driver_args)
OperationalError: unable to open database file


[web2py] need help with unicode decoding/encoding upload file

2012-03-11 Thread weheh
I'm embarrassed to say that I'm *still* having trouble getting unicode
working on uploaded files. I'm sure this is an incredibly stupid easy
thing to do, but unicode has never come easy for me.

# model
db.define_table('infile',
Field('name', 'upload',uploadseparate=True))

# controller for uploading using a component
def from_file():
form = SQLFORM(db.infile)
if form.process().accepted:
# store uploaded file
request.vars.name.file.seek(0)  # rewind uploaded file
infile_id = db.infile.insert(
name=db.infile.name.store(
request.vars.name.file,
request.vars.name.filename
)
)
response.flash = ...
response.js = ...
elif file_form.errors:
...
return dict(form=form)

I'm trying to figure out how to encode the uploaded file before
inserting it into the db manually. I've tried lots of things to encode
before inserting. The latest failed attempt is this:

text = reqeust.vars.name.file.getvalue()
from gluon import decoder
text = decoder.decoder(text)

and then inserted text rather than request.vars.name.file, but this
doesn't work. decoder throws a ticket saying

  File "N:\web2py\gluon\decoder.py", line 74, in decoder
return buffer.decode(encoding).encode('utf8')
  File "c:\Program Files (x86)\Python25\lib\encodings\utf_8.py", line
16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 4-7:
invalid data

I'm really just grasping at straws right now.

Any helpful examples would be appreciated.


[web2py] Re: represent

2012-03-11 Thread Annet
Hi Alan and Anthony,

Thanks for your replies. This solution partially solved the problem:

db.NodeRelatedCard.targetID.represent = lambda targetID, row:
db(db.Organization.nodeID == targetID).select().first().name

In appadmin the targetID is now represented by the name of the
organization, however, in the following delete form
the targetID is still the id:

@auth.requires(auth.has_membership(VCARD) or
auth.has_membership(ROOT))
def relatedcards():
id=auth.user.nodeID
db.NodeRelatedCard.sourceID.default=id
 
rows=db((db.NodeRelatedCard.sourceID==id)&(db.NodeRelatedCard.targetID==db.Organization.id))
\

.select(db.NodeRelatedCard.ALL,db.Organization.name,orderby=db.Organization.name)
if not rows:
if not response.flash: response.flash='No related cards in
database'
else:
if not response.flash: response.flash='Related cards in
database'
if len(request.args):
if request.args(0)=='delete':
 
row=db(db.NodeRelatedCard.id==request.args(1)).select().first()
response.flash='Delete related card'
message='Related card deleted'
 
form=crud.update(table=db.NodeRelatedCard,record=row,message=message,deletable=True)
form[0][-1]
[1].append(INPUT(_type="button",_value="Cancel",_onclick='javascript:history.go(-1);'))
return dict(form=form,rows=rows)


Adding this:

db.NodeRelatedCard.targetID.represent=lambda targetID, row:
db(db.Organization.nodeID==targetID).select().first().name

after:

db.NodeRelatedCard.sourceID.default=id

doesn't make any difference. What's wrong with the function above?


Kind regards,

Annet.